Skip to content

Commit 62e8323

Browse files
committed
Fix #176. Update to the latest IceServer definition
Old: dictionary RTCIceServer { DOMString url; DOMString? credential; }; New: dictionary RTCIceServer { (DOMString or sequence<DOMString>) urls; DOMString? username = null; DOMString? credential; }; Note: Current Firefox Nightly "28.0a1 (2013-11-18)" Does not support multiple 'urls'
1 parent ed643f7 commit 62e8323

File tree

2 files changed

+28
-15
lines changed

2 files changed

+28
-15
lines changed

src/RTCSession/RTCMediaHandler.js

+4-9
Original file line numberDiff line numberDiff line change
@@ -105,24 +105,19 @@ RTCMediaHandler.prototype = {
105105
* @param {Function} onSuccess Fired when there are no more ICE candidates
106106
*/
107107
init: function(constraints) {
108-
var idx, length, server, scheme, url,
108+
var idx, length, server,
109109
self = this,
110110
servers = [],
111111
config = this.session.ua.configuration;
112112

113-
length = config.stun_servers.length;
114-
for (idx = 0; idx < length; idx++) {
115-
server = config.stun_servers[idx];
116-
servers.push({'url': server});
117-
}
113+
servers.push({'url': config.stun_servers});
118114

119115
length = config.turn_servers.length;
120116
for (idx = 0; idx < length; idx++) {
121117
server = config.turn_servers[idx];
122-
url = server.server;
123-
scheme = url.substr(0, url.indexOf(':'));
124118
servers.push({
125-
'url': scheme + ':' + server.username + '@' + url.substr(scheme.length+1),
119+
'url': server.urls,
120+
'username': server.username,
126121
'credential': server.password
127122
});
128123
}

src/UA.js

+24-6
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,7 @@ UA.configuration_check = {
10881088
},
10891089

10901090
turn_servers: function(turn_servers) {
1091-
var idx, length, turn_server;
1091+
var idx, length, turn_server, url;
10921092

10931093
if (turn_servers instanceof Array) {
10941094
// Do nothing
@@ -1099,14 +1099,32 @@ UA.configuration_check = {
10991099
length = turn_servers.length;
11001100
for (idx = 0; idx < length; idx++) {
11011101
turn_server = turn_servers[idx];
1102-
if (!turn_server.server || !turn_server.username || !turn_server.password) {
1102+
1103+
// Backward compatibility:
1104+
//Allow defining the turn_server url with the 'server' property.
1105+
if (turn_server.server) {
1106+
turn_server.urls = [turn_server.server];
1107+
}
1108+
1109+
if (!turn_server.urls || !turn_server.username || !turn_server.password) {
11031110
return;
1104-
} else if (!(/^turns?:/.test(turn_server.server))) {
1105-
turn_server.server = 'turn:' + turn_server.server;
11061111
}
1112+
1113+
if (!turn_server.urls instanceof Array) {
1114+
turn_server.urls = [turn_server.urls];
1115+
}
1116+
1117+
length = turn_server.urls.length;
1118+
for (idx = 0; idx < length; idx++) {
1119+
url = turn_server.urls[idx];
1120+
1121+
if (!(/^turns?:/.test(url))) {
1122+
url = 'turn:' + url;
1123+
}
11071124

1108-
if(JsSIP.Grammar.parse(turn_server.server, 'turn_URI') === -1) {
1109-
return;
1125+
if(JsSIP.Grammar.parse(url, 'turn_URI') === -1) {
1126+
return;
1127+
}
11101128
}
11111129
}
11121130
return turn_servers;

0 commit comments

Comments
 (0)