Add out-parameter 'track id' to loopback setting functions 08/261708/4
authorSangchul Lee <sc11.lee@samsung.com>
Fri, 23 Jul 2021 04:19:49 +0000 (13:19 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Mon, 26 Jul 2021 04:21:20 +0000 (13:21 +0900)
This newly added parameter will be utilized by other functions that
are for setting properties/operations per the track id.

[Version] 0.2.54
[Issue Type] API

Change-Id: Ib3d8c1fea15d7a762fba0320ca8b6b875118f66a
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
include/webrtc.h
include/webrtc_private.h
packaging/capi-media-webrtc.spec
src/webrtc.c
src/webrtc_source.c
test/webrtc_test.c

index e5861dd1559b9678b43b24f732d05c0ac20499b6..7d4cb755b79ec83fad53879539c2893729464399 100644 (file)
@@ -1145,6 +1145,7 @@ int webrtc_unset_encoded_video_frame_cb(webrtc_h webrtc);
  * @param[in] webrtc      WebRTC handle
  * @param[in] source_id   The audio source id
  * @param[in] stream_info The sound stream information
+ * @param[out] track_id   The track id (optional, this can be NULL)
  * @return @c 0 on success,
  *         otherwise a negative error value
  * @retval #WEBRTC_ERROR_NONE    Successful
@@ -1153,7 +1154,7 @@ int webrtc_unset_encoded_video_frame_cb(webrtc_h webrtc);
  * @pre Add media source to @a webrtc to get @a source_id by calling webrtc_add_media_source().
  * @see webrtc_media_source_set_video_loopback()
  */
-int webrtc_media_source_set_audio_loopback(webrtc_h webrtc, unsigned source_id, sound_stream_info_h stream_info);
+int webrtc_media_source_set_audio_loopback(webrtc_h webrtc, unsigned source_id, sound_stream_info_h stream_info, unsigned int *track_id);
 
 /**
  * @brief Sets a video loopback to render the video frames of the media source.
@@ -1167,6 +1168,7 @@ int webrtc_media_source_set_audio_loopback(webrtc_h webrtc, unsigned source_id,
  * @param[in] source_id   The video source id
  * @param[in] type        The display type
  * @param[in] display     The display handle
+ * @param[out] track_id   The track id (optional, this can be NULL)
  * @return @c 0 on success,
  *         otherwise a negative error value
  * @retval #WEBRTC_ERROR_NONE    Successful
@@ -1175,7 +1177,7 @@ int webrtc_media_source_set_audio_loopback(webrtc_h webrtc, unsigned source_id,
  * @pre Add media source to @a webrtc to get @a source_id by calling webrtc_add_media_source().
  * @see webrtc_media_source_set_audio_loopback()
  */
-int webrtc_media_source_set_video_loopback(webrtc_h webrtc, unsigned source_id, webrtc_display_type_e type, webrtc_display_h display);
+int webrtc_media_source_set_video_loopback(webrtc_h webrtc, unsigned source_id, webrtc_display_type_e type, webrtc_display_h display, unsigned int *track_id);
 
 /**
  * @}
index 405c0e8a2f924defdd71e36f622c4dc0d5ed616f..d5080930c9ede0a7efd2797cc1ac40fd279d8a7a 100644 (file)
@@ -442,6 +442,7 @@ typedef struct _webrtc_gst_slot_s {
                bool pause;
                unsigned int payload_id;
                struct {
+                       unsigned int track_id;
                        bool need_decoding;
                        GstPad *src_pad;
                        gulong src_pad_probe_id;
@@ -571,8 +572,8 @@ int _add_rendering_sink_bin(webrtc_s *webrtc, GstPad *src_pad);
 int _add_forwarding_sink_bin(webrtc_s *webrtc, GstPad *src_pad, bool is_video);
 int _set_stream_info_to_sink(webrtc_s *webrtc, unsigned int track_id, sound_stream_info_h stream_info);
 int _set_display_to_sink(webrtc_s *webrtc, unsigned int track_id, unsigned int type, void *display);
-int _set_audio_loopback(webrtc_s *webrtc, unsigned int source_id, sound_stream_info_h stream_info);
-int _set_video_loopback(webrtc_s *webrtc, unsigned int source_id, unsigned int type, void *display);
+int _set_audio_loopback(webrtc_s *webrtc, unsigned int source_id, sound_stream_info_h stream_info, unsigned int *track_id);
+int _set_video_loopback(webrtc_s *webrtc, unsigned int source_id, unsigned int type, void *display, unsigned int *track_id);
 int _decodebin_autoplug_select_cb(GstElement *decodebin, GstPad *pad, GstCaps *caps, GstElementFactory *factory, gpointer user_data);
 bool _is_owner_of_track_build_context(webrtc_s *webrtc, unsigned int track_id);
 void _track_build_context_destroy_cb(gpointer data);
index efbcc8f9a598877ab0a2646189c98a290119a365..b2167fd7e5c46664b1e2694e7413641f9da1fbab 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.2.53
+Version:    0.2.54
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 8501201ca2bd38969638796574769f885ac09d86..c6d77356c4f7932fb78244cc3585d97574c45098 100644 (file)
@@ -754,7 +754,7 @@ int webrtc_unset_encoded_video_frame_cb(webrtc_h webrtc)
        return WEBRTC_ERROR_NONE;
 }
 
-int webrtc_media_source_set_audio_loopback(webrtc_h webrtc, unsigned source_id, sound_stream_info_h stream_info)
+int webrtc_media_source_set_audio_loopback(webrtc_h webrtc, unsigned source_id, sound_stream_info_h stream_info, unsigned int *track_id)
 {
        int ret = WEBRTC_ERROR_NONE;
        webrtc_s *_webrtc = (webrtc_s*)webrtc;
@@ -765,14 +765,14 @@ int webrtc_media_source_set_audio_loopback(webrtc_h webrtc, unsigned source_id,
 
        g_mutex_lock(&_webrtc->mutex);
 
-       ret = _set_audio_loopback(webrtc, source_id, stream_info);
+       ret = _set_audio_loopback(webrtc, source_id, stream_info, track_id);
 
        g_mutex_unlock(&_webrtc->mutex);
 
        return ret;
 }
 
-int webrtc_media_source_set_video_loopback(webrtc_h webrtc, unsigned source_id, webrtc_display_type_e type, webrtc_display_h display)
+int webrtc_media_source_set_video_loopback(webrtc_h webrtc, unsigned source_id, webrtc_display_type_e type, webrtc_display_h display, unsigned int *track_id)
 {
        int ret = WEBRTC_ERROR_NONE;
        webrtc_s *_webrtc = (webrtc_s*)webrtc;
@@ -784,7 +784,7 @@ int webrtc_media_source_set_video_loopback(webrtc_h webrtc, unsigned source_id,
 
        g_mutex_lock(&_webrtc->mutex);
 
-       ret = _set_video_loopback(webrtc, source_id, (unsigned int)type, (void *)display);
+       ret = _set_video_loopback(webrtc, source_id, (unsigned int)type, (void *)display, track_id);
 
        g_mutex_unlock(&_webrtc->mutex);
 
index 90e81fb43f7be7f104dc64d49e37e8aff7f93eea..f611a61a4491daea3e38e00a08201ff1f52c606b 100644 (file)
@@ -3481,7 +3481,7 @@ static void __loopback_decodebin_pad_added_cb(GstElement *decodebin, GstPad *new
        }
 }
 
-static int __build_loopback_render_pipeline(webrtc_s *webrtc, webrtc_gst_slot_s *source, media_type_e type)
+static int __build_loopback_render_pipeline(webrtc_s *webrtc, webrtc_gst_slot_s *source, media_type_e type, unsigned int *track_id)
 {
        int idx = (type == MEDIA_TYPE_AUDIO) ? AV_IDX_AUDIO : AV_IDX_VIDEO;
        GstElement *appsrc;
@@ -3542,11 +3542,20 @@ static int __build_loopback_render_pipeline(webrtc_s *webrtc, webrtc_gst_slot_s
 
        source->av[idx].render.appsrc = appsrc;
 
-       LOG_INFO("source_id[%u] pipeline[%p, %s] appsrc[%p]", source->id, source->av[idx].render.pipeline,
+       /* NOTE : The track id has already been used for a remote stream. Here we newly add the track id
+        * for loopback rendering pipeline, we also need to distinguish which value belongs to remote's
+        * or loopback's. Hence a simple operation is added to make the track id of loopback's. */
+       source->av[idx].render.track_id = source->id * 100 + idx;
+
+       LOG_INFO("source_id[%u] track_id[%u] pipeline[%p, %s] appsrc[%p]",
+               source->id, source->av[idx].render.track_id, source->av[idx].render.pipeline,
                GST_ELEMENT_NAME(source->av[idx].render.pipeline), source->av[idx].render.appsrc);
 
        gst_element_set_state(source->av[idx].render.pipeline, GST_STATE_PLAYING);
 
+       if (track_id)
+               *track_id = source->av[idx].render.track_id;
+
        return WEBRTC_ERROR_NONE;
 
 error:
@@ -3554,7 +3563,7 @@ error:
        return WEBRTC_ERROR_INVALID_OPERATION;
 }
 
