/* global config, APP, $, interfaceConfig */ /* jshint -W101 */ import AudioLevels from "../audio_levels/AudioLevels"; import ContactList from "../side_pannels/contactlist/ContactList"; import UIEvents from "../../../service/UI/UIEvents"; import UIUtil from "../util/UIUtil"; import RemoteVideo from "./RemoteVideo"; import LargeVideo from "./LargeVideo"; import LocalVideo from "./LocalVideo"; var MediaStreamType = require("../../../service/RTC/MediaStreamTypes"); var RTCBrowserType = require('../../RTC/RTCBrowserType'); 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; /** * On contact list item clicked. */ $(ContactList).bind('contactclicked', function(event, id) { if (!id) { return; } if (APP.conference.isLocalId(id)) { $("#localVideoContainer").click(); return; } var remoteVideo = remoteVideos[id]; if (remoteVideo && remoteVideo.selectVideoElement().length) { var videoThumb = remoteVideo.selectVideoElement()[0]; // It is not always the case that a videoThumb exists (if there is // no actual video). if (RTC.getVideoSrc(videoThumb)) { // 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); } } }); var VideoLayout = { init (emitter) { eventEmitter = emitter; localVideoThumbnail = new LocalVideo(VideoLayout, emitter); if (interfaceConfig.filmStripOnly) { LargeVideo.disable(); } else { LargeVideo.init(VideoLayout, emitter); } VideoLayout.resizeLargeVideoContainer(); }, 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'); stream.attach($(localAudio)); return; // FIXME maybe move this into the library? // Writing volume not allowed in IE if (!RTCBrowserType.isIExplorer()) { localAudio.autoplay = true; localAudio.volume = 0; } // Now when Temasys plugin is converting also