mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-12-18 16:16:28 +00:00
transcriberbin: set latencies on transcribers as soon as possible
Otherwise if we wait for setup_transcription(), the transcribers might already have reached the playing state. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1930>
This commit is contained in:
parent
ee6ab26d2a
commit
a71fd35ebf
1 changed files with 81 additions and 2 deletions
|
@ -117,6 +117,26 @@ pub struct TranscriberBin {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TranscriberBin {
|
impl TranscriberBin {
|
||||||
|
fn configure_transcriber(&self, transcriber: &gst::Element) {
|
||||||
|
let settings = self.settings.lock().unwrap();
|
||||||
|
let latency_ms = settings.latency.mseconds() as u32;
|
||||||
|
|
||||||
|
if transcriber.has_property_with_type("transcribe-latency", u32::static_type()) {
|
||||||
|
transcriber.set_property("transcribe-latency", latency_ms);
|
||||||
|
} else if transcriber.has_property_with_type("latency", u32::static_type()) {
|
||||||
|
transcriber.set_property("latency", latency_ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
if transcriber.has_property_with_type("translate-latency", u32::static_type()) {
|
||||||
|
let translate_latency_ms = settings.translate_latency.mseconds() as u32;
|
||||||
|
transcriber.set_property("translate-latency", translate_latency_ms);
|
||||||
|
}
|
||||||
|
if transcriber.has_property_with_type("lateness", u32::static_type()) {
|
||||||
|
let lateness_ms = settings.lateness.mseconds() as u32;
|
||||||
|
transcriber.set_property("lateness", lateness_ms);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn link_transcriber_to_channel(
|
fn link_transcriber_to_channel(
|
||||||
&self,
|
&self,
|
||||||
topbin: &super::TranscriberBin,
|
topbin: &super::TranscriberBin,
|
||||||
|
@ -1645,16 +1665,53 @@ impl ObjectImpl for TranscriberBin {
|
||||||
fn set_property(&self, _id: usize, value: &glib::Value, pspec: &glib::ParamSpec) {
|
fn set_property(&self, _id: usize, value: &glib::Value, pspec: &glib::ParamSpec) {
|
||||||
match pspec.name() {
|
match pspec.name() {
|
||||||
"latency" => {
|
"latency" => {
|
||||||
|
let state = self.state.lock().unwrap();
|
||||||
let mut settings = self.settings.lock().unwrap();
|
let mut settings = self.settings.lock().unwrap();
|
||||||
settings.latency = gst::ClockTime::from_mseconds(
|
settings.latency = gst::ClockTime::from_mseconds(
|
||||||
value.get::<u32>().expect("type checked upstream").into(),
|
value.get::<u32>().expect("type checked upstream").into(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if let Some(state) = state.as_ref() {
|
||||||
|
for pad in state.audio_sink_pads.values() {
|
||||||
|
let ps = pad.imp().state.lock().unwrap();
|
||||||
|
let pad_state = ps.as_ref().unwrap();
|
||||||
|
|
||||||
|
if let Some(ref transcriber) = pad_state.transcriber {
|
||||||
|
let latency_ms = settings.latency.mseconds() as u32;
|
||||||
|
|
||||||
|
if transcriber
|
||||||
|
.has_property_with_type("transcribe-latency", u32::static_type())
|
||||||
|
{
|
||||||
|
transcriber.set_property("transcribe-latency", latency_ms);
|
||||||
|
} else if transcriber
|
||||||
|
.has_property_with_type("latency", u32::static_type())
|
||||||
|
{
|
||||||
|
transcriber.set_property("latency", latency_ms);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
"lateness" => {
|
"lateness" => {
|
||||||
|
let state = self.state.lock().unwrap();
|
||||||
let mut settings = self.settings.lock().unwrap();
|
let mut settings = self.settings.lock().unwrap();
|
||||||
settings.lateness = gst::ClockTime::from_mseconds(
|
settings.lateness = gst::ClockTime::from_mseconds(
|
||||||
value.get::<u32>().expect("type checked upstream").into(),
|
value.get::<u32>().expect("type checked upstream").into(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if let Some(state) = state.as_ref() {
|
||||||
|
for pad in state.audio_sink_pads.values() {
|
||||||
|
let ps = pad.imp().state.lock().unwrap();
|
||||||
|
let pad_state = ps.as_ref().unwrap();
|
||||||
|
|
||||||
|
if let Some(ref transcriber) = pad_state.transcriber {
|
||||||
|
if transcriber.has_property_with_type("lateness", u32::static_type()) {
|
||||||
|
let lateness_ms = settings.lateness.mseconds() as u32;
|
||||||
|
transcriber.set_property("lateness", lateness_ms);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
"accumulate-time" => {
|
"accumulate-time" => {
|
||||||
let mut settings = self.settings.lock().unwrap();
|
let mut settings = self.settings.lock().unwrap();
|
||||||
|
@ -1692,10 +1749,27 @@ impl ObjectImpl for TranscriberBin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"translate-latency" => {
|
"translate-latency" => {
|
||||||
|
let state = self.state.lock().unwrap();
|
||||||
let mut settings = self.settings.lock().unwrap();
|
let mut settings = self.settings.lock().unwrap();
|
||||||
settings.translate_latency = gst::ClockTime::from_mseconds(
|
settings.translate_latency = gst::ClockTime::from_mseconds(
|
||||||
value.get::<u32>().expect("type checked upstream").into(),
|
value.get::<u32>().expect("type checked upstream").into(),
|
||||||
);
|
);
|
||||||
|
if let Some(state) = state.as_ref() {
|
||||||
|
for pad in state.audio_sink_pads.values() {
|
||||||
|
let ps = pad.imp().state.lock().unwrap();
|
||||||
|
let pad_state = ps.as_ref().unwrap();
|
||||||
|
|
||||||
|
if let Some(ref transcriber) = pad_state.transcriber {
|
||||||
|
if transcriber
|
||||||
|
.has_property_with_type("translate-latency", u32::static_type())
|
||||||
|
{
|
||||||
|
let translate_latency_ms =
|
||||||
|
settings.translate_latency.mseconds() as u32;
|
||||||
|
transcriber.set_property("translate-latency", translate_latency_ms);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
"mux-method" => {
|
"mux-method" => {
|
||||||
let mut settings = self.settings.lock().unwrap();
|
let mut settings = self.settings.lock().unwrap();
|
||||||
|
@ -2524,14 +2598,19 @@ impl ObjectImpl for TranscriberSinkPad {
|
||||||
}
|
}
|
||||||
"transcriber" => {
|
"transcriber" => {
|
||||||
if let Some(this) = self.obj().parent().and_downcast::<super::TranscriberBin>() {
|
if let Some(this) = self.obj().parent().and_downcast::<super::TranscriberBin>() {
|
||||||
|
let new_transcriber: Option<gst::Element> =
|
||||||
|
value.get().expect("type checked upstream");
|
||||||
|
|
||||||
|
if let Some(ref transcriber) = new_transcriber {
|
||||||
|
this.imp().configure_transcriber(transcriber);
|
||||||
|
}
|
||||||
|
|
||||||
let mut s = this.imp().state.lock().unwrap();
|
let mut s = this.imp().state.lock().unwrap();
|
||||||
let mut ps = self.state.lock().unwrap();
|
let mut ps = self.state.lock().unwrap();
|
||||||
let Ok(pad_state) = ps.as_mut() else {
|
let Ok(pad_state) = ps.as_mut() else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let old_transcriber = pad_state.transcriber.clone();
|
let old_transcriber = pad_state.transcriber.clone();
|
||||||
let new_transcriber: Option<gst::Element> =
|
|
||||||
value.get().expect("type checked upstream");
|
|
||||||
pad_state.transcriber.clone_from(&new_transcriber);
|
pad_state.transcriber.clone_from(&new_transcriber);
|
||||||
|
|
||||||
if old_transcriber != new_transcriber {
|
if old_transcriber != new_transcriber {
|
||||||
|
|
Loading…
Reference in a new issue