cea708mux: handle different timestamped inputs

If different inputs have different framerates, then an input buffer may need
to be combined or split.  Account for that in the aggregate loop.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1942>
This commit is contained in:
Matthew Waters 2024-12-03 12:38:18 +11:00 committed by GStreamer Marge Bot
parent 00cb3fefe9
commit fe49837107

View file

@ -162,11 +162,6 @@ impl AggregatorImpl for Cea708Mux {
.expect("Not a Cea708MuxSinkPad?!") .expect("Not a Cea708MuxSinkPad?!")
}) { }) {
let mut pad_state = pad.imp().pad_state.lock().unwrap(); let mut pad_state = pad.imp().pad_state.lock().unwrap();
// any data we currently have stored
let have_pending = pad_state
.pending_services
.values()
.any(|codes| !codes.is_empty());
if pad.is_eos() { if pad.is_eos() {
if pad_state.pending_buffer.is_some() { if pad_state.pending_buffer.is_some() {
@ -207,17 +202,10 @@ impl AggregatorImpl for Cea708Mux {
} }
let duration = buffer.duration().unwrap_or(gst::ClockTime::ZERO); let duration = buffer.duration().unwrap_or(gst::ClockTime::ZERO);
let buffer_end_ts = buffer_start_ts + duration; let buffer_end_ts = buffer_start_ts + duration;
// allow a 1 second grace period before dropping data if start_running_time.saturating_sub(buffer_end_ts) > gst::ClockTime::ZERO {
if start_running_time.saturating_sub(buffer_end_ts) > gst::ClockTime::from_seconds(1) { // need to wait for the next input buffer which might need to be part of this
gst::warning!(CAT, obj = pad, // output buffer.
"Dropping buffer because start_running_time {} is more than 1s later than buffer_end_ts {}", need_data = true;
start_running_time.display(),
buffer_end_ts.display());
pad.drop_buffer();
if !have_pending {
need_data = true;
}
continue;
} }
let Ok(mapped) = buffer.map_readable() else { let Ok(mapped) = buffer.map_readable() else {
@ -242,6 +230,12 @@ impl AggregatorImpl for Cea708Mux {
cc_data[1] = 0xFF; cc_data[1] = 0xFF;
cc_data.extend(mapped.iter()); cc_data.extend(mapped.iter());
pad_state.ccp_parser.push(&cc_data).unwrap(); pad_state.ccp_parser.push(&cc_data).unwrap();
if let Some(cea608) = pad_state.ccp_parser.cea608() {
for pair in cea608 {
state.writer.push_cea608(*pair);
}
}
} }
_ => unreachable!(), _ => unreachable!(),
} }
@ -330,12 +324,6 @@ impl AggregatorImpl for Cea708Mux {
} }
} }
} }
if let Some(cea608) = pad_state.ccp_parser.cea608() {
for pair in cea608 {
state.writer.push_cea608(*pair);
}
}
} }
_ => (), _ => (),
} }