Add stun server fallback and I-told-you-so message if we get no TURN server and the connection fails.
parent
a31bf77776
commit
c0936b103c
|
@ -68,10 +68,16 @@ angular.module('MatrixCall', [])
|
||||||
|
|
||||||
MatrixCall.getTurnServer = function() {
|
MatrixCall.getTurnServer = function() {
|
||||||
matrixService.getTurnServer().then(function(response) {
|
matrixService.getTurnServer().then(function(response) {
|
||||||
console.log("Got TURN URIs: "+response.data.uris);
|
if (response.data.uris) {
|
||||||
MatrixCall.turnServer = response.data;
|
console.log("Got TURN URIs: "+response.data.uris);
|
||||||
// re-fetch when we're about to reach the TTL
|
MatrixCall.turnServer = response.data;
|
||||||
$timeout(MatrixCall.getTurnServer, MatrixCall.turnServer.ttl * 1000 * 0.9);
|
$rootScope.haveTurn = true;
|
||||||
|
// re-fetch when we're about to reach the TTL
|
||||||
|
$timeout(MatrixCall.getTurnServer, MatrixCall.turnServer.ttl * 1000 * 0.9);
|
||||||
|
} else {
|
||||||
|
console.log("Got no TURN URIs from HS");
|
||||||
|
$rootScope.haveTurn = false;
|
||||||
|
}
|
||||||
}, function(error) {
|
}, function(error) {
|
||||||
console.log("Failed to get TURN URIs");
|
console.log("Failed to get TURN URIs");
|
||||||
MatrixCall.turnServer = {};
|
MatrixCall.turnServer = {};
|
||||||
|
@ -83,31 +89,41 @@ angular.module('MatrixCall', [])
|
||||||
MatrixCall.getTurnServer();
|
MatrixCall.getTurnServer();
|
||||||
|
|
||||||
MatrixCall.CALL_TIMEOUT = 60000;
|
MatrixCall.CALL_TIMEOUT = 60000;
|
||||||
|
MatrixCall.FALLBACK_STUN_SERVER = 'stun:stun.l.google.com:19302';
|
||||||
|
|
||||||
MatrixCall.prototype.createPeerConnection = function() {
|
MatrixCall.prototype.createPeerConnection = function() {
|
||||||
var pc;
|
var pc;
|
||||||
if (window.mozRTCPeerConnection) {
|
if (window.mozRTCPeerConnection) {
|
||||||
var iceServers = [];
|
var iceServers = [];
|
||||||
if (MatrixCall.turnServer) {
|
if (MatrixCall.turnServer) {
|
||||||
for (var i = 0; i < MatrixCall.turnServer.uris.length; i++) {
|
if (MatrixCall.turnServer.uris) {
|
||||||
iceServers.push({
|
for (var i = 0; i < MatrixCall.turnServer.uris.length; i++) {
|
||||||
'url': MatrixCall.turnServer.uris[i],
|
iceServers.push({
|
||||||
'username': MatrixCall.turnServer.username,
|
'url': MatrixCall.turnServer.uris[i],
|
||||||
'credential': MatrixCall.turnServer.password,
|
'username': MatrixCall.turnServer.username,
|
||||||
});
|
'credential': MatrixCall.turnServer.password,
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log("No TURN server: using fallback STUN server");
|
||||||
|
iceServers.push({ 'url' : MatrixCall.FALLBACK_STUN_SERVER });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pc = new window.mozRTCPeerConnection({"iceServers":iceServers});
|
pc = new window.mozRTCPeerConnection({"iceServers":iceServers});
|
||||||
//pc = new window.mozRTCPeerConnection({'url': stunServer});
|
|
||||||
} else {
|
} else {
|
||||||
var iceServers = [];
|
var iceServers = [];
|
||||||
if (MatrixCall.turnServer) {
|
if (MatrixCall.turnServer) {
|
||||||
iceServers.push({
|
if (MatrixCall.turnServer.uris) {
|
||||||
'urls': MatrixCall.turnServer.uris,
|
iceServers.push({
|
||||||
'username': MatrixCall.turnServer.username,
|
'urls': MatrixCall.turnServer.uris,
|
||||||
'credential': MatrixCall.turnServer.password,
|
'username': MatrixCall.turnServer.username,
|
||||||
});
|
'credential': MatrixCall.turnServer.password,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.log("No TURN server: using fallback STUN server");
|
||||||
|
iceServers.push({ 'urls' : MatrixCall.FALLBACK_STUN_SERVER });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pc = new window.RTCPeerConnection({"iceServers":iceServers});
|
pc = new window.RTCPeerConnection({"iceServers":iceServers});
|
||||||
|
|
|
@ -69,7 +69,7 @@
|
||||||
<span ng-show="currentCall.state == 'ringing' && currentCall && currentCall.type == 'voice'">Incoming Voice Call</span>
|
<span ng-show="currentCall.state == 'ringing' && currentCall && currentCall.type == 'voice'">Incoming Voice Call</span>
|
||||||
<span ng-show="currentCall.state == 'connecting'">Call Connecting...</span>
|
<span ng-show="currentCall.state == 'connecting'">Call Connecting...</span>
|
||||||
<span ng-show="currentCall.state == 'connected'">Call Connected</span>
|
<span ng-show="currentCall.state == 'connected'">Call Connected</span>
|
||||||
<span ng-show="currentCall.state == 'ended' && currentCall.hangupReason == 'ice_failed'">Media Connection Failed</span>
|
<span ng-show="currentCall.state == 'ended' && currentCall.hangupReason == 'ice_failed'">Media Connection Failed{{ haveTurn ? "" : " (VoIP relaying unsupported by Home Server)" }}</span>
|
||||||
<span ng-show="currentCall.state == 'ended' && !currentCall.hangupReason && !currentCall.didConnect && currentCall.direction == 'outbound' && currentCall.hangupParty == 'remote'">Call Rejected</span>
|
<span ng-show="currentCall.state == 'ended' && !currentCall.hangupReason && !currentCall.didConnect && currentCall.direction == 'outbound' && currentCall.hangupParty == 'remote'">Call Rejected</span>
|
||||||
<span ng-show="currentCall.state == 'ended' && !currentCall.hangupReason && !currentCall.didConnect && currentCall.direction == 'outbound' && currentCall.hangupParty == 'local'">Call Canceled</span>
|
<span ng-show="currentCall.state == 'ended' && !currentCall.hangupReason && !currentCall.didConnect && currentCall.direction == 'outbound' && currentCall.hangupParty == 'local'">Call Canceled</span>
|
||||||
<span ng-show="currentCall.state == 'ended' && currentCall.hangupReason == 'invite_timeout' && !currentCall.didConnect && currentCall.direction == 'outbound' && currentCall.hangupParty == 'local'">User Not Responding</span>
|
<span ng-show="currentCall.state == 'ended' && currentCall.hangupReason == 'invite_timeout' && !currentCall.didConnect && currentCall.direction == 'outbound' && currentCall.hangupParty == 'local'">User Not Responding</span>
|
||||||
|
|
Loading…
Reference in New Issue