From 9950ce23342a754e9598419fc1b71cb1dc5c4de6 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 12 Nov 2014 17:34:00 +0000 Subject: [PATCH] Detect OpenWebRTC and add workarounds, but comment out the turn server removal for now so we have a live demo of it not working. --- .../webclient/components/matrix/matrix-call.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/syweb/webclient/components/matrix/matrix-call.js b/syweb/webclient/components/matrix/matrix-call.js index 7687cb6971..a1c3aaa103 100644 --- a/syweb/webclient/components/matrix/matrix-call.js +++ b/syweb/webclient/components/matrix/matrix-call.js @@ -92,7 +92,8 @@ angular.module('MatrixCall', []) var pc; if (window.mozRTCPeerConnection) { var iceServers = []; - if (MatrixCall.turnServer) { + // https://github.com/EricssonResearch/openwebrtc/issues/85 + if (MatrixCall.turnServer /*&& !this.isOpenWebRTC()*/) { if (MatrixCall.turnServer.uris) { for (var i = 0; i < MatrixCall.turnServer.uris.length; i++) { iceServers.push({ @@ -110,7 +111,8 @@ angular.module('MatrixCall', []) pc = new window.mozRTCPeerConnection({"iceServers":iceServers}); } else { var iceServers = []; - if (MatrixCall.turnServer) { + // https://github.com/EricssonResearch/openwebrtc/issues/85 + if (MatrixCall.turnServer /*&& !this.isOpenWebRTC()*/) { if (MatrixCall.turnServer.uris) { iceServers.push({ 'urls': MatrixCall.turnServer.uris, @@ -492,6 +494,8 @@ angular.module('MatrixCall', []) $timeout(function() { var vel = self.getRemoteVideoElement(); if (vel.play) vel.play(); + // OpenWebRTC does not support oniceconnectionstatechange yet + if (self.isOpenWebRTC()) self.state = 'connected'; }); } }; @@ -641,5 +645,15 @@ angular.module('MatrixCall', []) return null; }; + MatrixCall.prototype.isOpenWebRTC = function() { + var scripts = angular.element('script'); + for (var i = 0; i < scripts.length; i++) { + if (scripts[i].src.indexOf("owr.js") > -1) { + return true; + } + } + return false; + }; + return MatrixCall; }]);