Displaying the Preview
Top  Previous  Next

To build a video preview graph, call the RenderStream method of ICaptureGraphBuilder2 interface.

The first parameter to the RenderStream method specifies a pin category; for a preview graph use PIN_CATEGORY_PREVIEW. The second parameter specifies a media type, as a major type GUID. For video, use MEDIATYPE_Video. The third parameter is a pointer to the capture filter's IBaseFilter 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 Video Renderer filter as the default renderer.

hr = pBuilder->RenderStream(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video,
pFilter, NULL, NULL);

To start/stop the graph, use the IMediaControl interface:

CComQIPtr <IMediaControl, &IID_IMediaContrlo> control = pGraph;

hr = control->Run();
   // start the graph
//// ........

   //stop the graph