media_source_file: Make the file source's transceiver direction changeable 51/278251/9
authorhj kim <backto.kim@samsung.com>
Mon, 18 Jul 2022 06:00:27 +0000 (15:00 +0900)
committerhj kim <backto.kim@samsung.com>
Mon, 25 Jul 2022 02:15:42 +0000 (11:15 +0900)
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

CMakeLists.txt
include/webrtc_private.h
packaging/capi-media-webrtc.spec
src/webrtc_source.c
src/webrtc_source_file.c

index 49f4ee876a592fdf989242b19bad2a83c0226e07..4c1dd4bd368b8839ef50ad58a412842fa3e901b6 100644 (file)
@@ -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()
index ad8b5c2752f4d0e79a79947e448fbc5ccf00872c..eeb778d54db96f1a9471e261707261f8123281eb 100644 (file)
@@ -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);
index f3bd2f51d32c9a3734364ffd8eabad905ac187e0..1d23059c6a6e20195e0e8db226f27740e66dd2f0 100644 (file)
@@ -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)
index ecb78ed7562b26d05f9531e51aeac8e574bd4c93..1f6093fb2d755fe3afda357c26c234b81084ce5e 100644 (file)
@@ -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;
index abcb77809dccd2378f5eedabbde24d732ad75ad3..2b3884a4487cb6de98e984ff7aa43d0a6dbc17f1 100644 (file)
@@ -14,6 +14,8 @@
  * limitations under the License.
  */
 
+#include <mm_file.h>
+
 #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;
+}