From de4b925b47d7bea80afa945778e463965a95e32f Mon Sep 17 00:00:00 2001 From: Sangchul Lee Date: Wed, 21 Feb 2024 15:19:22 +0900 Subject: [PATCH] webrtc_internal: Add function to get transceiver mid webrtc_media_source_get_transceiver_mid() has been added. [Version] 0.4.45 [Issue Type] Internal API Change-Id: Ia69250ac27b46c68e01bbae125ebbbd103d874da Signed-off-by: Sangchul Lee --- include/webrtc_internal.h | 18 ++++++++++++++++++ include/webrtc_private.h | 1 + packaging/capi-media-webrtc.spec | 2 +- src/webrtc_internal.c | 14 ++++++++++++++ src/webrtc_transceiver.c | 19 +++++++++++++++++++ 5 files changed, 53 insertions(+), 1 deletion(-) diff --git a/include/webrtc_internal.h b/include/webrtc_internal.h index 7688d0f8..c3d7755c 100644 --- a/include/webrtc_internal.h +++ b/include/webrtc_internal.h @@ -385,6 +385,24 @@ int webrtc_media_source_remove_transceiver_encoding(webrtc_h webrtc, unsigned in */ int webrtc_media_source_active_transceiver_encoding(webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e media_type, const char *rid, bool active); +/** + * @brief Gets the transceiver media id of the media source. + * @since_tizen 8.0 + * @remarks The @a mid should be released using free() if the value is not NULL. + * @param[in] webrtc WebRTC handle + * @param[in] source_id The media source id + * @param[in] media_type The media type + * @param[out] mid The transceiver media id + * @return @c 0 on success, + * otherwise a negative error value + * @retval #WEBRTC_ERROR_NONE Successful + * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WEBRTC_ERROR_INVALID_OPERATION Invalid operation + * @pre Add media source to @a webrtc to get @a source_id by calling webrtc_add_media_source(). + * @pre Call webrtc_start() before calling this function, otherwise NULL can be set to @a mid. + */ +int webrtc_media_source_get_transceiver_mid(webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e media_type, char **mid); + /** * @internal * @brief Gets the media type of the media source. diff --git a/include/webrtc_private.h b/include/webrtc_private.h index 4fd339a3..e80946ba 100644 --- a/include/webrtc_private.h +++ b/include/webrtc_private.h @@ -751,6 +751,7 @@ int _foreach_supported_transceiver_codec(webrtc_s *webrtc, webrtc_media_source_t int _add_transceiver_encoding(webrtc_s *webrtc, unsigned int source_id, webrtc_media_type_e media_type, const char *rid, int target_bitrate, int width, int height); int _remove_transceiver_encoding(webrtc_s *webrtc, unsigned int source_id, webrtc_media_type_e media_type, const char *rid); int _active_transceiver_encoding(webrtc_s *webrtc, unsigned int source_id, webrtc_media_type_e media_type, const char *rid, bool active); +int _get_transceiver_mid(webrtc_s *webrtc, unsigned int source_id, webrtc_media_type_e media_type, char **mid); GstCaps *_make_rtp_caps_with_encoding(webrtc_gst_slot_s *source, bool is_audio); /* file source */ diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index 5ab2ee9d..c00160f3 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.4.44 +Version: 0.4.45 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc_internal.c b/src/webrtc_internal.c index 3f6e5543..365cec94 100644 --- a/src/webrtc_internal.c +++ b/src/webrtc_internal.c @@ -272,6 +272,20 @@ int webrtc_media_source_active_transceiver_encoding(webrtc_h webrtc, unsigned in return _active_transceiver_encoding(webrtc, source_id, media_type, rid, active); } +int webrtc_media_source_get_transceiver_mid(webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e media_type, char **mid) +{ + g_autoptr(GMutexLocker) locker = NULL; + webrtc_s *_webrtc = (webrtc_s *)webrtc; + + RET_VAL_IF(_webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL"); + RET_VAL_IF(source_id == 0, WEBRTC_ERROR_INVALID_PARAMETER, "source_id is 0"); + RET_VAL_IF(mid == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "mid is NULL"); + + locker = g_mutex_locker_new(&_webrtc->mutex); + + return _get_transceiver_mid(webrtc, source_id, media_type, mid); +} + int webrtc_media_source_get_type(webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e *media_type) { webrtc_s *_webrtc = (webrtc_s *)webrtc; diff --git a/src/webrtc_transceiver.c b/src/webrtc_transceiver.c index e30db3c5..a8d75e52 100644 --- a/src/webrtc_transceiver.c +++ b/src/webrtc_transceiver.c @@ -877,3 +877,22 @@ int _active_transceiver_encoding(webrtc_s *webrtc, unsigned int source_id, webrt return __active_encoding(source, av_idx, rid, active); } + +int _get_transceiver_mid(webrtc_s *webrtc, unsigned int source_id, webrtc_media_type_e media_type, char **mid) +{ + webrtc_gst_slot_s *source; + int av_idx = (media_type == WEBRTC_MEDIA_TYPE_AUDIO) ? AV_IDX_AUDIO : AV_IDX_VIDEO; + + RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL"); + RET_VAL_IF((source = _get_slot_by_id(webrtc->gst.source_slots, source_id)) == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL"); + RET_VAL_IF(mid == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "mid is NULL"); + + if (source->av[av_idx].mid) + *mid = strdup(source->av[av_idx].mid); + else + *mid = NULL; + + LOG_INFO("source_id[%u], av_idx[%d], mid[%s]", source->id, av_idx, *mid); + + return WEBRTC_ERROR_NONE; +} -- 2.34.1