IFilterGraph2::AddSourceFilterForMoniker method (strmif.h)
[The feature associated with this page, DirectShow, is a legacy feature. It has been superseded by MediaPlayer, IMFMediaEngine, and Audio/Video Capture in Media Foundation. Those features have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use MediaPlayer, IMFMediaEngine and Audio/Video Capture in Media Foundation instead of DirectShow, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]
The AddSourceFilterForMoniker
method creates a source filter from an IMoniker pointer and adds the filter to the graph. For example, you can obtain a moniker for a system device, such as a video capture device, and add a video capture filter for that device. (For more information about system device monikers, see the ICreateDevEnum interface.)
Syntax
HRESULT AddSourceFilterForMoniker(
[in] IMoniker *pMoniker,
[in] IBindCtx *pCtx,
[in] LPCWSTR lpcwstrFilterName,
[out] IBaseFilter **ppFilter
);
Parameters
[in] pMoniker
Pointer to the IMoniker interface.
[in] pCtx
Pointer to an IBindCtx bind context interface.
[in] lpcwstrFilterName
Name for the filter.
[out] ppFilter
Receives a pointer to the source filter's IBaseFilter pointer. The caller must release the interface.
Return value
Returns and HRESULT value. Possible values include the following.
Return code | Description |
---|---|
|
Success. |
|
Success; but the specified name was a duplicate, so the Filter Graph Manager modified the name. |
|
Failure. |
|
Insufficient memory. |
|
Failed to add a filter with a duplicate name. |
|
The source filter for could not be loaded. |
|
The media type of this file is not recognized. |
Remarks
The Filter Graph Manager holds a reference count on the filter until the filter is removed from the graph or the Filter Graph Manager is released.
Examples
C++ |
---|
IBaseFilter *pSource = NULL; IMoniker *pMoniker = NULL; |
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 2000 Professional [desktop apps only] |
Minimum supported server | Windows 2000 Server [desktop apps only] |
Target Platform | Windows |
Header | strmif.h (include Dshow.h) |
Library | Strmiids.lib |