From: Sangchul Lee Date: Tue, 27 Apr 2021 23:27:20 +0000 (+0900) Subject: Invoke state changed callback in the main context X-Git-Tag: submit/tizen/20210729.023123~82 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=750184d1012e64ac327e80fbdadf689b89662dc4;p=platform%2Fcore%2Fapi%2Fwebrtc.git Invoke state changed callback in the main context Some of caller of state changed callback invoked it in a thread context. It is now fixed that all of the callbacks are called in the main context. [Version] 0.1.159 [Issue Type] Improvement Change-Id: Ib3e1047e306247405189bdd2bededed558edec37 Signed-off-by: Sangchul Lee --- diff --git a/include/webrtc_private.h b/include/webrtc_private.h index 8fbef603..accd45f3 100644 --- a/include/webrtc_private.h +++ b/include/webrtc_private.h @@ -469,6 +469,7 @@ int _push_media_packet(webrtc_s *webrtc, unsigned int source_id, media_packet_h int _get_transceiver_direction(webrtc_s *webrtc, unsigned int source_id, webrtc_media_type_e media_type, webrtc_transceiver_direction_e *direction); int _set_transceiver_direction(webrtc_s *webrtc, unsigned int source_id, webrtc_media_type_e media_type, webrtc_transceiver_direction_e direction); void _invoke_state_changed_cb(webrtc_s *webrtc, webrtc_state_e old, webrtc_state_e new); +void _post_state_cb_in_idle(webrtc_s *webrtc, webrtc_state_e new_state); void _post_error_cb_in_idle(webrtc_s *webrtc, webrtc_error_e error); void _connect_and_append_signal(GList **signals, GObject *obj, const char *sig_name, GCallback cb, gpointer user_data); diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index 41625aed..08d29557 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.1.158 +Version: 0.1.159 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc_data_channel.c b/src/webrtc_data_channel.c index 8f9bdfe2..9674aacb 100644 --- a/src/webrtc_data_channel.c +++ b/src/webrtc_data_channel.c @@ -142,14 +142,10 @@ void _webrtcbin_on_data_channel_cb(GstElement *webrtcbin, GObject *data_channel, g_mutex_unlock(&channel->mutex); g_mutex_lock(&webrtc->mutex); - if (webrtc->state == WEBRTC_STATE_NEGOTIATING) { - webrtc_state_e old_state = webrtc->state; - webrtc->state = webrtc->pend_state = WEBRTC_STATE_PLAYING; - g_mutex_unlock(&webrtc->mutex); - _invoke_state_changed_cb(webrtc, old_state, webrtc->state); - } else { - g_mutex_unlock(&webrtc->mutex); - } + if (webrtc->state == WEBRTC_STATE_NEGOTIATING) + _post_state_cb_in_idle(webrtc, WEBRTC_STATE_PLAYING); + g_mutex_unlock(&webrtc->mutex); + __invoke_data_channel_cb(webrtc, channel); } diff --git a/src/webrtc_private.c b/src/webrtc_private.c index 9cfe89c3..fd303f72 100644 --- a/src/webrtc_private.c +++ b/src/webrtc_private.c @@ -340,7 +340,7 @@ static gboolean __idle_cb(gpointer user_data) return G_SOURCE_REMOVE; } -static void __post_state_cb_in_idle(webrtc_s *webrtc, webrtc_state_e new_state) +void _post_state_cb_in_idle(webrtc_s *webrtc, webrtc_state_e new_state) { idle_userdata_s *data; @@ -612,14 +612,8 @@ static void __webrtcbin_peer_connection_state_cb(GstElement *webrtcbin, GParamSp new_state = "NEW"; g_mutex_lock(&webrtc->mutex); - if (webrtc->state == WEBRTC_STATE_NEGOTIATING) { - webrtc_state_e old_state = webrtc->state; - webrtc->state = webrtc->pend_state = WEBRTC_STATE_PLAYING; - g_mutex_unlock(&webrtc->mutex); - _invoke_state_changed_cb(webrtc, old_state, webrtc->state); - break; - } - + if (webrtc->state == WEBRTC_STATE_NEGOTIATING) + _post_state_cb_in_idle(webrtc, WEBRTC_STATE_PLAYING); g_mutex_unlock(&webrtc->mutex); break; @@ -1572,7 +1566,7 @@ int _webrtc_stop(webrtc_s *webrtc) __destroy_sink_pipeline(webrtc); - __post_state_cb_in_idle(webrtc, WEBRTC_STATE_IDLE); + _post_state_cb_in_idle(webrtc, WEBRTC_STATE_IDLE); LOG_INFO("webrtc[%p] is stopped", webrtc);