Building a VMR-9 Filter Graph
Because the Video Mixing Renderer 9 Filter (VMR-9) is not the default video renderer, an application that uses the VMR-9 must explicitly add it to the graph and connect it. This section presents two different approaches to building filter graphs with the VMR-9.
Using the Capture Graph Builder
The Capture Graph Builder is a helper object for building custom filter graphs. You can use it to build VMR-9 graphs as follows:
- Create and initialize the Capture Graph Builder, as described in the topic About the Capture Graph Builder.
- Call CoCreateInstance to create the VMR-9:
- Call IFilterGraph::AddFilter on the Filter Graph Manager to add the VMR-9 to the filter graph:
- Call IGraphBuilder::AddSourceFilter to add a source filter for the video file:
- Call the ICaptureGraphBuilder2::RenderStream method to render the video stream to the VMR:
- Optionally, call RenderStream again to render the audio stream:
You can mix several video streams by calling AddSourceFilter and RenderStream for each source file.
Using the Filter Graph Manager
If you prefer not to use the Capture Graph Builder, you can build a VMR-9 graph simply using methods on the Filter Graph Manager, as follows:
- Create the VMR-9 and add it to the graph, as shown in the previous procedure.
- Use AddSourceFilter to add a source filter for the video file, as shown in the previous procedure.
- If you want to render the audio, create an instance of the DirectSound Renderer filter and add it to the filter graph.
- Use the IBaseFilter::EnumPins method to find an output pin on the source filter. See Enumerating Pins for details.
- Query the Filter Graph Manager for the IFilterGraph2 interface.
- Call IFilterGraph2::RenderEx with the AM_RENDEREX_RENDERTOEXISTINGRENDERERS flag. This call renders the output pin, using only the renderer filters already in the graph — in this case, the VMR-9 and the DirectSound Renderer. This prevents the Intelligent Connect logic from adding the default video renderer to the graph, which would leave the VMR-9 unconnected.