I would like to try to rewrite my video decoder with tbb flow graph and thought I'd ask for some advice.
Basically I thought I'd setup my graph as follows:
VideoDecoder(1 in -> x out) / Pushing Packet Source -> Broadcast Join -> Polling Target / AudioDecoder(1 in ->; x out)
The packet source basically sends video and audio packets interleaved with undefined distance/grouping, and only the decoders can decide if the packets are video or audio. For every valid packet the decoders can output none or several items.
"Packet Source" can be potentially blocking and should therefore preferrably be pushing so that I can put it on an explicit thread.The problem is that the decoders can have for every input token x amount of output tokens (including zero), is that even possible to achieve with tbb flow_graph? Taking the problem an additional step, if several output tokens can be generated from a single input token, I would only like to compute the extra output tokens if there is a "poll" on the decoder or if the decoder can "push" into the output (in ms concrt and agents this is achieved by calling "send" for every output token).
Furthermore, even though e.g. the audio-decoder has an item ready for the join, the video-decoder could potentially need y amount of more packets from the source before it has a ready item (due to the undefined interleaving/grouping). Though it is important that the audio-decoder does not miss any packets (even though it alrdy has enough packets) since there could potentially be audio-packets amongst them.
Then instead of calling graph.wait_for_all() I would like to be able to "poll" the graph for items, since flow rate of the graph should be decided by the target.Even though limiting the number of tokens in the graph is good enough, it would be preferrable to have some other limit, e.g. the size of all existing tokens in the graph.
I hoped I could get some advice and direction on possible solutions.