locked
How to pass an existing Direct3DDeviceManager to a custom EVR presenter RRS feed

  • Question

  • Hi everyone,

    the custom EVR presenter documentation (http://msdn.microsoft.com/en-us/library/bb530107%28v=VS.85%29.aspx#ManagingtheDirect3DDevice) assumes that the presenter creates the Direct3D device and the device manager for that device. I was wondering what the best way is to do it the other way round...

    Assume a hosting application that uses Direct3D to do some rendering and creates a DeviceManager. I want to pass that existing DeviceManager to the custom presenter so it does not create it's own Direct3D device (as in the custom EVR presenter sample) but uses the same as the host application. The idea is to directly use the textures created by the custom presenter to do some rendering in the 3D scene. For this I have to move the present engine initialization to another call so I get a chance to pass my DeviceManager to the presenter. The question is where to move it to and what is the right time for the host application (when the presenter already exists but rendering has not started yet) to set the DeviceManager in the presenter?

    Note that I'm currently forced to use Direct3D 9 not 9Ex (might change in the future) and that there will be multiple videos running at the same time, each having it's own EVR instance I guess...

    Thanks

    Alex

    Wednesday, November 3, 2010 12:14 PM

Answers

  • If you are not using the protected media path, you do not need to instantiate an activate for the EVR.  You can just call MFCreateVideoRenderer to create the EVR directly. Then call IMFVideoRenderer::InitializeRenderer to set the right presenter, and use the SetVideoWindow and SetVideoPosition functions on IMFVideoDisplayControl to set up the EVR.  You can do all this before calling SetTopology on the session to guarantee that your custom presenter is initialized properly before streaming starts.
    • Marked as answer by ak_ventuz Wednesday, February 16, 2011 4:29 PM
    Wednesday, December 8, 2010 11:05 PM

All replies

  • The device manager should be set on the custom presenter before passing the presenter to IMFVideoRenderer::InitializeRenderer.  The custom presenter should return the common device manager when asked for the MR_VIDEO_RENDER_SERVICE service.
    Tuesday, November 16, 2010 2:54 AM
  • Hi Matt,

    that exactly was my question, how to do that "BEFORE" part. The sample program just sets the CLSIDPresenter in

    pActivate->SetGUID(MF_ACTIVATE_CUSTOM_VIDEO_PRESENTER_CLSID, m_clsidPresenter));

    then calls

    CHECK_HR(hr = m_pSession->SetTopology(0, pTopology));

    and before the player has a chance to react on the new COM instance being created the MR_VIDEO_RENDER_SERVICE service is requested. Seen from the player's perspective,it triggers SetTopology asynchronously and the next thing that happens is OnTopologyReady where it's already too late. I was almost expecting that the player would run into OnGetEvent or something else that basically says the presenter has been created but is not really "initialized" yet.

    Alex

    Monday, November 22, 2010 2:36 PM
  • If you are not using the protected media path, you do not need to instantiate an activate for the EVR.  You can just call MFCreateVideoRenderer to create the EVR directly. Then call IMFVideoRenderer::InitializeRenderer to set the right presenter, and use the SetVideoWindow and SetVideoPosition functions on IMFVideoDisplayControl to set up the EVR.  You can do all this before calling SetTopology on the session to guarantee that your custom presenter is initialized properly before streaming starts.
    • Marked as answer by ak_ventuz Wednesday, February 16, 2011 4:29 PM
    Wednesday, December 8, 2010 11:05 PM
  • Thanks, works like a charm. Took me a bit to figure out the exact calls in my case but now the implementation is pretty elegant...
    Wednesday, February 16, 2011 4:33 PM