Microsoft DirectX 8.1 (C++) |
A capture device with a hardware video port might use the video port extensions (VPE) in Microsoft® DirectX®. If so, the capture filter will have a video port (VP) pin. On Windows® 98SE, Windows 2000, and Windows Me, the VP pin must connect to the Overlay Mixer filter, and the Overlay Mixer must connect to the Video Renderer filter. On Windows XP Home Edition and Windows XP Professional, the VP pin connects to the Video Port Manager (as shown in the diagram on that filter’s reference page).
No video data travels from the VP pin through the filter graph. Instead, video frames are produced in hardware and sent directly to video memory. The VP pin allows control messages to be sent to the hardware. It is very important to connect the VP pin, even if you're only interested in capture functionality, since if you leave the pin unconnected, your capture graph will not work. This is different from preview pins, which can remain unconnected. Always connect the VP pin to input pin 0 if you are using the Overlay Mixer.
The Video Renderer filter does not receive any video data from the Overlay Mixer. It controls the video window, however, so the filter graph must include it. You can make the video window a child of your application window by querying the filter graph manager for the IVideoWindow interface. For more information, see Setting the Video Window.
The following illustration shows a capture graph with a video port pin. (This diagram does not apply to filter graphs on Windows XP Home Edition and Windows XP Professional.)
The following code example connects a video port pin to the Overlay Mixer. It uses the ICaptureGraphBuilder2::FindPin method to find the capture filter's video port pin and the Overlay Mixer's input pin 0. (You could use the IBaseFilter::EnumPins method instead.) For brevity, the example omits error checking.
IPin *pPinOut, // Video port pin on capture filter.
*pPinIn; // Input pin on Overlay Mixer.
IBaseFilter *pOvMix = NULL;
// Find the video port pin.
pCGB->FindPin(
pCaptureFilter, // Pointer to capture filter.
PINDIR_OUTPUT, // Find an output pin.
&PIN_CATEGORY_VIDEOPORT, // Find a video port pin.
NULL, // Any media type.
TRUE, // Pin must be unconnected.
0, // Retrieve first matching pin.
&pPinOut // Address of pointer to pin.
);
// Create the overlay mixer.
CoCreateInstance(CLSID_OverlayMixer, NULL, CLSCTX_INPROC,
IID_IBaseFilter, (void **)&pOvMix);
// Add it to the filter graph.
pGraph->AddFilter(pOvMix, L"Overlay Mixer");
// Retrieve input pin 0 on the overlay mixer.
pCGB->FindPin(pOvMix, PINDIR_INPUT, NULL, NULL, TRUE, 0, &pPinIn);
//Connect the two pins.
pGraph->Connect(pPinOut, pPinIn);
You can use similar code to connect the Overlay Mixer to the Video Renderer, or call IGraphBuilder::Render with the Overlay Mixer's output pin.