GMFBridge with GMF GDCL MPEG 4 Mux Filter
I try to use GDCL MPEG 4 Mux with GMFBridge.
My original graph is:
SourceFilter ---> GDCL MPEG 4 Mux Filter ---> FileWriter
I want to give new file name based on my special criteria (such as time , for example every five minute) but not want to create whole graph again. So i try to use GMFBridge.
I does not work. I really can not figure out how to use GMFBridge or it does not work.
Note: Here is what i do with GMFBridge
In order to use , i divide my graph into two pieces:
FirstPart ==> SourceFilter---> GDCL MPEG 4 Mux Filter--> BridgeSinkFilter
and
SecondPart ==> BridgeSourceFilter ---> FileWriter
My Program Pseudo Code
IGraphBuilder firstPartGraph = (IGraphBuilder) new FilterGraph();
IGraphBuilder secondPartGraph = (IGraphBuilder) new FilterGraph();
IBaseFilter bridgeSinkFilter;
IBaseFilter bridgeSourceFilter;
IBaseFilter sourceFilter;
IBaseFilter muxerFilter;
IBaseFilter fileWriterFilter;
// Create bridge controller and init
IGMFBridgeController bridge = (IGMFBridgeController)new GMFBridgeController();
bridge.AddStream(true,eFormatType.MuxInputs, true);
// Then insert Sink filter
bridge.InsertSinkFilter(firstPartGraph, bridgeSinkFilter);
// Configure first part filters
firstPartGraph.AddFilter(sourceFilter);
firstPartGraph.AddFilter(muxerFilter);
firstPartGraph.AddFilter(bridgeSinkFilter); // Have to add this??
ConnectFilters(firstPar开发者_StackOverflow中文版tGraph,sourceFilter,muxerFilter);
ConnectFilters(firstPartGraph,muxerFilter,bridgeSinkFilter);
// Now add bridge sourceFilter
bridge.InsertSourceFilter(bridgeSinkFilter,secondPartGraph,bridgeSourceFilter);
// Then configure second part graph
secondPartGraph.AddFilter(bridgeSourceFilter); // Have to add this??
secondPartGraph.AddFilter(fileWriterFilter);
ConnectFilters(secondPartGraph,bridgeSourceFilter,fileWriterFilter);
// Now bridge two graphs
bridge.BridgeGraphs(bridgeSinkFilter,fileWriterFilter,bridgeSourceFilter);
// Execute both graphs
IMediaControl mediaControlForPartOne = (IMediaControl)firstPartGraph;
mediaControlForPartOne->Run();
IMediaControl mediaControlForPartSecond = (IMediaControl)secondPartGraph;
mediaControlForPartSecond->Run();
Now how to stop the second graph part and set new file name and then reconnect graphs using bridge?
FIX IT:
Thanks.
I just change my grapg divison and Now work:
FirstPart ==> SourceFilter--> BridgeSinkFilter
SecondPart ==> BridgeSourceFilter ---> GDCL MPEG 4 Mux Filter---> FileWriter
You need to place the mux & file writer in the second graph. There are two reasons for this. Firstly, the traffic between mux and file writer includes custom interfaces, not just standard IMemInputPin protocols (to permit finalisation of headers after the graph has stopped) and secondly, it is the mux that you want to stop in order to close the file, not the file writer.
So, source in the first graph, and mux=>file writer in the second graph and you should be ok.
G
If you have both graphs working, and getting correct output in the second graph; you can disconnect the graphs:
BridgeGraphs(NULL, NULL);
Now you can stop the second graph, delete it and create a new one. Start the new graph, and connect them again:
BridgeGraphs(bridgeSinkFilter, newBridgeSourceFilter);
精彩评论