Partager via


Video Previews

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

To build a video preview graph, call the ICaptureGraphBuilder2::RenderStream method as follows:

ICaptureGraphBuilder2 *pBuild; // Capture Graph Builder
// Initialization of pBuild (not shown).

IBaseFilter *pCap; // Video capture filter.
// Initialize pCap and add it to the filter graph (not shown).

hr = pBuild->RenderStream(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video, 
    pCap, NULL, NULL);

This example assumes the following:

  • pBuild was initialized as described in the topic Capture Graph Builder.
  • pCap was initialized, by creating an instance of the capture filter and adding it to the filter graph**.

The first parameter to the ICaptureGraphBuilder2::RenderStream method specifies a pin category; for a preview graph, use PIN_CATEGORY_PREVIEW (see Pin Property Set). The second parameter specifies a media type, as a major type GUID. For video, use MEDIATYPE_Video (see Media Types and Sub Types). DV devices deliver interleaved audio and video, for which the media type is MEDIATYPE_Interleaved.

The third parameter is a pointer to the capture filter's IBaseFilter Interface interface. The next two parameters are not needed in this example. They are used to specify additional filters that might be needed to render the stream. Setting the last parameter to NULL causes the Capture Graph Builder to select a default renderer for the stream, based on the media type. For video, the Capture Graph Builder always uses the DirectShow Video Renderer Filter as the default renderer.

Although the pin category is given as PIN_CATEGORY_PREVIEW, it does not matter whether the filter actually has a preview pin; it could just have a capture pin. In either case, the Capture Graph Builder automatically builds the correct graph.

The following diagram shows the simplest possible graph for previewing video.

Aa931680.5320faeb-2b6c-4332-ae2e-09e7b1b3c1e6(en-us,MSDN.10).gif

In this diagram, the capture filter has a preview pin, which connects directly to the video renderer.

If the capture filter has only a capture pin, the Capture Graph Builder inserts a Smart Tee Filter, which splits the stream into a capture stream and a preview stream. This is described in more detail in Combining Video Capture and Preview.

See Also

Concepts

Video Capture