From: Sangchul Lee Date: Wed, 9 Jun 2021 00:28:02 +0000 (+0900) Subject: webrtc_private: Ensure the NEGOTIATING state to get ready for negotiation operation X-Git-Tag: submit/tizen/20210729.023123~56 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3aebd5d776e996db09564452afcf81c2eb46d358;p=platform%2Fcore%2Fapi%2Fwebrtc.git webrtc_private: Ensure the NEGOTIATING state to get ready for negotiation operation Invoking state callback for NEGOTIATING state is moved to the inside of negotiation needed callback. This ensures to get the SSRC parameter successfully while creating offer SDP. [Version] 0.2.7 [Issue Type] Improvement Change-Id: I4cfe0f5214b12925170ba2cd6fbfa4c52a66daa5 Signed-off-by: Sangchul Lee --- diff --git a/include/webrtc.h b/include/webrtc.h index b419d6cf..44f2df4a 100644 --- a/include/webrtc.h +++ b/include/webrtc.h @@ -1230,6 +1230,7 @@ int webrtc_unset_ice_candidate_cb(webrtc_h webrtc); * @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. + * @see webrtc_state_changed_cb() * @see webrtc_negotiation_needed_cb() * @see webrtc_set_local_description() */ diff --git a/include/webrtc_private.h b/include/webrtc_private.h index cd95e549..d05da8ee 100644 --- a/include/webrtc_private.h +++ b/include/webrtc_private.h @@ -387,6 +387,11 @@ typedef struct _webrtc_s { webrtc_callbacks_s encoded_video_frame_cb; webrtc_callbacks_s data_channel_cb; + /* FIXME: Once signal is emitted by webrtcbin, it'll not be triggered + * even if the pipeline state is changed to NULL to PLAYING again. + * This variable could be removed, some improvements are applied to webrtcbin. */ + bool negotiation_needed_cb_invoked; + webrtc_negotiation_states_s negotiation_states; #ifdef TIZEN_FEATURE_RES_MGR webrtc_resource_s resource; diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index 48a93cea..96923de6 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.6 +Version: 0.2.7 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc_private.c b/src/webrtc_private.c index 24226ae4..16e4300b 100644 --- a/src/webrtc_private.c +++ b/src/webrtc_private.c @@ -217,12 +217,12 @@ static gchar *__make_ice_candidate_message(guint mlineindex, gchar *candidate) return text; } -static bool __meet_gst_state(webrtc_state_e state, GstState gst_state) +static bool __meet_gst_state(webrtc_state_e state, GstState gst_state, bool negotiation_needed_cb_invoked) { if (state == WEBRTC_STATE_IDLE && gst_state == GST_STATE_READY) return true; - if (state == WEBRTC_STATE_NEGOTIATING && gst_state == GST_STATE_PLAYING) + if (state == WEBRTC_STATE_NEGOTIATING && gst_state == GST_STATE_PLAYING && negotiation_needed_cb_invoked) return true; return false; @@ -232,6 +232,9 @@ void _invoke_state_changed_cb(webrtc_s *webrtc, webrtc_state_e old, webrtc_state { RET_IF(webrtc == NULL, "webrtc is NULL"); + if (old == new) + return; + LOG_INFO("state is changed [%s] -> [%s]", __state_str[old], __state_str[new]); if (webrtc->state_changed_cb.callback) { @@ -379,7 +382,7 @@ static gboolean __bus_watch_cb(GstBus *bus, GstMessage *message, gpointer user_d break; } - if (__meet_gst_state(webrtc->pend_state, gst_state_new)) { + if (__meet_gst_state(webrtc->pend_state, gst_state_new, webrtc->negotiation_needed_cb_invoked)) { webrtc_state_e old_state = webrtc->state; webrtc->state = webrtc->pend_state; g_mutex_unlock(&webrtc->mutex); @@ -676,10 +679,20 @@ void _disconnect_signal(gpointer data) static void __webrtcbin_on_negotiation_needed_cb(GstElement *webrtcbin, gpointer user_data) { webrtc_s *webrtc = (webrtc_s *)user_data; + webrtc_state_e old_state; RET_IF(webrtcbin == NULL, "webrtcbin is NULL"); RET_IF(webrtc == NULL, "webrtc is NULL"); + g_mutex_lock(&webrtc->mutex); + + old_state = webrtc->state; + webrtc->state = webrtc->pend_state; + + g_mutex_unlock(&webrtc->mutex); + _invoke_state_changed_cb(webrtc, old_state, webrtc->state); + webrtc->negotiation_needed_cb_invoked = true; + if (webrtc->negotiation_needed_cb.callback == NULL) { LOG_DEBUG("negotiation_needed_cb is NULL, skip it"); return;