Use reliable TCP for ms-turn since it generates tcp candidates
authorYouness Alaoui <youness.alaoui@collabora.co.uk>
Thu, 10 Apr 2014 00:35:33 +0000 (20:35 -0400)
committerOlivier CrĂȘte <olivier.crete@ocrete.ca>
Thu, 15 May 2014 13:44:00 +0000 (09:44 -0400)
agent/agent.c

index 05baba7..1d96675 100644 (file)
@@ -1796,14 +1796,24 @@ priv_add_new_candidate_discovery_turn (NiceAgent *agent,
     cdisco->nicesock = nicesock;
   } else {
     NiceAddress proxy_server;
-    nicesock = NULL;
+    gboolean reliable_tcp = FALSE;
+
+    /* MS-TURN will allocate a transport with the same protocol it received
+     * the allocate request. So if we are connecting in TCP, then the candidate
+     * will be TCP-ACT/TCP-PASS which means it will be reliable all the way
+     * to the peer
+     */
+    if (agent->compatibility == NICE_COMPATIBILITY_OC2007 ||
+        agent->compatibility == NICE_COMPATIBILITY_OC2007R2)
+      reliable_tcp = TRUE;
 
+    nicesock = NULL;
     if (agent->proxy_type != NICE_PROXY_TYPE_NONE &&
         agent->proxy_ip != NULL &&
         nice_address_set_from_string (&proxy_server, agent->proxy_ip)) {
       nice_address_set_port (&proxy_server, agent->proxy_port);
       nicesock = nice_tcp_bsd_socket_new (agent->main_context, &proxy_server,
-          FALSE);
+          reliable_tcp);
 
       if (nicesock) {
         _priv_set_socket_tos (agent, nicesock, stream->tos);
@@ -1822,7 +1832,7 @@ priv_add_new_candidate_discovery_turn (NiceAgent *agent,
     }
     if (nicesock == NULL) {
       nicesock = nice_tcp_bsd_socket_new (agent->main_context, &turn->server,
-          FALSE);
+          reliable_tcp);
 
       if (nicesock)
         _priv_set_socket_tos (agent, nicesock, stream->tos);