From: Olivier CrĂȘte Date: Thu, 26 Mar 2020 00:50:01 +0000 (-0400) Subject: webrtcbin: Accept end-of-candidate pass it to libnice X-Git-Tag: submit/tizen/20210818.024548~12 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3e7457d8791ab589f3ee006d837ef7a0f9bf4cc0;p=platform%2Fupstream%2Fgst-plugins-bad.git 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 --- diff --git a/ext/webrtc/gstwebrtcbin.c b/ext/webrtc/gstwebrtcbin.c index 725b865f7..875cd21b0 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 473da7f7f..1931ddc99 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 3e7a5d1d8..49e8d4bb2 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'])