From: hj kim Date: Mon, 18 Jul 2022 06:00:27 +0000 (+0900) Subject: media_source_file: Make the file source's transceiver direction changeable X-Git-Tag: submit/tizen/20220726.122258~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f22419e8d460055e38a9927a89b910300aba57d1;p=platform%2Fcore%2Fapi%2Fwebrtc.git media_source_file: Make the file source's transceiver direction changeable Transceiver's direction can be changed for each media types before webrtc_start(). However, file source's media types were determined after webrtc_start(). So, set media types when set media path(before webrtc_start()), and allow transceiver direction change. [Version] 0.3.163 [Issue Type] Improvement Change-Id: I181ba95e5877fad103e50d8253cda8eeeba0d66f --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 49f4ee87..4c1dd4bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ INCLUDE_DIRECTORIES(${INC_DIR}) SET(dependents "dlog glib-2.0 gstreamer-1.0 gstreamer-webrtc-1.0 gstreamer-video-1.0 gstreamer-audio-1.0 \ gstreamer-allocators-1.0 libpulse json-glib-1.0 iniparser mm-common mm-display-interface capi-media-tool \ - libtbm libwebsockets cynara-client libsmack capi-system-info libsoup-2.4 bundle capi-media-sound-manager") + libtbm libwebsockets cynara-client libsmack capi-system-info libsoup-2.4 bundle capi-media-sound-manager mm-fileinfo") IF(NOT TIZEN_PROFILE_TV) SET(dependents "${dependents} mm-resource-manager") ELSE() diff --git a/include/webrtc_private.h b/include/webrtc_private.h index ad8b5c27..eeb778d5 100644 --- a/include/webrtc_private.h +++ b/include/webrtc_private.h @@ -679,6 +679,7 @@ int _gst_filesrc_pipeline_set_state(webrtc_s *webrtc, GstState state); int _set_filesrc_looping(webrtc_s *webrtc, unsigned int source_id, bool looping); int _get_filesrc_looping(webrtc_s *webrtc, unsigned int source_id, bool *looping); int _remove_filesrc_pad_block_probe(webrtc_s *webrtc); +void _set_filesrc_media_types(webrtc_gst_slot_s *source, const char *path); int _build_mediapacketsrc(webrtc_s *webrtc, webrtc_gst_slot_s *source); int _complete_rest_of_mediapacketsrc(webrtc_gst_slot_s *source, GstPad **src_pad, GstElement *appsrc, GList *element_list); int _complete_mediapacketsrc_from_encoded_format(webrtc_s *webrtc, webrtc_gst_slot_s *source); diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index f3bd2f51..1d23059c 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.3.162 +Version: 0.3.163 Release: 0 Group: Multimedia/API License: Apache-2.0 @@ -34,6 +34,7 @@ BuildRequires: pkgconfig(libsmack) BuildRequires: pkgconfig(capi-system-info) BuildRequires: pkgconfig(capi-media-sound-manager) BuildRequires: pkgconfig(bundle) +BuildRequires: pkgconfig(mm-fileinfo) %if "%{tizen_profile_name}" != "tv" BuildRequires: pkgconfig(mm-resource-manager) BuildRequires: pkgconfig(esplusplayer) diff --git a/src/webrtc_source.c b/src/webrtc_source.c index ecb78ed7..1f6093fb 100644 --- a/src/webrtc_source.c +++ b/src/webrtc_source.c @@ -1482,12 +1482,21 @@ static GstPadProbeReturn __fakesink_probe_cb(GstPad *pad, GstPadProbeInfo *info, LOG_INFO("setting caps for [%s appsrc] successfully", (av_idx == AV_IDX_AUDIO) ? "audio" : "video"); PRINT_CAPS(caps, "appsrc"); - source->av[av_idx].codec = gst_structure_get_string(gst_caps_get_structure(caps, 0), "encoding-name"); - gst_caps_unref(caps); - source->filesrc_av[av_idx].sink_pad = pad; source->filesrc_av[av_idx].sink_pad_probe_id = gst_pad_add_probe(pad, GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_BLOCK, __fakesink_block_probe_cb, source, NULL); + source->av[av_idx].codec = gst_structure_get_string(gst_caps_get_structure(caps, 0), "encoding-name"); + + if (source->av[av_idx].direction == WEBRTC_TRANSCEIVER_DIRECTION_RECVONLY) { + rtp_payload_info_s payload_info = { + .media_type = _get_media_type_from_pad(pad), + .encoding_name = source->av[av_idx].codec, + }; + gst_structure_get_int(gst_caps_get_structure(caps, 0), "clock-rate", &payload_info.clock_rate); + __add_transceiver(source, (av_idx == AV_IDX_AUDIO) ? WEBRTC_MEDIA_TYPE_AUDIO : WEBRTC_MEDIA_TYPE_VIDEO, &payload_info); + g_free((gchar *)payload_info.media_type); + } + gst_caps_unref(caps); return GST_PAD_PROBE_REMOVE; } @@ -3025,10 +3034,13 @@ int _set_media_path(webrtc_s *webrtc, unsigned int source_id, const char *path) if (location) { __release_filesrc_resources(source); g_free(location); + source->media_types = 0; } g_object_set(G_OBJECT(filesrc), "location", path, NULL); + _set_filesrc_media_types(source, path); + LOG_DEBUG("source_id[%u] path[%s]", source_id, path); return WEBRTC_ERROR_NONE; diff --git a/src/webrtc_source_file.c b/src/webrtc_source_file.c index abcb7780..2b3884a4 100644 --- a/src/webrtc_source_file.c +++ b/src/webrtc_source_file.c @@ -14,6 +14,8 @@ * limitations under the License. */ +#include + #include "webrtc_private.h" #include "webrtc_source_private.h" @@ -107,3 +109,24 @@ int _remove_filesrc_pad_block_probe(webrtc_s *webrtc) return WEBRTC_ERROR_NONE; } + +void _set_filesrc_media_types(webrtc_gst_slot_s *source, const char *path) +{ + int ret = FILEINFO_ERROR_NONE; + int audio_tracks_num = 0; + int video_tracks_num = 0; + + RET_IF(source == NULL, "source is NULL"); + RET_IF(path == NULL, "path is NULL"); + + ret = mm_file_get_stream_info(path, &audio_tracks_num, &video_tracks_num); + RET_IF(ret != FILEINFO_ERROR_NONE, "fail to mm_file_get_stream_info [%d]", ret); + + LOG_DEBUG("audio_tracks_num[%d] video_tracks_num[%d]", audio_tracks_num, video_tracks_num); + + if (audio_tracks_num) + source->media_types |= MEDIA_TYPE_AUDIO; + + if (video_tracks_num) + source->media_types |= MEDIA_TYPE_VIDEO; +}