Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

MFCreateSourceReaderFromMediaSource function

Creates the source reader from a media source.


HRESULT MFCreateSourceReaderFromMediaSource(
  _In_  IMFMediaSource  *pMediaSource,
  _In_  IMFAttributes   *pAttributes,
  _Out_ IMFSourceReader **ppSourceReader


pMediaSource [in]

A pointer to the IMFMediaSource interface of a media source.

pAttributes [in]

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 [out]

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

Return value

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

Return codeDescription

The method succeeded.


The source contains protected content.



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.


Minimum supported client

Windows 7, Windows Vista and Platform Update Supplement for Windows Vista [desktop apps | Windows Store apps]

Minimum supported server

Windows Server 2008 R2 [desktop apps | Windows Store apps]

Minimum supported phone

Windows Phone 8.1







See also

Media Foundation Functions
Source Reader



© 2017 Microsoft