webrtcsink: Close data channel and disconnect signal handler when dropping them

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2078>
This commit is contained in:
Sebastian Dröge 2025-02-14 16:24:24 +02:00 committed by GStreamer Marge Bot
parent 63b6fe5edc
commit 812d4fdc9d

View file

@ -495,12 +495,12 @@ struct PipelineWrapper(gst::Pipeline);
// This is simply used to hold references to the inner items.
#[allow(dead_code)]
#[derive(Debug)]
struct NavigationEventHandler((glib::SignalHandlerId, WebRTCDataChannel));
struct NavigationEventHandler((Option<glib::SignalHandlerId>, WebRTCDataChannel));
// Structure to generate arbitrary upstream events from a WebRTCDataChannel
#[allow(dead_code)]
#[derive(Debug)]
struct ControlRequestHandler((glib::SignalHandlerId, WebRTCDataChannel));
struct ControlRequestHandler((Option<glib::SignalHandlerId>, WebRTCDataChannel));
/// Our instance structure
#[derive(Default)]
@ -1598,7 +1598,7 @@ impl NavigationEventHandler {
let session_id = session_id.to_string();
Self((
channel.connect_closure(
Some(channel.connect_closure(
"on-message-string",
false,
glib::closure!(
@ -1610,12 +1610,19 @@ impl NavigationEventHandler {
create_navigation_event(element, msg, &session_id);
}
),
),
)),
channel,
))
}
}
impl Drop for NavigationEventHandler {
fn drop(&mut self) {
self.0 .1.disconnect(self.0 .0.take().unwrap());
self.0 .1.close();
}
}
impl ControlRequestHandler {
fn new(element: &super::BaseWebRTCSink, webrtcbin: &gst::Element, session_id: &str) -> Self {
let channel = webrtcbin.emit_by_name::<WebRTCDataChannel>(
@ -1631,7 +1638,7 @@ impl ControlRequestHandler {
let session_id = session_id.to_string();
Self((
channel.connect_closure(
Some(channel.connect_closure(
"on-message-string",
false,
glib::closure!(
@ -1659,12 +1666,19 @@ impl ControlRequestHandler {
}
}
),
),
)),
channel,
))
}
}
impl Drop for ControlRequestHandler {
fn drop(&mut self) {
self.0 .1.disconnect(self.0 .0.take().unwrap());
self.0 .1.close();
}
}
/// How to configure RTP extensions for payloaders, if at all
enum ExtensionConfigurationType {
/// Skip configuration, do not add any extensions