Video Samples

The video sample object is a specialized implementation of the IMFSample interface for use with the Enhanced Video Renderer (EVR). To create an instance of this object, call the MFCreateVideoSampleFromSurface function. The function takes a pointer to a Direct3D surface and returns a pointer to the IMFSample interface. The following types of objects should allocate samples using this function:

The video sample object implements the following interfaces:

If the pUnkSurface parameter of MFCreateVideoSampleFromSurface is non-NULL, the resulting video sample contains a single media buffer that encapsulates the Direct3D surface. This buffer object has limited functionality:

The only way to access the surface from the buffer is to call IMFGetService::GetService, using the service identifier MR_BUFFER_SERVICE.

If the pUnkSurface parameter is NULL, the video sample is created with zero media buffers. To add a buffer the sample, do the following:

  1. Create a Direct3D surface.

  2. Create a surface buffer by calling MFCreateDXSurfaceBuffer. For more information, see DirectX Surface Buffer.

  3. Add the buffer to the sample by calling IMFSample::AddBuffer.

Use this approach if you need the surface memory to be accessible through the IMF2DBuffer interface.

Media Buffers

Media Samples