COMMIT_MESSAGE

 1patch
 2

Tools/ChangeLog

 12016-10-12 Philippe Normand <pnormand@igalia.com>
 2
 3 WebRTC: [GTK] Update jhbuild environment for OpenWebRTC
 4 https://bugs.webkit.org/show_bug.cgi?id=163330
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Bring back the openwebrtc JHBuild moduleset in the time being. It
 9 should be removed after the bump to GStreamer 1.10 is complete and
 10 the libnice patches have been upstreamed. The GStreamer git
 11 snapshots used in this patch are the ones configured in Ericsson's
 12 GStreamer Cerbero fork.
 13
 14 * gtk/openwebrtc.modules: Added.
 15 * gtk/patches/libnice-0001-TURN-allow-REALM-to-be-empty.patch: Added.
 16 * gtk/patches/libnice-0001-agent-Remove-unnecessary-NULL-check.patch: Added.
 17 * gtk/patches/libnice-0001-nicesrc-spin-the-agent-mainloop-in-a-separate-thread.patch: Added.
 18 * gtk/patches/libnice-0002-Do-not-update-a-remote-candidate-s-type.patch: Added.
 19 * gtk/patches/libnice-0002-TURN-handle-437-Allocation-Mismatch-responses.patch: Added.
 20 * gtk/patches/libnice-0003-Do-not-compare-scope-for-IPv6-address-when-scope-is-.patch: Added.
 21 * gtk/patches/libnice-0004-Removing-no-op-assignment.patch: Added.
 22
1232016-10-11 Alex Christensen <achristensen@webkit.org>
224
325 Update API test expectation after r207162.

Tools/gtk/openwebrtc.modules

 1<?xml version="1.0"?>
 2<!DOCTYPE moduleset SYSTEM "moduleset.dtd">
 3<?xml-stylesheet type="text/xsl" href="moduleset.xsl"?>
 4<moduleset>
 5
 6 <repository type="tarball" name="github-tarball"
 7 href="https://github.com/"/>
 8 <repository type="git" name="gstreamer"
 9 href="git://anongit.freedesktop.org/git/gstreamer/"/>
 10 <repository type="tarball" name="nice.freedesktop.org"
 11 href="http://nice.freedesktop.org"/>
 12
 13 <autotools id="openh264" supports-non-srcdir-builds="no" autogen-sh="pseudo-configure">
 14 <branch module="cisco/openh264/archive/v${version}.tar.gz" version="1.5.0"
 15 checkoutdir="openh264-${version}" repo="github-tarball">
 16 <patch file="openh264-configure.patch" strip="0"/>
 17 </branch>
 18 </autotools>
 19
 20 <autotools id="libnice" supports-non-srcdir-builds="no">
 21 <dependencies>
 22 <dep package="gstreamer"/>
 23 </dependencies>
 24 <branch repo="nice.freedesktop.org" module="releases/libnice-${version}.tar.gz" version="0.1.13" checkoutdir="libnice-${version}">
 25 <patch file="libnice-0001-agent-Remove-unnecessary-NULL-check.patch" strip="1"/>
 26 <patch file="libnice-0002-Do-not-update-a-remote-candidate-s-type.patch" strip="1"/>
 27 <patch file="libnice-0003-Do-not-compare-scope-for-IPv6-address-when-scope-is-.patch" strip="1"/>
 28 <patch file="libnice-0004-Removing-no-op-assignment.patch" strip="1"/>
 29 <patch file="libnice-0001-nicesrc-spin-the-agent-mainloop-in-a-separate-thread.patch" strip="1"/>
 30 <patch file="libnice-0001-TURN-allow-REALM-to-be-empty.patch" strip="1"/>
 31 <patch file="libnice-0002-TURN-handle-437-Allocation-Mismatch-responses.patch" strip="1"/>
 32 </branch>
 33 </autotools>
 34
 35 <autotools id="gstreamer" autogenargs="--disable-gtk-doc">
 36 <if condition-set="macos">
 37 <autogenargs value="--disable-introspection"/>
 38 </if>
 39 <dependencies>
 40 <dep package="orc"/>
 41 </dependencies>
 42 <branch repo="gstreamer" module="gstreamer" checkoutdir="gstreamer-b6e69ffdfb3bb21dbada8f01b488ae877f8d205c" tag="b6e69ffdfb3bb21dbada8f01b488ae877f8d205c"/>
 43 </autotools>
 44
 45 <autotools id="gst-plugins-base"
 46 autogen-sh="autogen.sh"
 47 autogenargs="--disable-examples --disable-gtk-doc">
 48 <if condition-set="macos">
 49 <autogenargs value="--disable-introspection"/>
 50 </if>
 51 <dependencies>
 52 <dep package="gstreamer"/>
 53 </dependencies>
 54 <branch repo="gstreamer" module="gst-plugins-base" checkoutdir="gst-plugins-base-cf18fae9deb02f0867b67593f678b932f8eb931a" tag="cf18fae9deb02f0867b67593f678b932f8eb931a"/>
 55 </autotools>
 56
 57 <autotools id="gst-plugins-good" autogenargs="--disable-examples --disable-soup --disable-gtk-doc">
 58 <if condition-set="macos">
 59 <autogenargs value="--disable-introspection"/>
 60 </if>
 61 <dependencies>
 62 <dep package="gst-plugins-base"/>
 63 </dependencies>
 64 <branch repo="gstreamer" module="gst-plugins-good" checkoutdir="gst-plugins-good-567afdd4d3f2fa07fecf4c02a7eca70f7a7ef7f7" tag="567afdd4d3f2fa07fecf4c02a7eca70f7a7ef7f7"/>
 65 </autotools>
 66
 67 <autotools id="gst-plugins-bad" autogenargs="--disable-examples --disable-gtk-doc --enable-openh264">
 68 <if condition-set="macos">
 69 <autogenargs value="--disable-introspection"/>
 70 </if>
 71 <dependencies>
 72 <dep package="gst-plugins-base"/>
 73 <dep package="openwebrtc"/>
 74 <dep package="openh264"/>
 75 </dependencies>
 76 <branch repo="gstreamer" module="gst-plugins-bad" checkoutdir="gst-plugins-bad-a036b7ef9ffe9fe5dac4a7e46fbc3bac92921a54" tag="a036b7ef9ffe9fe5dac4a7e46fbc3bac92921a54"/>
 77 </autotools>
 78
 79</moduleset>

