Introducing GraphEdit

Introducing GraphEdit

The basic elements of DirectShow applications filters, connections, and filter graphs can be easily represented visually, and drawing a diagram of a DirectShow filter graph can be an important aid in the design process. GraphEdit can be thought of as a whiteboard on which prototype DirectShow filter graphs can be sketched. However, because GraphEdit is built using DirectShow components, these whiteboard designs are fully functional, executable DirectShow programs. More than just a design tool, GraphEdit is a rapid prototyping environment for DirectShow. Any DirectShow application, regardless of complexity, can be built and tested in GraphEdit before you write a single line of application code.

To launch GraphEdit, select Programs from the Start menu, select Microsoft DirectX 9.0 SDK, select DirectX Utilities, and then select GraphEdit. When the program launches, you ll be presented with a large blank area, representative of an empty filter graph with no component filters, as shown in Figure 2-1.

figure 2-1 graphedit s startup state

Figure 2-1. GraphEdit s startup state

Rendering Media Files

GraphEdit makes it easy to render a wide range of media files. From the File menu, select Render Media File. You ll be presented with an Open File dialog box asking you to select a file to be rendered. Select the file John Boy 9 Foggy Day.wav (included on the CD-ROM). If your DirectX installation is correct, you should see the the filter graph shown in Figure 2-2.

GraphEdit has created a complete filter graph, with three components. From left to right, the filter graphs are

  • A source filter that points to the WAV file

  • A transform filter that parses the file into a series of samples

  • A renderer filter that passes the stream along to the default DirectSound device

As explained in Chapter 1, these three types of filters source, transform, and renderer can be found in nearly every filter graph. The filter graph created by GraphEdit to render the WAV file is minimal but complete. To hear the WAV file being rendered to the speakers (or whichever DirectSound device has been selected as the default), click the Play button on the toolbar, immediately below the menu bar, as shown in Figure 2-3.

figure 2-2 filter graph to render a wav file

Figure 2-2. Filter graph to render a WAV file

When you click the Play button, the WAV file begins to render and the control below the toolbar begins to fill with color, corresponding to how much of the WAV file has been read into the filter graph. You can pause the filter graph by clicking Pause or stop it by clicking Stop. (As you might expect, the Play, Pause, and Stop buttons send the run, pause, and stop messages to the filter graph.) After the entire stream has rendered to the DirectSound device, GraphEdit stops the filter graph.

Using the Render Media File option, a broad range of media files all the types understood by DirectShow can be rendered. In fact, trying to render these files is a good test of the DirectShow capabilities of your system. If you open a media file and DirectShow can t render it, it s likely that you don t have the appropriate collection of DirectShow filters (which might encourage you to write a DirectShow filter that could render the media type you re interested in).

figure 2-3 rendering the wav file

Figure 2-3. Rendering the WAV file

Enumerating Filter Types

To understand what kinds of filter graphs you can create in GraphEdit, you have to enumerate (list) all the possible filters available for DirectShow s use. From GraphEdit s Graph menu, select the first item, Insert Filters, and you ll see the dialog box shown in Figure 2-4.

figure 2-4 graphedit s insert filters dialog box enumerating all available directshow filters

Figure 2-4. GraphEdit s Insert Filters dialog box enumerating all available DirectShow filters

This dialog box uses the Windows convention of expandable lists of items. To the left of each list entry in the dialog box is a plus sign, which hides a list of DirectShow filters underneath. Clicking on the DirectShow Filters entry will present the entire list of DirectShow filters available to GraphEdit. The other filters enumerated in the Insert Filters dialog box are Windows Driver Model (WDM) devices (all valid WDM devices are available to DirectShow as filters), DirectX Media Objects (DMOs), Video for Windows devices, and so forth.



Programming Microsoft DirectShow for Digital Video and Television
Programming Microsoft DirectShow for Digital Video and Television (Pro-Developer)
ISBN: 0735618216
EAN: 2147483647
Year: 2002
Pages: 108
Authors: Mark D. Pesce

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