tttocea608: make mode property mutable in PLAYING

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/474>
This commit is contained in:
Mathieu Duponchelle 2021-02-10 19:28:43 +01:00 committed by GStreamer Merge Bot
parent 2cde437bee
commit 126df546c0

View file

@ -107,7 +107,6 @@ impl Default for Settings {
} }
struct State { struct State {
settings: Settings,
framerate: gst::Fraction, framerate: gst::Fraction,
erase_display_frame_no: Option<u64>, erase_display_frame_no: Option<u64>,
last_frame_no: u64, last_frame_no: u64,
@ -118,12 +117,12 @@ struct State {
underline: bool, underline: bool,
column: u32, column: u32,
mode: Cea608Mode, mode: Cea608Mode,
force_clear: bool,
} }
impl Default for State { impl Default for State {
fn default() -> Self { fn default() -> Self {
Self { Self {
settings: Settings::default(),
framerate: gst::Fraction::new(DEFAULT_FPS_N, DEFAULT_FPS_D), framerate: gst::Fraction::new(DEFAULT_FPS_N, DEFAULT_FPS_D),
erase_display_frame_no: None, erase_display_frame_no: None,
last_frame_no: 0, last_frame_no: 0,
@ -134,6 +133,7 @@ impl Default for State {
style: TextStyle::White, style: TextStyle::White,
underline: false, underline: false,
mode: Cea608Mode::PopOn, mode: Cea608Mode::PopOn,
force_clear: false,
} }
} }
} }
@ -801,12 +801,14 @@ impl TtToCea608 {
})?; })?;
let mut state = self.state.lock().unwrap(); let mut state = self.state.lock().unwrap();
let settings = self.settings.lock().unwrap();
let mut lines = Lines { let mut lines = Lines {
lines: Vec::new(), lines: Vec::new(),
mode: None, mode: Some(settings.mode),
clear: None, clear: Some(state.force_clear),
}; };
state.force_clear = false;
match state.json_input { match state.json_input {
false => { false => {
let data = std::str::from_utf8(&data).map_err(|err| { let data = std::str::from_utf8(&data).map_err(|err| {
@ -841,6 +843,8 @@ impl TtToCea608 {
} }
} }
drop(settings);
self.generate(&mut state, element, pts, duration, lines) self.generate(&mut state, element, pts, duration, lines)
} }
@ -929,8 +933,8 @@ impl TtToCea608 {
let mut state = self.state.lock().unwrap(); let mut state = self.state.lock().unwrap();
*state = State::default(); *state = State::default();
state.settings = self.settings.lock().unwrap().clone();
state.mode = state.settings.mode; state.mode = self.settings.lock().unwrap().mode;
if state.mode != Cea608Mode::PopOn { if state.mode != Cea608Mode::PopOn {
state.send_roll_up_preamble = true; state.send_roll_up_preamble = true;
@ -996,7 +1000,7 @@ impl ObjectImpl for TtToCea608 {
"Which mode to operate in", "Which mode to operate in",
Cea608Mode::static_type(), Cea608Mode::static_type(),
DEFAULT_MODE as i32, DEFAULT_MODE as i32,
glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_READY, glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_PLAYING,
)] )]
}); });
@ -1023,6 +1027,7 @@ impl ObjectImpl for TtToCea608 {
settings.mode = value settings.mode = value
.get_some::<Cea608Mode>() .get_some::<Cea608Mode>()
.expect("type checked upstream"); .expect("type checked upstream");
self.state.lock().unwrap().force_clear = true;
} }
_ => unimplemented!(), _ => unimplemented!(),
} }
@ -1110,10 +1115,9 @@ impl ElementImpl for TtToCea608 {
match transition { match transition {
gst::StateChange::ReadyToPaused => { gst::StateChange::ReadyToPaused => {
let mut state = self.state.lock().unwrap(); let mut state = self.state.lock().unwrap();
let settings = self.settings.lock().unwrap();
*state = State::default(); *state = State::default();
state.settings = settings.clone(); state.force_clear = false;
state.mode = state.settings.mode; state.mode = self.settings.lock().unwrap().mode;
if state.mode != Cea608Mode::PopOn { if state.mode != Cea608Mode::PopOn {
state.send_roll_up_preamble = true; state.send_roll_up_preamble = true;
} }