cea708overlay: clear more things on caption timeout

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1983>
This commit is contained in:
Matthew Waters 2024-12-11 22:22:30 +11:00 committed by GStreamer Marge Bot
parent ae90dd4afe
commit db8e1da65d
3 changed files with 33 additions and 6 deletions

View file

@ -774,4 +774,13 @@ impl Cea608Renderer {
self.rectangle = Some(rect.clone());
Some(rect)
}
pub fn clear(&mut self) {
self.state.reset();
let channel = self.channel();
self.frame.reset();
if let Some(channel) = channel {
self.set_channel(channel);
}
}
}

View file

@ -241,6 +241,7 @@ impl Cea708Overlay {
}
state.cea708_renderer.push_service(service);
self.reset_timeout(state, pts);
}
}
@ -296,6 +297,7 @@ impl Cea708Overlay {
}
fn reset_timeout(&self, state: &mut State, pts: gst::ClockTime) {
gst::trace!(CAT, "resetting timeout to {pts:?}");
state.last_cc_pts = Some(pts);
}

View file

@ -399,6 +399,10 @@ impl Cea708Renderer {
pub fn clear_composition(&mut self) {
self.composition.take();
if let Some(service) = self.service.as_mut() {
service.clear();
}
self.cea608.clear();
}
pub fn generate_composition(&mut self) -> Option<gst_video::VideoOverlayComposition> {
@ -583,6 +587,14 @@ impl ServiceState {
*self = Self::new();
}
fn clear(&mut self) {
for window in self.windows.iter_mut() {
window.lines.clear();
window.pen_location = SetPenLocationArgs::default();
window.rectangle.take();
}
}
fn handle_code(&mut self, code: &Code) {
match code {
Code::DefineWindow(args) => self.define_window(args),
@ -1297,13 +1309,17 @@ impl Window {
}
};
let buffer = match render_buffer() {
let buffer = if width > 0 && height > 0 {
match render_buffer() {
Ok(buffer) => buffer,
Err(e) => {
self.dump();
gst::error!(CAT, "Failed to render buffer: \"{e}\"");
return None;
}
}
} else {
return None;
};
gst::trace!(
CAT,