From c49fa976d79c11d8047dedebf5751ee47dcbefe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Thu, 21 Feb 2019 17:21:17 +0100 Subject: [PATCH 1/2] Fix disabling video when joining a call in a room with > 5 participants MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Until now, when entering a room with more than five participants the video was disabled. However, if the local video is available it is enabled when WebRTC starts. Due to this, if WebRTC was also started when joining the call (that is, no previous calls were made in other rooms since the last page reload) the video was enabled instead of disabled. Besides that, if leaving the call with the video enabled and joining it again the video was still enabled, as the room had not been entered again to disable the video. To fix both issues now the video is disabled when joining the call instead of when entering the room. Signed-off-by: Daniel Calviño Sánchez --- js/app.js | 19 +++++++++---------- js/embedded.js | 15 +++++++++------ 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/js/app.js b/js/app.js index 72066ddbf12..1d3662cc86f 100644 --- a/js/app.js +++ b/js/app.js @@ -328,7 +328,6 @@ self.stopListening(self.activeRoom, 'change:displayName'); self.stopListening(self.activeRoom, 'change:participantFlags'); - var participants; if (OC.getCurrentUser().uid) { roomChannel.trigger('active', token); @@ -337,15 +336,6 @@ self.activeRoom = room; } }); - participants = self.activeRoom.get('participants'); - } else { - // The public page supports only a single room, so the - // active room is already the room for the given token. - participants = self.activeRoom.get('participants'); - } - // Disable video when entering a room with more than 5 participants. - if (participants && Object.keys(participants).length > 5) { - self.disableVideo(); } self._emptyContentView.setActiveRoom(self.activeRoom); @@ -605,6 +595,15 @@ } }.bind(this)); + this.signaling.on('joinCall', function() { + // Disable video when joining a call in a room with more than 5 + // participants. + var participants = this.activeRoom.get('participants'); + if (participants && Object.keys(participants).length > 5) { + this.disableVideo(); + } + }.bind(this)); + $(window).unload(function () { this.connection.leaveCurrentRoom(); this.signaling.disconnect(); diff --git a/js/embedded.js b/js/embedded.js index 3d4972f7c47..21ebd9a1cc3 100644 --- a/js/embedded.js +++ b/js/embedded.js @@ -83,7 +83,6 @@ .then(function() { self.stopListening(self.activeRoom, 'change:participantFlags'); - var participants; if (OC.getCurrentUser().uid) { roomChannel.trigger('active', token); @@ -92,11 +91,6 @@ self.activeRoom = room; } }); - participants = self.activeRoom.get('participants'); - } - // Disable video when entering a room with more than 5 participants. - if (participants && Object.keys(participants).length > 5) { - self.disableVideo(); } }); }, @@ -127,6 +121,15 @@ this.signaling = OCA.Talk.Signaling.createConnection(); this.connection = new OCA.Talk.Connection(this); + this.signaling.on('joinCall', function() { + // Disable video when joining a call in a room with more than 5 + // participants. + var participants = this.activeRoom.get('participants'); + if (participants && Object.keys(participants).length > 5) { + this.disableVideo(); + } + }.bind(this)); + $(window).unload(function () { this.connection.leaveCurrentRoom(); this.signaling.disconnect(); From 57b7a4e9d7defa69575ea3007ded6abd25c0ffd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Thu, 21 Feb 2019 17:57:07 +0100 Subject: [PATCH 2/2] Make "disableVideo" consistent with "enableVideo" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When calling "disableVideo" the video was hidden even if it was not possible to disable the video; this was done to hide the video even if WebRTC was not started yet when "disableVideo" was called. Now that the video is disabled when joining the call in a room with more than five participants instead of just when entering a room with more than five participants that special behaviour is no longer needed. Signed-off-by: Daniel Calviño Sánchez --- js/app.js | 6 +++--- js/embedded.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/js/app.js b/js/app.js index 1d3662cc86f..6a68846adc1 100644 --- a/js/app.js +++ b/js/app.js @@ -791,9 +791,9 @@ localVideo.hide(); }, disableVideo: function() { - this._mediaControlsView.disableVideo(); - // Always hide the video, even if "disableVideo" returned "false". - this.hideVideo(); + if (this._mediaControlsView.disableVideo()) { + this.hideVideo(); + } }, // Called from webrtc.js disableScreensharingButton: function() { diff --git a/js/embedded.js b/js/embedded.js index 21ebd9a1cc3..795a0eeb8db 100644 --- a/js/embedded.js +++ b/js/embedded.js @@ -237,9 +237,9 @@ localVideo.hide(); }, disableVideo: function() { - this._mediaControlsView.disableVideo(); - // Always hide the video, even if "disableVideo" returned "false". - this.hideVideo(); + if (this._mediaControlsView.disableVideo()) { + this.hideVideo(); + } }, // Called from webrtc.js disableScreensharingButton: function() {