@@ -1088,7 +1088,7 @@ UA.configuration_check = {
1088
1088
} ,
1089
1089
1090
1090
turn_servers : function ( turn_servers ) {
1091
- var idx , length , turn_server ;
1091
+ var idx , length , turn_server , url ;
1092
1092
1093
1093
if ( turn_servers instanceof Array ) {
1094
1094
// Do nothing
@@ -1099,14 +1099,32 @@ UA.configuration_check = {
1099
1099
length = turn_servers . length ;
1100
1100
for ( idx = 0 ; idx < length ; idx ++ ) {
1101
1101
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 ) {
1103
1110
return ;
1104
- } else if ( ! ( / ^ t u r n s ? : / . test ( turn_server . server ) ) ) {
1105
- turn_server . server = 'turn:' + turn_server . server ;
1106
1111
}
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 ( ! ( / ^ t u r n s ? : / . test ( url ) ) ) {
1122
+ url = 'turn:' + url ;
1123
+ }
1107
1124
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
+ }
1110
1128
}
1111
1129
}
1112
1130
return turn_servers ;
0 commit comments