IMFSourceReader::SetStreamSelection method (mfreadwrite.h)

Selects or deselects one or more streams.


HRESULT SetStreamSelection(
  [in] DWORD dwStreamIndex,
  [in] BOOL  fSelected


[in] dwStreamIndex

The stream to set. The value can be any of the following.

Value Meaning
The zero-based index of a stream.
The first video stream.
The first audio stream.
All streams.

[in] fSelected

Specify TRUE to select streams or FALSE to deselect streams. If a stream is deselected, it will not generate data.

Return value

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.


There are two common uses for this method:

  • To change the default stream selection. Some media files contain multiple streams of the same type. For example, a file might include audio streams for multiple languages. You can use this method to change which of the streams is selected. To get information about each stream, call IMFSourceReader::GetPresentationAttribute or IMFSourceReader::GetNativeMediaType.
  • If you will not need data from one of the streams, it is a good idea to deselect that stream. If the stream is selected, the media source might hold onto a queue of unread data, and the queue might grow indefinitely, consuming memory.
For an example of deselecting a stream, see Tutorial: Decoding Audio.

If a stream is deselected, the IMFSourceReader::ReadSample method returns MF_E_INVALIDREQUEST for that stream. Other IMFSourceReader methods are valid for deselected streams.

Stream selection does not affect how the source reader loads or unloads decoders in memory. In particular, deselecting a stream does not force the source reader to unload the decoder for that stream.

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


Requirement Value
Minimum supported client Windows 7, Windows Vista and Platform Update Supplement for Windows Vista [desktop apps | UWP apps]
Minimum supported server Windows Server 2008 R2 [desktop apps | UWP apps]
Target Platform Windows
Header mfreadwrite.h

See also


Source Reader