The problem is to build a capture graph supported three states:
- Preview only
- Capture to AVI-file only
- Combine
I have built the graph like this:
This graph corresponds to state 3. Now, if I want to change on state 2 I remove the preview stream and get the graph like this:
Imagine I run the graph and start capture. Now I want to back to state 3. How can I do this (add a preview stream) without stopping the graph? (Capture should continue).
UPD. Maybe it will be possible to capture to the end of AVI-file? If so, I could stop the graph at state 2, add a preview stream to it (change to state 3) and continue capture to the end of exsisting AVI-file (generated on previous step). Is it possible?
UPD2. I found some hack. When I want to change on state 2 from state 3 I just hide a preview-window. When I want to back to state 3 I show a preview-window. Thus, I don't need state 2 anymore since state 2 is just state 3 with hided preview-window!
Even though Dynamic Graph Building exists (see also Dynamic Reconnection), in most cases it is of little use:
In most DirectShow filters, pins cannot be reconnected while the graph is actively streaming data. The application must stop the graph before reconnecting the pins. However, some filters do support pin reconnections while the graph is running, a process known as dynamic reconnection.
Most likely the filters you are using would be incompatible with dynamic reconnection, or limiting extensibility. You might have other reasons to not use this approach, e.g. if you cannot afford delays and dropped data while dynamic operation is in progress.
The typical solution involves two graphs: live (capture, preview presentation) and recording. You pass data between the two to make the work in sync. You might want to read up of graph bridging and GMFBridge.
There are quite a few questions on this topic you might want to read as well:
- Directshow Preview Only and Capture & Preview with a single Graph
- DirectShow capturing to multiple files
- change recording file programmatically in directshow