From: Sangchul Lee Date: Fri, 11 Oct 2024 01:32:46 +0000 (+0900) Subject: webrtc_private: Check and release remaining transceivers when destroying handle X-Git-Tag: accepted/tizen/unified/20241017.114714^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d6b84d0bf848d8979231a938fa2899f0c33d2d85;p=platform%2Fcore%2Fapi%2Fwebrtc.git webrtc_private: Check and release remaining transceivers when destroying handle 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 --- diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index 5ccc6fc9..94784241 100644 --- a/packaging/capi-media-webrtc.spec +++ b/packaging/capi-media-webrtc.spec @@ -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 diff --git a/src/webrtc_private.c b/src/webrtc_private.c index 4a26377b..119e5643 100644 --- a/src/webrtc_private.c +++ b/src/webrtc_private.c @@ -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;