From: backto.kim Date: Thu, 14 Oct 2021 07:38:38 +0000 (+0900) Subject: webrtc_source: Enable file path change for the same source X-Git-Tag: submit/tizen/20211020.012736~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F94%2F265294%2F6;p=platform%2Fcore%2Fapi%2Fwebrtc.git webrtc_source: Enable file path change for the same source [Version] 0.2.127 [Issue Type] Improvement Change-Id: I3af2d27448915826bbd2becd1fade6e3c99dd14c --- diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index a525020a..e1e65aa6 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.126 +Version: 0.2.127 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc_source.c b/src/webrtc_source.c index c428c89b..e3733bf0 100644 --- a/src/webrtc_source.c +++ b/src/webrtc_source.c @@ -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); }