mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 17:44:49 -04:00
Merge branch 'turn' into develop
This commit is contained in:
commit
c58eb0d5a3
7 changed files with 165 additions and 6 deletions
|
@ -66,15 +66,67 @@ angular.module('MatrixCall', [])
|
|||
|
||||
}
|
||||
|
||||
MatrixCall.getTurnServer = function() {
|
||||
matrixService.getTurnServer().then(function(response) {
|
||||
if (response.data.uris) {
|
||||
console.log("Got TURN URIs: "+response.data.uris);
|
||||
MatrixCall.turnServer = response.data;
|
||||
$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) {
|
||||
console.log("Failed to get TURN URIs");
|
||||
MatrixCall.turnServer = {};
|
||||
$timeout(MatrixCall.getTurnServer, 60000);
|
||||
});
|
||||
}
|
||||
|
||||
// FIXME: we should prevent any class from being placed or accepted before this has finished
|
||||
MatrixCall.getTurnServer();
|
||||
|
||||
MatrixCall.CALL_TIMEOUT = 60000;
|
||||
MatrixCall.FALLBACK_STUN_SERVER = 'stun:stun.l.google.com:19302';
|
||||
|
||||
MatrixCall.prototype.createPeerConnection = function() {
|
||||
var stunServer = 'stun:stun.l.google.com:19302';
|
||||
var pc;
|
||||
if (window.mozRTCPeerConnection) {
|
||||
pc = new window.mozRTCPeerConnection({'url': stunServer});
|
||||
var iceServers = [];
|
||||
if (MatrixCall.turnServer) {
|
||||
if (MatrixCall.turnServer.uris) {
|
||||
for (var i = 0; i < MatrixCall.turnServer.uris.length; i++) {
|
||||
iceServers.push({
|
||||
'url': MatrixCall.turnServer.uris[i],
|
||||
'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});
|
||||
} else {
|
||||
pc = new window.RTCPeerConnection({"iceServers":[{"urls":"stun:stun.l.google.com:19302"}]});
|
||||
var iceServers = [];
|
||||
if (MatrixCall.turnServer) {
|
||||
if (MatrixCall.turnServer.uris) {
|
||||
iceServers.push({
|
||||
'urls': MatrixCall.turnServer.uris,
|
||||
'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});
|
||||
}
|
||||
var self = this;
|
||||
pc.oniceconnectionstatechange = function() { self.onIceConnectionStateChanged(); };
|
||||
|
|
|
@ -767,6 +767,10 @@ angular.module('matrixService', [])
|
|||
var deferred = $q.defer();
|
||||
deferred.reject({data:{error: "Invalid room: " + room_id}});
|
||||
return deferred.promise;
|
||||
},
|
||||
|
||||
getTurnServer: function() {
|
||||
return doRequest("GET", "/voip/turnServer");
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
<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 == '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 == '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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue