DirectShow Animated Header -- IFileSourceFilter Interface DirectShow Animated Header -- IFileSourceFilter Interface* Microsoft DirectShow SDK
*Index  *Topic Contents
*Previous Topic: IFileSinkFilter2 Interface
*Next Topic: IFilterGraph Interface

IFileSourceFilter Interface


The IFileSourceFilter interface is exposed by source filters to set the file name and media type of the media file that they are to render. It is an abbreviated version of the COM IPersistFile interface. If the file has a type that can be determined by the algorithm described in Registering a Custom File Type, the recommended file source filter CLSID is used when the filter graph manager attempts to render the filter graph.

When to Implement

If a filter needs the name of a file to open, it should expose this interface to allow an application to set the file name. Note that there is no base class implementation of this interface.

When to Use

An application that inserts file source filters directly must query for this interface and set the file name. Normally, the filter graph manager uses this interface when an application calls IGraphBuilder::RenderFile. The Graphedt.exe tool queries for the IFileSourceFilter interface and prompts for a file name if it finds it.

Methods in Vtable Order
IUnknown methods Description
QueryInterface Returns pointers to supported interfaces.
AddRef Increments the reference count.
Release Decrements the reference count.
IFileSourceFilter methods Description
Load Loads the source filter with the file.
GetCurfile Retrieves the current file.


IFileSourceFilter::GetCurfile

IFileSourceFilter Interface

Collects information about the file to open.

HRESULT GetCurfile(
  LPOLESTR *ppszFileName,
  AM_MEDIA_TYPE *pmt
  );

Parameters
ppszFileName
[out] Path to the loaded file.
pmt
[out] Media type.
Return Values

Returns an HRESULT value that depends on the implementation. HRESULT can be one of the following standard constants, or other values not listed:
Value Meaning
E_FAIL Failure.
E_POINTER Null pointer argument.
E_INVALIDARG Invalid argument.
E_NOTIMPL Method isn't supported.
S_OK or NOERROR Success.


IFileSourceFilter::Load

IFileSourceFilter Interface

Loads a media file.

HRESULT Load(
  LPCOLESTR pszFileName,
  const AM_MEDIA_TYPE *pmt
  );

Parameters
pszFileName
[in] Absolute path of the file to open.
pmt
[in] Media type of the file. This can be NULL.
Return Values

Returns an HRESULT value that depends on the implementation. HRESULT can be one of the following standard constants, or other values not listed:
Value Meaning
E_FAIL Failure.
E_POINTER Null pointer argument.
E_INVALIDARG Invalid argument.
E_NOTIMPL Method isn't supported.
S_OK or NOERROR Success.

Remarks

This is an initialization method for the interface. It is not designed to load multiple files, and any calls to this method after the first call will fail.

You should implement this method to load the file specified by pszFileName.

Note that the name in pszFileName need not actually be a disk file name (that is, one you could pass to the Microsoft® Win32® CreateFile function, for example). It could also be a URL name. The URL moniker filter uses IFileSourceFilter to retrieve its URL name, and IGraphBuilder::AddSourceFilter (and hence IGraphBuilder::RenderFile) handles this correctly. IGraphBuilder::AddSourceFilter returns a specific error (ERROR_FILE_NOT_FOUND) upon not finding the file, which indicates that the file specified does not exist and not that the filter does not exist.

© 1998 Microsoft Corporation. All rights reserved. Terms of Use.

*Top of Page