Working with the Filter Graph Manager of a Capture Graph

Working with the Filter Graph Manager of a Capture Graph

After using the Capture Graph Builder to create the filter graph, we must obtain the IMediaControl interface on the Filter Graph Manager to run, stop, and pause the graph. By calling ICaptureGraphBuilder2::GetFilterGraph, we obtain a pointer to the Filter Graph Manager s IGraphBuilder interface. We can then use that interface to obtain the IMediaControl interface.

The EnumerateAudioInputFilters function used in DSAudioCap has been reworked slightly to create GetAudioInputFilter, which returns an audio input filter with a specific FriendlyName, if it exists. The function is invoked with a request for a filter with the Logitech label a microphone built into the webcam. Changing the value of this string returns a different audio input filter if a match can be found. You d change this string if you were using another brand of webcam in your own DirectShow programs. (Ideally, you d write a program that wouldn t be tied to any particular brand of hardware, allowing the user to select from a list of hardware that had been recognized by DirectShow as being attached to the computer.) Once the appropriate filter is located, it s added to the filter graph using the IGraphBuilder method AddFilter.

Next we do much the same thing with video input devices. We ve created the GetVideoInputFilter routine, which is nearly a carbon copy of GetAudioInputFilter, except that the GUID for the class enumerator provided in the call to CreateClassEnumerator is CLSID_VideoInputDeviceCategory rather than CLSID_AudioInputDeviceCategory. Once again, the function walks through the list of available capture devices, looking for one that has a FriendlyName that will match the one I m looking for, which is labeled Logitech. An instance of the matching video input filter is returned to the caller, and it s then added to the filter graph. (Monikers are a fast, cheap way to find a particular filter because DirectShow doesn t need to create instances of each filter object to determine its FriendlyName or other properties.)



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