fmp4mux: Accept more data on already filled streams if the remaining streams need more data for finishing a GOP

In other words, continue queueing buffers in sync from all streams until
all of them are ready for draining instead of stopping to queue buffers
on every stream that is already filled individually.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/issues/310

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1086>
This commit is contained in:
Sebastian Dröge 2023-02-08 16:18:22 +02:00
parent 19c527a9c5
commit e52bb160c7

View file

@ -609,6 +609,19 @@ impl FMP4Mux {
timeout: bool,
fragment_duration: gst::ClockTime,
) -> Result<Option<&'a mut Stream>, gst::FlowError> {
if state
.streams
.iter()
.all(|s| s.fragment_filled || s.chunk_filled)
{
gst::trace!(
CAT,
imp: self,
"All streams are currently filled and have to be drained"
);
return Ok(None);
}
let mut earliest_stream = None;
let mut all_have_data_or_eos = true;
@ -627,16 +640,6 @@ impl FMP4Mux {
Err(err) => return Err(err),
};
if stream.fragment_filled {
gst::trace!(CAT, obj: stream.sinkpad, "Stream has current fragment filled");
continue;
}
if stream.chunk_filled {
gst::trace!(CAT, obj: stream.sinkpad, "Stream has current chunk filled");
continue;
}
gst::trace!(
CAT,
obj: stream.sinkpad,
@ -689,8 +692,6 @@ impl FMP4Mux {
stream: &mut Stream,
mut pre_queued_buffer: PreQueuedBuffer,
) -> Result<(), gst::FlowError> {
assert!(!stream.fragment_filled);
gst::trace!(CAT, obj: stream.sinkpad, "Handling buffer {:?}", pre_queued_buffer);
let delta_frames = stream.delta_frames;
@ -1096,7 +1097,7 @@ impl FMP4Mux {
gst::trace!(
CAT,
obj: stream.sinkpad,
"Current fragment start{}, current fragment end {}",
"Current fragment start {}, current fragment end {}",
fragment_start_pts,
fragment_start_pts + settings.fragment_duration,
);