From: Sangchul Lee Date: Fri, 28 Oct 2022 05:14:36 +0000 (+0900) Subject: Change state constraint on functions for negotiation X-Git-Tag: accepted/tizen/unified/20240618.010058~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8b9e763780c9085fbba10c1380ab864813455931;p=platform%2Fcore%2Fapi%2Fwebrtc.git Change state constraint on functions for negotiation It allows for easing the state constraints for below functions. : webrtc_create_offer[_async]() : webrtc_create_answer[_async]() : webrtc_set_local_description() : webrtc_set_remote_description() [Version] 1.0.0 [Issue Type] Release state constraints Change-Id: Ia7a7db4a7ac4648e4fd7cb1bf46ff079710b727b Signed-off-by: Sangchul Lee --- diff --git a/include/webrtc.h b/include/webrtc.h index 0b32056a..90a05d54 100644 --- a/include/webrtc.h +++ b/include/webrtc.h @@ -2385,7 +2385,8 @@ int webrtc_unset_ice_candidate_cb(webrtc_h webrtc); * @brief Creates SDP offer to start a new WebRTC connection to a remote peer. * @since_tizen 6.5 * @remarks The @a offer should be released using free().\n - * The @a options currently has no effect. + * The @a options currently has no effect.\n + * This function can be called in the state of #WEBRTC_STATE_PLAYING. (Since 9.0) * @param[in] webrtc WebRTC handle * @param[in] options Configuration options for the offer (optional, this can be NULL) * @param[out] offer SDP offer @@ -2395,7 +2396,7 @@ int webrtc_unset_ice_candidate_cb(webrtc_h webrtc); * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #WEBRTC_ERROR_INVALID_OPERATION Invalid operation * @retval #WEBRTC_ERROR_INVALID_STATE Invalid state - * @pre @a webrtc state must be set to #WEBRTC_STATE_NEGOTIATING. + * @pre @a webrtc state must be set to #WEBRTC_STATE_NEGOTIATING or WEBRTC_STATE_PLAYING. * @post @a offer must be set as a local description by calling webrtc_set_local_description() * @post @a offer must be sent to the remote peer via the signaling channel. * @see webrtc_state_changed_cb() @@ -2408,7 +2409,8 @@ int webrtc_create_offer(webrtc_h webrtc, bundle *options, char **offer); * @brief Creates SDP answer to an offer received from a remote peer during the negotiation of a WebRTC connection. * @since_tizen 6.5 * @remarks The @a answer should be released using free().\n - * The @a options currently has no effect. + * The @a options currently has no effect.\n + * This function can be called in the state of #WEBRTC_STATE_PLAYING. (Since 9.0) * @param[in] webrtc WebRTC handle * @param[in] options Configuration options for the answer (optional, this can be NULL) * @param[out] answer SDP answer @@ -2418,7 +2420,7 @@ int webrtc_create_offer(webrtc_h webrtc, bundle *options, char **offer); * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #WEBRTC_ERROR_INVALID_OPERATION Invalid operation * @retval #WEBRTC_ERROR_INVALID_STATE Invalid state - * @pre @a webrtc state must be set to #WEBRTC_STATE_NEGOTIATING. + * @pre @a webrtc state must be set to #WEBRTC_STATE_NEGOTIATING or WEBRTC_STATE_PLAYING. * @pre The remote SDP offer must be set by calling webrtc_set_remote_description(). * @pre The signaling state must be set to #WEBRTC_SIGNALING_STATE_HAVE_REMOTE_OFFER. * @post @a answer must be set as a local description by calling webrtc_set_local_description() @@ -2434,7 +2436,8 @@ int webrtc_create_answer(webrtc_h webrtc, bundle *options, char **answer); * @brief Creates SDP offer asynchronously to start a new WebRTC connection to a remote peer. * @since_tizen 6.5 * @remarks The registered callback will be invoked in the main thread.\n - * The @a options currently has no effect. + * The @a options currently has no effect.\n + * This function can be called in the state of #WEBRTC_STATE_PLAYING. (Since 9.0) * @param[in] webrtc WebRTC handle * @param[in] options Configuration options for the offer (optional, this can be NULL) * @param[in] callback Callback function pointer @@ -2445,7 +2448,7 @@ int webrtc_create_answer(webrtc_h webrtc, bundle *options, char **answer); * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #WEBRTC_ERROR_INVALID_OPERATION Invalid operation * @retval #WEBRTC_ERROR_INVALID_STATE Invalid state - * @pre @a webrtc state must be set to #WEBRTC_STATE_NEGOTIATING. + * @pre @a webrtc state must be set to #WEBRTC_STATE_NEGOTIATING or WEBRTC_STATE_PLAYING. * @post webrtc_session_description_created_cb() will be invoked. * @see webrtc_state_changed_cb() * @see webrtc_negotiation_needed_cb() @@ -2458,7 +2461,8 @@ int webrtc_create_offer_async(webrtc_h webrtc, bundle *options, webrtc_session_d * @brief Creates SDP answer asynchronously to an offer received from a remote peer during the negotiation of a WebRTC connection. * @since_tizen 6.5 * @remarks The registered callback will be invoked in the main thread.\n - * The @a options currently has no effect. + * The @a options currently has no effect.\n + * This function can be called in the state of #WEBRTC_STATE_PLAYING. (Since 9.0) * @param[in] webrtc WebRTC handle * @param[in] options Configuration options for the answer (optional, this can be NULL) * @param[in] callback Callback function pointer @@ -2469,7 +2473,7 @@ int webrtc_create_offer_async(webrtc_h webrtc, bundle *options, webrtc_session_d * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #WEBRTC_ERROR_INVALID_OPERATION Invalid operation * @retval #WEBRTC_ERROR_INVALID_STATE Invalid state - * @pre @a webrtc state must be set to #WEBRTC_STATE_NEGOTIATING. + * @pre @a webrtc state must be set to #WEBRTC_STATE_NEGOTIATING or WEBRTC_STATE_PLAYING. * @pre The remote SDP offer must be set by calling webrtc_set_remote_description(). * @pre The signaling state must be set to #WEBRTC_SIGNALING_STATE_HAVE_REMOTE_OFFER. * @post webrtc_session_description_created_cb() will be invoked. @@ -2485,7 +2489,8 @@ int webrtc_create_answer_async(webrtc_h webrtc, bundle *options, webrtc_session_ * @brief Sets the session description for a local peer associated with a WebRTC connection. * @since_tizen 6.5 * @remarks @a description is a JSON string.\n - * It will be {"sdp":{"type":"offer or answer","sdp":"..."}}. + * It will be {"sdp":{"type":"offer or answer","sdp":"..."}}.\n + * This function can be called in the state of #WEBRTC_STATE_PLAYING. (Since 9.0) * @param[in] webrtc WebRTC handle * @param[in] description The local session description * @return @c 0 on success, @@ -2494,7 +2499,7 @@ int webrtc_create_answer_async(webrtc_h webrtc, bundle *options, webrtc_session_ * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #WEBRTC_ERROR_INVALID_OPERATION Invalid operation * @retval #WEBRTC_ERROR_INVALID_STATE Invalid state - * @pre @a webrtc state must be set to #WEBRTC_STATE_NEGOTIATING. + * @pre @a webrtc state must be set to #WEBRTC_STATE_NEGOTIATING or WEBRTC_STATE_PLAYING. * @see webrtc_create_offer() * @see webrtc_create_offer_async() * @see webrtc_create_answer() @@ -2509,6 +2514,7 @@ int webrtc_set_local_description(webrtc_h webrtc, const char *description); * @since_tizen 6.5 * @remarks @a description is a JSON string.\n * It should be {"sdp":{"type":"offer or answer","sdp":"..."}}. + * This function can be called in the state of #WEBRTC_STATE_PLAYING. (Since 9.0) * @param[in] webrtc WebRTC handle * @param[in] description The remote session description * @return @c 0 on success, @@ -2517,7 +2523,7 @@ int webrtc_set_local_description(webrtc_h webrtc, const char *description); * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #WEBRTC_ERROR_INVALID_OPERATION Invalid operation * @retval #WEBRTC_ERROR_INVALID_STATE Invalid state - * @pre @a webrtc state must be set to #WEBRTC_STATE_NEGOTIATING. + * @pre @a webrtc state must be set to #WEBRTC_STATE_NEGOTIATING or WEBRTC_STATE_PLAYING. * @see webrtc_state_changed_cb() * @see webrtc_set_signaling_state_change_cb() * @see webrtc_get_signaling_state() diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index e991a9d4..494ae155 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.55 +Version: 1.0.0 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc.c b/src/webrtc.c index 30318771..ab481e46 100644 --- a/src/webrtc.c +++ b/src/webrtc.c @@ -1642,7 +1642,7 @@ int webrtc_create_offer(webrtc_h webrtc, bundle *options, char **offer) locker = g_mutex_locker_new(&_webrtc->mutex); - RET_VAL_IF(_webrtc->state != WEBRTC_STATE_NEGOTIATING, WEBRTC_ERROR_INVALID_STATE, "the state should be NEGOTIATING"); + RET_VAL_IF(_webrtc->state == WEBRTC_STATE_IDLE, WEBRTC_ERROR_INVALID_STATE, "the state should not be IDLE"); LOG_INFO("webrtc[%p] offer[%p]", webrtc, offer); @@ -1662,7 +1662,7 @@ int webrtc_create_answer(webrtc_h webrtc, bundle *options, char **answer) locker = g_mutex_locker_new(&_webrtc->mutex); - RET_VAL_IF(_webrtc->state != WEBRTC_STATE_NEGOTIATING, WEBRTC_ERROR_INVALID_STATE, "the state should be NEGOTIATING"); + RET_VAL_IF(_webrtc->state == WEBRTC_STATE_IDLE, WEBRTC_ERROR_INVALID_STATE, "the state should not be IDLE"); RET_VAL_IF(!_webrtcbin_have_remote_offer(_webrtc), WEBRTC_ERROR_INVALID_STATE, "remote offer should be set"); LOG_INFO("webrtc[%p] answer[%p]", webrtc, answer); @@ -1682,7 +1682,7 @@ int webrtc_create_offer_async(webrtc_h webrtc, bundle *options, webrtc_session_d locker = g_mutex_locker_new(&_webrtc->mutex); - RET_VAL_IF(_webrtc->state != WEBRTC_STATE_NEGOTIATING, WEBRTC_ERROR_INVALID_STATE, "the state should be NEGOTIATING"); + RET_VAL_IF(_webrtc->state == WEBRTC_STATE_IDLE, WEBRTC_ERROR_INVALID_STATE, "the state should not be IDLE"); LOG_INFO("webrtc[%p] options[%p] callback[%p] user_data[%p]", webrtc, options, callback, user_data); @@ -1702,7 +1702,7 @@ int webrtc_create_answer_async(webrtc_h webrtc, bundle *options, webrtc_session_ locker = g_mutex_locker_new(&_webrtc->mutex); - RET_VAL_IF(_webrtc->state != WEBRTC_STATE_NEGOTIATING, WEBRTC_ERROR_INVALID_STATE, "the state should be NEGOTIATING"); + RET_VAL_IF(_webrtc->state == WEBRTC_STATE_IDLE, WEBRTC_ERROR_INVALID_STATE, "the state should not be IDLE"); RET_VAL_IF(!_webrtcbin_have_remote_offer(_webrtc), WEBRTC_ERROR_INVALID_STATE, "remote offer should be set"); LOG_INFO("webrtc[%p] options[%p] callback[%p] user_data[%p]", webrtc, options, callback, user_data); @@ -1722,7 +1722,7 @@ int webrtc_set_local_description(webrtc_h webrtc, const char *description) locker = g_mutex_locker_new(&_webrtc->mutex); - RET_VAL_IF(_webrtc->state != WEBRTC_STATE_NEGOTIATING, WEBRTC_ERROR_INVALID_STATE, "the state should be NEGOTIATING"); + RET_VAL_IF(_webrtc->state == WEBRTC_STATE_IDLE, WEBRTC_ERROR_INVALID_STATE, "the state should not be IDLE"); LOG_INFO("webrtc[%p] description: %s", webrtc, description); @@ -1739,7 +1739,7 @@ int webrtc_set_remote_description(webrtc_h webrtc, const char *description) locker = g_mutex_locker_new(&_webrtc->mutex); - RET_VAL_IF(_webrtc->state != WEBRTC_STATE_NEGOTIATING, WEBRTC_ERROR_INVALID_STATE, "the state should be NEGOTIATING"); + RET_VAL_IF(_webrtc->state == WEBRTC_STATE_IDLE, WEBRTC_ERROR_INVALID_STATE, "the state should not be IDLE"); LOG_INFO("webrtc[%p] description: %s", webrtc, description);