From: Sangchul Lee Date: Wed, 21 Apr 2021 11:52:06 +0000 (+0900) Subject: webrtc_private: Destroy sink pipeline in case of webrtc_stop() X-Git-Tag: submit/tizen/20210729.023123~91 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F42%2F257242%2F2;p=platform%2Fcore%2Fapi%2Fwebrtc.git webrtc_private: Destroy sink pipeline in case of webrtc_stop() When the webrtc_stop() is called, the state is changed to IDLE. The state will be changed to NEGOTIATING with following webrtc_start() again which means the re-negotiation is required. Therefore, releasing the previous sink pipeline should be performed inside of webrtc_stop(). [Version] 0.1.150 [Issue Type] Improvement Change-Id: I1bd03ecf8b8f27d93dec7d1488fa20223299a737 Signed-off-by: Sangchul Lee --- diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index f2a874d2..9b46ed9d 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: 0.1.149 +Version: 0.1.150 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc_private.c b/src/webrtc_private.c index 4e42723a..0da26394 100644 --- a/src/webrtc_private.c +++ b/src/webrtc_private.c @@ -1035,23 +1035,36 @@ error: return WEBRTC_ERROR_INVALID_OPERATION; } -void _gst_destroy_pipeline(webrtc_s *webrtc) +static void __destroy_sink_pipeline(webrtc_s *webrtc) { - if (!webrtc) - return; + RET_IF(webrtc == NULL, "webrtc is NULL"); - if (webrtc->track_build_contexts) { - g_hash_table_destroy(webrtc->track_build_contexts); - webrtc->track_build_contexts = NULL; - } if (webrtc->gst.sink_slots) { g_hash_table_destroy(webrtc->gst.sink_slots); webrtc->gst.sink_slots = NULL; } +} + +static void __destroy_source_pipeline(webrtc_s *webrtc) +{ + RET_IF(webrtc == NULL, "webrtc is NULL"); + if (webrtc->gst.source_slots) { g_hash_table_destroy(webrtc->gst.source_slots); webrtc->gst.source_slots = NULL; } +} + +void _gst_destroy_pipeline(webrtc_s *webrtc) +{ + RET_IF(webrtc == NULL, "webrtc is NULL"); + + if (webrtc->track_build_contexts) { + g_hash_table_destroy(webrtc->track_build_contexts); + webrtc->track_build_contexts = NULL; + } + __destroy_sink_pipeline(webrtc); + __destroy_source_pipeline(webrtc); if (webrtc->gst.bus_watcher > 0) { gst_bus_remove_watch(webrtc->gst.bus); webrtc->gst.bus_watcher = 0; @@ -1556,6 +1569,9 @@ int _webrtc_stop(webrtc_s *webrtc) ret = _release_all_resources(webrtc); RET_VAL_WITH_UNLOCK_IF(ret != WEBRTC_ERROR_NONE, ret, &webrtc->mutex, "failed to release all resources"); #endif + + __destroy_sink_pipeline(webrtc); + __post_state_cb_in_idle(webrtc, WEBRTC_STATE_IDLE); LOG_INFO("webrtc[%p] is stopped", webrtc);