mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-15 23:01:02 +00:00
webrtcsink: further refactor connection to stats signals
- Stop passing webrtcbin around without using it - Stop using glib::closure as clippy complains when using a unit type default-return Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1234>
This commit is contained in:
parent
e9d32fb221
commit
8248425905
1 changed files with 10 additions and 7 deletions
|
@ -1618,7 +1618,7 @@ impl WebRTCSink {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let session = Session::new(
|
let mut session = Session::new(
|
||||||
session_id.clone(),
|
session_id.clone(),
|
||||||
pipeline.clone(),
|
pipeline.clone(),
|
||||||
webrtcbin.clone(),
|
webrtcbin.clone(),
|
||||||
|
@ -1644,21 +1644,24 @@ impl WebRTCSink {
|
||||||
if session.congestion_controller.is_some() {
|
if session.congestion_controller.is_some() {
|
||||||
let session_id_str = session_id.to_string();
|
let session_id_str = session_id.to_string();
|
||||||
rtpbin.connect_closure("on-new-ssrc", true,
|
rtpbin.connect_closure("on-new-ssrc", true,
|
||||||
glib::closure!(@weak-allow-none element, @weak-allow-none webrtcbin
|
glib::closure!(@weak-allow-none element,
|
||||||
=> move |rtpbin: gst::Object, session_id: u32, _src: u32| {
|
=> move |rtpbin: gst::Object, session_id: u32, _src: u32| {
|
||||||
let rtp_session = rtpbin.emit_by_name::<gst::Element>("get-session", &[&session_id]);
|
let rtp_session = rtpbin.emit_by_name::<gst::Element>("get-session", &[&session_id]);
|
||||||
|
|
||||||
let element = element.expect("on-new-ssrc emited when webrtcsink has been disposed?");
|
let element = element.expect("on-new-ssrc emited when webrtcsink has been disposed?");
|
||||||
let webrtcbin = webrtcbin.unwrap();
|
|
||||||
let mut state = element.imp().state.lock().unwrap();
|
let mut state = element.imp().state.lock().unwrap();
|
||||||
if let Some(mut session) = state.sessions.get_mut(&session_id_str) {
|
if let Some(mut session) = state.sessions.get_mut(&session_id_str) {
|
||||||
|
|
||||||
if session.stats_sigid.is_none() {
|
if session.stats_sigid.is_none() {
|
||||||
|
let session_id_str = session_id_str.clone();
|
||||||
|
let element = element.downgrade();
|
||||||
session.stats_sigid = Some(rtp_session.connect_notify(Some("twcc-stats"),
|
session.stats_sigid = Some(rtp_session.connect_notify(Some("twcc-stats"),
|
||||||
glib::clone!(@strong session_id_str, @weak webrtcbin, @weak element => @default-return (), move |sess, pspec| {
|
move |sess, pspec| {
|
||||||
|
if let Some(element) = element.upgrade() {
|
||||||
// Run the Loss-based control algorithm on new peer TWCC feedbacks
|
// Run the Loss-based control algorithm on new peer TWCC feedbacks
|
||||||
element.imp().process_loss_stats(&element, &session_id_str, &sess.property::<gst::Structure>(pspec.name()));
|
element.imp().process_loss_stats(&element, &session_id_str, &sess.property::<gst::Structure>(pspec.name()));
|
||||||
})
|
}
|
||||||
|
}
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue