IMFCaptureSink::AddStream method (mfcaptureengine.h)

Connects a stream from the capture source to this capture sink.

Syntax

HRESULT AddStream(
  DWORD         dwSourceStreamIndex,
  IMFMediaType  *pMediaType,
  IMFAttributes *pAttributes,
  DWORD         *pdwSinkStreamIndex
);

Parameters

dwSourceStreamIndex

The source stream to connect. The value can be any of the following.

Value Meaning
0–0xFFFFFFFB
The zero-based index of a stream. To get the number of streams, call IMFCaptureSource::GetDeviceStreamCount.
MF_CAPTURE_ENGINE_FIRST_SOURCE_PHOTO_STREAM
0xFFFFFFFB
The first image stream.
MF_CAPTURE_ENGINE_FIRST_SOURCE_VIDEO_STREAM
0xFFFFFFFC
The first video stream.
MF_CAPTURE_ENGINE_FIRST_SOURCE_AUDIO_STREAM
0xFFFFFFFD
The first audio stream.

pMediaType

An IMFMediaType pointer that specifies the desired format of the output stream. The details of the format will depend on the capture sink.

  • Photo sink: A still image format compatible with Windows Imaging Component (WIC).
  • Preview sink: An uncompressed audio or video format.
  • Record sink: The audio or video format that will be written to the output file.

pAttributes

A pointer to the IMFAttributes interface. For compressed streams, you can use this parameter to configure the encoder. This parameter can also be NULL.

For the preview sink, set this parameter to NULL.

pdwSinkStreamIndex

Receives the index of the new stream on the capture sink. Note that this index will not necessarily match the value of dwSourceStreamIndex.

Return value

This method can return one of these values.

Return code Description
S_OK
Success.
MF_E_INVALIDMEDIATYPE
The format specified in pMediaType is not valid for this capture sink.
MF_E_INVALIDSTREAMNUMBER
The dwSourceStreamIndex parameter is invalid, or the specified source stream was already connected to this sink.

Requirements

   
Minimum supported client Windows 8 [desktop apps only]
Minimum supported server Windows Server 2012 [desktop apps only]
Target Platform Windows
Header mfcaptureengine.h

See also

IMFCaptureSink