From d993c95e389667516024820a4cfe4aca37ee42cd Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Wed, 13 Nov 2024 19:16:37 +0100 Subject: [PATCH] transcriberbin: fix initial transcription setup Only link the audio tee with the pad transcriber when it is not in passthrough mode. Fixes: https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/issues/628 Part-of: --- video/closedcaption/src/transcriberbin/imp.rs | 37 ++++++++++++++++--- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/video/closedcaption/src/transcriberbin/imp.rs b/video/closedcaption/src/transcriberbin/imp.rs index 3639b8d9..71e9766c 100644 --- a/video/closedcaption/src/transcriberbin/imp.rs +++ b/video/closedcaption/src/transcriberbin/imp.rs @@ -39,6 +39,7 @@ const DEFAULT_MUX_METHOD: MuxMethod = MuxMethod::Cea608; const CEAX08MUX_LATENCY: gst::ClockTime = gst::ClockTime::from_mseconds(100); +#[derive(Debug)] enum TargetPassthroughState { None, Enabled, @@ -567,11 +568,15 @@ impl TranscriberBin { .transcription_bin .sync_state_with_parent() .unwrap(); - let transcription_sink_pad = state.transcription_bin.static_pad(&pad.name()).unwrap(); - // Might be linked already if "translation-languages" is set - if transcription_sink_pad.peer().is_none() { - let audio_tee_pad = pad_state.audio_tee.request_pad_simple("src_%u").unwrap(); - audio_tee_pad.link(&transcription_sink_pad).unwrap(); + let pad_settings = pad.imp().settings.lock().unwrap(); + if !pad_settings.passthrough { + let transcription_sink_pad = + state.transcription_bin.static_pad(&pad.name()).unwrap(); + // Might be linked already if "translation-languages" is set + if transcription_sink_pad.peer().is_none() { + let audio_tee_pad = pad_state.audio_tee.request_pad_simple("src_%u").unwrap(); + audio_tee_pad.link(&transcription_sink_pad).unwrap(); + } } } @@ -594,6 +599,9 @@ impl TranscriberBin { let bin_sink_pad = state.transcription_bin.static_pad(&pad.name()).unwrap(); if let Some(audio_tee_pad) = bin_sink_pad.peer() { audio_tee_pad.unlink(&bin_sink_pad).unwrap(); + + gst::debug!(CAT, obj = pad, "releasing audio tee pad"); + pad_state.audio_tee.release_request_pad(&audio_tee_pad); } @@ -622,11 +630,21 @@ impl TranscriberBin { state: &mut State, pad_state: &mut TranscriberSinkPadState, ) { + gst::debug!(CAT, imp = sinkpad, "enabling transcription bin"); + for channel in pad_state.transcription_channels.values() { let srcpad = pad_state .transcription_bin .static_pad(&format!("src_{}", channel.language)) .unwrap(); + + gst::log!( + CAT, + obj = srcpad, + "linking transcription channel for language {}", + channel.language + ); + let sinkpad = state .ccmux .static_pad(&channel.ccmux_pad_name) @@ -686,6 +704,8 @@ impl TranscriberBin { return gst::PadProbeReturn::Remove; }; + gst::debug!(CAT, imp = imp, "pad probed"); + let pad_imp = pad .downcast_ref::() .unwrap() @@ -2078,6 +2098,13 @@ impl ObjectImpl for TranscriberSinkPad { } drop(pad_settings); + gst::debug!( + CAT, + imp = self, + "target passthrough state: {:?}", + pad_state.target_passthrough_state + ); + parent.imp().block_and_update(self, s, ps); } "translation-languages" => {