Bug 901560 - Interim fix of datachannel ICE components to be compatible with old and new versions r=abr

This commit is contained in:
Ethan Hugg 2013-09-04 13:13:16 -07:00
parent b6645f5b3a
commit 4fe9eed4e9
2 changed files with 50 additions and 1 deletions

View File

@ -4,6 +4,8 @@
* 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"
@ -100,6 +102,39 @@ gsmsdp_add_remote_track(uint16_t idx, uint16_t track,
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
@ -6955,6 +6990,19 @@ gsmsdp_install_peer_ice_attributes(fsm_fcb_t *fcb_p)
}
}
/* 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)

View File

@ -43,7 +43,8 @@ PMH_EXTERN void sipsdp_free(cc_sdp_t **sip_sdp);
*/
#define SIPSDP_VERSION 0
// RAMC_DEBUG #define SIPSDP_ORIGIN_USERNAME "CiscoSystemsSIP-GW-UserAgent"
#define SIPSDP_ORIGIN_USERNAME "Mozilla-SIPUA-" MOZ_APP_UA_VERSION
#define SIPSDP_ORIGIN_APPNAME "Mozilla-SIPUA-"
#define SIPSDP_ORIGIN_USERNAME SIPSDP_ORIGIN_APPNAME MOZ_APP_UA_VERSION
#define SIPSDP_SESSION_NAME "SIP Call"
/* Possible encoding names fo static payload types*/