i
i
i
i
i
i
i
i
390 15. Using Multimedia in VR
In multimedia applications, timing is important, and all FilterGraphs are
designed so that they can be synchronized with a real-time clock. Whether
playing back video files or recording video from a USB webcam, all programs
need to keep up with this clock. If the hardwar e or application software
cannot deliver the samples through the graph fast enough then some samples
will have to be discar ded.
For example, a video recorder application is saving AVI movie
files from a DV camera with a compression filter in the chain.
For NTSC video, it must read, compress and write 30 samples
(frames) per second. But suppose the compression filter can only
compress 25 samples per second. The camera cannot be slowed
down, nor are we allowed to only write 25 frames per second
into the AVI file while still claiming the AVI is a 30-fps movie
file.
DirectShow cleverly solved the problem for us, without any work
on the part of the program designer. It does this (in our exam-
ple) by dropping 5 out of every 30 samples, say samples 6, 12,
18, 24, 30, before the compression filter stage. After the com-
pression filter stage it adjusts the sample timings in the AVI file
so that either 30 samples (with some duplicates) are written per
second or 25 samples are written per second with the timing
changed so that a player will think each sample should be dis-
played for 40 ms instead of 33 ms.
Similar things happen in movie-player applications. If the video
source is supposed to play at 30 fps but the renderer filter can
only keep up at 25 fps then the DirectShow FilterGraph drops
five out of every 30 frames read from the file. It may even skip
reading samples from the source file itself.
Another term you will read about, with respect to DirectShow filters, is
the pin. A pin is a point of connection on a filter. Source filters have one
or more pins. Output filters generally have one pin. In-place filters have at
least two pins. Pins a re designated either as being an input pin or an output
pin. The FilterGraph is build by connecting one filter’s output pin to another
filter’s input pin. Thus, a FilterGraph can be something as simple as a source
filter and a sink filter, with the source filter’s output pin connected to the sink
filter’s input pin.