Transcript Direct Show

Direct Show
Introduction to DirectShow
And, I wish, a discussion
Direct Show Introduction
Component Model
Direct Show can build
your application
composing filters,
Combining them
togheter you can
view movies,
capture and so on .
....
Direct Show Introduction
What does DirectShow manage?
Video (play Back / Capture)
Audio (play Back / Capture)
Compression / Decompression
Filtering
Splitting / Mux / Demux
Direct Show Introduction
But, what’s the story with DSound and
DMusic?
DShow uses DSound to manipulate music
a DirectGraphics (3D and Draw) to
manipulate images and video effects
DMusic is something advanced for music
orchestration, a scripting environment to
control musical timeline
Direct Show Introduction
What’s a DShow App like?
1.
2.
3.
The application creates an instance of the Filter Graph Manager.
The application uses the Filter Graph Manager to build a filter
graph. The exact set of filters in the graph will depend on the
application.
The application uses the Filter Graph Manager to control the filter
graph and stream data through the filters. Throughout this
process, the application will also respond to events from the Filter
Graph Manager.
Direct Show Introduction
Recrompress Example
Open a file with a file Source
Split audio and video
First decompress the video stream
Recompress the Video
Use a mux to put video and audio togheter again
Write it down to a file
Direct Show Introduction
The Direct Show Transormation
DShow use a graph from sources to
renderes (audio and video)
Along the graph you can have filters
2 approaches
In place transformations
Not in place transformations
Only C++ (the unmanaged one!)
Direct Show Introduction
CTransformFilter::Transform
This filter uses the CTransformInputPin
class for its input pin, and the
CTransformOutputPin class for its output
pin.
Use this base class if you want to try filter
and then pass it through the graph
Beware of memory leak!
Direct Show Introduction
Example of transform
HRESULT CRleFilter::Transform(IMediaSample *pSource, IMediaSample *pDest) {
// Get pointers to the underlying buffers. BYTE *pBufferIn, *pBufferOut;
hr = pSource->GetPointer(&pBufferIn);
if (FAILED(hr)) {
return hr;
}
hr = pDest->GetPointer(&pBufferOut);
if (FAILED(hr)) {
return hr;
}
// Process the data.
DWORD cbDest = EncodeFrame(pBufferIn, pBufferOut); KASSERT((long)cbDest <=
pDest->GetSize());
pDest->SetActualDataLength(cbDest);
pDest->SetSyncPoint(TRUE);
return S_OK;
}
Direct Show Introduction
CTransInPlaceFilter::Transform
Transform the input sample in place
Use it for real real-time processing
What do you want more?
Direct Show Introduction
The Frame Dispatcer Class
If you want to apply filter to a real time
camera or to an avi file in C# there’s an
utility from the Medialab (university of
Pisa) that can help you to get your frames
inside a managed application!
Direct Show Introduction