webrtcbin: Notify missing ice-gathering-state for COMPLETE 80/266680/1
authorSangchul Lee <sc11.lee@samsung.com>
Fri, 29 Oct 2021 06:45:18 +0000 (15:45 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Wed, 17 Nov 2021 06:13:42 +0000 (06:13 +0000)
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 <sc11.lee@samsung.com>
(cherry picked from commit 68f3bee3a48d7f006123f01fc10bdcc8be4dbbde)

ext/webrtc/gstwebrtcbin.c
ext/webrtc/gstwebrtcbin.h

index 3b7a3da79fabeb9329c567408aa7cc3914d4cc04..cdc392dbbade12ec9e4e7084fbdfdd13f51767c1 100644 (file)
@@ -1138,6 +1138,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)
 {
@@ -1154,11 +1180,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;
 
@@ -1176,6 +1214,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
@@ -5273,6 +5312,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
index f3eb9f6d60aa92f705636684273504e4eda4df49..7886700b93271f79daed856b4b3517053360246f 100644 (file)
@@ -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;