webrtc_private: Destroy sink pipeline in case of webrtc_stop() 42/257242/2
authorSangchul Lee <sc11.lee@samsung.com>
Wed, 21 Apr 2021 11:52:06 +0000 (20:52 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Wed, 21 Apr 2021 12:03:37 +0000 (21:03 +0900)
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 <sc11.lee@samsung.com>
packaging/capi-media-webrtc.spec
src/webrtc_private.c

index f2a874d229e87484ead6e1fd383e453f05cb3147..9b46ed9dedbf1ffdeeb385910e9ccc3464fa4fa4 100644 (file)
@@ -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
index 4e42723a53f4ae67fb5911b31c7b893bc74eac18..0da263948bcca3361e0cf5a3168db02d826c3345 100644 (file)
@@ -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);