webrtc_source: Allow location to be set multiple times for a single file source 80/261980/5
authorbackto.kim <backto.kim@samsung.com>
Fri, 30 Jul 2021 01:51:20 +0000 (10:51 +0900)
committerhj kim <backto.kim@samsung.com>
Tue, 3 Aug 2021 01:38:28 +0000 (01:38 +0000)
[Version] 0.2.63
[Issue Type] Improvement

Change-Id: I7bc728f957f368ff2db689535a88cc2318a6a526

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

index ceea00e81f902cc80882a5f188bfbf6e8e982af7..52fecbb975eed9a9335790916ffae3949c47b985 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.2.62
+Version:    0.2.63
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 49869d10a956378daf1db5d56593431b42e3537f..a7df50460d00b133ac5997c66c496426de735cd9 100644 (file)
@@ -1061,6 +1061,7 @@ static void __remove_probe_from_pad_for_pause(webrtc_gst_slot_s *source, unsigne
        LOG_DEBUG("source[id:%u, av_idx:%u] pad[%p] probe_id[%lu]",
                source->id, idx, source->av[idx].src_pad, source->av[idx].src_pad_probe_id);
        gst_pad_remove_probe(source->av[idx].src_pad, source->av[idx].src_pad_probe_id);
+       gst_element_remove_pad(GST_ELEMENT(source->bin), source->av[idx].src_pad);
        source->av[idx].src_pad_probe_id = 0;
        source->av[idx].src_pad = NULL;
 }
@@ -2671,10 +2672,36 @@ bool _check_if_format_is_set_to_packet_sources(webrtc_s *webrtc)
        return true;
 }
 
+static void __remove_filesrc_element(webrtc_gst_slot_s *source)
+{
+       GstElement *payload = NULL;
+       GstElement *queue = NULL;
+       GstElement *capsfilter = NULL;
+
+       payload = gst_bin_get_by_name(source->bin, DEFAULT_NAME_AUDIO_PAYLOAD);
+       if (payload) {
+               queue = gst_bin_get_by_name(source->bin, DEFAULT_NAME_AUDIO_QUEUE);
+               capsfilter = gst_bin_get_by_name(source->bin, DEFAULT_NAME_AUDIO_CAPSFILTER);
+               gst_bin_remove_many(source->bin, payload, queue, capsfilter, NULL);
+
+               __remove_probe_from_pad_for_pause(source, AV_IDX_AUDIO);
+       }
+
+       payload = gst_bin_get_by_name(source->bin, DEFAULT_NAME_VIDEO_PAYLOAD);
+       if (payload) {
+               queue = gst_bin_get_by_name(source->bin, DEFAULT_NAME_VIDEO_QUEUE);
+               capsfilter = gst_bin_get_by_name(source->bin, DEFAULT_NAME_VIDEO_CAPSFILTER);
+               gst_bin_remove_many(source->bin, payload, queue, capsfilter, NULL);
+
+               __remove_probe_from_pad_for_pause(source, AV_IDX_VIDEO);
+       }
+}
+
 int _set_media_path(webrtc_s *webrtc, unsigned int source_id, const char *path)
 {
        webrtc_gst_slot_s *source = NULL;
        GstElement *filesrc = NULL;
+       gchar *location = NULL;
 
        RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
        RET_VAL_IF(source_id == 0, WEBRTC_ERROR_INVALID_PARAMETER, "source_id is 0");
@@ -2695,6 +2722,12 @@ int _set_media_path(webrtc_s *webrtc, unsigned int source_id, const char *path)
        filesrc = gst_bin_get_by_name(source->bin, DEFAULT_NAME_FILE_SRC);
        RET_VAL_IF(filesrc == NULL, WEBRTC_ERROR_INVALID_OPERATION, "filesrc is NULL");
 
+       g_object_get(G_OBJECT(filesrc), "location", &location, NULL);
+       if (location) {
+               __remove_filesrc_element(source);
+               g_free(location);
+       }
+
        g_object_set(G_OBJECT(filesrc), "location", path, NULL);
 
        LOG_DEBUG("source_id[%u] path[%s]", source_id, path);