From 3e7457d8791ab589f3ee006d837ef7a0f9bf4cc0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Olivier=20Cr=C3=AAte?= Date: Wed, 25 Mar 2020 20:50:01 -0400 Subject: [PATCH] webrtcbin: Accept end-of-candidate pass it to libnice 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: Signed-off-by: Sangchul Lee --- ext/webrtc/gstwebrtcbin.c | 13 ++++++++----- ext/webrtc/gstwebrtcice.c | 12 +++++++++--- ext/webrtc/meson.build | 2 +- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/ext/webrtc/gstwebrtcbin.c b/ext/webrtc/gstwebrtcbin.c index 725b865..875cd21 100644 --- a/ext/webrtc/gstwebrtcbin.c +++ b/ext/webrtc/gstwebrtcbin.c @@ -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", diff --git a/ext/webrtc/gstwebrtcice.c b/ext/webrtc/gstwebrtcice.c index 473da7f..1931ddc 100644 --- a/ext/webrtc/gstwebrtcice.c +++ b/ext/webrtc/gstwebrtcice.c @@ -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); diff --git a/ext/webrtc/meson.build b/ext/webrtc/meson.build index 3e7a5d1..49e8d4b 100644 --- a/ext/webrtc/meson.build +++ b/ext/webrtc/meson.build @@ -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']) -- 2.7.4