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.

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.

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 methodsDescription
QueryInterface Returns pointers to supported interfaces.
AddRef Increments the reference count.
Release Decrements the reference count.
IFileSourceFilter methodsDescription
Load Loads the source filter with the file.
GetCurfile Retrieves the current file.

IFileSourceFilter::GetCurfile

IFileSourceFilter Interface

Collects information about the file to open.

Syntax

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

Parameters

ppszFileName
[out] Address of a pointer to the path to the loaded file.
pmt
[out] Pointer to the media type.

Return Value

Returns an HRESULT value that depends on the implementation. HRESULT can be one of the following standard constants, or other values not listed.
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.

Syntax

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

Parameters

pszFileName
[in] Pointer to the absolute path of the file to open.
pmt
[in] Pointer to the media type of the file. This can be NULL.

Return Value

Returns an HRESULT value that depends on the implementation. HRESULT can be one of the following standard constants, or other values not listed.
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.

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.


Top of Page Top of Page
© 2000 Microsoft and/or its suppliers. All rights reserved. Terms of Use.