From: Sangchul Lee Date: Fri, 23 Jul 2021 04:19:49 +0000 (+0900) Subject: Add out-parameter 'track id' to loopback setting functions X-Git-Tag: submit/tizen/20210729.023123~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9fe2cf400111572a2f95efe75ffe335d4f385510;p=platform%2Fcore%2Fapi%2Fwebrtc.git Add out-parameter 'track id' to loopback setting functions 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 --- diff --git a/include/webrtc.h b/include/webrtc.h index e5861dd1..7d4cb755 100644 --- a/include/webrtc.h +++ b/include/webrtc.h @@ -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); /** * @} diff --git a/include/webrtc_private.h b/include/webrtc_private.h index 405c0e8a..d5080930 100644 --- a/include/webrtc_private.h +++ b/include/webrtc_private.h @@ -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); diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index efbcc8f9..b2167fd7 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.53 +Version: 0.2.54 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc.c b/src/webrtc.c index 8501201c..c6d77356 100644 --- a/src/webrtc.c +++ b/src/webrtc.c @@ -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); diff --git a/src/webrtc_source.c b/src/webrtc_source.c index 90e81fb4..f611a61a 100644 --- a/src/webrtc_source.c +++ b/src/webrtc_source.c @@ -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; diff --git a/test/webrtc_test.c b/test/webrtc_test.c index 5b78b15e..0cfa3563 100644 --- a/test/webrtc_test.c +++ b/test/webrtc_test.c @@ -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);