webrtc_private: Check and release remaining transceivers when destroying handle 20/318920/4 accepted/tizen_unified_toolchain accepted/tizen/9.0/unified/20241030.231517 accepted/tizen/unified/20241017.114714 accepted/tizen/unified/toolchain/20241022.122556 accepted/tizen/unified/toolchain/20241022.123011 accepted/tizen/unified/x/20241017.170400 accepted/tizen/unified/x/asan/20241022.113525 tizen_9.0_m2_release
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 00:27:48 +0000 (09:27 +0900)
These unreferencing objects will finally lead to call nice_stream_finalize()
of libnice via gstwebrtcbin.

[Version] 1.1.37
[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 5ccc6fc9c753872fc9bd5b142bfdb4e75d42b0f2..94784241c05ff06850afbf2153076ea73348146a 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    1.1.36
+Version:    1.1.37
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 4a26377bfdb272e2e2d591fe11f7aff090a75267..119e56434630a277f93a4f8d11332a7d8d9b28d0 100644 (file)
@@ -1652,6 +1652,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");
@@ -1666,6 +1683,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;