Microsoft DirectX 8.1 (C++) |
To capture a type-1 file while previewing, use the filter graph shown in the following diagram.
The Smart Tee filter splits the interleaved DV stream, which enables you to capture the stream to a file while sending it to the DV Splitter for preview at the same time. You can build this graph in just a few lines of code, as follows:
ICaptureGraphBuilder2 *pBuilder; // Capture graph builder.
IBaseFilter *pDV; // MSDV.
IBaseFilter *pAviMux // Avi Mux.
// Initialize pDV (not shown).
// Create the Capture Graph Builder (not shown).
// Create the file-writing section of the graph.
hr = pBuilder->SetOutputFileName(&MEDIASUBTYPE_Avi,
OLESTR("C:\\Example1.avi"), &pAviMux, 0);
// Render the capture and preview streams.
hr = pBuilder->RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Interleaved,
pDV, 0, pAviMux);
hr = pBuilder->RenderStream(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Interleaved,
pDV, 0, 0);
// Remember to release all interfaces!
The ICaptureGraphBuilder2::SetOutputFileName method connects the AVI Mux filter to the File Writer filter. The first call to ICaptureGraphBuilder2::RenderStream automatically inserts the Smart Tee filter and connects it to the AVI Mux. The second call renders the Smart Tee filter's preview pin. Except for MSDV, every filter is automatically added to the graph by these two methods.