webrtcbin: Accept end-of-candidate pass it to libnice 75/262575/2
authorOlivier CrĂȘte <olivier.crete@collabora.com>
Thu, 26 Mar 2020 00:50:01 +0000 (20:50 -0400)
committerSangchul Lee <sc11.lee@samsung.com>
Fri, 13 Aug 2021 09:10:57 +0000 (09:10 +0000)
libnice now supports the concept of end-of-candidate, so use the API
for it. This also means that if you don't do that, the webrtcbin will
never declared the connection as failed.

This requires bumping the dependency to libnice 0.1.16

Change-Id: I6eae82ce39e7e65ff71247f6d4343e6df0b547e5
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1139>
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
ext/webrtc/gstwebrtcbin.c
ext/webrtc/gstwebrtcice.c
ext/webrtc/meson.build

index 725b865..875cd21 100644 (file)
@@ -4804,10 +4804,12 @@ gst_webrtc_bin_add_ice_candidate (GstWebRTCBin * webrtc, guint mline,
 
   item = g_new0 (IceCandidateItem, 1);
   item->mlineindex = mline;
-  if (!g_ascii_strncasecmp (attr, "a=candidate:", 12))
-    item->candidate = g_strdup (attr);
-  else if (!g_ascii_strncasecmp (attr, "candidate:", 10))
-    item->candidate = g_strdup_printf ("a=%s", attr);
+  if (attr && attr[0] != 0) {
+    if (!g_ascii_strncasecmp (attr, "a=candidate:", 12))
+      item->candidate = g_strdup (attr);
+    else if (!g_ascii_strncasecmp (attr, "candidate:", 10))
+      item->candidate = g_strdup_printf ("a=%s", attr);
+  }
   gst_webrtc_bin_enqueue_task (webrtc,
       (GstWebRTCBinFunc) _add_ice_candidate_task, item,
       (GDestroyNotify) _free_ice_candidate_item, NULL);
@@ -6355,7 +6357,8 @@ gst_webrtc_bin_class_init (GstWebRTCBinClass * klass)
    * GstWebRTCBin::add-ice-candidate:
    * @object: the #webrtcbin
    * @mline_index: the index of the media description in the SDP
-   * @ice-candidate: an ice candidate
+   * @ice-candidate: an ice candidate or NULL/"" to mark that no more candidates
+   * will arrive
    */
   gst_webrtc_bin_signals[ADD_ICE_CANDIDATE_SIGNAL] =
       g_signal_new_class_handler ("add-ice-candidate",
index 473da7f..1931ddc 100644 (file)
@@ -613,7 +613,7 @@ failure:
   return FALSE;
 }
 
-/* must start with "a=candidate:" */
+/* candidate must start with "a=candidate:" or be NULL*/
 void
 gst_webrtc_ice_add_candidate (GstWebRTCICE * ice, GstWebRTCICEStream * stream,
     const gchar * candidate)
@@ -625,6 +625,12 @@ gst_webrtc_ice_add_candidate (GstWebRTCICE * ice, GstWebRTCICEStream * stream,
   item = _find_item (ice, -1, -1, stream);
   g_return_if_fail (item != NULL);
 
+  if (candidate == NULL) {
+    nice_agent_peer_candidate_gathering_done (ice->priv->nice_agent,
+        item->nice_stream_id);
+    return;
+  }
+
   cand =
       nice_agent_parse_remote_candidate_sdp (ice->priv->nice_agent,
       item->nice_stream_id, candidate);
@@ -1059,8 +1065,8 @@ gst_webrtc_ice_constructed (GObject * object)
 
   _start_thread (ice);
 
-  ice->priv->nice_agent = nice_agent_new (ice->priv->main_context,
-      NICE_COMPATIBILITY_RFC5245);
+  ice->priv->nice_agent = nice_agent_new_full (ice->priv->main_context,
+      NICE_COMPATIBILITY_RFC5245, NICE_AGENT_OPTION_ICE_TRICKLE);
   g_signal_connect (ice->priv->nice_agent, "new-candidate-full",
       G_CALLBACK (_on_new_candidate), ice);
 
index 3e7a5d1..49e8d4b 100644 (file)
@@ -15,7 +15,7 @@ webrtc_sources = [
   'webrtcdatachannel.c',
 ]
 
-libnice_dep = dependency('nice', version : '>=0.1.14', required : get_option('webrtc'),
+libnice_dep = dependency('nice', version : '>=0.1.16', required : get_option('webrtc'),
                          fallback : ['libnice', 'libnice_dep'],
                          default_options: ['tests=disabled'])