GMFBridge usage in DirectShow

馋奶兔 提交于 2019-11-28 12:54:48

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!