diff --git a/video/closedcaption/src/cea708mux/imp.rs b/video/closedcaption/src/cea708mux/imp.rs index eb4668b7..78491fe6 100644 --- a/video/closedcaption/src/cea708mux/imp.rs +++ b/video/closedcaption/src/cea708mux/imp.rs @@ -162,11 +162,6 @@ impl AggregatorImpl for Cea708Mux { .expect("Not a Cea708MuxSinkPad?!") }) { 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_state.pending_buffer.is_some() { @@ -207,17 +202,10 @@ impl AggregatorImpl for Cea708Mux { } let duration = buffer.duration().unwrap_or(gst::ClockTime::ZERO); 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::from_seconds(1) { - gst::warning!(CAT, obj = pad, - "Dropping buffer because start_running_time {} is more than 1s later than buffer_end_ts {}", - start_running_time.display(), - buffer_end_ts.display()); - pad.drop_buffer(); - if !have_pending { - need_data = true; - } - continue; + if start_running_time.saturating_sub(buffer_end_ts) > gst::ClockTime::ZERO { + // need to wait for the next input buffer which might need to be part of this + // output buffer. + need_data = true; } let Ok(mapped) = buffer.map_readable() else { @@ -242,6 +230,12 @@ impl AggregatorImpl for Cea708Mux { cc_data[1] = 0xFF; cc_data.extend(mapped.iter()); 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!(), } @@ -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); - } - } } _ => (), }