Added changes in apprtc demo to ignore turn address through query string for FF. Also made sure that the iceServers array doesnot include transport parameter in turn url for FF. Finally removed turn: from the turn_url when creating iceservers for pre-M28 chrome.
R=dutton@google.com, juberti@google.com Review URL: https://webrtc-codereview.appspot.com/1627006 git-svn-id: http://webrtc.googlecode.com/svn/trunk@4259 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@@ -51,6 +51,13 @@
|
||||
}
|
||||
|
||||
function maybeRequestTurn() {
|
||||
// Skipping TURN Http request for Firefox version <=22.
|
||||
// Firefox does not support TURN for version <=22.
|
||||
if (webrtcDetectedBrowser === 'firefox' && webrtcDetectedVersion <=22) {
|
||||
turnDone = true;
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0, len = pcConfig.iceServers.length; i < len; i++) {
|
||||
if (pcConfig.iceServers[i].url.substr(0, 5) === 'turn:') {
|
||||
turnDone = true;
|
||||
@@ -82,7 +89,9 @@
|
||||
// Create a turnUri using the polyfill (adapter.js).
|
||||
var iceServer = createIceServer(turnServer.uris[0], turnServer.username,
|
||||
turnServer.password);
|
||||
if (iceServer !== null) {
|
||||
pcConfig.iceServers.push(iceServer);
|
||||
}
|
||||
} else {
|
||||
console.log('Request for TURN server failed.');
|
||||
}
|
||||
|
@@ -18,6 +18,9 @@ if (navigator.mozGetUserMedia) {
|
||||
|
||||
webrtcDetectedBrowser = "firefox";
|
||||
|
||||
webrtcDetectedVersion =
|
||||
parseInt(navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]);
|
||||
|
||||
// The RTCPeerConnection object.
|
||||
RTCPeerConnection = mozRTCPeerConnection;
|
||||
|
||||
@@ -31,11 +34,23 @@ if (navigator.mozGetUserMedia) {
|
||||
// Code from Adam Barth.
|
||||
getUserMedia = navigator.mozGetUserMedia.bind(navigator);
|
||||
|
||||
// Creates Turn Uri with new turn format.
|
||||
createIceServer = function(turn_url, username, password) {
|
||||
var iceServer = { 'url': turn_url,
|
||||
// Creates iceServer from the url for FF.
|
||||
createIceServer = function(url, username, password) {
|
||||
var iceServer = null;
|
||||
var url_parts = url.split(':');
|
||||
if (url_parts[0].indexOf('stun') === 0) {
|
||||
// Create iceServer with stun url.
|
||||
iceServer = { 'url': url };
|
||||
} else if (url_parts[0].indexOf('turn') === 0 &&
|
||||
(url.indexOf('transport=udp') !== -1 ||
|
||||
url.indexOf('?transport') === -1)) {
|
||||
// Create iceServer with turn url.
|
||||
// Ignore the transport parameter from TURN url.
|
||||
var turn_url_parts = url.split("?");
|
||||
iceServer = { 'url': turn_url_parts[0],
|
||||
'credential': password,
|
||||
'username': username };
|
||||
}
|
||||
return iceServer;
|
||||
};
|
||||
|
||||
@@ -67,21 +82,28 @@ if (navigator.mozGetUserMedia) {
|
||||
webrtcDetectedVersion =
|
||||
parseInt(navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)[2]);
|
||||
|
||||
// For pre-M28 chrome versions use old turn format, else use the new format.
|
||||
// Creates iceServer from the url for Chrome.
|
||||
createIceServer = function(url, username, password) {
|
||||
var iceServer = null;
|
||||
var url_parts = url.split(':');
|
||||
if (url_parts[0].indexOf('stun') === 0) {
|
||||
// Create iceServer with stun url.
|
||||
iceServer = { 'url': url };
|
||||
} else if (url_parts[0].indexOf('turn') === 0) {
|
||||
if (webrtcDetectedVersion < 28) {
|
||||
createIceServer = function(turn_url, username, password) {
|
||||
var iceServer = { 'url': 'turn:' + username + '@' + turn_url,
|
||||
// For pre-M28 chrome versions use old TURN format.
|
||||
var url_turn_parts = url.split("turn:");
|
||||
iceServer = { 'url': 'turn:' + username + '@' + url_turn_parts[1],
|
||||
'credential': password };
|
||||
return iceServer;
|
||||
};
|
||||
} else {
|
||||
createIceServer = function(turn_url, username, password) {
|
||||
var iceServer = { 'url': turn_url,
|
||||
// For Chrome M28 & above use new TURN format.
|
||||
iceServer = { 'url': url,
|
||||
'credential': password,
|
||||
'username': username };
|
||||
}
|
||||
}
|
||||
return iceServer;
|
||||
};
|
||||
}
|
||||
|
||||
// The RTCPeerConnection object.
|
||||
RTCPeerConnection = webkitRTCPeerConnection;
|
||||
|
Reference in New Issue
Block a user