The DirectShow Filter Graph Manager
A DirectShow application interacts with a filter graph manager. This provides a central point of control for the application and is responsible for building and controlling the graph, and distributing state change information to the filters.
The filter graph manager is a COM object created by CoCreateInstance. It will build the graph using IGraphBuilder either by passing in a file or by directly inserting and connecting filters. Filters can be connected indirectly, in which case the filter graph manager will use transform filters as necessary to transform the data type so that a connection can be made.
In addition to basic graph-building services, the filter graph manager also acts as a single point of control. The application queries for control and status interfaces from the filter graph manager, which will implement the interfaces by calls to the graph. For example, IMediaControl::Run is implemented by calling the Run method of every filter (in a particular order: the threading rules of DirectShow which are designed to ensure that filters do not have to have their own thread require state changes such as Run to be done in an upstream order or a deadlock may result: one reason for letting the filter graph manager do it).
This mechanism is extensible via plug-in distributors. You can register a COM object as a distributor for any interface not currently supported by the filter graph: when the application queries for that interface on the filter graph manager, it will look in the registry for a Distributor key in the registry and will load that object. The distributor is then responsible for implementing its interfaces by calls to the filters in the graph. This provides an extension mechanism so that any filter can implement custom interfaces that are then exposed straightforwardly to the application, even if that application is Visual Basic. All the standard control interfaces are implemented by plug-in distributors in DirectShow. Note that although they are in theory replaceable, in practice you are unlikely to survive replacing any of them as they are all interwoven.