MFCreateSourceReaderFromMediaSource

Creates the source reader from a media source.

Syntax

HRESULT MFCreateSourceReaderFromMediaSource(
         IMFMediaSource *pMediaSource,
         IMFAttributes *pAttributes,
         IMFSourceReader **ppSourceReader
)  

Parameters

pMediaSource
Type: IMFMediaSource *

[in] A pointer to the IMFMediaSource interface of a media source.

pAttributes
Type: IMFAttributes *

[in, optional] Pointer to the IMFAttributes interface. You can use this parameter to configure the source reader. For more information, see Source Reader Attributes. This parameter can be NULL.

ppSourceReader
Type: IMFSourceReader **

[out] Receives a pointer to the IMFSourceReader interface. The caller must release the interface.

Return value

Type: HRESULT 

The method returns an HRESULT. Possible values include, but are not limited to, those in the following table.

Return codes
Return code Description
S_OK The method succeeded.
MF_E_DRM_UNSUPPORTED The source contains protected content.

Refer to Media Foundation return codes.

Remarks

Call CoInitialize(Ex) and MFStartup before calling this function.

By default, when the application releases the source reader, the source reader shuts down the media source by calling IMFMediaSource::Shutdown on the media source. At that point, the application can no longer use the media source.

To change this default behavior, set the MF_SOURCE_READER_DISCONNECT_MEDIASOURCE_ON_SHUTDOWN attribute in the pAttributes parameter. If this attribute is TRUE, the application is responsible for shutting down the media source.

When using the Source Reader, do not call any of the following methods on the media source:

This function is available on Windows Vista if Platform Update Supplement for Windows Vista is installed.

Requirements

Header: Declared in mfreadwrite.h.

Library: Use mfreadwrite.lib.