Detect OpenWebRTC and add workarounds, but comment out the turn server removal for now so we have a live demo of it not working.

This commit is contained in:
David Baker 2014-11-12 17:34:00 +00:00
parent 2b64c573c3
commit 9950ce2334

View File

@ -92,7 +92,8 @@ angular.module('MatrixCall', [])
var pc; var pc;
if (window.mozRTCPeerConnection) { if (window.mozRTCPeerConnection) {
var iceServers = []; var iceServers = [];
if (MatrixCall.turnServer) { // https://github.com/EricssonResearch/openwebrtc/issues/85
if (MatrixCall.turnServer /*&& !this.isOpenWebRTC()*/) {
if (MatrixCall.turnServer.uris) { if (MatrixCall.turnServer.uris) {
for (var i = 0; i < MatrixCall.turnServer.uris.length; i++) { for (var i = 0; i < MatrixCall.turnServer.uris.length; i++) {
iceServers.push({ iceServers.push({
@ -110,7 +111,8 @@ angular.module('MatrixCall', [])
pc = new window.mozRTCPeerConnection({"iceServers":iceServers}); pc = new window.mozRTCPeerConnection({"iceServers":iceServers});
} else { } else {
var iceServers = []; var iceServers = [];
if (MatrixCall.turnServer) { // https://github.com/EricssonResearch/openwebrtc/issues/85
if (MatrixCall.turnServer /*&& !this.isOpenWebRTC()*/) {
if (MatrixCall.turnServer.uris) { if (MatrixCall.turnServer.uris) {
iceServers.push({ iceServers.push({
'urls': MatrixCall.turnServer.uris, 'urls': MatrixCall.turnServer.uris,
@ -492,6 +494,8 @@ angular.module('MatrixCall', [])
$timeout(function() { $timeout(function() {
var vel = self.getRemoteVideoElement(); var vel = self.getRemoteVideoElement();
if (vel.play) vel.play(); 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; 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; return MatrixCall;
}]); }]);