GMFBridge usage in DirectShow

前端 未结 1 864
感情败类
感情败类 2020-12-10 22:53

enter code hereI have to stop and start Video Renderer Filter dynamically . That is not possible with \"normal\" Direct Show Architecture without creat

相关标签:
1条回答
  • 2020-12-10 23:21

    You probably want to create the following two graphs:

    1: SourceFilter ---> MyCustomTransformFilter ---> GMFBridgeSinkFilter
    
    2: GMFBridgeSourceFilter ---> Video Renderer Filter
    

    Basically you do the following:

    Create a GMFBridgeController and configure it, for example one video and one audio stream:

    IGMFBridgeControllerPtr  m_pController; 
    HRESULT hr = m_pController.CreateInstance(__uuidof(GMFBridgeController)); 
    m_pController->AddStream(true, eUncompressed, true); 
    m_pController->AddStream(false, eUncompressed, true); 
    

    Now let the controller add a sink filter to the source graph and connect it:

    hr = m_pController->InsertSinkFilter(m_pSourceGraph, &m_pSourceGraphSinkFilter);
    // now connect it like this:
    // SourceFilter ---> MyCustomTransformFilter ---> SourceGraphSinkFilter
    

    In your second graph let the controller add a source filter, and connect it to the renderer:

    hr = m_pController->InsertSourceFilter(m_pSourceGraphSinkFilter, m_pRenderGraph, &m_pRenderGraphSourceFilter); 
    // now connect it like this:
    // RenderGraphSourceFilter ---> Video Renderer Filter
    

    Start both graphs and connect them:

    hr = m_pController->BridgeGraphs(m_pSourceGraphSinkFilter, m_pRenderGraphSourceFilter); 
    

    If you want to stop one graph, first disconnect:

    m_pController->BridgeGraphs(NULL, NULL);
    

    edit

    Here are some clarifications you asked for:

    GMFBridgeSinkFilter and GMFBridgeSourceFilter are the filters created by GMFBridge. I don't know their exact types, but at least they derive from IBaseFilter.

    m_pSourceGraph and m_pRenderGraph are the IGraphBuilder interfaces of both graphs you have created.

    m_pSourceGraphSinkFilter and m_pRenderGraphSourceFilter are pointers to IBaseFilter to receive the pointer to the filter created by GMFBridge.

    And yes, when I say connect filters, I mean programtically connect them. As far as I know you cannot test GMFBridge in graphedit.

    0 讨论(0)
提交回复
热议问题