Tools/gtk/patches/libnice-0001-TURN-allow-REALM-to-be-empty.patch

 1From 0c55166a817ec51096460f789234ef49237000cc Mon Sep 17 00:00:00 2001
 2From: Alessandro Decina <alessandro.d@gmail.com>
 3Date: Thu, 24 Mar 2016 10:48:27 +1100
 4Subject: [PATCH 1/2] TURN: allow REALM to be empty
 5
 6---
 7 agent/conncheck.c | 6 ++----
 8 stun/stunhmac.c | 6 ++++--
 9 2 files changed, 6 insertions(+), 6 deletions(-)
 10
 11diff --git a/agent/conncheck.c b/agent/conncheck.c
 12index 057fc81..97bf536 100644
 13--- a/agent/conncheck.c
 14+++ b/agent/conncheck.c
 15@@ -2768,13 +2768,11 @@ static gboolean priv_map_reply_to_relay_request (NiceAgent *agent, StunMessage *
 16 agent->compatibility == NICE_COMPATIBILITY_OC2007R2) &&
 17 stun_message_get_class (resp) == STUN_ERROR &&
 18 stun_message_find_error (resp, &code) ==
 19- STUN_MESSAGE_RETURN_SUCCESS &&
 20- recv_realm != NULL && recv_realm_len > 0) {
 21-
 22+ STUN_MESSAGE_RETURN_SUCCESS) {
 23 if (code == 438 ||
 24 (code == 401 &&
 25 !(recv_realm_len == sent_realm_len &&
 26- sent_realm != NULL &&
 27+ recv_realm != NULL && sent_realm != NULL &&
 28 memcmp (sent_realm, recv_realm, sent_realm_len) == 0))) {
 29 d->stun_resp_msg = *resp;
 30 memcpy (d->stun_resp_buffer, resp->buffer,
 31diff --git a/stun/stunhmac.c b/stun/stunhmac.c
 32index df5deb6..f73943f 100644
 33--- a/stun/stunhmac.c
 34+++ b/stun/stunhmac.c
 35@@ -90,8 +90,10 @@ static const uint8_t *priv_trim_var (const uint8_t *var, size_t *var_len)
 36 ptr++;
 37 (*var_len)--;
 38 }
 39- while(ptr[*var_len-1] == '"' ||
 40- ptr[*var_len-1] == 0) {
 41+
 42+ while(*var_len > 0 &&
 43+ (ptr[*var_len-1] == '"' ||
 44+ ptr[*var_len-1] == 0)) {
 45 (*var_len)--;
 46 }
 47
 48--
 492.3.4
 50

Tools/gtk/patches/libnice-0001-agent-Remove-unnecessary-NULL-check.patch

 1From 7b7d2d986876fc53a23af7b516d78f82f2a546e9 Mon Sep 17 00:00:00 2001
 2From: Philip Withnall <philip@tecnocode.co.uk>
 3Date: Sun, 3 May 2015 16:05:30 +0100
 4Subject: [PATCH 1/4] agent: Remove unnecessary NULL check
 5
 6With the changes in commit 483bdcf8, @name is now guaranteed to be
 7non-NULL. Spotted by Coverity.
 8
 9CID: #109878
 10---
 11 agent/agent.c | 16 +++++++---------
 12 1 file changed, 7 insertions(+), 9 deletions(-)
 13
 14diff --git a/agent/agent.c b/agent/agent.c
 15index 259fdc9..e733c82 100644
 16--- a/agent/agent.c
 17+++ b/agent/agent.c
 18@@ -5329,16 +5329,14 @@ nice_agent_set_stream_name (NiceAgent *agent, guint stream_id,
 19
 20 agent_lock();
 21
 22- if (name != NULL) {
 23- for (i = agent->streams; i; i = i->next) {
 24- Stream *stream = i->data;
 25+ for (i = agent->streams; i; i = i->next) {
 26+ Stream *stream = i->data;
 27
 28- if (stream->id != stream_id &&
 29- g_strcmp0 (stream->name, name) == 0)
 30- goto done;
 31- else if (stream->id == stream_id)
 32- stream_to_name = stream;
 33- }
 34+ if (stream->id != stream_id &&
 35+ g_strcmp0 (stream->name, name) == 0)
 36+ goto done;
 37+ else if (stream->id == stream_id)
 38+ stream_to_name = stream;
 39 }
 40
 41 if (stream_to_name == NULL)
 42--
 432.3.2 (Apple Git-55)
 44

Tools/gtk/patches/libnice-0001-nicesrc-spin-the-agent-mainloop-in-a-separate-thread.patch

 1From 3196a96a408a90f707dff3f31fa3d05d64aeb68a Mon Sep 17 00:00:00 2001
 2From: Alessandro Decina <alessandro.d@gmail.com>
 3Date: Tue, 13 Oct 2015 12:49:19 +1100
 4Subject: [PATCH] nicesrc: spin the agent mainloop in a separate thread
 5
 6Don't run the mainloop from the srcpad task, since that can get blocked in the
 7pipeline and cause unnecessary STUN retrasmissions (at best) and completely
 8block the agent (at worst).
 9---
 10 gst/gstnicesrc.c | 158 ++++++++++++++++++++++++++++++++-----------------------
 11 gst/gstnicesrc.h | 4 +-
 12 2 files changed, 93 insertions(+), 69 deletions(-)
 13
 14diff --git a/gst/gstnicesrc.c b/gst/gstnicesrc.c
 15index d369e09..eb59fe9 100644
 16--- a/gst/gstnicesrc.c
 17+++ b/gst/gstnicesrc.c
 18@@ -48,6 +48,14 @@ GST_DEBUG_CATEGORY_STATIC (nicesrc_debug);
 19
 20 #define BUFFER_SIZE (65536)
 21
 22+static gboolean
 23+gst_nice_src_start (
 24+ GstBaseSrc *basesrc);
 25+
 26+static gboolean
 27+gst_nice_src_stop (
 28+ GstBaseSrc *basesrc);
 29+
 30 static GstFlowReturn
 31 gst_nice_src_create (
 32 GstPushSrc *basesrc,
 33@@ -57,10 +65,6 @@ static gboolean
 34 gst_nice_src_unlock (
 35 GstBaseSrc *basesrc);
 36
 37-static gboolean
 38-gst_nice_src_unlock_stop (
 39- GstBaseSrc *basesrc);
 40-
 41 static void
 42 gst_nice_src_set_property (
 43 GObject *object,
 44@@ -116,8 +120,9 @@ gst_nice_src_class_init (GstNiceSrcClass *klass)
 45 gstpushsrc_class->create = GST_DEBUG_FUNCPTR (gst_nice_src_create);
 46
 47 gstbasesrc_class = (GstBaseSrcClass *) klass;
 48+ gstbasesrc_class->start = GST_DEBUG_FUNCPTR (gst_nice_src_start);
 49+ gstbasesrc_class->stop = GST_DEBUG_FUNCPTR (gst_nice_src_stop);
 50 gstbasesrc_class->unlock = GST_DEBUG_FUNCPTR (gst_nice_src_unlock);
 51- gstbasesrc_class->unlock_stop = GST_DEBUG_FUNCPTR (gst_nice_src_unlock_stop);
 52
 53 gobject_class = (GObjectClass *) klass;
 54 gobject_class->set_property = gst_nice_src_set_property;
 55@@ -179,9 +184,83 @@ gst_nice_src_init (GstNiceSrc *src)
 56 src->component_id = 0;
 57 src->mainctx = g_main_context_new ();
 58 src->mainloop = g_main_loop_new (src->mainctx, FALSE);
 59- src->unlocked = FALSE;
 60- src->idle_source = NULL;
 61 src->outbufs = g_queue_new ();
 62+ src->agent_io_thread = NULL;
 63+ g_cond_init (&src->outcond);
 64+}
 65+
 66+static gpointer
 67+gst_nice_src_agent_io_thread (gpointer data)
 68+{
 69+ GstNiceSrc *nicesrc = GST_NICE_SRC (data);
 70+
 71+ GST_INFO_OBJECT (nicesrc, "starting agent io thread");
 72+ g_main_loop_run (nicesrc->mainloop);
 73+ GST_INFO_OBJECT (nicesrc, "exiting agent io thread");
 74+
 75+ return NULL;
 76+}
 77+
 78+static gboolean
 79+main_loop_running_cb (gpointer data)
 80+{
 81+ GstNiceSrc *nicesrc = GST_NICE_SRC (data);
 82+
 83+ GST_OBJECT_LOCK (nicesrc);
 84+ /* _start() and _stop() could both be waiting for the mainloop to start so we
 85+ * need to broadcast */
 86+ g_cond_broadcast (&nicesrc->outcond);
 87+ GST_OBJECT_UNLOCK (nicesrc);
 88+
 89+ return FALSE;
 90+}
 91+
 92+static gboolean
 93+gst_nice_src_start (GstBaseSrc * basesrc)
 94+{
 95+ GstNiceSrc *nicesrc = GST_NICE_SRC (basesrc);
 96+ GSource *source;
 97+ gchar *thread_name;
 98+
 99+ GST_OBJECT_LOCK (nicesrc);
 100+ source = g_idle_source_new ();
 101+ g_source_set_callback (source,
 102+ (GSourceFunc) main_loop_running_cb, nicesrc, NULL);
 103+ g_source_attach (source, nicesrc->mainctx);
 104+ g_source_unref (source);
 105+
 106+ thread_name = g_strdup_printf ("%s:agent_io", GST_OBJECT_NAME (nicesrc));
 107+ nicesrc->agent_io_thread = g_thread_new (thread_name, gst_nice_src_agent_io_thread, nicesrc);
 108+ g_free (thread_name);
 109+ /* wait until the agent thread starts spinning the mainloop or _stop() is
 110+ * called */
 111+ while (GST_BASE_SRC_IS_STARTING (basesrc) &&
 112+ !g_main_loop_is_running (nicesrc->mainloop))
 113+ g_cond_wait (&nicesrc->outcond, GST_OBJECT_GET_LOCK (nicesrc));
 114+ GST_OBJECT_UNLOCK (nicesrc);
 115+
 116+ return TRUE;
 117+}
 118+
 119+static gboolean
 120+gst_nice_src_stop (GstBaseSrc * basesrc)
 121+{
 122+ GstNiceSrc *nicesrc = GST_NICE_SRC (basesrc);
 123+ GThread *agent_io_thread = NULL;
 124+
 125+ GST_OBJECT_LOCK (nicesrc);
 126+ /* here we wait for the agent thread created in _start() to be scheduled so
 127+ * that we don't risk calling _quit() first and then _run() on the mainloop */
 128+ while (!g_main_loop_is_running (nicesrc->mainloop))
 129+ g_cond_wait (&nicesrc->outcond, GST_OBJECT_GET_LOCK (nicesrc));
 130+ g_main_loop_quit (nicesrc->mainloop);
 131+ agent_io_thread = nicesrc->agent_io_thread;
 132+ nicesrc->agent_io_thread = NULL;
 133+ GST_OBJECT_UNLOCK (nicesrc);
 134+
 135+ g_thread_join (agent_io_thread);
 136+
 137+ return TRUE;
 138 }
 139
 140 static void
 141@@ -207,62 +286,17 @@ gst_nice_src_read_callback (NiceAgent *agent,
 142 #endif
 143 GST_OBJECT_LOCK (nicesrc);
 144 g_queue_push_tail (nicesrc->outbufs, buffer);
 145- g_main_loop_quit (nicesrc->mainloop);
 146+ g_cond_signal (&nicesrc->outcond);
 147 GST_OBJECT_UNLOCK (nicesrc);
 148 }
 149
 150 static gboolean
 151-gst_nice_src_unlock_idler (gpointer data)
 152-{
 153- GstNiceSrc *nicesrc = GST_NICE_SRC (data);
 154-
 155- GST_OBJECT_LOCK (nicesrc);
 156- if (nicesrc->unlocked)
 157- g_main_loop_quit (nicesrc->mainloop);
 158-
 159- if (nicesrc->idle_source) {
 160- g_source_destroy (nicesrc->idle_source);
 161- g_source_unref (nicesrc->idle_source);
 162- nicesrc->idle_source = NULL;
 163- }
 164- GST_OBJECT_UNLOCK (nicesrc);
 165-
 166- return FALSE;
 167-}
 168-
 169-static gboolean
 170 gst_nice_src_unlock (GstBaseSrc *src)
 171 {
 172 GstNiceSrc *nicesrc = GST_NICE_SRC (src);
 173
 174 GST_OBJECT_LOCK (src);
 175- nicesrc->unlocked = TRUE;
 176-
 177- g_main_loop_quit (nicesrc->mainloop);
 178-
 179- if (!nicesrc->idle_source) {
 180- nicesrc->idle_source = g_idle_source_new ();
 181- g_source_set_priority (nicesrc->idle_source, G_PRIORITY_HIGH);
 182- g_source_set_callback (nicesrc->idle_source, gst_nice_src_unlock_idler, src, NULL);
 183- g_source_attach (nicesrc->idle_source, g_main_loop_get_context (nicesrc->mainloop));
 184- }
 185- GST_OBJECT_UNLOCK (src);
 186-
 187- return TRUE;
 188-}
 189-
 190-static gboolean
 191-gst_nice_src_unlock_stop (GstBaseSrc *src)
 192-{
 193- GstNiceSrc *nicesrc = GST_NICE_SRC (src);
 194-
 195- GST_OBJECT_LOCK (src);
 196- nicesrc->unlocked = FALSE;
 197- if (nicesrc->idle_source) {
 198- g_source_destroy (nicesrc->idle_source);
 199- g_source_unref(nicesrc->idle_source);
 200- }
 201- nicesrc->idle_source = NULL;
 202+ g_cond_signal (&nicesrc->outcond);
 203 GST_OBJECT_UNLOCK (src);
 204
 205 return TRUE;
 206@@ -278,19 +312,8 @@ gst_nice_src_create (
 207 GST_LOG_OBJECT (nicesrc, "create called");
 208
 209 GST_OBJECT_LOCK (basesrc);
 210- if (nicesrc->unlocked) {
 211- GST_OBJECT_UNLOCK (basesrc);
 212-#if GST_CHECK_VERSION (1,0,0)
 213- return GST_FLOW_FLUSHING;
 214-#else
 215- return GST_FLOW_WRONG_STATE;
 216-#endif
 217- }
 218- if (g_queue_is_empty (nicesrc->outbufs)) {
 219- GST_OBJECT_UNLOCK (basesrc);
 220- g_main_loop_run (nicesrc->mainloop);
 221- GST_OBJECT_LOCK (basesrc);
 222- }
 223+ if (g_queue_is_empty (nicesrc->outbufs))
 224+ g_cond_wait (&nicesrc->outcond, GST_OBJECT_GET_LOCK (nicesrc));
 225
 226 *buffer = g_queue_pop_head (nicesrc->outbufs);
 227 GST_OBJECT_UNLOCK (basesrc);
 228@@ -331,6 +354,7 @@ gst_nice_src_dispose (GObject *object)
 229 g_queue_free (src->outbufs);
 230 }
 231 src->outbufs = NULL;
 232+ g_cond_clear (&src->outcond);
 233
 234 G_OBJECT_CLASS (gst_nice_src_parent_class)->dispose (object);
 235 }
 236diff --git a/gst/gstnicesrc.h b/gst/gstnicesrc.h
 237index 5d3f554..2d9f674 100644
 238--- a/gst/gstnicesrc.h
 239+++ b/gst/gstnicesrc.h
 240@@ -68,8 +68,8 @@ struct _GstNiceSrc
 241 GMainContext *mainctx;
 242 GMainLoop *mainloop;
 243 GQueue *outbufs;
 244- gboolean unlocked;
 245- GSource *idle_source;
 246+ GCond outcond;
 247+ GThread *agent_io_thread;
 248 };
 249
 250 typedef struct _GstNiceSrcClass GstNiceSrcClass;
 251--
 2522.3.4
 253

Tools/gtk/patches/libnice-0002-Do-not-update-a-remote-candidate-s-type.patch

 1From 93862c1e1940618e06143d4788f54bffd4d1c5da Mon Sep 17 00:00:00 2001
 2From: Youness Alaoui <kakaroto@kakaroto.homelinux.net>
 3Date: Tue, 5 May 2015 14:24:15 -0400
 4Subject: [PATCH 2/4] Do not update a remote candidate's type
 5
 6When adding a remote candidate, if it's the same ip:port, we should
 7also check its type, otherwise it's a new candidate. We can't allow
 8a candidate type to be updated. This caused issues to ikonst_ on IRC
 9where for some reason a host candidate appeared as both host and prflx
 10and the update caused a remote host candidate to be updated to prflx
 11causing a crash when the sockptr was being accessed.
 12---
 13 agent/agent.c | 2 +-
 14 1 file changed, 1 insertion(+), 1 deletion(-)
 15
 16diff --git a/agent/agent.c b/agent/agent.c
 17index e733c82..38b679f 100644
 18--- a/agent/agent.c
 19+++ b/agent/agent.c
 20@@ -3041,7 +3041,7 @@ static gboolean priv_add_remote_candidate (
 21
 22 /* step: check whether the candidate already exists */
 23 candidate = component_find_remote_candidate(component, addr, transport);
 24- if (candidate) {
 25+ if (candidate && candidate->type == type) {
 26 if (nice_debug_is_enabled ()) {
 27 gchar tmpbuf[INET6_ADDRSTRLEN];
 28 nice_address_to_string (addr, tmpbuf);
 29--
 302.3.2 (Apple Git-55)
 31

Tools/gtk/patches/libnice-0002-TURN-handle-437-Allocation-Mismatch-responses.patch

 1From 9e2ced131ac0fc642ef5c861851c5988d8b96d16 Mon Sep 17 00:00:00 2001
 2From: Alessandro Decina <alessandro.d@gmail.com>
 3Date: Thu, 24 Mar 2016 10:54:20 +1100
 4Subject: [PATCH 2/2] TURN: handle 437 Allocation Mismatch responses
 5
 6On Allocation Mismatch responses, the client is supposed to retry with a
 7different host:port combination.
 8---
 9 agent/conncheck.c | 42 +++++++++++++++++++++++++++++++++---------
 10 agent/discovery.h | 1 +
 11 stun/stunagent.c | 2 +-
 12 3 files changed, 35 insertions(+), 10 deletions(-)
 13
 14diff --git a/agent/conncheck.c b/agent/conncheck.c
 15index 97bf536..d03e57a 100644
 16--- a/agent/conncheck.c
 17+++ b/agent/conncheck.c
 18@@ -2630,9 +2630,10 @@ static gboolean priv_map_reply_to_relay_request (NiceAgent *agent, StunMessage *
 19 StunTransactionId discovery_id;
 20 StunTransactionId response_id;
 21 stun_message_id (resp, response_id);
 22+ CandidateDiscovery *d = NULL;
 23
 24 for (i = agent->discovery_list; i && trans_found != TRUE; i = i->next) {
 25- CandidateDiscovery *d = i->data;
 26+ d = i->data;
 27
 28 if (d->type == NICE_CANDIDATE_TYPE_RELAYED &&
 29 d->stun_message.buffer) {
 30@@ -2757,6 +2758,7 @@ static gboolean priv_map_reply_to_relay_request (NiceAgent *agent, StunMessage *
 31 uint16_t sent_realm_len = 0;
 32 uint16_t recv_realm_len = 0;
 33
 34+ trans_found = TRUE;
 35 sent_realm = (uint8_t *) stun_message_find (&d->stun_message,
 36 STUN_ATTRIBUTE_REALM, &sent_realm_len);
 37 recv_realm = (uint8_t *) stun_message_find (resp,
 38@@ -2769,11 +2771,31 @@ static gboolean priv_map_reply_to_relay_request (NiceAgent *agent, StunMessage *
 39 stun_message_get_class (resp) == STUN_ERROR &&
 40 stun_message_find_error (resp, &code) ==
 41 STUN_MESSAGE_RETURN_SUCCESS) {
 42- if (code == 438 ||
 43+ if (code == 437 ||
 44+ code == 438 ||
 45 (code == 401 &&
 46 !(recv_realm_len == sent_realm_len &&
 47 recv_realm != NULL && sent_realm != NULL &&
 48 memcmp (sent_realm, recv_realm, sent_realm_len) == 0))) {
 49+ if (code == 437) {
 50+ if (d->turn_retries++ == 3)
 51+ goto error;
 52+
 53+ /* retry up to three times on Allocation Mismatch errors */
 54+ NiceAddress addr = d->nicesock->addr;
 55+ NiceSocket *new_socket;
 56+
 57+ /* FIXME: this ignores nice_agent_set_port_range */
 58+ nice_address_set_port (&addr, 0);
 59+
 60+ new_socket = nice_udp_bsd_socket_new (&addr);
 61+ if (new_socket) {
 62+ _priv_set_socket_tos (agent, new_socket, d->stream->tos);
 63+ component_attach_socket (d->component, new_socket);
 64+ d->nicesock = new_socket;
 65+ }
 66+ }
 67+
 68 d->stun_resp_msg = *resp;
 69 memcpy (d->stun_resp_buffer, resp->buffer,
 70 stun_message_length (resp));
 71@@ -2782,23 +2804,25 @@ static gboolean priv_map_reply_to_relay_request (NiceAgent *agent, StunMessage *
 72 d->pending = FALSE;
 73 } else {
 74 /* case: a real unauthorized error */
 75- d->stun_message.buffer = NULL;
 76- d->stun_message.buffer_len = 0;
 77- d->done = TRUE;
 78+ goto error;
 79 }
 80 } else {
 81 /* case: STUN error, the check STUN context was freed */
 82- d->stun_message.buffer = NULL;
 83- d->stun_message.buffer_len = 0;
 84- d->done = TRUE;
 85+ goto error;
 86 }
 87- trans_found = TRUE;
 88 }
 89 }
 90 }
 91 }
 92
 93 return trans_found;
 94+
 95+error:
 96+ d->stun_message.buffer = NULL;
 97+ d->stun_message.buffer_len = 0;
 98+ d->done = TRUE;
 99+
 100+ return trans_found;
 101 }
 102
 103
 104diff --git a/agent/discovery.h b/agent/discovery.h
 105index c22ea6a..148b8c2 100644
 106--- a/agent/discovery.h
 107+++ b/agent/discovery.h
 108@@ -56,6 +56,7 @@ typedef struct
 109 Stream *stream;
 110 Component *component;
 111 TurnServer *turn;
 112+ gint turn_retries;
 113 StunAgent stun_agent;
 114 StunTimer timer;
 115 uint8_t stun_buffer[STUN_MAX_MESSAGE_SIZE_IPV6];
 116diff --git a/stun/stunagent.c b/stun/stunagent.c
 117index 2abcc29..0abae3d 100644
 118--- a/stun/stunagent.c
 119+++ b/stun/stunagent.c
 120@@ -301,7 +301,7 @@ StunValidationStatus stun_agent_validate (StunAgent *agent, StunMessage *msg,
 121 } else if (!(stun_message_get_class (msg) == STUN_ERROR &&
 122 stun_message_find_error (msg, &error_code) ==
 123 STUN_MESSAGE_RETURN_SUCCESS &&
 124- (error_code == 400 || error_code == 401))) {
 125+ (error_code == 400 || error_code == 401 || error_code == 437))) {
 126 stun_debug ("STUN auth error: No message integrity attribute!");
 127 return STUN_VALIDATION_UNAUTHORIZED;
 128 }
 129--
 1302.3.4
 131

Tools/gtk/patches/libnice-0003-Do-not-compare-scope-for-IPv6-address-when-scope-is-.patch

 1From 91a7b9324244844baf35d8fcef019a4ea3872d30 Mon Sep 17 00:00:00 2001
 2From: Youness Alaoui <kakaroto@kakaroto.homelinux.net>
 3Date: Tue, 5 May 2015 15:00:30 -0400
 4Subject: [PATCH 3/4] Do not compare scope for IPv6 address when scope is 0
 5
 6This caused issues with thinking local host candidates were peer-reflexive
 7candidates because the nice_address_equal would fail since the scope
 8would be 6 (or some other value) but locally created NiceAddress from
 9a stun response would have the scope set to 0.
 10We ignore the scope when comparing ipv6 candidates when scope is 0
 11to avoid these kinds of issues.
 12Thanks to ikonst_ for finding these issues
 13---
 14 agent/address.c | 6 ++++--
 15 1 file changed, 4 insertions(+), 2 deletions(-)
 16
 17diff --git a/agent/address.c b/agent/address.c
 18index a8d9c76..01eebab 100644
 19--- a/agent/address.c
 20+++ b/agent/address.c
 21@@ -297,7 +297,8 @@ nice_address_equal (const NiceAddress *a, const NiceAddress *b)
 22 case AF_INET6:
 23 return IN6_ARE_ADDR_EQUAL (&a->s.ip6.sin6_addr, &b->s.ip6.sin6_addr)
 24 && (a->s.ip6.sin6_port == b->s.ip6.sin6_port)
 25- && (a->s.ip6.sin6_scope_id == b->s.ip6.sin6_scope_id);
 26+ && (a->s.ip6.sin6_scope_id == 0 || b->s.ip6.sin6_scope_id == 0 ||
 27+ (a->s.ip6.sin6_scope_id == b->s.ip6.sin6_scope_id));
 28
 29 default:
 30 g_return_val_if_reached (FALSE);
 31@@ -412,7 +413,8 @@ nice_address_equal_no_port (const NiceAddress *a, const NiceAddress *b)
 32
 33 case AF_INET6:
 34 return IN6_ARE_ADDR_EQUAL (&a->s.ip6.sin6_addr, &b->s.ip6.sin6_addr)
 35- && (a->s.ip6.sin6_scope_id == b->s.ip6.sin6_scope_id);
 36+ && (a->s.ip6.sin6_scope_id == 0 || b->s.ip6.sin6_scope_id == 0 ||
 37+ (a->s.ip6.sin6_scope_id == b->s.ip6.sin6_scope_id));
 38
 39 default:
 40 g_return_val_if_reached (FALSE);
 41--
 422.3.2 (Apple Git-55)
 43

Tools/gtk/patches/libnice-0004-Removing-no-op-assignment.patch

 1From 6a8c63219c632c27707267b6510dca096c6fd511 Mon Sep 17 00:00:00 2001
 2From: Youness Alaoui <kakaroto@kakaroto.homelinux.net>
 3Date: Tue, 5 May 2015 15:07:10 -0400
 4Subject: [PATCH 4/4] Removing no-op assignment
 5
 6---
 7 agent/agent.c | 1 -
 8 1 file changed, 1 deletion(-)
 9
 10diff --git a/agent/agent.c b/agent/agent.c
 11index 38b679f..84d4093 100644
 12--- a/agent/agent.c
 13+++ b/agent/agent.c
 14@@ -3051,7 +3051,6 @@ static gboolean priv_add_remote_candidate (
 15 username, password, priority);
 16 }
 17 /* case 1: an existing candidate, update the attributes */
 18- candidate->type = type;
 19 if (base_addr)
 20 candidate->base_addr = *base_addr;
 21 candidate->priority = priority;
 22--
 232.3.2 (Apple Git-55)
 24