From: Sangchul Lee Date: Fri, 9 Aug 2024 00:45:58 +0000 (+0900) Subject: Add webrtc_get_local_description() and webrtc_get_remote_description() X-Git-Tag: accepted/tizen/unified/20240821.081515~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5c109b0a3d11efca98ebfe54ed30c53c18348a14;p=platform%2Fcore%2Fapi%2Fwebrtc.git Add webrtc_get_local_description() and webrtc_get_remote_description() [Version] 1.1.22 [Issue Type] API Change-Id: Ifee7174a06158b57d8dd0b0883c68bf9bf050300 Signed-off-by: Sangchul Lee --- diff --git a/include/webrtc.h b/include/webrtc.h index f76006c4..5131a17b 100644 --- a/include/webrtc.h +++ b/include/webrtc.h @@ -2513,9 +2513,27 @@ int webrtc_create_answer_async(webrtc_h webrtc, bundle *options, webrtc_session_ * @see webrtc_create_answer_async() * @see webrtc_set_signaling_state_change_cb() * @see webrtc_get_signaling_state() + * @see webrtc_get_local_description() */ int webrtc_set_local_description(webrtc_h webrtc, const char *description); +/** + * @brief Gets the local session description. + * @since_tizen 9.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. + * @param[in] webrtc WebRTC handle + * @param[out] description The local session description + * @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 + * @see webrtc_set_local_description() + */ +int webrtc_get_local_description(webrtc_h webrtc, char **description); + /** * @brief Sets the session description of the remote peer's current offer or answer. * @since_tizen 6.5 @@ -2534,9 +2552,27 @@ int webrtc_set_local_description(webrtc_h webrtc, const char *description); * @see webrtc_state_changed_cb() * @see webrtc_set_signaling_state_change_cb() * @see webrtc_get_signaling_state() + * @see webrtc_get_remote_description() */ int webrtc_set_remote_description(webrtc_h webrtc, const char *description); +/** + * @brief Gets the remote session description. + * @since_tizen 9.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. + * @param[in] webrtc WebRTC handle + * @param[out] description The remote session description + * @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 + * @see webrtc_set_remote_description() + */ +int webrtc_get_remote_description(webrtc_h webrtc, char **description); + /** * @brief Adds a new ICE candidate from the remote peer over its signaling channel. * @since_tizen 6.5 diff --git a/include/webrtc_internal.h b/include/webrtc_internal.h index 3481ca56..f7660705 100644 --- a/include/webrtc_internal.h +++ b/include/webrtc_internal.h @@ -478,42 +478,6 @@ int webrtc_media_source_get_type(webrtc_h webrtc, unsigned int source_id, webrtc */ int webrtc_null_source_set_media_type(webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e media_type); -/** - * @internal - * @brief Gets the local session description. - * @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. - * @param[in] webrtc WebRTC handle - * @param[out] description The local session description - * @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 - * @see webrtc_set_local_description() - */ -int webrtc_get_local_description(webrtc_h webrtc, char **description); - -/** - * @internal - * @brief Gets the remote session description. - * @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. - * @param[in] webrtc WebRTC handle - * @param[out] description The remote session description - * @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 - * @see webrtc_set_remote_description() - */ -int webrtc_get_remote_description(webrtc_h webrtc, char **description); - /** * @internal * @brief Sets the probability of RTP packet dropping. diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index 3761ee12..d5b9f3d6 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: 1.1.21 +Version: 1.1.22 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc.c b/src/webrtc.c index e9db0c90..d20fed62 100644 --- a/src/webrtc.c +++ b/src/webrtc.c @@ -1722,6 +1722,26 @@ int webrtc_set_local_description(webrtc_h webrtc, const char *description) return _webrtcbin_set_session_description(webrtc, description, false); } +int webrtc_get_local_description(webrtc_h webrtc, char **description) +{ + 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(description == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "description is NULL"); + + locker = g_mutex_locker_new(&_webrtc->mutex); + + if (_webrtc->local_desc) + *description = strdup(_webrtc->local_desc); + else + *description = NULL; + + LOG_INFO("webrtc[%p] description: %s", _webrtc, *description); + + return WEBRTC_ERROR_NONE; +} + int webrtc_set_remote_description(webrtc_h webrtc, const char *description) { g_autoptr(GMutexLocker) locker = NULL; @@ -1739,6 +1759,26 @@ int webrtc_set_remote_description(webrtc_h webrtc, const char *description) return _webrtcbin_set_session_description(webrtc, description, true); } +int webrtc_get_remote_description(webrtc_h webrtc, char **description) +{ + 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(description == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "description is NULL"); + + locker = g_mutex_locker_new(&_webrtc->mutex); + + if (_webrtc->remote_desc) + *description = strdup(_webrtc->remote_desc); + else + *description = NULL; + + LOG_INFO("webrtc[%p] description: %s", _webrtc, *description); + + return WEBRTC_ERROR_NONE; +} + int webrtc_add_ice_candidate(webrtc_h webrtc, const char *candidate) { g_autoptr(GMutexLocker) locker = NULL; diff --git a/src/webrtc_internal.c b/src/webrtc_internal.c index 4a1268ba..0a633814 100644 --- a/src/webrtc_internal.c +++ b/src/webrtc_internal.c @@ -470,46 +470,6 @@ int webrtc_null_source_set_media_type(webrtc_h webrtc, unsigned int source_id, w return WEBRTC_ERROR_NONE; } -int webrtc_get_local_description(webrtc_h webrtc, char **description) -{ - 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(description == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "description is NULL"); - - locker = g_mutex_locker_new(&_webrtc->mutex); - - if (_webrtc->local_desc) - *description = strdup(_webrtc->local_desc); - else - *description = NULL; - - LOG_INFO("webrtc[%p] description: %s", _webrtc, *description); - - return WEBRTC_ERROR_NONE; -} - -int webrtc_get_remote_description(webrtc_h webrtc, char **description) -{ - 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(description == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "description is NULL"); - - locker = g_mutex_locker_new(&_webrtc->mutex); - - if (_webrtc->remote_desc) - *description = strdup(_webrtc->remote_desc); - else - *description = NULL; - - LOG_INFO("webrtc[%p] description: %s", _webrtc, *description); - - return WEBRTC_ERROR_NONE; -} - int webrtc_util_strip_description(const char *origin_description, char **description) { g_autoptr(JsonParser) parser = NULL;