From f0df6874d8d76785abd4a62b4e035be75111a7ba Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Fri, 28 Jun 2024 16:04:44 +0200 Subject: [PATCH] transcriberbin: fix property proxying As part of https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1546 the element started implementing the GstChildProxy interface in order to expose properties on its sink pads, but the implementation was incorrect and broke proxying to children elements. In addition, an intermediary bin was introduced with no name, making it hard to set the properties of the inner elements through the child proxy interface, it is now named according to the name of the pad it corresponds to. Finally, the default transcriber is back to being named "transcriber". Part-of: --- video/closedcaption/src/transcriberbin/imp.rs | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/video/closedcaption/src/transcriberbin/imp.rs b/video/closedcaption/src/transcriberbin/imp.rs index fda0e447..10dfa70f 100644 --- a/video/closedcaption/src/transcriberbin/imp.rs +++ b/video/closedcaption/src/transcriberbin/imp.rs @@ -235,6 +235,10 @@ impl TranscriberBin { ) -> Result<(), Error> { gst::debug!(CAT, imp: self, "Linking input audio stream {pad_name}"); + pad_state + .transcription_bin + .set_property("name", format!("transcription-bin-{}", pad_name)); + state .internal_bin .add_many([ @@ -1132,12 +1136,23 @@ impl TranscriberBin { } impl ChildProxyImpl for TranscriberBin { - fn child_by_index(&self, _index: u32) -> Option { - None + fn child_by_index(&self, index: u32) -> Option { + let parent_children_count = self.parent_children_count(); + + if index < parent_children_count { + self.parent_child_by_index(index) + } else { + self.obj() + .pads() + .into_iter() + .nth((index - parent_children_count) as usize) + .map(|p| p.upcast()) + } } fn children_count(&self) -> u32 { - 0 + let object = self.obj(); + self.parent_children_count() + object.num_pads() as u32 } fn child_by_name(&self, name: &str) -> Option { @@ -1796,7 +1811,9 @@ impl TranscriberSinkPadState { transcription_bin: gst::Bin::new(), transcriber_resample: gst::ElementFactory::make("audioresample").build()?, transcriber_aconv: gst::ElementFactory::make("audioconvert").build()?, - transcriber: gst::ElementFactory::make("awstranscriber").build()?, + transcriber: gst::ElementFactory::make("awstranscriber") + .name("transcriber") + .build()?, queue_passthrough: gst::ElementFactory::make("queue").build()?, transcription_channels: HashMap::new(), srcpad_name: None,