From 9cde2f0927ef0b7f7277d4fbbc23a02313e37e39 Mon Sep 17 00:00:00 2001 From: Emil Ljungdahl Date: Mon, 14 Oct 2024 11:26:20 +0200 Subject: [PATCH] webrtcbin: Clean up bin elements when datachannel is removed When a datachannel within a session is removed after proper close, reference to the error_ignore_bin elements of the datachannel appsrc/appsink were left in webrtcbin. This caused the bin-objects to be left and not freed until the whole webrtc session was terminated. Among other things that includes a thread from the appsrc. Part-of: --- .../gst-plugins-bad/ext/webrtc/gstwebrtcbin.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcbin.c b/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcbin.c index 21ecd8b588..f170f512bf 100644 --- a/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcbin.c +++ b/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcbin.c @@ -2585,8 +2585,18 @@ _on_data_channel_ready_state (WebRTCDataChannel * channel, if (found == FALSE) { GST_FIXME_OBJECT (webrtc, "Received close for unknown data channel"); - } else if (found_pending == FALSE) { - webrtc->priv->data_channels_closed++; + } else { + gst_element_set_locked_state (channel->src_bin, TRUE); + gst_element_set_state (channel->src_bin, GST_STATE_NULL); + gst_bin_remove (GST_BIN (webrtc), channel->src_bin); + + gst_element_set_locked_state (channel->sink_bin, TRUE); + gst_element_set_state (channel->sink_bin, GST_STATE_NULL); + gst_bin_remove (GST_BIN (webrtc), channel->sink_bin); + + if (found_pending == FALSE) { + webrtc->priv->data_channels_closed++; + } } DC_UNLOCK (webrtc); }