sink: Add a new-webrtcbin signal

Allowing user to add a data channel for example
This commit is contained in:
Thibault Saunier 2021-11-19 00:00:14 -03:00 committed by Mathieu Duponchelle
parent 444ee40f09
commit 63337c7df1

View file

@ -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<Vec<glib::subclass::Signal>> = 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);