From 2cc174f96555e44bb8b58b84aa423dd471367043 Mon Sep 17 00:00:00 2001 From: Fabrice Bellet Date: Sun, 24 Jan 2016 09:41:48 +0100 Subject: [PATCH] call-stream: send local candidates after gathering completed This patch improves a lot the ICE algorithm efficiency, because the conncheck algorithm starts after both local peers candidates have been exchanged. Previously, the remote candidates were transmitted by gabble one at a time, after a long round trip time to the xmpp server, long after the conncheck processing had started. The conncheck started with low priority candidates from the partial remote candidates, causing many unrequired checks. More problematic, the ICE specs assumes that both pairs starts conncheck with the same sets of candidates, which was a wrong assertion. --- telepathy-farstream/call-stream.c | 20 ++++++++++---------- telepathy-farstream/call-stream.h | 1 + 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/telepathy-farstream/call-stream.c b/telepathy-farstream/call-stream.c index 3e1bb67..b2803c8 100644 --- a/telepathy-farstream/call-stream.c +++ b/telepathy-farstream/call-stream.c @@ -1476,8 +1476,6 @@ fscandidate_to_tpcandidate (TfCallStream *stream, FsCandidate *candidate) static void cb_fs_new_local_candidate (TfCallStream *stream, FsCandidate *candidate) { - GPtrArray *candidate_list; - if (!stream->multiple_usernames) { if ((!stream->last_local_username && candidate->username) || @@ -1512,16 +1510,11 @@ cb_fs_new_local_candidate (TfCallStream *stream, FsCandidate *candidate) candidate->ttl,candidate-> base_ip, candidate->base_port); - candidate_list = g_ptr_array_sized_new (1); - g_ptr_array_add (candidate_list, + if (!stream->candidate_list) + stream->candidate_list = g_ptr_array_sized_new (1); + g_ptr_array_add (stream->candidate_list, fscandidate_to_tpcandidate (stream, candidate)); - /* Should also check for errors */ - tp_cli_call_stream_interface_media_call_add_candidates (stream->proxy, - -1, candidate_list, NULL, NULL, NULL, NULL); - - - g_boxed_free (TP_ARRAY_TYPE_CANDIDATE_LIST, candidate_list); } static void @@ -1529,6 +1522,13 @@ cb_fs_local_candidates_prepared (TfCallStream *stream) { g_debug ("Local candidates prepared"); + /* Should also check for errors */ + tp_cli_call_stream_interface_media_call_add_candidates (stream->proxy, + -1, stream->candidate_list, NULL, NULL, NULL, NULL); + + g_boxed_free (TP_ARRAY_TYPE_CANDIDATE_LIST, stream->candidate_list); + stream->candidate_list = NULL; + tp_cli_call_stream_interface_media_call_finish_initial_candidates ( stream->proxy, -1, NULL, NULL, NULL, NULL); } diff --git a/telepathy-farstream/call-stream.h b/telepathy-farstream/call-stream.h index 31961c1..d05f0a0 100644 --- a/telepathy-farstream/call-stream.h +++ b/telepathy-farstream/call-stream.h @@ -104,6 +104,7 @@ struct _TfCallStream { gboolean server_info_retrieved; GPtrArray *stun_servers; GPtrArray *relay_info; + GPtrArray *candidate_list; }; struct _TfCallStreamClass{ -- 2.5.0