I'm using DirectShow.NET with GMFBridge to build an application similar to the the GMFPreview example application, which allows one to render a preview from the video without glitches when video capture is stopped.
In my application, instead of starting/stopping to capture when a button is clicked, it does so every 30 minutes, so that I have continuous recording from the video source, broken into 30 minutes files - it shouldn't lose a single frame during the stop/start interval.
A simplified layout of the filters would be:
[ Source Graph ]
RTSP/RTMP Source [video+audio] --> Inf. Tee Filter --> Bridge Sink -->
--> [ Bridge Controller ] -->
--> Bridge Source --> AsfWriter [Capture graph]
--> Bridge Source --> NullRenderer [Preview graph]
The point of using GMFBridge here is that it allows the RTSP/RTMP Source to be always connected. BTW, my source comes from a device in the LAN.
When I stop capturing I do this:
public void Break()
{
int hr = BridgeController.BridgeGraphs(null, null);
int hr = RecMediaControl.Stop(); // stops the capture graph
... // Set filename for next recording
int hr = RecMediaControl.Run(); // starts the capture graph
int hr = BridgeController.BridgeGraphs(bridgeSink, captureGraph);
}
The problem is that the thread running this code sometimes gets stuck inside the "disconnect" method:
BridgeGraphs(null, null);
No error is thrown, it just stays there forever. Other threads continue executing normally, so I get a huge video file, instead of several 30 minutes files.
Preview graph is started when application starts to run and is also stopped when application finishes. The article explaining how to use GMFBridge seems to be written for a device which had a Capture pin and a Preview pin, which is not my case. I think that what I've done sets the Bridge Controller in suspend mode instead of discard mode, which would probably be more appropriate, but I'm not sure. Still, if I eliminate the preview graph, the same problem occurs.
This problem doesn't happen on all machines, and also it happens randomly - sometimes I have to wait several hours or even days for it to happen. I'm running out of ideas, anyone has a clue of what is going on? Thanks.