/* global APP, $, interfaceConfig */ const logger = require("jitsi-meet-logger").getLogger(__filename); import Filmstrip from "./Filmstrip"; import UIEvents from "../../../service/UI/UIEvents"; import UIUtil from "../util/UIUtil"; import RemoteVideo from "./RemoteVideo"; import LargeVideoManager from "./LargeVideoManager"; import {VIDEO_CONTAINER_TYPE} from "./VideoContainer"; import LocalVideo from "./LocalVideo"; var remoteVideos = {}; var localVideoThumbnail = null; var currentDominantSpeaker = null; var eventEmitter = null; /** * Currently focused video jid * @type {String} */ var pinnedId = null; /** * flipX state of the localVideo */ let localFlipX = null; /** * 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(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. eventEmitter.emit(UIEvents.PINNED_ENDPOINT, remoteVideo, true); } } } /** * Handler for local flip X changed event. * @param {Object} val */ function onLocalFlipXChanged (val) { localFlipX = val; if(largeVideo) { largeVideo.onLocalFlipXChange(val); } } /** * 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; // Unregister listeners in case of reinitialization this.unregisterListeners(); localVideoThumbnail = new LocalVideo(VideoLayout, emitter); // sets default video type of local video // FIXME container type is totally different thing from the video type localVideoThumbnail.setVideoType(VIDEO_CONTAINER_TYPE); // if we do not resize the thumbs here, if there is no video device // the local video thumb maybe one pixel this.resizeThumbnails(false, true); this.registerListeners(); }, /** * Cleans up any existing largeVideo instance. * * @returns {void} */ resetLargeVideo() { if (largeVideo) { largeVideo.destroy(); } largeVideo = null; }, /** * Registering listeners for UI events in Video layout component. * * @returns {void} */ registerListeners() { eventEmitter.addListener(UIEvents.LOCAL_FLIPX_CHANGED, onLocalFlipXChanged); eventEmitter.addListener(UIEvents.CONTACT_CLICKED, onContactClicked); }, /** * Unregistering listeners for UI events in Video layout component. * * @returns {void} */ unregisterListeners() { eventEmitter.removeListener(UIEvents.CONTACT_CLICKED, onContactClicked); }, initLargeVideo () { this.resetLargeVideo(); largeVideo = new LargeVideoManager(eventEmitter); if(localFlipX) { largeVideo.onLocalFlipXChange(localFlipX); } largeVideo.updateContainerSize(); }, /** * Sets the audio level of the video elements associated to the given id. * * @param id the video identifier in the form it comes from the library * @param lvl the new audio level to update to */ setAudioLevel(id, lvl) { let smallVideo = this.getSmallVideo(id); if (smallVideo) smallVideo.updateAudioLevelIndicator(lvl); if (largeVideo && id === largeVideo.id) largeVideo.updateLargeVideoAudioLevel(lvl); }, changeLocalAudio (stream) { let localAudio = document.getElementById('localAudio'); localAudio = stream.attach(localAudio); // Now when Temasys plugin is converting also