From 9abc78ef24b1eb67db5643dc00b9b105adca7b2c Mon Sep 17 00:00:00 2001 From: damencho Date: Thu, 24 Mar 2016 14:34:18 -0500 Subject: [PATCH 1/2] Do not send SELECTED_ENDPOINT events for custom containers. --- modules/UI/videolayout/VideoLayout.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/UI/videolayout/VideoLayout.js b/modules/UI/videolayout/VideoLayout.js index bfa844954..33a553a48 100644 --- a/modules/UI/videolayout/VideoLayout.js +++ b/modules/UI/videolayout/VideoLayout.js @@ -922,7 +922,8 @@ var VideoLayout = { let currentId = largeVideo.id; if (!isOnLarge || forceUpdate) { - if (id !== currentId) { + let videoType = this.getRemoteVideoType(id); + if (id !== currentId && videoType === VIDEO_CONTAINER_TYPE) { eventEmitter.emit(UIEvents.SELECTED_ENDPOINT, id); } if (currentId) { @@ -931,7 +932,6 @@ var VideoLayout = { let smallVideo = this.getSmallVideo(id); - let videoType = this.getRemoteVideoType(id); largeVideo.updateLargeVideo( id, smallVideo.videoStream, From af9f651702c6c6fcc159c2a16a334a96c69ae991 Mon Sep 17 00:00:00 2001 From: damencho Date: Thu, 24 Mar 2016 15:25:26 -0500 Subject: [PATCH 2/2] Check whether commands are coming from moderator. --- conference.js | 32 ++++++++++++++++++++------ modules/FollowMe.js | 7 +++++- modules/UI/UI.js | 21 +++++++++-------- modules/UI/shared_video/SharedVideo.js | 19 ++++++++------- 4 files changed, 54 insertions(+), 25 deletions(-) diff --git a/conference.js b/conference.js index a59cfd429..d48388422 100644 --- a/conference.js +++ b/conference.js @@ -402,6 +402,15 @@ export default { listMembersIds () { return room.getParticipants().map(p => p.getId()); }, + /** + * Checks whether the participant identified by id is a moderator. + * @id id to search for participant + * @return {boolean} whether the participant is moderator + */ + isParticipantModerator (id) { + let user = room.getParticipantById(id); + return user && user.isModerator(); + }, /** * Check if SIP is supported. * @returns {boolean} @@ -737,7 +746,7 @@ export default { console.log('USER %s LEFT', id, user); APP.API.notifyUserLeft(id); APP.UI.removeUser(id, user.getDisplayName()); - APP.UI.stopSharedVideo({from: id}); + APP.UI.stopSharedVideo(id); }); @@ -1083,7 +1092,6 @@ export default { room.sendCommandOnce(Commands.SHARED_VIDEO, { value: url, attributes: { - from: APP.conference.localId, state: state, time: time, volume: volume @@ -1096,7 +1104,6 @@ export default { room.sendCommand(Commands.SHARED_VIDEO, { value: url, attributes: { - from: APP.conference.localId, state: state, time: time, volume: volume @@ -1105,14 +1112,25 @@ export default { } }); room.addCommandListener( - Commands.SHARED_VIDEO, ({value, attributes}) => { + Commands.SHARED_VIDEO, ({value, attributes}, id) => { + + // if we are not the moderator or + // the command is coming from a user which is not the moderator + if (!(this.isLocalId(id) && room.isModerator()) + && !this.isParticipantModerator(id)) + { + console.warn('Received shared video command ' + + 'not from moderator'); + return; + } + if (attributes.state === 'stop') { - APP.UI.stopSharedVideo(attributes); + APP.UI.stopSharedVideo(id, attributes); } else if (attributes.state === 'start') { - APP.UI.showSharedVideo(value, attributes); + APP.UI.showSharedVideo(id, value, attributes); } else if (attributes.state === 'playing' || attributes.state === 'pause') { - APP.UI.updateSharedVideo(value, attributes); + APP.UI.updateSharedVideo(id, value, attributes); } }); } diff --git a/modules/FollowMe.js b/modules/FollowMe.js index dd9bd3926..e7401ecc0 100644 --- a/modules/FollowMe.js +++ b/modules/FollowMe.js @@ -270,7 +270,12 @@ class FollowMe { if (this._conference.isLocalId(id)) return; - // TODO Don't obey commands issued by non-moderators. + if (!this._conference.isParticipantModerator(id)) + { + console.warn('Received follow-me command ' + + 'not from moderator'); + return; + } // Applies the received/remote command to the user experience/interface // of the local participant. diff --git a/modules/UI/UI.js b/modules/UI/UI.js index a914e1d24..c0fad8f89 100644 --- a/modules/UI/UI.js +++ b/modules/UI/UI.js @@ -1107,32 +1107,35 @@ UI.updateDevicesAvailability = function (id, devices) { }; /** -* Show shared video. -* @param {string} url video url -* @param {string} attributes + * Show shared video. + * @param {string} id the id of the sender of the command + * @param {string} url video url + * @param {string} attributes */ -UI.showSharedVideo = function (url, attributes) { +UI.showSharedVideo = function (id, url, attributes) { if (sharedVideoManager) - sharedVideoManager.showSharedVideo(url, attributes); + sharedVideoManager.showSharedVideo(id, url, attributes); }; /** * Update shared video. + * @param {string} id the id of the sender of the command * @param {string} url video url * @param {string} attributes */ -UI.updateSharedVideo = function (url, attributes) { +UI.updateSharedVideo = function (id, url, attributes) { if (sharedVideoManager) - sharedVideoManager.updateSharedVideo(url, attributes); + sharedVideoManager.updateSharedVideo(id, url, attributes); }; /** * Stop showing shared video. + * @param {string} id the id of the sender of the command * @param {string} attributes */ -UI.stopSharedVideo = function (attributes) { +UI.stopSharedVideo = function (id, attributes) { if (sharedVideoManager) - sharedVideoManager.stopSharedVideo(attributes); + sharedVideoManager.stopSharedVideo(id, attributes); }; module.exports = UI; diff --git a/modules/UI/shared_video/SharedVideo.js b/modules/UI/shared_video/SharedVideo.js index d76c2a3a8..f769a1f59 100644 --- a/modules/UI/shared_video/SharedVideo.js +++ b/modules/UI/shared_video/SharedVideo.js @@ -50,10 +50,11 @@ export default class SharedVideoManager { /** * Shows the player component and starts the checking function * that will be sending updates, if we are the one shared the video + * @param id the id of the sender of the command * @param url the video url * @param attributes */ - showSharedVideo (url, attributes) { + showSharedVideo (id, url, attributes) { if (this.isSharedVideoShown) return; @@ -61,7 +62,7 @@ export default class SharedVideoManager { this.url = url; // the owner of the video - this.from = attributes.from; + this.from = id; // This code loads the IFrame Player API code asynchronously. var tag = document.createElement('script'); @@ -184,10 +185,11 @@ export default class SharedVideoManager { /** * Updates video, if its not playing and needs starting or * if its playing and needs to be paysed + * @param id the id of the sender of the command * @param url the video url * @param attributes */ - updateSharedVideo (url, attributes) { + updateSharedVideo (id, url, attributes) { // if we are sending the event ignore if(APP.conference.isLocalId(this.from)) { return; @@ -196,7 +198,7 @@ export default class SharedVideoManager { if (attributes.state == 'playing') { if(!this.isSharedVideoShown) { - this.showSharedVideo(url, attributes); + this.showSharedVideo(id, url, attributes); return; } @@ -239,22 +241,23 @@ export default class SharedVideoManager { else { // if not shown show it, passing attributes so it can // be shown paused - this.showSharedVideo(url, attributes); + this.showSharedVideo(id, url, attributes); } } } /** * Stop shared video if it is currently showed. If the user started the - * shared video is the one in the attributes.from (called when user + * shared video is the one in the id (called when user * left and we want to remove video if the user sharing it left). + * @param id the id of the sender of the command * @param attributes */ - stopSharedVideo (attributes) { + stopSharedVideo (id, attributes) { if (!this.isSharedVideoShown) return; - if(this.from !== attributes.from) + if(this.from !== id) return; if(this.intervalId) {