From 68f3bee3a48d7f006123f01fc10bdcc8be4dbbde Mon Sep 17 00:00:00 2001 From: Sangchul Lee Date: Fri, 29 Oct 2021 15:45:18 +0900 Subject: [PATCH] webrtcbin: Notify missing ice-gathering-state for COMPLETE Occasionally, GATHERING_STATE_COMPLETE was obtained in _update_ice_ gathering_state_task() before consuming all the tasks for local ICE candidates in _on_local_ice_candidate_task(). It missed notifying the 'ice-gathering-state' signal for gathering completion. This patch fixes it. Change-Id: Ie0a997e6976f48b876cb0741f488826a0c172116 Signed-off-by: Sangchul Lee --- ext/webrtc/gstwebrtcbin.c | 45 +++++++++++++++++++++++++++++++++++++++ ext/webrtc/gstwebrtcbin.h | 3 +++ 2 files changed, 48 insertions(+) diff --git a/ext/webrtc/gstwebrtcbin.c b/ext/webrtc/gstwebrtcbin.c index 7162e8784..76f6c448d 100644 --- a/ext/webrtc/gstwebrtcbin.c +++ b/ext/webrtc/gstwebrtcbin.c @@ -1141,6 +1141,32 @@ _collate_peer_connection_states (GstWebRTCBin * webrtc) #undef STATE } +#ifdef __TIZEN__ +static void +_update_and_notify_ice_gathering_state (GstWebRTCBin * webrtc, GstWebRTCICEGatheringState state) +{ + GstWebRTCICEGatheringState old_state = webrtc->ice_gathering_state; + + if (state != webrtc->ice_gathering_state) { + gchar *old_s, *new_s; + + old_s = _enum_value_to_string (GST_TYPE_WEBRTC_ICE_GATHERING_STATE, + old_state); + new_s = _enum_value_to_string (GST_TYPE_WEBRTC_ICE_GATHERING_STATE, + state); + GST_INFO_OBJECT (webrtc, "ICE gathering state change from %s(%u) to %s(%u)", + old_s, old_state, new_s, state); + g_free (old_s); + g_free (new_s); + + webrtc->ice_gathering_state = state; + PC_UNLOCK (webrtc); + g_object_notify (G_OBJECT (webrtc), "ice-gathering-state"); + PC_LOCK (webrtc); + } +} +#endif + static void _update_ice_gathering_state_task (GstWebRTCBin * webrtc, gpointer data) { @@ -1157,11 +1183,23 @@ _update_ice_gathering_state_task (GstWebRTCBin * webrtc, gpointer data) ICE_LOCK (webrtc); if (webrtc->priv->pending_local_ice_candidates->len != 0) { /* ICE candidates queued for emissiong -> we're gathering, not complete */ +#ifdef __TIZEN__ + webrtc->pending_ice_gathering_state = GST_WEBRTC_ICE_GATHERING_STATE_COMPLETE; + GST_INFO_OBJECT (webrtc, "set pending_ice_gathering_state to (%u)", + webrtc->pending_ice_gathering_state); + ICE_UNLOCK (webrtc); + return; + } +#else new_state = GST_WEBRTC_ICE_GATHERING_STATE_GATHERING; } +#endif ICE_UNLOCK (webrtc); } +#ifdef __TIZEN__ + _update_and_notify_ice_gathering_state (webrtc, new_state); +#else if (new_state != webrtc->ice_gathering_state) { gchar *old_s, *new_s; @@ -1179,6 +1217,7 @@ _update_ice_gathering_state_task (GstWebRTCBin * webrtc, gpointer data) g_object_notify (G_OBJECT (webrtc), "ice-gathering-state"); PC_LOCK (webrtc); } +#endif } static void @@ -5286,6 +5325,12 @@ _on_local_ice_candidate_task (GstWebRTCBin * webrtc) } g_array_free (items, TRUE); +#ifdef __TIZEN__ + if (webrtc->pending_ice_gathering_state == GST_WEBRTC_ICE_GATHERING_STATE_COMPLETE) { + _update_and_notify_ice_gathering_state (webrtc, GST_WEBRTC_ICE_GATHERING_STATE_COMPLETE); + webrtc->pending_ice_gathering_state = GST_WEBRTC_ICE_GATHERING_STATE_NEW; + } +#endif } static void diff --git a/ext/webrtc/gstwebrtcbin.h b/ext/webrtc/gstwebrtcbin.h index f3eb9f6d6..7886700b9 100644 --- a/ext/webrtc/gstwebrtcbin.h +++ b/ext/webrtc/gstwebrtcbin.h @@ -72,6 +72,9 @@ struct _GstWebRTCBin GstWebRTCSignalingState signaling_state; GstWebRTCICEGatheringState ice_gathering_state; +#ifdef __TIZEN__ + GstWebRTCICEGatheringState pending_ice_gathering_state; +#endif GstWebRTCICEConnectionState ice_connection_state; GstWebRTCPeerConnectionState peer_connection_state; -- 2.34.1