diff options
author | David Baker <dbkr@matrix.org> | 2014-09-24 16:07:33 +0100 |
---|---|---|
committer | David Baker <dbkr@matrix.org> | 2014-09-24 16:08:31 +0100 |
commit | 7679ee7321ff588a84edab31507185d2cee80fc7 (patch) | |
tree | 512892469b5a8048bae93f7464a2497bf4bc2f9b /webclient | |
parent | Oops (diff) | |
download | synapse-7679ee7321ff588a84edab31507185d2cee80fc7.tar.xz |
Hopefully implement turn in the web client (probably wrong for Firefox because Firefox is a special snowflake)
Diffstat (limited to '')
-rw-r--r-- | webclient/components/matrix/matrix-call.js | 33 | ||||
-rw-r--r-- | webclient/components/matrix/matrix-service.js | 4 |
2 files changed, 34 insertions, 3 deletions
diff --git a/webclient/components/matrix/matrix-call.js b/webclient/components/matrix/matrix-call.js index 7b5d9cffef..888f853472 100644 --- a/webclient/components/matrix/matrix-call.js +++ b/webclient/components/matrix/matrix-call.js @@ -49,6 +49,15 @@ angular.module('MatrixCall', []) .factory('MatrixCall', ['matrixService', 'matrixPhoneService', '$rootScope', '$timeout', function MatrixCallFactory(matrixService, matrixPhoneService, $rootScope, $timeout) { $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) { this.room_id = room_id; this.call_id = "c" + new Date().getTime(); @@ -69,12 +78,30 @@ angular.module('MatrixCall', []) MatrixCall.CALL_TIMEOUT = 60000; 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) { + 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 { - 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; pc.oniceconnectionstatechange = function() { self.onIceConnectionStateChanged(); }; diff --git a/webclient/components/matrix/matrix-service.js b/webclient/components/matrix/matrix-service.js index 069e02e939..69e6caccd3 100644 --- a/webclient/components/matrix/matrix-service.js +++ b/webclient/components/matrix/matrix-service.js @@ -762,6 +762,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/turnServers"); } }; |