Microsoft DirectX 8.1 (C++)

Filter Graphs and the Filter Graph Manager

To accomplish any task in DirectShow, an application creates one or more filters and connects them together, so that the data from one filter travels to the next, going from source filter to renderer. A set of filters that work together is called a filter graph. For example, the following illustration shows a filter graph for playing back an AVI file with compressed video:

Filter graph for playing back an AVI file with compressed video

The arrows show the direction of data flow. The source filter is the Async File Source, which reads a byte stream from the file and passes it to the AVI Splitter filter. The AVI Splitter reads the AVI headers and parses the data into time-stamped media samples. It passes the video samples to the AVI Decompressor, which decompresses each video frame and passes it to the video renderer filter. The video renderer displays the video. The AVI Splitter gives uncompressed audio samples to the DirectSound Renderer filter, which plays the audio on the sound card. If the audio were compressed, the graph would need an audio decompression filter between the AVI Splitter and the Default DirectSound Device filter.

The filter graph itself is not a distinct software component. However, it is managed by a COM object called the Filter Graph Manager. Among other tasks, the Filter Graph Manager controls state changes in the filter graph, establishes a reference clock for all the filters, and communicates between the filters and the application. The Filter Graph Manager can automatically build filter graphs for file playback. For more complex graphs, the Filter Graph Manager can often build a portion of the graph, reducing the amount of work required by the application.

Note   Filters always reside in the same process as the Filter Graph Manager. They are always loaded from in-process servers. Therefore, method calls are not marshalled between filters, or between filters and the Filter Graph Manager.

In graph terminology, a filter graph is a directed, acyclic, non-connected graph: