This article details sample source filters. By definition, each of these source filter samples provides at least one output pin. (That is part of what makes them source filters as opposed to other kinds of filters.)
This article contains the following sections.
The sample asynchronous file reader source filter, Async, shows how to implement "progressive download" in the Microsoft® DirectShow® environment. Async implements the IAsyncReader interface, which is perhaps the most important aspect of asynchronous processing. It also implements the IFileSourceFilter interface and defines some helper classes to create filters that conform to the IAsyncReader interface.
The Memfile.exe application uses part of the Async sample code. This program reads a file into memory at a given rate (in kilobytes per second) and plays that file as it comes in.
This filter is not installed in the DirectShow run time and is not included in the list of DirectShow filters in the Filter Graph Editor. To use this filter, you must build and register it.
The bouncing ball sample source filter, Ball, illustrates format negotiation. Ball also illustrates the use of the source filter base classes CSource and CSourceStream.
The code in Fball.h and Fball.cpp manages the filter interfaces. Those two files contain approximately the minimum code required for a source filter. The Ball.h and Ball.cpp files contain the code that bounces the ball.
This filter has a single output pin, which provides a video stream that shows a ball bouncing around in the frame. The Ball filter also accepts quality-management requests from the downstream graph, which illustrates a simple quality-management strategy. This filter implements the IQualityControl interface for that purpose.
This filter is installed with the DirectShow run time and is available through the Filter Graph Editor when you choose Insert Filters from the Graph menu, and select the DirectShow Filters category.
The audio synthesizer sample filter, Synth, demonstrates use of the CSource and CSourceStream classes in an environment that derives its source from audio. You can use the Synth filter as a source filter to synthesize audio waveforms such as sine waveforms, square waveforms, sawtooth waveforms, and swept frequency waveforms.
The Synth source filter enables the user to set the waveform, frequency, number of channels, and other properties through the radio buttons, text boxes, sliders, and other controls on a property page. To set either the upper or lower endpoint of the swept frequency range, hold down SHIFT while adjusting the frequency slider. The property page enables only the controls that affect the audio formatfor example, channels, bits per sample, and sampling frequencywhile the filter is in a stopped state.
This filter is installed with the DirectShow run time and is available through the Filter Graph Editor when you choose Insert Filters from the Graph menu, and select the DirectShow Filters category.
The Mult sample contains code that supports the MultiFile source filter. The DirectShow Mult sample contains three subdirectories:
The VidCap sample video capture filter shows you how to handle special category filters, how to implement the COM interfaces for video capture, and how to implement miscellaneous other requirements for video capture.
The VidCap sample filter is not installed with the DirectShow run time. You must install it by calling Regsvr32.exe for VidCap.ax. The sample video capture filter is not part of the run time, but is part of the SDK.
A video capture filter with the same capability as VidCap is installed with the DirectShow run time and can be seen in the Filter Graph Editor when you choose Insert Filters from the Graph menu, under the Video Capture Sources category. The VidCap sample is included so that you can view the source code for a video capture filter and see how to write capture filters.
Unlike ordinary DirectShow filters, special category filters, such as Video Capture Source filters, can work with more than one device.
This sample demonstrates the use of IFilterMapper2, IAMVfwCaptureDialogs, IAMStreamControl, IAMStreamConfig, IAMVideoCompression, IAMDroppedFrames, IAMBufferNegotiation, and IKsPropertySet.
Top of Page
© 2000 Microsoft and/or its suppliers. All rights reserved. Terms of Use.