Using GraphEdit to Explore DirectShow


The quickest way to see DirectShow in action is to play around with the GraphEdit utility. This utility, which is installed as part of the DirectX SDK, gives you a way to visualize what happens inside a DirectShow application. With GraphEdit, you ll get an intuitive feel for filters and filter graphs.

Launch GraphEdit from the Start menu. Under Programs, click Microsoft DirectX 9.0 SDK, then DirectX Utilities, and then GraphEdit. Figure 9.3 shows the GraphEdit window after startup.

click to expand
Figure 9.3: DirectShow GraphEdit utility.

To see how GraphEdit works, trying using it to play a video file. From the File menu, click Render Media File. From the Open File dialog box that appears, select an AVI file on your local machine and click Open. At this point, a bunch of rectangles and arrows will appear in the GraphEdit window. The rectangles represent DirectShow filters, and the arrows represent pin connections. Figure 9.4 shows the result if you open Ruby.avi, one of the sample media files provided in the DirectX SDK. If you select a different video file, a different set of filters might be selected.

click to expand
Figure 9.4: AVI file playback in GraphEdit.

Next click the Play button in the toolbar, or click Play from the Graph menu. The video will begin to play inside a pop-up window entitled ActiveMovie Window. You can stop playback by clicking the Stop button, or pause playback by clicking the Pause button. While the video is paused , the most recent frame is displayed in the window. If you pause before starting playback, the first frame in the file is displayed. You can seek by dragging the slider bar.

Now we ll describe the same steps in terms of the DirectShow architecture. When you select Render Media File, GraphEdit calls a DirectShow method that instructs the Filter Graph Manager to build a filter graph for file playback.

In very broad terms, the graph-building process works as follows :

  • The Filter Graph Manager first determines the file format. Based on this information, it selects a source filter and adds it to the filter graph.

  • Next, the Filter Graph Manager goes through a recursive process of adding more filters to the graph. At each step, it queries the most recent filter for a list of possible media types. Then it looks for filters installed on the user s computer that can accept any of those media types as input. (This information is stored in the system registry.) If it finds a match, it adds that filter to the graph and attempts to connect it to the previous filter.

  • This process continues until every stream terminates with a renderer filter.

Once the process completes, the filter graph is ready to begin playback. When you click the Play button in GraphEdit, the Filter Graph Manager sets the graph in motion by sending run commands to all the filters. At that point, data begins to stream through the graph and is rendered as audio and video.




Fundamentals of Audio and Video Programming for Games
Fundamentals of Audio and Video Programming for Games (Pro-Developer)
ISBN: 073561945X
EAN: 2147483647
Year: 2003
Pages: 120

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net