From 63337c7df1ed5da13bd8850bc3fb18e8d9ab2ca2 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Fri, 19 Nov 2021 00:00:14 -0300 Subject: [PATCH] sink: Add a `new-webrtcbin` signal Allowing user to add a data channel for example --- plugins/src/webrtcsink/imp.rs | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/plugins/src/webrtcsink/imp.rs b/plugins/src/webrtcsink/imp.rs index 2b6b0d5e..8ba3e564 100644 --- a/plugins/src/webrtcsink/imp.rs +++ b/plugins/src/webrtcsink/imp.rs @@ -1396,7 +1396,7 @@ impl WebRTCSink { let mut consumer = Consumer { pipeline: pipeline.clone(), - webrtcbin, + webrtcbin: webrtcbin.clone(), webrtc_pads: HashMap::new(), peer_id: peer_id.to_string(), congestion_controller: match settings.cc_heuristic { @@ -1455,6 +1455,10 @@ impl WebRTCSink { } }); + pipeline.set_state(gst::State::Ready)?; + + element.emit_by_name("new-webrtcbin", &[&peer_id.to_value(), &webrtcbin.to_value()])?; + pipeline.set_state(gst::State::Playing)?; state.consumers.insert(peer_id.to_string(), consumer); @@ -2024,6 +2028,29 @@ impl ObjectImpl for WebRTCSink { } } + fn signals() -> &'static [glib::subclass::Signal] { + static SIGNALS: Lazy> = Lazy::new(|| { + vec![ + /* + * RsWebRTCSink::new-webrtcbin: + * @peer_id: Identifier of the peer associated with the consumer added + * @webrtcbin: The new webrtcbin + * + * This signal can be used to tweak @webrtcbin, creating a data + * channel for example. + */ + glib::subclass::Signal::builder( + "new-webrtcbin", + &[String::static_type().into(), gst::Element::static_type().into()], + glib::types::Type::UNIT.into(), + ) + .build(), + ] + }); + + SIGNALS.as_ref() + } + fn constructed(&self, obj: &Self::Type) { self.parent_constructed(obj);