webrtc_private: Check and release remaining transceivers when destroying handle 35/319035/1 accepted/tizen/8.0/unified/20241014.163637
authorSangchul Lee <sc11.lee@samsung.com>
Fri, 11 Oct 2024 01:32:46 +0000 (10:32 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Mon, 14 Oct 2024 01:21:38 +0000 (10:21 +0900)
These unreferencing objects will finally lead to call nice_stream_finalize()
of libnice via gstwebrtcbin.

[Version] 0.4.69
[Issue Type] Resource leak

Change-Id: Iec14856967c0c14670784e48d7a82c5b9b480702
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
packaging/capi-media-webrtc.spec
src/webrtc_private.c

index d182a2725ceec3a61f66848e228d5b1d6dbb4ec4..b241753715f2051049fee4764076fa05602b8239 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.4.68
+Version:    0.4.69
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index a9d7b37823983c278f0cc9b0b2bf944cf3cdaeab..816d6eb0bdfbffacd3a252f5b9b9bd7aeb845789 100644 (file)
@@ -1650,6 +1650,23 @@ static void __destroy_source_pipeline(webrtc_s *webrtc)
        }
 }
 
+static void __release_all_remaining_transceivers(webrtc_s *webrtc)
+{
+       GArray *trans_array;
+       int i;
+
+       ASSERT(webrtc);
+
+       g_signal_emit_by_name(webrtc->gst.webrtcbin, "get-transceivers", &trans_array, NULL);
+       for (i = 0; i < (int)trans_array->len; i++) {
+               GstWebRTCRTPTransceiver *trans = g_array_index(trans_array, GstWebRTCRTPTransceiver*, i);
+               LOG_DEBUG("unreferencing transceiver[%p]", trans);
+               gst_object_unref(trans); /* unreferencing it due to the increased referencing value by calling get-transceivers() */
+               gst_object_unref(trans); /* unreferencing it once again to demand to release this object */
+       }
+       g_array_unref(trans_array);
+}
+
 void _gst_destroy_pipeline(webrtc_s *webrtc)
 {
        RET_IF(webrtc == NULL, "webrtc is NULL");
@@ -1664,6 +1681,9 @@ void _gst_destroy_pipeline(webrtc_s *webrtc)
                g_hash_table_destroy(webrtc->sources);
                webrtc->sources = NULL;
        }
+
+       __release_all_remaining_transceivers(webrtc);
+
        if (webrtc->gst.bus_watcher > 0) {
                gst_bus_remove_watch(webrtc->gst.bus);
                webrtc->gst.bus_watcher = 0;