/* global config, APP, $, interfaceConfig */ /* jshint -W101 */ import AudioLevels from "../audio_levels/AudioLevels"; import Avatar from "../avatar/Avatar"; import BottomToolbar from "../toolbars/BottomToolbar"; import UIEvents from "../../../service/UI/UIEvents"; import UIUtil from "../util/UIUtil"; import RemoteVideo from "./RemoteVideo"; import LargeVideoManager, {VideoContainerType} from "./LargeVideo"; import {PreziContainerType} from '../prezi/Prezi'; import LocalVideo from "./LocalVideo"; const RTCUIUtil = JitsiMeetJS.util.RTCUIHelper; var remoteVideos = {}; var remoteVideoTypes = {}; var localVideoThumbnail = null; var currentDominantSpeaker = null; var lastNCount = config.channelLastN; var localLastNCount = config.channelLastN; var localLastNSet = []; var lastNEndpointsCache = []; var lastNPickupId = null; var eventEmitter = null; /** * Currently focused video jid * @type {String} */ var focusedVideoResourceJid = null; const thumbAspectRatio = 16.0 / 9.0; /** * On contact list item clicked. */ function onContactClicked (id) { if (APP.conference.isLocalId(id)) { $("#localVideoContainer").click(); return; } let remoteVideo = remoteVideos[id]; if (remoteVideo && remoteVideo.hasVideo()) { // It is not always the case that a videoThumb exists (if there is // no actual video). if (remoteVideo.hasVideoStarted()) { // We have a video src, great! Let's update the large video // now. VideoLayout.handleVideoThumbClicked(false, id); } else { // If we don't have a video src for jid, there's absolutely // no point in calling handleVideoThumbClicked; Quite // simply, it won't work because it needs an src to attach // to the large video. // // Instead, we trigger the pinned endpoint changed event to // let the bridge adjust its lastN set for myjid and store // the pinned user in the lastNPickupId variable to be // picked up later by the lastN changed event handler. lastNPickupId = id; eventEmitter.emit(UIEvents.PINNED_ENDPOINT, id); } } } /** * Returns the corresponding resource id to the given peer container * DOM element. * * @return the corresponding resource id to the given peer container * DOM element */ function getPeerContainerResourceId (containerElement) { if (localVideoThumbnail.container === containerElement) { return localVideoThumbnail.id; } let i = containerElement.id.indexOf('participant_'); if (i >= 0) { return containerElement.id.substring(i + 12); } } let largeVideo; var VideoLayout = { init (emitter) { eventEmitter = emitter; localVideoThumbnail = new LocalVideo(VideoLayout, emitter); emitter.addListener(UIEvents.CONTACT_CLICKED, onContactClicked); }, initLargeVideo (isSideBarVisible) { largeVideo = new LargeVideoManager(); largeVideo.updateContainerSize(isSideBarVisible); AudioLevels.init(); }, setAudioLevel(id, lvl) { if (!largeVideo) { return; } AudioLevels.updateAudioLevel( id, lvl, largeVideo.id ); }, isInLastN (resource) { return lastNCount < 0 || // lastN is disabled // lastNEndpoints cache not built yet (lastNCount > 0 && !lastNEndpointsCache.length) || (lastNEndpointsCache && lastNEndpointsCache.indexOf(resource) !== -1); }, changeLocalAudio (stream) { let localAudio = document.getElementById('localAudio'); localAudio = stream.attach(localAudio); // Now when Temasys plugin is converting also