Microsoft DirectX 9.0

IGraphBuilder::AddSourceFilter

The AddSourceFilter method adds a source filter for a specified file to the filter graph.

Syntax

HRESULT AddSourceFilter(
  LPCWSTR lpwstrFileName,
  LPCWSTR lpwstrFilterName,
  IBaseFilter **ppFilter
);

Parameters

lpwstrFileName

[in] Specifies the name of the file to load.

lpwstrFilterName

[in] Specifies a name for the source filter.

ppFilter

[out] Pointer to a variable that receives the IBaseFilter interface pointer of the source filter.

Return Value

Returns an HRESULT. Possible values include the following.

Value Description
S_OK Success.
E_NOINTERFACE The source filter does not support the IFileSourceFilter interface.
E_OUTOFMEMORY Insufficient memory.
E_POINTER NULL pointer argument.
VFW_E_CANNOT_LOAD_SOURCE_FILTER The source filter for this file could not be loaded.
VFW_E_NOT_FOUND File or object not found.
VFW_E_UNKNOWN_FILE_TYPE The media type of this file was not recognized.

Remarks

This method searches for an installed filter that can read the specified file. If it finds one, the method adds it to the filter graph and returns a pointer to the filter's IBaseFilter interface. To determine the media type and compression scheme of the file, the Filter Graph Manager reads the first few bytes of the file, looking for specific patterns of bytes, as documented in the article Registering a Custom File Type.

The application is responsible for building the rest of the filter graph. To do so, call IBaseFilter::EnumPins to enumerate the output pins on the source filter. Then use either the IGraphBuilder::Connect method or the IGraphBuilder::Render method.

If the method succeeds, the IBaseFilter interface has an outstanding reference count. The caller must release the interface.

To render a file for default playback, use the IGraphBuilder::RenderFile method.

See Also