From ec6290d63ff59f81e0078a65df8e3bfa534c7349 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 20 Dec 2022 13:03:44 +0200 Subject: [PATCH] examples: webrtc: Remove the bus watch at the end Otherwise a file descriptor will be leaked. Part-of: --- .../webrtc/multiparty-sendrecv/gst/mp-webrtc-sendrecv.c | 5 +++++ subprojects/gst-examples/webrtc/sendonly/webrtc-recvonly-h264.c | 6 ++++++ .../gst-examples/webrtc/sendonly/webrtc-unidirectional-h264.c | 6 ++++++ 3 files changed, 17 insertions(+) diff --git a/subprojects/gst-examples/webrtc/multiparty-sendrecv/gst/mp-webrtc-sendrecv.c b/subprojects/gst-examples/webrtc/multiparty-sendrecv/gst/mp-webrtc-sendrecv.c index a184e19..30f4962 100644 --- a/subprojects/gst-examples/webrtc/multiparty-sendrecv/gst/mp-webrtc-sendrecv.c +++ b/subprojects/gst-examples/webrtc/multiparty-sendrecv/gst/mp-webrtc-sendrecv.c @@ -973,6 +973,7 @@ int main (int argc, char *argv[]) { GOptionContext *context; + GstBus *bus; GError *error = NULL; context = g_option_context_new ("- gstreamer webrtc sendrecv demo"); @@ -1021,6 +1022,10 @@ main (int argc, char *argv[]) gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL); gst_print ("Pipeline stopped\n"); + bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); + gst_bus_remove_watch (bus); + gst_object_unref (bus); + gst_object_unref (pipeline); g_free (server_url); g_free (local_id); diff --git a/subprojects/gst-examples/webrtc/sendonly/webrtc-recvonly-h264.c b/subprojects/gst-examples/webrtc/sendonly/webrtc-recvonly-h264.c index 0533f08..58dbf02 100644 --- a/subprojects/gst-examples/webrtc/sendonly/webrtc-recvonly-h264.c +++ b/subprojects/gst-examples/webrtc/sendonly/webrtc-recvonly-h264.c @@ -392,9 +392,15 @@ destroy_receiver_entry (gpointer receiver_entry_ptr) g_assert (receiver_entry != NULL); if (receiver_entry->pipeline != NULL) { + GstBus *bus; + gst_element_set_state (GST_ELEMENT (receiver_entry->pipeline), GST_STATE_NULL); + bus = gst_pipeline_get_bus (GST_PIPELINE (receiver_entry->pipeline)); + gst_bus_remove_watch (bus); + gst_object_unref (bus); + gst_object_unref (GST_OBJECT (receiver_entry->webrtcbin)); gst_object_unref (GST_OBJECT (receiver_entry->pipeline)); } diff --git a/subprojects/gst-examples/webrtc/sendonly/webrtc-unidirectional-h264.c b/subprojects/gst-examples/webrtc/sendonly/webrtc-unidirectional-h264.c index 4717b6a..5d6ed25 100644 --- a/subprojects/gst-examples/webrtc/sendonly/webrtc-unidirectional-h264.c +++ b/subprojects/gst-examples/webrtc/sendonly/webrtc-unidirectional-h264.c @@ -324,9 +324,15 @@ destroy_receiver_entry (gpointer receiver_entry_ptr) g_assert (receiver_entry != NULL); if (receiver_entry->pipeline != NULL) { + GstBus *bus; + gst_element_set_state (GST_ELEMENT (receiver_entry->pipeline), GST_STATE_NULL); + bus = gst_pipeline_get_bus (GST_PIPELINE (receiver_entry->pipeline)); + gst_bus_remove_watch (bus); + gst_object_unref (bus); + gst_object_unref (GST_OBJECT (receiver_entry->webrtcbin)); gst_object_unref (GST_OBJECT (receiver_entry->pipeline)); } -- 2.7.4