mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-12-26 16:49:26 -05:00
Hopefully implement turn in the web client (probably wrong for Firefox because Firefox is a special snowflake)
This commit is contained in:
parent
4553651138
commit
7679ee7321
@ -49,6 +49,15 @@ angular.module('MatrixCall', [])
|
|||||||
.factory('MatrixCall', ['matrixService', 'matrixPhoneService', '$rootScope', '$timeout', function MatrixCallFactory(matrixService, matrixPhoneService, $rootScope, $timeout) {
|
.factory('MatrixCall', ['matrixService', 'matrixPhoneService', '$rootScope', '$timeout', function MatrixCallFactory(matrixService, matrixPhoneService, $rootScope, $timeout) {
|
||||||
$rootScope.isWebRTCSupported = isWebRTCSupported();
|
$rootScope.isWebRTCSupported = isWebRTCSupported();
|
||||||
|
|
||||||
|
// FIXME: we should prevent any class from being placed or accepted before this has finished
|
||||||
|
matrixService.getTurnServer().then(function(response) {
|
||||||
|
console.log("Got TURN URIs: "+response.data.uris);
|
||||||
|
MatrixCall.turnServer = response.data;
|
||||||
|
}, function(error) {
|
||||||
|
console.log("Failed to get TURN URIs");
|
||||||
|
MatrixCall.turnServer = {};
|
||||||
|
});
|
||||||
|
|
||||||
var MatrixCall = function(room_id) {
|
var MatrixCall = function(room_id) {
|
||||||
this.room_id = room_id;
|
this.room_id = room_id;
|
||||||
this.call_id = "c" + new Date().getTime();
|
this.call_id = "c" + new Date().getTime();
|
||||||
@ -69,12 +78,30 @@ angular.module('MatrixCall', [])
|
|||||||
MatrixCall.CALL_TIMEOUT = 60000;
|
MatrixCall.CALL_TIMEOUT = 60000;
|
||||||
|
|
||||||
MatrixCall.prototype.createPeerConnection = function() {
|
MatrixCall.prototype.createPeerConnection = function() {
|
||||||
var stunServer = 'stun:stun.l.google.com:19302';
|
|
||||||
var pc;
|
var pc;
|
||||||
if (window.mozRTCPeerConnection) {
|
if (window.mozRTCPeerConnection) {
|
||||||
pc = new window.mozRTCPeerConnection({'url': stunServer});
|
var iceServers = [];
|
||||||
|
if (MatrixCall.turnServer) {
|
||||||
|
iceServers.push({
|
||||||
|
'urls': MatrixCall.turnServer.uris,
|
||||||
|
'username': MatrixCall.turnServer.username,
|
||||||
|
'credential': MatrixCall.turnServer.password,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
pc = new window.mozRTCPeerConnection({"iceServers":iceServers});
|
||||||
|
//pc = new window.mozRTCPeerConnection({'url': stunServer});
|
||||||
} else {
|
} else {
|
||||||
pc = new window.RTCPeerConnection({"iceServers":[{"urls":"stun:stun.l.google.com:19302"}]});
|
var iceServers = [];
|
||||||
|
if (MatrixCall.turnServer) {
|
||||||
|
iceServers.push({
|
||||||
|
'urls': MatrixCall.turnServer.uris,
|
||||||
|
'username': MatrixCall.turnServer.username,
|
||||||
|
'credential': MatrixCall.turnServer.password,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
pc = new window.RTCPeerConnection({"iceServers":iceServers});
|
||||||
}
|
}
|
||||||
var self = this;
|
var self = this;
|
||||||
pc.oniceconnectionstatechange = function() { self.onIceConnectionStateChanged(); };
|
pc.oniceconnectionstatechange = function() { self.onIceConnectionStateChanged(); };
|
||||||
|
@ -762,6 +762,10 @@ angular.module('matrixService', [])
|
|||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
deferred.reject({data:{error: "Invalid room: " + room_id}});
|
deferred.reject({data:{error: "Invalid room: " + room_id}});
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
|
},
|
||||||
|
|
||||||
|
getTurnServer: function() {
|
||||||
|
return doRequest("GET", "/voip/turnServers");
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user