Implement SetPCR in stream outputs
Motivations:
PCR
events gives solid information of a stream data input timestamps state. When a PCR
event comes in, you know that no data will arrive with a timestamp below the given pcr value.
This kind of information could be very valuable in stream out scenarios where you need precise stream advancement. I'm currently working on an HLS stream output implementation (mainly for chromecast uses) and PCR
events are a great tool to properly end HLS segments.
Problematics:
PCR
events can hardly travel as in-band data after they've left demux. Implementing it that way would've required an enormous amount of reworks so we decided not to go that way.
Instead we decided to forward the PCR
events from the demuxer to the stream outputs using separate callbacks. This could work well but the implementation require a lot of care due to some of the problematics listed below:
- The asynchronous nature of the
es_out
'sDecoderThread
and thetranscode
pipeline. Frames are treated in a separate thread so we can't just forward PCR events, there need to be a synchronizing mechanism for such cases, at least for modules (we can work around the case in the input decoder by removing the decoder thread since it's not really needed). - In some filter or encoder cases, frame timestamps can be shifted, frames can be duplicated/merged/dropped. PCR value needs to be re-synthetized accordingly.
- Muxers work on the pull model for now, it makes forwarding PCR events to them non-trivial and the implementation method should still be discussed.
Work to be done
This subject has been approached at some VLC Workshop: #26378 (closed) #26825 (closed)
To submit these changes, I've decided to split modifications in several merge requests to ease the review and introduce the changes progressively:
-
Remove the decoder thread in stream output scenarios (!1847 (merged)) -
Implement the SetPCR
callback and forward it from the demux (!1394 (merged)) -
Properly forward SetPCR
insout filters
to the next streams (!2694 (merged))-
Autodel -
Bridge -
Cycle -
Delay -
Duplicate -
Gather -
Setid -
Stats -
Transcode (!2052 (merged))
-
-
Forward SetPCR
from sout to demuxes