From: Sangchul Lee Date: Wed, 21 Feb 2024 04:23:08 +0000 (+0900) Subject: webrtc_internal: Add function to get media type by source id X-Git-Tag: accepted/tizen/unified/20240327.141705~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F78%2F306478%2F1;p=platform%2Fcore%2Fapi%2Fwebrtc.git webrtc_internal: Add function to get media type by source id webrtc_media_source_get_type() has been added. [Version] 0.4.44 [Issue Type] Internal API Change-Id: I8659fcb85957ae353cf3e774d34477f8ebea7388 Signed-off-by: Sangchul Lee --- diff --git a/include/webrtc_internal.h b/include/webrtc_internal.h index 7186ae9a..7688d0f8 100644 --- a/include/webrtc_internal.h +++ b/include/webrtc_internal.h @@ -324,7 +324,7 @@ int webrtc_media_source_get_payload_type(webrtc_h webrtc, unsigned int source_id /** * @internal * @brief Adds the transceiver encoding option to the media source. - * @since_tizen 9.0 + * @since_tizen 8.0 * @remarks If @a source_id should be a media source of #WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST or #WEBRTC_MEDIA_SOURCE_TYPE_MIC or #WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST or #WEBRTC_MEDIA_SOURCE_TYPE_NULL, * otherwise this function will return #WEBRTC_ERROR_INVALID_PARAMETER.\n * If @a source_id is a media source of #WEBRTC_MEDIA_SOURCE_TYPE_NULL, @a target_bitrate, @a width, and @a height will be ignored.\n @@ -350,7 +350,7 @@ int webrtc_media_source_add_transceiver_encoding(webrtc_h webrtc, unsigned int s /** * @internal * @brief Removes the transceiver encoding option from the media source. - * @since_tizen 9.0 + * @since_tizen 8.0 * @param[in] webrtc WebRTC handle * @param[in] source_id The media source id * @param[in] media_type The media type @@ -367,7 +367,7 @@ int webrtc_media_source_remove_transceiver_encoding(webrtc_h webrtc, unsigned in /** * @internal * @brief Actives the transceiver encoding option of the media source. - * @since_tizen 9.0 + * @since_tizen 8.0 * @remarks The default value is @c true. * @param[in] webrtc WebRTC handle * @param[in] source_id The media source id @@ -385,10 +385,27 @@ 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); +/** + * @internal + * @brief Gets the media type of the media source. + * @since_tizen 8.0 + * @remarks If @a source_id is a media source of #WEBRTC_MEDIA_SOURCE_TYPE_FILE, this function will return #WEBRTC_ERROR_INVALID_PARAMETER. + * @param[in] webrtc WebRTC handle + * @param[in] source_id The media source id + * @param[out] media_type The media type + * @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(). + */ +int webrtc_media_source_get_type(webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e *media_type); + /** * @internal * @brief Gets the local session description. - * @since_tizen 9.0 + * @since_tizen 8.0 * @remarks @a description is a JSON string.\n * It will be {"sdp":{"type":"offer or answer","sdp":"..."}}.\n * The @a description should be released using free() if the value is not NULL. @@ -406,7 +423,7 @@ int webrtc_get_local_description(webrtc_h webrtc, char **description); /** * @internal * @brief Gets the remote session description. - * @since_tizen 9.0 + * @since_tizen 8.0 * @remarks @a description is a JSON string.\n * It should be {"sdp":{"type":"offer or answer","sdp":"..."}}.\n * The @a description should be released using free() if the value is not NULL. diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index d10c2a7b..5ab2ee9d 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.43 +Version: 0.4.44 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc_internal.c b/src/webrtc_internal.c index eb505749..3f6e5543 100644 --- a/src/webrtc_internal.c +++ b/src/webrtc_internal.c @@ -272,6 +272,40 @@ 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_type(webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e *media_type) +{ + webrtc_s *_webrtc = (webrtc_s *)webrtc; + webrtc_gst_slot_s *source; + g_autoptr(GMutexLocker) locker = NULL; + + 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(media_type == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "media type is NULL"); + + locker = g_mutex_locker_new(&_webrtc->mutex); + + RET_VAL_IF((source = _get_slot_by_id(_webrtc->gst.source_slots, source_id)) == NULL, + WEBRTC_ERROR_INVALID_PARAMETER, "could not find source"); + RET_VAL_IF(source->type == WEBRTC_MEDIA_SOURCE_TYPE_FILE, WEBRTC_ERROR_INVALID_PARAMETER, "file source type is not supported"); + RET_VAL_IF(source->media_types == 0, WEBRTC_ERROR_INVALID_OPERATION, "media_types is not assigned yet"); + + switch (source->media_types) { + case MEDIA_TYPE_AUDIO: + *media_type = WEBRTC_MEDIA_TYPE_AUDIO; + break; + case MEDIA_TYPE_VIDEO: + *media_type = WEBRTC_MEDIA_TYPE_VIDEO; + break; + default: + LOG_ERROR("media_types[0x%x]", source->media_types); + return WEBRTC_ERROR_INVALID_OPERATION; + } + + LOG_INFO("webrtc[%p] source_id[%u] media_type[%d]", _webrtc, source_id, *media_type); + + return WEBRTC_ERROR_NONE; +} + int webrtc_get_local_description(webrtc_h webrtc, char **description) { g_autoptr(GMutexLocker) locker = NULL;