Bug 901560 - Backout of compatibility-breaking datachannel ice component fix r=jesup a=bajaj
authorEthan Hugg <ethanhugg@gmail.com>
Tue, 29 Oct 2013 08:52:04 -0700
changeset 167274 8f2fa1bfc17921d9c35b56bcc09a66e1b283c081
parent 167273 d042a03e7087a0e41ee39679da780c74203a363d
child 167275 373cd1f52f7f0c283307822aa49aea57585c712b
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup, bajaj
bugs901560
milestone27.0a2
Bug 901560 - Backout of compatibility-breaking datachannel ice component fix r=jesup a=bajaj
media/mtransport/third_party/nICEr/src/ice/ice_media_stream.c
media/webrtc/signaling/src/sipcc/core/gsm/gsm_sdp.c
--- a/media/mtransport/third_party/nICEr/src/ice/ice_media_stream.c
+++ b/media/mtransport/third_party/nICEr/src/ice/ice_media_stream.c
@@ -841,18 +841,17 @@ int nr_ice_media_stream_disable_componen
 
     if (stream->ice_state != NR_ICE_MEDIA_STREAM_UNPAIRED)
       ABORT(R_FAILED);
 
     if ((r=nr_ice_media_stream_find_component(stream, component_id, &comp)))
       ABORT(r);
 
     /* Can only disable before pairing */
-    if (comp->state != NR_ICE_COMPONENT_UNPAIRED &&
-        comp->state != NR_ICE_COMPONENT_DISABLED)
+    if (comp->state != NR_ICE_COMPONENT_UNPAIRED)
       ABORT(R_FAILED);
 
     comp->state = NR_ICE_COMPONENT_DISABLED;
 
     _status=0;
  abort:
     return(_status);
   }
--- a/media/webrtc/signaling/src/sipcc/core/gsm/gsm_sdp.c
+++ b/media/webrtc/signaling/src/sipcc/core/gsm/gsm_sdp.c
@@ -1,14 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include <errno.h>
+
 #include "cpr_in.h"
 #include "cpr_rand.h"
 #include "cpr_stdlib.h"
 #include "lsm.h"
 #include "fsm.h"
 #include "ccapi.h"
 #include "ccsip_sdp.h"
 #include "sdp.h"
@@ -96,16 +98,48 @@ gsmsdp_add_remote_track(uint16_t idx, ui
                          fsmdef_dcb_t *dcb_p, fsmdef_media_t *media);
 
 
 
 extern cc_media_cap_table_t g_media_table;
 
 extern boolean g_disable_mass_reg_debug_print;
 
+/*
+ * gsmsdp_requires_two_dc_components
+ *
+ * returns TRUE if we are talking to Firefox and it's
+ * a version that required two components for datachannel.
+ */
+static boolean gsmsdp_requires_two_dc_components(void *sdp) {
+#define FIRST_VERSION_TO_USE_ONE_DC_COMPONENT 26
+    const char *owner_name = sdp_get_owner_username(sdp);
+    unsigned long remote_version;
+    char* strtoul_end;
+
+    if (strncmp(owner_name, SIPSDP_ORIGIN_APPNAME,
+        strlen(SIPSDP_ORIGIN_APPNAME)) == 0) {
+        /* This means we are talking to firefox, now read the major version */
+        errno = 0;
+        remote_version = strtoul(owner_name + strlen(SIPSDP_ORIGIN_APPNAME),
+            &strtoul_end, 10);
+        if (errno ||
+            strtoul_end == (owner_name + strlen(SIPSDP_ORIGIN_APPNAME)) ||
+            !remote_version) {
+            /* Unable to parse remote, must not be earlier firefox */
+            return FALSE;
+        }
+
+        return (remote_version < FIRST_VERSION_TO_USE_ONE_DC_COMPONENT) ?
+            TRUE : FALSE;
+    }
+
+    return FALSE;
+}
+
 /**
  * A wraper function to return the media capability supported by
  * the platform and session. This is a convient place if policy
  * to get the capability table as it applies to the session
  * updates the media_cap_tbl ptr in dcb
  *
  * @param[in]dcb     - pointer to the fsmdef_dcb_t
 
@@ -5694,23 +5728,16 @@ gsmsdp_create_local_sdp (fsmdef_dcb_t *d
             media_enabled = FALSE;
         }
 
         /*
          * Add each enabled media line to the SDP
          */
         if (media_enabled && ( media_cap->enabled || force_streams_enabled)) {
             level = level + 1;  /* next level */
-
-            /* Only audio and video use two ICE components */
-            if (media_cap->type != SDP_MEDIA_AUDIO &&
-                media_cap->type != SDP_MEDIA_VIDEO) {
-                vcmDisableRtcpComponent(dcb_p->peerconnection, level);
-            }
-
             ip_mode = platform_get_ip_address_mode();
             if (ip_mode >= CPR_IP_MODE_IPV6) {
                 if (gsmsdp_add_media_line(dcb_p, media_cap, cap_index,
                                           level, CPR_IP_ADDR_IPV6, offer)
                     == NULL) {
                     /* fail to add a media line, go back one level */
                     level = level - 1;
                 }
@@ -6989,16 +7016,29 @@ gsmsdp_install_peer_ice_attributes(fsm_f
         vcm_res = vcmDisableRtcpComponent(dcb_p->peerconnection,
           media->level);
 
         if (vcm_res) {
           return (CC_CAUSE_SETTING_ICE_SESSION_PARAMETERS_FAILED);
         }
       }
 
+      /* If this is Datachannel and we are talking to anything other
+         than an older version of Firefox then disable the second component
+         of the ICE stream */
+      if (media->type == DATA &&
+          !gsmsdp_requires_two_dc_components(sdp_p->dest_sdp)) {
+        vcm_res = vcmDisableRtcpComponent(dcb_p->peerconnection,
+          media->level);
+
+        if (vcm_res) {
+          return CC_CAUSE_SETTING_ICE_SESSION_PARAMETERS_FAILED;
+        }
+      }
+
       sdp_res = sdp_attr_get_ice_attribute(sdp_p->dest_sdp, media->level, 0,
         SDP_ATTR_ICE_UFRAG, 1, &ufrag);
       if (sdp_res != SDP_SUCCESS)
         ufrag = NULL;
 
       sdp_res = sdp_attr_get_ice_attribute(sdp_p->dest_sdp, media->level, 0,
         SDP_ATTR_ICE_PWD, 1, &pwd);
       if (sdp_res != SDP_SUCCESS)