Export (0) Print
Expand All

Using the Video Display Controls

The IMFVideoDisplayControl interface controls how the enhanced video renderer (EVR) displays video inside an application window. This interface can be used in either DirectShow or Media Foundation. Internally, the video display controls are provided by the EVR's default presenter. If you write a custom presenter, you can provide the same interface or define a custom interface.

The correct way to get a pointer to the IMFVideoDisplayControl interface depends on whether you are using the DirectShow version of the EVR or the Media Foundation version. For the Media Foundation EVR, it also depends on whether you are using the EVR directly or using it through the Media Session (which is more typical).

To get a pointer to the IMFVideoDisplayControl interface, do the following:

  1. Get a pointer to the IMFGetService interface.

    • If you are using the DirectShow EVR filter, call QueryInterface on the filter.

    • If you are using the EVR media sink directly, call QueryInterface on the media sink.

    • If you are using the Media Session, call QueryInterface on the Media Session.

  2. If you are using the Media Session, wait for the Media Session to send the MESessionTopologyStatus event with a status value of MF_TOPOSTATUS_READY. (Skip this step otherwise.)

  3. Call IMFGetService::GetService to get the IMFVideoDisplayControl interface. The service identifier is MR_VIDEO_RENDER_SERVICE.

You can use the IMFVideoDisplayControl interface to perform the following tasks:

  • Set the clipping window.

  • Set the source and destination rectangles.

  • Update the video window in response to window messages.

  • Enable or disable full-screen mode.

Clipping Window

The application must provide a window where the EVR draws the video. To set the clipping window, call IMFVideoDisplayControl::SetVideoWindow with a handle to the application window.

If you create the EVR media sink through its activation object, this step is not required. The activation object automatically calls SetVideoWindow, using the window handle that you provided in the MFCreateVideoRendererActivate function.

Source and Destination Rectangles

During playback, the presenter takes a portion of the composited video image and draws it onto an area of the video window. The portion of the composited image is the source rectangle, and the area of the video window is the destination rectangle.

The source rectangle is defined using normalized coordinates where the point (0.0, 0.0) corresponds to the upper left corner of the video, and (1.0, 1.0) corresponds to the lower right corner of the video. The source rectangle can be any region within this rectangle. The destination rectangle is specified in pixels, relative to the client area of the window. The default source rectangle is the entire image, and the default destination rectangle is an empty rectangle.

To set the source and destination rectangles, call IMFVideoDisplayControl::SetVideoPosition.

If you create the EVR media sink through its activation object, this step is not required. The activation object automatically sets the destination rectangle equal to the entire client area of the window. However, you should call SetVideoPosition if you want to change the source rectangle or set a different destination rectangle.

Window Messages

During playback, your application should respond to certain window messages, as follows:

  • WM_PAINT: Call IMFVideoDisplayControl::RepaintVideo to repaint the video. Also, avoid painting over the destination rectangle while video is playing, because this can cause flickering.

  • WM_SIZE: You might need to call SetVideoPosition to resize the destination rectangle.

Unlike the Video Mixing Renderer (VMR) filter in DirectShow, you do not have to notify the EVR when you receive a WM_DISPLAYCHANGE message.

Related topics

Enhanced Video Renderer

 

 

Community Additions

ADD
Show:
© 2014 Microsoft