tttocea608: expose roll-up timeout property

In roll-up mode, when no more timed text comes in, the closed
captions may remain displayed on screen indefinitely (unless the
decoder implements a timeout, but that is not mandatory).

Expose a property to erase the display memory after a configurable
amount of time has elapsed instead.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/754>
This commit is contained in:
Mathieu Duponchelle 2022-05-10 18:50:33 +02:00 committed by Sebastian Dröge
parent a3fad9e028
commit 71877934b5

View file

@ -95,6 +95,7 @@ struct Settings {
mode: Cea608Mode,
origin_row: i32,
origin_column: u32,
roll_up_timeout: Option<gst::ClockTime>,
}
impl Default for Settings {
@ -103,6 +104,7 @@ impl Default for Settings {
mode: DEFAULT_MODE,
origin_row: DEFAULT_ORIGIN_ROW,
origin_column: DEFAULT_ORIGIN_COLUMN,
roll_up_timeout: gst::ClockTime::NONE,
}
}
}
@ -188,6 +190,8 @@ impl State {
if let Some(erase_display_frame_no) = self.erase_display_frame_no {
if self.last_frame_no == erase_display_frame_no - 1 {
self.erase_display_frame_no = None;
self.column = 0;
self.send_roll_up_preamble = true;
self.erase_display_memory(element, bufferlist);
return true;
}
@ -792,6 +796,9 @@ impl TtToCea608 {
if state.mode == Cea608Mode::PopOn {
state.erase_display_frame_no =
Some(state.last_frame_no + duration.mul_div_round(fps_n, fps_d).unwrap().seconds());
} else if let Some(timeout) = settings.roll_up_timeout {
state.erase_display_frame_no =
Some(state.last_frame_no + timeout.mul_div_round(fps_n, fps_d).unwrap().seconds());
}
state.pad(element, mut_list, state.max_frame_no);
@ -1081,6 +1088,15 @@ impl ObjectImpl for TtToCea608 {
DEFAULT_ORIGIN_COLUMN,
glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_PLAYING,
),
glib::ParamSpecUInt64::new(
"roll-up-timeout",
"Roll-Up Timeout",
"Duration after which to erase display memory in roll-up mode",
0,
u64::MAX,
u64::MAX,
glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_PLAYING,
),
]
});
@ -1121,6 +1137,16 @@ impl ObjectImpl for TtToCea608 {
state.force_clear = true;
state.column = settings.origin_column;
}
"roll-up-timeout" => {
let mut settings = self.settings.lock().unwrap();
let timeout = value.get().expect("type checked upstream");
settings.roll_up_timeout = match timeout {
u64::MAX => gst::ClockTime::NONE,
_ => Some(gst::ClockTime::from_nseconds(timeout)),
};
}
_ => unimplemented!(),
}
}
@ -1139,6 +1165,15 @@ impl ObjectImpl for TtToCea608 {
let settings = self.settings.lock().unwrap();
settings.origin_column.to_value()
}
"roll-up-timeout" => {
let settings = self.settings.lock().unwrap();
if let Some(timeout) = settings.roll_up_timeout {
timeout.nseconds().to_value()
} else {
u64::MAX.to_value()
}
}
_ => unimplemented!(),
}
}