MFCreateAggregateSource function (mfidl.h)

Creates a media source that aggregates a collection of media sources.

Syntax

HRESULT MFCreateAggregateSource(
  [in]  IMFCollection  *pSourceCollection,
  [out] IMFMediaSource **ppAggSource
);

Parameters

[in] pSourceCollection

A pointer to the IMFCollection interface of the collection object that contains a list of media sources.

[out] ppAggSource

Receives a pointer to the IMFMediaSource interface of the aggregated media source. The caller must release the interface.

Return value

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

Return code Description
S_OK
The method succeeded.
E_INVALIDARG
The pSourceCollection collection does not contain any elements.

Remarks

The aggregated media source is useful for combining streams from separate media sources. For example, you can use it to combine a video capture source and an audio capture source.

Examples

HRESULT CreateAggregatedSource(
    IMFMediaSource *pSource1,
    IMFMediaSource *pSource2,
    IMFMediaSource **ppAggSource
    )
{
    *ppAggSource = NULL;

    IMFCollection *pCollection = NULL;

    HRESULT hr = MFCreateCollection(&pCollection);

    if (SUCCEEDED(hr))
    {
        hr = pCollection->AddElement(pSource1);
    }
    if (SUCCEEDED(hr))
    {
        hr = pCollection->AddElement(pSource2);
    }
    if (SUCCEEDED(hr))
    {
        hr = MFCreateAggregateSource(pCollection, ppAggSource);
    }
    SafeRelease(&pCollection);
    return hr;    
}

Requirements

Requirement Value
Minimum supported client Windows 7 [desktop apps | UWP apps]
Minimum supported server Windows Server 2008 R2 [desktop apps | UWP apps]
Target Platform Windows
Header mfidl.h
Library Mf.lib
DLL Mf.dll

See also

IMFMediaSource

Media Foundation Functions