User`s manual

Programming Guide 41
5 Programming Guide
5.1 DirectShow Application Programming Introduc-
tion
A complete documentation on DirectShow application program-
ming can be found at http://msdn.microsoft.com/library/
default.asp?url=/library/en-us/directx9_c/directX/htm/intro-
ductiontodirectshow.asp. If a DirectX 9.0 is installed, this docu-
mentation is also available from DirectX SDK Help.
The purpose of writing a DirectShow Application is to build a filter
graph by connecting several filters together to perform a given
task such as previewing video/audio, capturing video/audio and
multiplexing them to write into a file. Each filter performs a single
operation and pass data from its output pin to the input pin of the
next filter in the graph.
To build a capture graph using a program, first obtain the interface
pointer of the capture filter. The ADLink Bt878 Video Capture filter
and the ADLINK Hardware MPEG4 Device filter can be obtained
through the system device enumerator. After holding an inter-
face pointer to the capture filter object, use method IGraph-
Builder::AddSourceFilter to add the source filter object to the
filter graph. Use IFilterGraph::AddFilter to add other downstream
filters to the filter graph. After filters are added, call IFilter-
Graph::ConnectDirect or IGraphBuilder::Connect methods to
connect output pins from upstream filters to the input pins of the
downstream filters. Calling methods such as IMediaCon-
trol::Run, IMediaControl::Pause, or IMediaControl::Stop will
change filter state to running, paused or stopped.
The filters needed for capturing MPEG4 streams are listed in sec-
tion 5.2, along with a detailed description for each filter and its
pins. Example filter graphs for previewing/capturing MPEG4
streams are illustrated in section 5.3. Section 5.4 provides exam-
ples of two ways of controlling the device driver.