From c881e7b64074c26738c2b1f78ef4aba5883baf9a Mon Sep 17 00:00:00 2001 From: yanas Date: Tue, 26 Apr 2016 16:38:07 -0500 Subject: [PATCH] Add hidden participant support --- conference.js | 5 +- connection.js | 14 ++-- modules/UI/UI.js | 6 -- modules/UI/recording/Recording.js | 15 +++++ modules/UI/videolayout/VideoLayout.js | 10 ++- modules/recorder/Recorder.js | 95 --------------------------- 6 files changed, 35 insertions(+), 110 deletions(-) delete mode 100644 modules/recorder/Recorder.js diff --git a/conference.js b/conference.js index 75333fcc3..c0dff5043 100644 --- a/conference.js +++ b/conference.js @@ -753,11 +753,14 @@ export default { room.on(ConferenceEvents.USER_JOINED, (id, user) => { + if (user.isHidden()) + return; + console.log('USER %s connnected', id, user); APP.API.notifyUserJoined(id); APP.UI.addUser(id, user.getDisplayName()); - // chek the roles for the new user and reflect them + // check the roles for the new user and reflect them APP.UI.updateUserRole(user); }); room.on(ConferenceEvents.USER_LEFT, (id, user) => { diff --git a/connection.js b/connection.js index 7764dfe92..d66dd24f3 100644 --- a/connection.js +++ b/connection.js @@ -132,15 +132,17 @@ function requestAuth() { */ export function openConnection({id, password, retry, roomName}) { - let predefinedLogin = window.localStorage.getItem("xmpp_login"); - let predefinedPassword = window.localStorage.getItem("xmpp_password"); + let usernameOverride + = window.localStorage.getItem("xmpp_username_override"); + let passwordOverride + = window.localStorage.getItem("xmpp_password_override"); - if (!id && predefinedLogin && predefinedLogin.length > 0) { - id = predefinedLogin; + if (usernameOverride && usernameOverride.length > 0) { + id = usernameOverride; } - if (!password && predefinedPassword && predefinedPassword.length > 0) { - password = predefinedPassword; + if (passwordOverride && passwordOverride.length > 0) { + password = passwordOverride; } return connect(id, password, roomName).catch(function (err) { diff --git a/modules/UI/UI.js b/modules/UI/UI.js index 8a2e2fa98..362979b66 100644 --- a/modules/UI/UI.js +++ b/modules/UI/UI.js @@ -29,7 +29,6 @@ var JitsiPopover = require("./util/JitsiPopover"); var Feedback = require("./Feedback"); import FollowMe from "../FollowMe"; -import Recorder from "../recorder/Recorder"; var eventEmitter = new EventEmitter(); UI.eventEmitter = eventEmitter; @@ -242,11 +241,6 @@ UI.initConference = function () { //if local role changes buttons state will be again updated UI.updateLocalRole(false); - // Initialise the recorder handler. We're doing this explicitly before - // calling showToolbar, because the recorder may want to disable all - // toolbars. - new Recorder(APP.conference); - // Once we've joined the muc show the toolbar ToolbarToggler.showToolbar(); diff --git a/modules/UI/recording/Recording.js b/modules/UI/recording/Recording.js index 23a660b29..fdf92f073 100644 --- a/modules/UI/recording/Recording.js +++ b/modules/UI/recording/Recording.js @@ -16,6 +16,11 @@ */ import UIEvents from "../../../service/UI/UIEvents"; import UIUtil from '../util/UIUtil'; +import VideoLayout from '../videolayout/VideoLayout'; +import Feedback from '../Feedback.js'; +import Toolbar from '../toolbars/Toolbar'; +import BottomToolbar from '../toolbars/BottomToolbar'; + /** * Indicates if the recording button should be enabled. @@ -218,6 +223,16 @@ var Recording = { this.currentState = Status.UNAVAILABLE; this.initRecordingButton(recordingType); + + // If I am a recorder then I publish my recorder custom role to notify + // everyone. + if (config.iAmRecorder) { + VideoLayout.enableDeviceAvailabilityIcons( + APP.conference.localId, true); + Feedback.enableFeedback(false); + Toolbar.enable(false); + BottomToolbar.enable(false); + } }, /** diff --git a/modules/UI/videolayout/VideoLayout.js b/modules/UI/videolayout/VideoLayout.js index 7c94da9db..5460633e6 100644 --- a/modules/UI/videolayout/VideoLayout.js +++ b/modules/UI/videolayout/VideoLayout.js @@ -277,7 +277,12 @@ var VideoLayout = { onRemoteStreamAdded (stream) { let id = stream.getParticipantId(); - remoteVideos[id].addRemoteStreamElement(stream); + let remoteVideo = remoteVideos[id]; + + if (!remoteVideo) + return; + + remoteVideo.addRemoteStreamElement(stream); // if track is muted make sure we reflect that if(stream.isMuted()) @@ -360,7 +365,8 @@ var VideoLayout = { }, /** - * Creates a remote video for participant for the given id. + * Creates a participant container for the given id and smallVideo. + * * @param id the id of the participant to add * @param {SmallVideo} smallVideo optional small video instance to add as a * remote video, if undefined RemoteVideo will be created diff --git a/modules/recorder/Recorder.js b/modules/recorder/Recorder.js deleted file mode 100644 index ca156f264..000000000 --- a/modules/recorder/Recorder.js +++ /dev/null @@ -1,95 +0,0 @@ -/* global config, APP */ -/* - * Copyright @ 2015 Atlassian Pty Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import VideoLayout from '../UI/videolayout/VideoLayout'; -import Feedback from '../UI/Feedback.js'; -import Toolbar from '../UI/toolbars/Toolbar'; -import BottomToolbar from '../UI/toolbars/BottomToolbar'; - -const _RECORDER_CUSTOM_ROLE = "recorder-role"; - -class Recorder { - /** - * Initializes a new {Recorder} instance. - * - * @param conference the {conference} which is to transport - * {Recorder}-related information between participants - */ - constructor (conference) { - this._conference = conference; - - // If I am a recorder then I publish my recorder custom role to notify - // everyone. - if (config.iAmRecorder) { - VideoLayout.enableDeviceAvailabilityIcons(conference.localId, true); - this._publishMyRecorderRole(); - Feedback.enableFeedback(false); - Toolbar.enable(false); - BottomToolbar.enable(false); - } - - // Listen to "CUSTOM_ROLE" commands. - this._conference.commands.addCommandListener( - this._conference.commands.defaults.CUSTOM_ROLE, - this._onCustomRoleCommand.bind(this)); - } - - /** - * Publish the recorder custom role. - * @private - */ - _publishMyRecorderRole () { - var conference = this._conference; - - var commands = conference.commands; - - commands.removeCommand(commands.defaults.CUSTOM_ROLE); - var self = this; - commands.sendCommandOnce( - commands.defaults.CUSTOM_ROLE, - { - attributes: { - recorderRole: true - } - }); - } - - /** - * Notifies this instance about a &qout;Custom Role&qout; command (delivered - * by the Command(s) API of {this._conference}). - * - * @param attributes the attributes {Object} carried by the command - * @param id the identifier of the participant who issued the command. A - * notable idiosyncrasy of the Command(s) API to be mindful of here is that - * the command may be issued by the local participant. - */ - _onCustomRoleCommand ({ attributes }, id) { - // We require to know who issued the command because (1) only a - // moderator is allowed to send commands and (2) a command MUST be - // issued by a defined commander. - if (typeof id === 'undefined' - || this._conference.isLocalId(id) - || !attributes.recorderRole) - return; - - var isRecorder = (attributes.recorderRole == 'true'); - - if (isRecorder) - VideoLayout.enableDeviceAvailabilityIcons(id, isRecorder); - } -} - -export default Recorder;