/* global config, APP, $, interfaceConfig, JitsiMeetJS */ /* jshint -W101 */ import AudioLevels from "../audio_levels/AudioLevels"; import Avatar from "../avatar/Avatar"; 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 {SHARED_VIDEO_CONTAINER_TYPE} from '../shared_video/SharedVideo'; import LocalVideo from "./LocalVideo"; const RTCUIUtil = JitsiMeetJS.util.RTCUIHelper; var remoteVideos = {}; var localVideoThumbnail = null; var currentDominantSpeaker = null; var localLastNCount = config.channelLastN; var localLastNSet = []; var lastNEndpointsCache = []; var lastNPickupId = 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. lastNPickupId = id; eventEmitter.emit(UIEvents.PINNED_ENDPOINT, remoteVideo, true); } } } /** * 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; eventEmitter.addListener(UIEvents.LOCAL_FLIPX_CHANGED, function (val) { localFlipX = val; if(largeVideo) largeVideo.onLocalFlipXChange(val); }); 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 let { localVideo } = this.resizeThumbnails(false, true); AudioLevels.createAudioLevelCanvas( "localVideoContainer", localVideo.thumbWidth, localVideo.thumbHeight); emitter.addListener(UIEvents.CONTACT_CLICKED, onContactClicked); this.lastNCount = config.channelLastN; }, initLargeVideo () { largeVideo = new LargeVideoManager(eventEmitter); if(localFlipX) { largeVideo.onLocalFlipXChange(localFlipX); } largeVideo.updateContainerSize(); AudioLevels.init(); }, setAudioLevel(id, lvl) { if (!largeVideo) { return; } AudioLevels.updateAudioLevel( id, lvl, largeVideo.id ); }, isInLastN (resource) { return this.lastNCount < 0 || // lastN is disabled // lastNEndpoints cache not built yet (this.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