webrtc_source: Enable file path change for the same source 94/265294/6
authorbackto.kim <backto.kim@samsung.com>
Thu, 14 Oct 2021 07:38:38 +0000 (16:38 +0900)
committerbackto.kim <backto.kim@samsung.com>
Tue, 19 Oct 2021 07:15:09 +0000 (16:15 +0900)
[Version] 0.2.127
[Issue Type] Improvement

Change-Id: I3af2d27448915826bbd2becd1fade6e3c99dd14c

packaging/capi-media-webrtc.spec
src/webrtc_source.c

index a525020aa1fb3e3bbb91d2474940e7362211adc9..e1e65aa69c3be2839c02be5f73c0acaa47bb72a5 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.2.126
+Version:    0.2.127
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index c428c89bd8f760fd015938e01eed18fa5ca62231..e3733bf0f9c8584e2ece19ec93108681396a2fd5 100644 (file)
@@ -3045,43 +3045,58 @@ bool _check_if_format_is_set_to_packet_sources(webrtc_s *webrtc)
        return true;
 }
 
-static void __remove_filesrc_element(webrtc_gst_slot_s *source)
+static void __release_filesrc_resources(webrtc_gst_slot_s *source)
 {
-       GstBin *bin = NULL;
-       GstElement *payload = NULL;
+       GstElement *appsrc = NULL;
+       GstElement *queue = NULL;
        GstElement *capsfilter = NULL;
-       GstElement *fakesink = NULL;
+       int av_idx = 0;
 
        RET_IF(source == NULL, "source is NULL");
+       RET_IF(source->bin == NULL, "bin is NULL");
        RET_IF(source->filesrc_pipeline == NULL, "filesrc_pipeline is NULL");
 
-       bin = GST_BIN(source->filesrc_pipeline);
+       gst_element_foreach_src_pad(GST_ELEMENT(source->bin), __foreach_src_pad_cb, source);
 
-       payload = gst_bin_get_by_name(bin, DEFAULT_NAME_AUDIO_PAYLOAD);
-       if (payload) {
-               capsfilter = gst_bin_get_by_name(bin, DEFAULT_NAME_AUDIO_CAPSFILTER);
-               fakesink = gst_bin_get_by_name(bin, DEFAULT_NAME_AUDIO_FAKESINK);
-               gst_bin_remove_many(bin, payload, capsfilter, fakesink, NULL);
+       for (av_idx = 0; av_idx < AV_IDX_MAX; av_idx++) {
+               if (source->av[av_idx].src_pad_probe_id == 0)
+                       continue;
 
-               if (source->av[AV_IDX_AUDIO].payload_id > 0)
-                       __return_payload_id(source->webrtc, source->av[AV_IDX_AUDIO].payload_id);
+               __remove_probe_from_pad_for_pause(source, av_idx);
+               __remove_probe_from_pad_for_render(source, av_idx);
 
-               __remove_probe_from_pad_for_pause(source, AV_IDX_AUDIO);
-       }
+               if (source->av[av_idx].payload_id > 0)
+                       __return_payload_id(source->webrtc, source->av[av_idx].payload_id);
 
-       payload = gst_bin_get_by_name(bin, DEFAULT_NAME_VIDEO_PAYLOAD);
-       if (payload) {
-               capsfilter = gst_bin_get_by_name(bin, DEFAULT_NAME_VIDEO_CAPSFILTER);
-               fakesink = gst_bin_get_by_name(bin, DEFAULT_NAME_VIDEO_FAKESINK);
-               gst_bin_remove_many(bin, payload, capsfilter, fakesink, NULL);
+               if (source->av[av_idx].render.pipeline) {
+                       gst_element_set_state(source->av[av_idx].render.pipeline, GST_STATE_NULL);
+                       SAFE_GST_OBJECT_UNREF(source->av[av_idx].render.pipeline);
+               }
+
+               __remove_rest_of_elements_for_filesrc_pipeline(source, (av_idx == AV_IDX_AUDIO));
+
+               appsrc = gst_bin_get_by_name(source->bin, _av_tbl[av_idx].appsrc_name);
+               if (!appsrc)
+                       LOG_ERROR("appsrc is NULL");
 
-               if (source->av[AV_IDX_VIDEO].payload_id > 0)
-                       __return_payload_id(source->webrtc, source->av[AV_IDX_VIDEO].payload_id);
+               queue = gst_bin_get_by_name(source->bin, _av_tbl[av_idx].queue_name);
+               if (!queue)
+                       LOG_ERROR("queue is NULL");
 
-               __remove_probe_from_pad_for_pause(source, AV_IDX_VIDEO);
+               capsfilter = gst_bin_get_by_name(source->bin, _av_tbl[av_idx].capsfilter_name);
+               if (!capsfilter)
+                       LOG_ERROR("capsfilter is NULL");
+
+               gst_bin_remove_many(source->bin, appsrc, queue, capsfilter, NULL);
        }
 
-       /* FIXME: filesrc_bin should be updated as well */
+       if (source->display)
+               _release_display(source->display);
+
+       if (source->sound_stream_info.type) {
+               free(source->sound_stream_info.type);
+               source->sound_stream_info.type = NULL;
+       }
 
        source->media_types = 0;
 }
@@ -3114,7 +3129,7 @@ int _set_media_path(webrtc_s *webrtc, unsigned int source_id, const char *path)
 
        g_object_get(G_OBJECT(filesrc), "location", &location, NULL);
        if (location) {
-               __remove_filesrc_element(source);
+               __release_filesrc_resources(source);
                g_free(location);
        }