Microsoft DirectX 8.1 (C++)

Building a Filter Graph with the VMR

This topic applies to Windows XP Home Edition and Windows XP Professional only.

The main point to remember when you create filter graphs with the VMR is that you must configure the VMR before you connect it. The easiest approach is to create the VMR, add it to the filter graph, and configure it before you call IGraphBuilder::RenderFile. The Filter Graph Manager always tries to connect a filter in the graph before it searches the registry for new filters (see Intelligent Connect).

To build a graph that sends two independent video streams to the VMR, for example, two video files, follow these steps:

  1. Create the filter by calling CoCreateInstance.
  2. Add it to the graph by calling IFilterGraph::AddFilter.
  3. Query the VMR for its IVMRFilterConfig interface and call IVMRFilterConfig::SetNumberOfStreams to configure it for two streams. When the method returns, the VRM has two input pins.
  4. Call IGraphBuilder::RenderFile, specifying the name of the first MPEG-2 file. This will cause all the necessary filters to be loaded and connected ultimately to the first pin on the VMR.
  5. Call RenderFile again, this time with the name of the second file. This will cause a second set of filters to be loaded and connected to the second pin on the VMR.
  6. Run the graph. The default Z-order is the pin order, so the second stream is shown on top of the first.

Note   If the output pin on the decoder and the input pin on the VMR cannot agree on a connection, then a new instance of the VMR with default settings will be created. This will result in a new window with "ActiveMovie" in the title bar. To prevent this from happening, the application should always verify that the correct instance of the VMR is being used by calling a method such as IPin::ConnectedTo.