Updated apprtc to use new TURN format for chrome versions M28 & above.

R=dutton@google.com, juberti@google.com

Review URL: https://webrtc-codereview.appspot.com/1563004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4139 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
vikasmarwaha@webrtc.org 2013-05-29 22:13:19 +00:00
parent 046bc448d5
commit fddf6be339
2 changed files with 31 additions and 4 deletions

View File

@ -75,10 +75,10 @@
function onTurnResult() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var turnServer = JSON.parse(xmlhttp.responseText);
pcConfig.iceServers.push({
'url': 'turn:' + turnServer.username + '@' + turnServer.turn,
'credential': turnServer.password
});
// Create a turnUri using the polyfill (adapter.js).
var iceServer = createIceServer(turnServer.uris[0], turnServer.username,
turnServer.password);
pcConfig.iceServers.push(iceServer);
} else {
console.log("Request for TURN server failed.")
}

View File

@ -3,6 +3,7 @@ var getUserMedia = null;
var attachMediaStream = null;
var reattachMediaStream = null;
var webrtcDetectedBrowser = null;
var webrtcDetectedVersion = null;
function trace(text) {
// This function is used for logging.
@ -30,6 +31,14 @@ 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,
'credential': password,
'username': username };
return iceServer;
};
// Attach a media stream to an element.
attachMediaStream = function(element, stream) {
console.log("Attaching media stream");
@ -55,6 +64,24 @@ if (navigator.mozGetUserMedia) {
console.log("This appears to be Chrome");
webrtcDetectedBrowser = "chrome";
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.
if (webrtcDetectedVersion < 28) {
createIceServer = function(turn_url, username, password) {
var iceServer = { 'url': 'turn:' + username + '@' + turn_url,
'credential': password };
return iceServer;
};
} else {
createIceServer = function(turn_url, username, password) {
var iceServer = { 'url': turn_url,
'credential': password,
'username': username };
return iceServer;
};
}
// The RTCPeerConnection object.
RTCPeerConnection = webkitRTCPeerConnection;