From 6fcf673f1fb4ba79a3c98855ebcd4c8dcc175925 Mon Sep 17 00:00:00 2001 From: "backto.kim" Date: Fri, 30 Jul 2021 10:51:20 +0900 Subject: [PATCH] webrtc_source: Allow location to be set multiple times for a single file source [Version] 0.2.63 [Issue Type] Improvement Change-Id: I7bc728f957f368ff2db689535a88cc2318a6a526 --- packaging/capi-media-webrtc.spec | 2 +- src/webrtc_source.c | 33 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index ceea00e8..52fecbb9 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.2.62 +Version: 0.2.63 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc_source.c b/src/webrtc_source.c index 49869d10..a7df5046 100644 --- a/src/webrtc_source.c +++ b/src/webrtc_source.c @@ -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); -- 2.34.1