-int _set_audio_loopback(webrtc_s *webrtc, unsigned int source_id, sound_stream_info_h stream_info)
+int _set_audio_loopback(webrtc_s *webrtc, unsigned int source_id, sound_stream_info_h stream_info, unsigned int *track_id)
 {
        webrtc_gst_slot_s *source;
        char *stream_type;
@@ -3594,10 +3603,10 @@ int _set_audio_loopback(webrtc_s *webrtc, unsigned int source_id, sound_stream_i
 
        LOG_INFO("source_id[%u] stream_info[%p, type:%s, index:%d]", source_id, stream_info, stream_type, stream_index);
 
-       return __build_loopback_render_pipeline(webrtc, source, MEDIA_TYPE_AUDIO);
+       return __build_loopback_render_pipeline(webrtc, source, MEDIA_TYPE_AUDIO, track_id);
 }
 
-int _set_video_loopback(webrtc_s *webrtc, unsigned int source_id, unsigned int type, void *display)
+int _set_video_loopback(webrtc_s *webrtc, unsigned int source_id, unsigned int type, void *display, unsigned int *track_id)
 {
        int ret = WEBRTC_ERROR_NONE;
        webrtc_gst_slot_s *source;
@@ -3625,7 +3634,7 @@ int _set_video_loopback(webrtc_s *webrtc, unsigned int source_id, unsigned int t
        if (ret != WEBRTC_ERROR_NONE)
                goto error;
 
-       ret = __build_loopback_render_pipeline(webrtc, source, MEDIA_TYPE_VIDEO);
+       ret = __build_loopback_render_pipeline(webrtc, source, MEDIA_TYPE_VIDEO, track_id);
        if (ret != WEBRTC_ERROR_NONE)
                goto error;
 
index 5b78b15e411b10d820c1d5b0bdb17014b7ac6f02..0cfa3563fce74215f5738be3008438fa175c6b15 100644 (file)
@@ -840,7 +840,7 @@ static void _webrtc_media_source_set_audio_loopback(int index, unsigned int sour
                RET_IF(ret != SOUND_MANAGER_ERROR_NONE, "failed to sound_manager_create_stream_information(), ret[0x%x]", ret);
        }
 
-       ret = webrtc_media_source_set_audio_loopback(g_conns[index].webrtc, source_id, g_conns[index].render.stream_info);
+       ret = webrtc_media_source_set_audio_loopback(g_conns[index].webrtc, source_id, g_conns[index].render.stream_info, NULL);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_media_source_set_audio_loopback() success, source_id[%u]\n", source_id);
@@ -850,7 +850,7 @@ static void _webrtc_media_source_set_video_loopback(int index, unsigned int sour
 {
        int ret = WEBRTC_ERROR_NONE;
 
-       ret = webrtc_media_source_set_video_loopback(g_conns[index].webrtc, source_id, WEBRTC_DISPLAY_TYPE_EVAS, g_eo_mine);
+       ret = webrtc_media_source_set_video_loopback(g_conns[index].webrtc, source_id, WEBRTC_DISPLAY_TYPE_EVAS, g_eo_mine, NULL);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_media_source_set_video_loopback() success, source_id[%u]\n", source_id);