Partager via


Finding the Filters (Windows Embedded CE 6.0)

1/6/2010

The first step in creating a filter graph is to find and create the needed filters. All DirectShow filters are registered in the Windows registry with a GUID and other information such as which media types are supported, by category, or the filter's merit.

In addition, a filter can register the media types which it will accept for its input and output pins. This is done by registering a 'majortype' and 'subtype' GUID for each media type the filter will accept. The 'majortype' and 'subtype' correspond to the first two fields of the DirectShow Media Type structure (AM_MEDIA_TYPE) and are used in this way to find filters which process particular types.

Given the name of a file to play in the RenderFile call, the Filter Graph Manager can rapidly search the registry for filters that will support the kind of file it wants to play. This involves either using the file extension or searching for special 'check bytes' in the file. This generally results in the filter graph finding a source filter that it creates and adds to the filter graph, as well as telling the source filter the name of the file.

The source filter will generally have one or more output pins, although in some cases it can have none. Assuming the source filter has at least one output pin, the Filter Graph Manager code inside RenderFile will ask the source filter's output pins to list the media types of the data they output. The Filter Graph Manager can then search the registry for filters that accept those media types on their input pins (by using the majortype and subtype fields in the media types).

To actually do the search, the Filter Graph Manager creates an instance of the DirectShow Filter Mapper object and calls the IFilterMapper::EnumMatchingFilters method to search the registry. This method can enumerate DirectShow filters (as well as hardware devices such as decoders) by category or by media type, and it returns a standard COM IEnumMoniker:IUnknown object containing monikers to all the filters and/or hardware devices that match the search criteria. The use of COM monikers allows this method to query objects without actually instantiating them, and also to create paths and enumerate things which are not actually COM objects, such as hardware devices.

See Also

Concepts

Graph Building with Intelligent Connect