diff --git a/webclient/components/matrix/matrix-call.js b/webclient/components/matrix/matrix-call.js index 494a37f340..a025ccf632 100644 --- a/webclient/components/matrix/matrix-call.js +++ b/webclient/components/matrix/matrix-call.js @@ -42,11 +42,13 @@ window.RTCIceCandidate = window.RTCIceCandidate || window.webkitRTCIceCandidate // Returns true if the browser supports all required features to make WebRTC call var isWebRTCSupported = function () { - return (navigator.getUserMedia || window.RTCPeerConnection || window.RTCSessionDescription || window.RTCIceCandidate); + return !!(navigator.getUserMedia || window.RTCPeerConnection || window.RTCSessionDescription || window.RTCIceCandidate); }; angular.module('MatrixCall', []) .factory('MatrixCall', ['matrixService', 'matrixPhoneService', '$rootScope', '$timeout', function MatrixCallFactory(matrixService, matrixPhoneService, $rootScope, $timeout) { + $rootScope.isWebRTCSupported = isWebRTCSupported(); + var MatrixCall = function(room_id) { this.room_id = room_id; this.call_id = "c" + new Date().getTime(); diff --git a/webclient/components/matrix/matrix-phone-service.js b/webclient/components/matrix/matrix-phone-service.js index d05eecf72a..9d0b84fb23 100644 --- a/webclient/components/matrix/matrix-phone-service.js +++ b/webclient/components/matrix/matrix-phone-service.js @@ -59,6 +59,16 @@ angular.module('matrixPhoneService', []) var MatrixCall = $injector.get('MatrixCall'); var call = new MatrixCall(event.room_id); + + if (!isWebRTCSupported()) { + console.log("Incoming call ID "+msg.call_id+" but this browser doesn't support WebRTC"); + // don't hang up the call: there could be other clients connected that do support WebRTC and declining the + // the call on their behalf would be really annoying. + // instead, we broadcast a fake call event with a non-functional call object + $rootScope.$broadcast(matrixPhoneService.INCOMING_CALL_EVENT, call); + return; + } + call.call_id = msg.call_id; call.initWithInvite(event); matrixPhoneService.allCalls[call.call_id] = call; diff --git a/webclient/index.html b/webclient/index.html index 47d3ebf657..39174d679d 100644 --- a/webclient/index.html +++ b/webclient/index.html @@ -79,7 +79,7 @@ - + diff --git a/webclient/room/room-controller.js b/webclient/room/room-controller.js index 7f2d405122..166434d1af 100644 --- a/webclient/room/room-controller.js +++ b/webclient/room/room-controller.js @@ -34,7 +34,6 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput']) stream_failure: undefined, // the response when the stream fails waiting_for_joined_event: false, // true when the join request is pending. Back to false once the corresponding m.room.member event is received messages_visibility: "hidden", // In order to avoid flickering when scrolling down the message table at the page opening, delay the message table display - webRTCSupported: isWebRTCSupported() // true if the browser does not support WebRTC }; $scope.members = {}; $scope.autoCompleting = false; diff --git a/webclient/room/room.html b/webclient/room/room.html index dfbea492d9..d12f79cd21 100644 --- a/webclient/room/room.html +++ b/webclient/room/room.html @@ -111,8 +111,8 @@ ng-class="containsBingWord(msg.content.body) && msg.user_id != state.user_id ? msg.echo_msg_state + ' messageBing' : msg.echo_msg_state" ng-bind-html="((msg.content.msgtype === 'm.text') ? msg.content.body : '') | linky:'_blank'"/> - Outgoing Call - Incoming Call + Outgoing Call{{ isWebRTCSupported ? '' : ' (But your browser does not support VoIP)' }} + Incoming Call{{ isWebRTCSupported ? '' : ' (But your browser does not support VoIP)' }}