2020-12-14 21:38:29 +00:00
|
|
|
/* global APP */
|
2020-05-20 10:57:03 +00:00
|
|
|
|
|
|
|
import Logger from 'jitsi-meet-logger';
|
2015-07-10 09:57:20 +00:00
|
|
|
|
2020-04-14 22:41:30 +00:00
|
|
|
import { MEDIA_TYPE, VIDEO_TYPE } from '../../../react/features/base/media';
|
2017-08-10 20:51:35 +00:00
|
|
|
import {
|
2019-02-07 03:19:02 +00:00
|
|
|
getLocalParticipant as getLocalParticipantFromStore,
|
2017-08-10 20:51:35 +00:00
|
|
|
getPinnedParticipant,
|
2020-04-14 22:41:30 +00:00
|
|
|
getParticipantById,
|
2017-08-10 20:51:35 +00:00
|
|
|
pinParticipant
|
|
|
|
} from '../../../react/features/base/participants';
|
2020-04-14 22:41:30 +00:00
|
|
|
import { getTrackByMediaTypeAndParticipant } from '../../../react/features/base/tracks';
|
2020-05-20 10:57:03 +00:00
|
|
|
import UIEvents from '../../../service/UI/UIEvents';
|
2018-05-22 17:13:51 +00:00
|
|
|
import { SHARED_VIDEO_CONTAINER_TYPE } from '../shared_video/SharedVideo';
|
|
|
|
import SharedVideoThumb from '../shared_video/SharedVideoThumb';
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
import LargeVideoManager from './LargeVideoManager';
|
2020-05-20 10:57:03 +00:00
|
|
|
import LocalVideo from './LocalVideo';
|
|
|
|
import RemoteVideo from './RemoteVideo';
|
2017-10-12 23:02:29 +00:00
|
|
|
import { VIDEO_CONTAINER_TYPE } from './VideoContainer';
|
2018-05-22 17:13:51 +00:00
|
|
|
|
2020-05-20 10:57:03 +00:00
|
|
|
const logger = Logger.getLogger(__filename);
|
2015-12-14 12:26:50 +00:00
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
const remoteVideos = {};
|
|
|
|
let localVideoThumbnail = null;
|
2015-06-23 08:00:46 +00:00
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
let eventEmitter = null;
|
|
|
|
|
|
|
|
let largeVideo;
|
2015-01-27 12:03:26 +00:00
|
|
|
|
2016-05-07 01:50:37 +00:00
|
|
|
/**
|
|
|
|
* flipX state of the localVideo
|
|
|
|
*/
|
|
|
|
let localFlipX = null;
|
|
|
|
|
2017-02-15 21:39:16 +00:00
|
|
|
/**
|
|
|
|
* Handler for local flip X changed event.
|
|
|
|
* @param {Object} val
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
function onLocalFlipXChanged(val) {
|
2017-02-15 21:39:16 +00:00
|
|
|
localFlipX = val;
|
2017-10-12 23:02:29 +00:00
|
|
|
if (largeVideo) {
|
2017-02-15 21:39:16 +00:00
|
|
|
largeVideo.onLocalFlipXChange(val);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-18 19:59:07 +00:00
|
|
|
/**
|
|
|
|
* Returns an array of all thumbnails in the filmstrip.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {Array}
|
|
|
|
*/
|
|
|
|
function getAllThumbnails() {
|
|
|
|
return [
|
2020-10-09 11:59:39 +00:00
|
|
|
...localVideoThumbnail ? [ localVideoThumbnail ] : [],
|
2018-05-18 19:59:07 +00:00
|
|
|
...Object.values(remoteVideos)
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2019-02-07 03:19:02 +00:00
|
|
|
/**
|
|
|
|
* Private helper to get the redux representation of the local participant.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {Object}
|
|
|
|
*/
|
|
|
|
function getLocalParticipant() {
|
|
|
|
return getLocalParticipantFromStore(APP.store.getState());
|
|
|
|
}
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
const VideoLayout = {
|
|
|
|
init(emitter) {
|
2015-01-27 12:03:26 +00:00
|
|
|
eventEmitter = emitter;
|
2017-02-15 21:39:16 +00:00
|
|
|
|
2018-05-21 22:10:43 +00:00
|
|
|
localVideoThumbnail = new LocalVideo(
|
|
|
|
emitter,
|
|
|
|
this._updateLargeVideoIfDisplayed.bind(this));
|
2017-10-12 23:02:29 +00:00
|
|
|
|
2017-02-15 21:39:16 +00:00
|
|
|
this.registerListeners();
|
|
|
|
},
|
|
|
|
|
2017-05-11 00:19:35 +00:00
|
|
|
/**
|
2019-01-01 21:19:34 +00:00
|
|
|
* Registering listeners for UI events in Video layout component.
|
2017-05-11 00:19:35 +00:00
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2019-01-01 21:19:34 +00:00
|
|
|
registerListeners() {
|
|
|
|
eventEmitter.addListener(UIEvents.LOCAL_FLIPX_CHANGED,
|
|
|
|
onLocalFlipXChanged);
|
2017-05-11 00:19:35 +00:00
|
|
|
},
|
|
|
|
|
2017-02-15 21:39:16 +00:00
|
|
|
/**
|
2019-01-01 21:19:34 +00:00
|
|
|
* Cleans up state of this singleton {@code VideoLayout}.
|
2017-02-15 21:39:16 +00:00
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2019-01-01 21:19:34 +00:00
|
|
|
reset() {
|
|
|
|
this._resetLargeVideo();
|
|
|
|
this._resetFilmstrip();
|
2015-12-14 12:26:50 +00:00
|
|
|
},
|
2015-01-19 09:20:00 +00:00
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
initLargeVideo() {
|
2019-01-01 21:19:34 +00:00
|
|
|
this._resetLargeVideo();
|
2017-05-11 00:19:35 +00:00
|
|
|
|
2016-09-14 21:26:17 +00:00
|
|
|
largeVideo = new LargeVideoManager(eventEmitter);
|
2017-10-12 23:02:29 +00:00
|
|
|
if (localFlipX) {
|
2016-05-07 01:50:37 +00:00
|
|
|
largeVideo.onLocalFlipXChange(localFlipX);
|
|
|
|
}
|
2016-09-08 18:16:23 +00:00
|
|
|
largeVideo.updateContainerSize();
|
2015-12-25 16:55:45 +00:00
|
|
|
},
|
|
|
|
|
2016-09-28 21:31:40 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2015-12-25 16:55:45 +00:00
|
|
|
setAudioLevel(id, lvl) {
|
2017-10-12 23:02:29 +00:00
|
|
|
if (largeVideo && id === largeVideo.id) {
|
2016-09-28 21:31:40 +00:00
|
|
|
largeVideo.updateLargeVideoAudioLevel(lvl);
|
2017-10-12 23:02:29 +00:00
|
|
|
}
|
2015-12-25 16:55:45 +00:00
|
|
|
},
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
changeLocalVideo(stream) {
|
2019-02-07 03:19:02 +00:00
|
|
|
const localId = getLocalParticipant().id;
|
2017-10-12 23:02:29 +00:00
|
|
|
|
2015-12-30 12:14:56 +00:00
|
|
|
this.onVideoTypeChanged(localId, stream.videoType);
|
2015-08-05 12:09:12 +00:00
|
|
|
|
2017-04-27 22:30:39 +00:00
|
|
|
localVideoThumbnail.changeVideo(stream);
|
2015-01-19 09:20:00 +00:00
|
|
|
|
2018-05-21 22:10:43 +00:00
|
|
|
this._updateLargeVideoIfDisplayed(localId);
|
2015-12-14 12:26:50 +00:00
|
|
|
},
|
2014-06-12 18:33:57 +00:00
|
|
|
|
2016-05-01 18:35:18 +00:00
|
|
|
/**
|
|
|
|
* Shows/hides local video.
|
|
|
|
* @param {boolean} true to make the local video visible, false - otherwise
|
|
|
|
*/
|
|
|
|
setLocalVideoVisible(visible) {
|
|
|
|
localVideoThumbnail.setVisible(visible);
|
|
|
|
},
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
onRemoteStreamAdded(stream) {
|
|
|
|
const id = stream.getParticipantId();
|
|
|
|
const remoteVideo = remoteVideos[id];
|
2016-04-26 21:38:07 +00:00
|
|
|
|
2019-09-17 20:26:34 +00:00
|
|
|
logger.debug(`Received a new ${stream.getType()} stream for ${id}`);
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
if (!remoteVideo) {
|
2019-09-17 20:26:34 +00:00
|
|
|
logger.debug('No remote video element to add stream');
|
|
|
|
|
2016-04-26 21:38:07 +00:00
|
|
|
return;
|
2017-10-12 23:02:29 +00:00
|
|
|
}
|
2016-04-26 21:38:07 +00:00
|
|
|
|
|
|
|
remoteVideo.addRemoteStreamElement(stream);
|
2016-01-14 16:28:24 +00:00
|
|
|
|
2020-11-09 20:59:13 +00:00
|
|
|
this.onVideoMute(id);
|
|
|
|
remoteVideo.updateView();
|
2015-12-14 12:26:50 +00:00
|
|
|
},
|
2016-02-23 22:47:55 +00:00
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
onRemoteStreamRemoved(stream) {
|
|
|
|
const id = stream.getParticipantId();
|
|
|
|
const remoteVideo = remoteVideos[id];
|
|
|
|
|
2016-10-03 16:12:04 +00:00
|
|
|
// Remote stream may be removed after participant left the conference.
|
|
|
|
if (remoteVideo) {
|
2016-02-26 13:20:36 +00:00
|
|
|
remoteVideo.removeRemoteStreamElement(stream);
|
2020-10-26 19:51:51 +00:00
|
|
|
remoteVideo.updateView();
|
2016-02-26 13:20:36 +00:00
|
|
|
}
|
2018-05-21 21:54:16 +00:00
|
|
|
|
2020-11-09 20:59:13 +00:00
|
|
|
this.updateVideoMutedForNoTracks(id);
|
2017-07-19 10:08:51 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* FIXME get rid of this method once muted indicator are reactified (by
|
|
|
|
* making sure that user with no tracks is displayed as muted )
|
|
|
|
*
|
|
|
|
* If participant has no tracks will make the UI display muted status.
|
|
|
|
* @param {string} participantId
|
|
|
|
*/
|
2020-11-09 20:59:13 +00:00
|
|
|
updateVideoMutedForNoTracks(participantId) {
|
2017-07-19 10:08:51 +00:00
|
|
|
const participant = APP.conference.getParticipantById(participantId);
|
|
|
|
|
2020-11-09 20:59:13 +00:00
|
|
|
if (participant && !participant.getTracksByMediaType('video').length) {
|
|
|
|
APP.UI.setVideoMuted(participantId);
|
2017-07-19 10:08:51 +00:00
|
|
|
}
|
2016-02-23 22:47:55 +00:00
|
|
|
},
|
2014-11-21 13:29:05 +00:00
|
|
|
|
2015-11-16 23:42:21 +00:00
|
|
|
/**
|
|
|
|
* Return the type of the remote video.
|
2015-12-14 12:26:50 +00:00
|
|
|
* @param id the id for the remote video
|
2016-03-15 18:36:17 +00:00
|
|
|
* @returns {String} the video type video or screen.
|
2015-11-16 23:42:21 +00:00
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
getRemoteVideoType(id) {
|
2020-04-14 22:41:30 +00:00
|
|
|
const state = APP.store.getState();
|
|
|
|
const participant = getParticipantById(state, id);
|
|
|
|
|
|
|
|
if (participant?.isFakeParticipant) {
|
|
|
|
return SHARED_VIDEO_CONTAINER_TYPE;
|
|
|
|
}
|
2017-10-12 23:02:29 +00:00
|
|
|
|
2020-04-14 22:41:30 +00:00
|
|
|
const videoTrack = getTrackByMediaTypeAndParticipant(state['features/base/tracks'], MEDIA_TYPE.VIDEO, id);
|
2017-10-12 23:02:29 +00:00
|
|
|
|
2020-04-14 22:41:30 +00:00
|
|
|
return videoTrack?.videoType;
|
2015-12-14 12:26:50 +00:00
|
|
|
},
|
2015-11-16 23:42:21 +00:00
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
isPinned(id) {
|
2017-08-10 20:51:35 +00:00
|
|
|
return id === this.getPinnedId();
|
2016-03-24 01:43:29 +00:00
|
|
|
},
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
getPinnedId() {
|
2017-08-10 20:51:35 +00:00
|
|
|
const { id } = getPinnedParticipant(APP.store.getState()) || {};
|
|
|
|
|
|
|
|
return id || null;
|
|
|
|
},
|
|
|
|
|
2018-11-30 22:13:39 +00:00
|
|
|
/**
|
|
|
|
* Triggers a thumbnail to pin or unpin itself.
|
|
|
|
*
|
|
|
|
* @param {number} videoNumber - The index of the video to toggle pin on.
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
togglePin(videoNumber) {
|
|
|
|
const videos = getAllThumbnails();
|
|
|
|
const videoView = videos[videoNumber];
|
|
|
|
|
|
|
|
videoView && videoView.togglePin();
|
|
|
|
},
|
|
|
|
|
2017-08-10 20:51:35 +00:00
|
|
|
/**
|
2018-05-18 19:59:07 +00:00
|
|
|
* Callback invoked to update display when the pin participant has changed.
|
2017-08-10 20:51:35 +00:00
|
|
|
*
|
2018-05-18 19:59:07 +00:00
|
|
|
* @paramn {string|null} pinnedParticipantID - The participant ID of the
|
|
|
|
* participant that is pinned or null if no one is pinned.
|
2017-08-10 20:51:35 +00:00
|
|
|
* @returns {void}
|
|
|
|
*/
|
2018-05-18 19:59:07 +00:00
|
|
|
onPinChange(pinnedParticipantID) {
|
|
|
|
getAllThumbnails().forEach(thumbnail =>
|
|
|
|
thumbnail.focus(pinnedParticipantID === thumbnail.getId()));
|
2015-12-14 12:26:50 +00:00
|
|
|
},
|
2014-06-12 18:33:57 +00:00
|
|
|
|
|
|
|
/**
|
2018-05-22 17:13:51 +00:00
|
|
|
* Creates a participant container for the given id.
|
2016-04-26 21:38:07 +00:00
|
|
|
*
|
2018-05-22 17:13:51 +00:00
|
|
|
* @param {Object} participant - The redux representation of a remote
|
|
|
|
* participant.
|
|
|
|
* @returns {void}
|
2014-06-12 18:33:57 +00:00
|
|
|
*/
|
2018-05-22 17:13:51 +00:00
|
|
|
addRemoteParticipantContainer(participant) {
|
|
|
|
if (!participant || participant.local) {
|
|
|
|
return;
|
2018-06-22 18:59:54 +00:00
|
|
|
} else if (participant.isFakeParticipant) {
|
2020-11-09 20:59:13 +00:00
|
|
|
const sharedVideoThumb = new SharedVideoThumb(participant);
|
2018-05-22 17:13:51 +00:00
|
|
|
|
|
|
|
this.addRemoteVideoContainer(participant.id, sharedVideoThumb);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const id = participant.id;
|
|
|
|
const jitsiParticipant = APP.conference.getParticipantById(id);
|
2020-11-09 20:59:13 +00:00
|
|
|
const remoteVideo = new RemoteVideo(jitsiParticipant);
|
2017-10-12 23:02:29 +00:00
|
|
|
|
2016-09-16 20:17:00 +00:00
|
|
|
this.addRemoteVideoContainer(id, remoteVideo);
|
2020-11-09 20:59:13 +00:00
|
|
|
this.updateVideoMutedForNoTracks(id);
|
2016-09-16 20:17:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds remote video container for the given id and <tt>SmallVideo</tt>.
|
|
|
|
*
|
|
|
|
* @param {string} the id of the video to add
|
|
|
|
* @param {SmallVideo} smallVideo the small video instance to add as a
|
|
|
|
* remote video
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
addRemoteVideoContainer(id, remoteVideo) {
|
2015-12-14 12:26:50 +00:00
|
|
|
remoteVideos[id] = remoteVideo;
|
2015-08-05 12:09:12 +00:00
|
|
|
|
2016-09-16 20:51:19 +00:00
|
|
|
// Initialize the view
|
|
|
|
remoteVideo.updateView();
|
2015-12-14 12:26:50 +00:00
|
|
|
},
|
2014-06-12 18:33:57 +00:00
|
|
|
|
2014-06-27 16:27:24 +00:00
|
|
|
/**
|
|
|
|
* On video muted event.
|
|
|
|
*/
|
2020-10-23 22:48:56 +00:00
|
|
|
onVideoMute(id) {
|
2016-01-06 22:39:13 +00:00
|
|
|
if (APP.conference.isLocalId(id)) {
|
2020-10-23 22:48:56 +00:00
|
|
|
localVideoThumbnail && localVideoThumbnail.updateView();
|
2014-06-12 18:33:57 +00:00
|
|
|
} else {
|
2017-10-12 23:02:29 +00:00
|
|
|
const remoteVideo = remoteVideos[id];
|
|
|
|
|
|
|
|
if (remoteVideo) {
|
2020-10-29 16:11:15 +00:00
|
|
|
remoteVideo.updateView();
|
2017-10-12 23:02:29 +00:00
|
|
|
}
|
2014-06-12 18:33:57 +00:00
|
|
|
}
|
2016-01-14 16:28:24 +00:00
|
|
|
|
2019-07-02 13:06:52 +00:00
|
|
|
// large video will show avatar instead of muted stream
|
|
|
|
this._updateLargeVideoIfDisplayed(id, true);
|
2015-12-14 12:26:50 +00:00
|
|
|
},
|
2014-06-12 18:33:57 +00:00
|
|
|
|
2014-06-24 11:59:14 +00:00
|
|
|
/**
|
2014-07-16 14:35:54 +00:00
|
|
|
* On dominant speaker changed event.
|
2018-05-18 00:41:28 +00:00
|
|
|
*
|
|
|
|
* @param {string} id - The participant ID of the new dominant speaker.
|
|
|
|
* @returns {void}
|
2014-06-24 11:59:14 +00:00
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
onDominantSpeakerChanged(id) {
|
2018-05-18 19:59:07 +00:00
|
|
|
getAllThumbnails().forEach(thumbnail =>
|
|
|
|
thumbnail.showDominantSpeakerIndicator(id === thumbnail.getId()));
|
2015-12-14 12:26:50 +00:00
|
|
|
},
|
2014-08-22 15:37:11 +00:00
|
|
|
|
2016-09-16 20:51:19 +00:00
|
|
|
/**
|
2018-06-25 17:44:12 +00:00
|
|
|
* Shows/hides warning about a user's connectivity issues.
|
2016-09-16 20:51:19 +00:00
|
|
|
*
|
2018-06-25 17:44:12 +00:00
|
|
|
* @param {string} id - The ID of the remote participant(MUC nickname).
|
|
|
|
* @returns {void}
|
2016-09-16 20:51:19 +00:00
|
|
|
*/
|
2020-02-04 07:25:13 +00:00
|
|
|
onParticipantConnectionStatusChanged(id) {
|
2018-06-25 17:44:12 +00:00
|
|
|
if (APP.conference.isLocalId(id)) {
|
|
|
|
|
|
|
|
return;
|
2016-09-24 18:24:18 +00:00
|
|
|
}
|
2017-10-12 23:02:29 +00:00
|
|
|
|
2018-06-25 17:44:12 +00:00
|
|
|
// We have to trigger full large video update to transition from
|
|
|
|
// avatar to video on connectivity restored.
|
|
|
|
this._updateLargeVideoIfDisplayed(id, true);
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
const remoteVideo = remoteVideos[id];
|
|
|
|
|
2016-09-16 20:51:19 +00:00
|
|
|
if (remoteVideo) {
|
2016-09-24 15:36:24 +00:00
|
|
|
remoteVideo.updateView();
|
2016-09-16 20:51:19 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-08-22 15:37:11 +00:00
|
|
|
/**
|
|
|
|
* On last N change event.
|
|
|
|
*
|
2017-03-21 21:51:49 +00:00
|
|
|
* @param endpointsLeavingLastN the list currently leaving last N
|
|
|
|
* endpoints
|
2014-08-22 15:37:11 +00:00
|
|
|
* @param endpointsEnteringLastN the list currently entering last N
|
|
|
|
* endpoints
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
onLastNEndpointsChanged(endpointsLeavingLastN, endpointsEnteringLastN) {
|
2017-03-21 21:51:49 +00:00
|
|
|
if (endpointsLeavingLastN) {
|
|
|
|
endpointsLeavingLastN.forEach(this._updateRemoteVideo, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (endpointsEnteringLastN) {
|
|
|
|
endpointsEnteringLastN.forEach(this._updateRemoteVideo, this);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates remote video by id if it exists.
|
|
|
|
* @param {string} id of the remote video
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
_updateRemoteVideo(id) {
|
|
|
|
const remoteVideo = remoteVideos[id];
|
2017-10-12 23:02:29 +00:00
|
|
|
|
2017-03-21 21:51:49 +00:00
|
|
|
if (remoteVideo) {
|
|
|
|
remoteVideo.updateView();
|
2019-07-02 13:06:52 +00:00
|
|
|
this._updateLargeVideoIfDisplayed(id);
|
2017-03-21 21:51:49 +00:00
|
|
|
}
|
2015-12-14 12:26:50 +00:00
|
|
|
},
|
2014-08-22 15:37:11 +00:00
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
removeParticipantContainer(id) {
|
2015-01-20 15:56:00 +00:00
|
|
|
// Unlock large video
|
2017-08-10 20:51:35 +00:00
|
|
|
if (this.getPinnedId() === id) {
|
2017-10-12 23:02:29 +00:00
|
|
|
logger.info('Focused video owner has left the conference');
|
2018-05-18 19:59:07 +00:00
|
|
|
APP.store.dispatch(pinParticipant(null));
|
2015-01-20 15:56:00 +00:00
|
|
|
}
|
2015-07-23 09:03:29 +00:00
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
const remoteVideo = remoteVideos[id];
|
|
|
|
|
2015-07-23 09:03:29 +00:00
|
|
|
if (remoteVideo) {
|
|
|
|
// Remove remote video
|
2017-10-12 23:02:29 +00:00
|
|
|
logger.info(`Removing remote video: ${id}`);
|
2015-12-14 12:26:50 +00:00
|
|
|
delete remoteVideos[id];
|
2015-10-01 22:46:42 +00:00
|
|
|
remoteVideo.remove();
|
2015-07-23 09:03:29 +00:00
|
|
|
} else {
|
2017-10-12 23:02:29 +00:00
|
|
|
logger.warn(`No remote video for ${id}`);
|
2015-07-23 09:03:29 +00:00
|
|
|
}
|
2015-12-14 12:26:50 +00:00
|
|
|
},
|
2015-11-30 11:54:54 +00:00
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
onVideoTypeChanged(id, newVideoType) {
|
2020-07-17 09:46:56 +00:00
|
|
|
const remoteVideo = remoteVideos[id];
|
|
|
|
|
2020-09-18 12:28:54 +00:00
|
|
|
if (!remoteVideo) {
|
2015-08-05 12:09:12 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
logger.info('Peer video type changed: ', id, newVideoType);
|
2020-10-26 19:51:51 +00:00
|
|
|
remoteVideo.updateView();
|
2015-12-14 12:26:50 +00:00
|
|
|
},
|
2015-11-13 17:04:49 +00:00
|
|
|
|
2015-06-23 08:00:46 +00:00
|
|
|
/**
|
2015-11-13 17:04:49 +00:00
|
|
|
* Resizes the video area.
|
2016-03-15 21:03:38 +00:00
|
|
|
*/
|
2020-02-10 15:27:43 +00:00
|
|
|
resizeVideoArea() {
|
2015-12-25 16:55:45 +00:00
|
|
|
if (largeVideo) {
|
2016-09-08 18:16:23 +00:00
|
|
|
largeVideo.updateContainerSize();
|
2020-02-10 15:27:43 +00:00
|
|
|
largeVideo.resize(false);
|
2015-12-25 16:55:45 +00:00
|
|
|
}
|
2015-12-14 12:26:50 +00:00
|
|
|
},
|
2015-08-06 23:34:40 +00:00
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
getSmallVideo(id) {
|
2015-12-14 12:26:50 +00:00
|
|
|
if (APP.conference.isLocalId(id)) {
|
2015-06-23 08:00:46 +00:00
|
|
|
return localVideoThumbnail;
|
|
|
|
}
|
2017-10-12 23:02:29 +00:00
|
|
|
|
|
|
|
return remoteVideos[id];
|
|
|
|
|
2015-12-14 12:26:50 +00:00
|
|
|
},
|
2015-06-29 14:24:21 +00:00
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
changeUserAvatar(id, avatarUrl) {
|
2015-12-25 16:55:45 +00:00
|
|
|
if (this.isCurrentlyOnLarge(id)) {
|
2016-01-19 23:10:44 +00:00
|
|
|
largeVideo.updateAvatar(avatarUrl);
|
2015-12-25 16:55:45 +00:00
|
|
|
}
|
2015-12-14 12:26:50 +00:00
|
|
|
},
|
2015-07-29 19:39:09 +00:00
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
isLargeVideoVisible() {
|
2016-03-18 20:00:55 +00:00
|
|
|
return this.isLargeContainerTypeVisible(VIDEO_CONTAINER_TYPE);
|
2015-12-25 16:55:45 +00:00
|
|
|
},
|
|
|
|
|
2016-03-18 03:19:09 +00:00
|
|
|
/**
|
|
|
|
* @return {LargeContainer} the currently displayed container on large
|
|
|
|
* video.
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
getCurrentlyOnLargeContainer() {
|
2017-07-10 09:02:22 +00:00
|
|
|
return largeVideo.getCurrentContainer();
|
2016-03-18 03:19:09 +00:00
|
|
|
},
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
isCurrentlyOnLarge(id) {
|
2015-12-25 16:55:45 +00:00
|
|
|
return largeVideo && largeVideo.id === id;
|
|
|
|
},
|
|
|
|
|
2017-04-05 15:14:26 +00:00
|
|
|
/**
|
|
|
|
* Triggers an update of remote video and large video displays so they may
|
|
|
|
* pick up any state changes that have occurred elsewhere.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
updateAllVideos() {
|
|
|
|
const displayedUserId = this.getLargeVideoID();
|
|
|
|
|
|
|
|
if (displayedUserId) {
|
|
|
|
this.updateLargeVideo(displayedUserId, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
Object.keys(remoteVideos).forEach(video => {
|
|
|
|
remoteVideos[video].updateView();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
updateLargeVideo(id, forceUpdate) {
|
2015-12-25 16:55:45 +00:00
|
|
|
if (!largeVideo) {
|
|
|
|
return;
|
|
|
|
}
|
2017-07-10 10:06:48 +00:00
|
|
|
const currentContainer = largeVideo.getCurrentContainer();
|
|
|
|
const currentContainerType = largeVideo.getCurrentContainerType();
|
|
|
|
const isOnLarge = this.isCurrentlyOnLarge(id);
|
2020-04-14 22:41:30 +00:00
|
|
|
const state = APP.store.getState();
|
|
|
|
const videoTrack = getTrackByMediaTypeAndParticipant(state['features/base/tracks'], MEDIA_TYPE.VIDEO, id);
|
|
|
|
const videoStream = videoTrack?.jitsiTrack;
|
2017-07-10 10:06:48 +00:00
|
|
|
|
|
|
|
if (isOnLarge && !forceUpdate
|
|
|
|
&& LargeVideoManager.isVideoContainer(currentContainerType)
|
2020-04-14 22:41:30 +00:00
|
|
|
&& videoStream) {
|
2017-07-10 10:06:48 +00:00
|
|
|
const currentStreamId = currentContainer.getStreamID();
|
2020-04-14 22:41:30 +00:00
|
|
|
const newStreamId = videoStream?.getId() || null;
|
2017-07-10 10:06:48 +00:00
|
|
|
|
|
|
|
// FIXME it might be possible to get rid of 'forceUpdate' argument
|
|
|
|
if (currentStreamId !== newStreamId) {
|
|
|
|
logger.debug('Enforcing large video update for stream change');
|
2017-10-12 23:02:29 +00:00
|
|
|
forceUpdate = true; // eslint-disable-line no-param-reassign
|
2017-07-10 10:06:48 +00:00
|
|
|
}
|
|
|
|
}
|
2015-12-25 16:55:45 +00:00
|
|
|
|
2020-04-14 22:41:30 +00:00
|
|
|
if (!isOnLarge || forceUpdate) {
|
2017-10-12 23:02:29 +00:00
|
|
|
const videoType = this.getRemoteVideoType(id);
|
|
|
|
|
2015-12-25 16:55:45 +00:00
|
|
|
|
2016-01-14 16:28:24 +00:00
|
|
|
largeVideo.updateLargeVideo(
|
2016-01-29 19:31:58 +00:00
|
|
|
id,
|
2020-04-14 22:41:30 +00:00
|
|
|
videoStream,
|
2018-07-02 15:39:28 +00:00
|
|
|
videoType || VIDEO_TYPE.CAMERA
|
2020-04-14 22:41:30 +00:00
|
|
|
).catch(() => {
|
|
|
|
// do nothing
|
2016-01-22 15:08:58 +00:00
|
|
|
});
|
2015-12-25 16:55:45 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
addLargeVideoContainer(type, container) {
|
2015-12-25 16:55:45 +00:00
|
|
|
largeVideo && largeVideo.addContainer(type, container);
|
|
|
|
},
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
removeLargeVideoContainer(type) {
|
2015-12-25 16:55:45 +00:00
|
|
|
largeVideo && largeVideo.removeContainer(type);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns Promise
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
showLargeVideoContainer(type, show) {
|
2015-12-25 16:55:45 +00:00
|
|
|
if (!largeVideo) {
|
|
|
|
return Promise.reject();
|
|
|
|
}
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
const isVisible = this.isLargeContainerTypeVisible(type);
|
|
|
|
|
2015-12-25 16:55:45 +00:00
|
|
|
if (isVisible === show) {
|
|
|
|
return Promise.resolve();
|
|
|
|
}
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
const currentId = largeVideo.id;
|
|
|
|
let oldSmallVideo;
|
|
|
|
|
|
|
|
if (currentId) {
|
|
|
|
oldSmallVideo = this.getSmallVideo(currentId);
|
2016-03-18 20:00:55 +00:00
|
|
|
}
|
|
|
|
|
2016-03-22 21:12:25 +00:00
|
|
|
let containerTypeToShow = type;
|
2017-10-12 23:02:29 +00:00
|
|
|
|
2016-03-22 21:12:25 +00:00
|
|
|
// if we are hiding a container and there is focusedVideo
|
|
|
|
// (pinned remote video) use its video type,
|
|
|
|
// if not then use default type - large video
|
2017-10-12 23:02:29 +00:00
|
|
|
|
2016-03-22 21:12:25 +00:00
|
|
|
if (!show) {
|
2017-08-10 20:51:35 +00:00
|
|
|
const pinnedId = this.getPinnedId();
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
if (pinnedId) {
|
2016-03-24 18:16:42 +00:00
|
|
|
containerTypeToShow = this.getRemoteVideoType(pinnedId);
|
2017-10-12 23:02:29 +00:00
|
|
|
} else {
|
2016-03-22 21:12:25 +00:00
|
|
|
containerTypeToShow = VIDEO_CONTAINER_TYPE;
|
2017-10-12 23:02:29 +00:00
|
|
|
}
|
2016-03-22 21:12:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return largeVideo.showContainer(containerTypeToShow)
|
2016-03-18 20:00:55 +00:00
|
|
|
.then(() => {
|
2017-10-12 23:02:29 +00:00
|
|
|
if (oldSmallVideo) {
|
2016-03-18 20:00:55 +00:00
|
|
|
oldSmallVideo && oldSmallVideo.updateView();
|
2017-10-12 23:02:29 +00:00
|
|
|
}
|
2016-03-18 20:00:55 +00:00
|
|
|
});
|
2015-12-25 16:55:45 +00:00
|
|
|
},
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
isLargeContainerTypeVisible(type) {
|
2015-12-25 16:55:45 +00:00
|
|
|
return largeVideo && largeVideo.state === type;
|
2016-01-14 19:30:27 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the id of the current video shown on large.
|
2016-03-18 20:00:55 +00:00
|
|
|
* Currently used by tests (torture).
|
2016-01-14 19:30:27 +00:00
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
getLargeVideoID() {
|
2018-04-12 21:23:03 +00:00
|
|
|
return largeVideo && largeVideo.id;
|
2016-03-18 20:00:55 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the the current video shown on large.
|
|
|
|
* Currently used by tests (torture).
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
getLargeVideo() {
|
2016-03-18 20:00:55 +00:00
|
|
|
return largeVideo;
|
2016-03-15 20:26:22 +00:00
|
|
|
},
|
|
|
|
|
2016-05-07 01:50:37 +00:00
|
|
|
/**
|
|
|
|
* Sets the flipX state of the local video.
|
|
|
|
* @param {boolean} true for flipped otherwise false;
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
setLocalFlipX(val) {
|
2016-05-07 01:50:37 +00:00
|
|
|
this.localFlipX = val;
|
2017-01-06 01:18:07 +00:00
|
|
|
},
|
|
|
|
|
2017-01-20 20:26:25 +00:00
|
|
|
/**
|
|
|
|
* Returns the wrapper jquery selector for the largeVideo
|
|
|
|
* @returns {JQuerySelector} the wrapper jquery selector for the largeVideo
|
|
|
|
*/
|
|
|
|
getLargeVideoWrapper() {
|
|
|
|
return this.getCurrentlyOnLargeContainer().$wrapper;
|
2017-05-19 00:40:14 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the number of remove video ids.
|
|
|
|
*
|
|
|
|
* @returns {number} The number of remote videos.
|
|
|
|
*/
|
|
|
|
getRemoteVideosCount() {
|
|
|
|
return Object.keys(remoteVideos).length;
|
2017-08-17 16:43:22 +00:00
|
|
|
},
|
2017-10-12 23:02:29 +00:00
|
|
|
|
2018-08-08 18:48:23 +00:00
|
|
|
/**
|
|
|
|
* Helper method to invoke when the video layout has changed and elements
|
|
|
|
* have to be re-arranged and resized.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
refreshLayout() {
|
|
|
|
localVideoThumbnail && localVideoThumbnail.updateDOMLocation();
|
|
|
|
VideoLayout.resizeVideoArea();
|
2020-01-24 16:28:47 +00:00
|
|
|
|
|
|
|
// Rerender the thumbnails since they are dependant on the layout because of the tooltip positioning.
|
|
|
|
localVideoThumbnail && localVideoThumbnail.rerender();
|
|
|
|
Object.values(remoteVideos).forEach(remoteVideoThumbnail => remoteVideoThumbnail.rerender());
|
2018-08-08 18:48:23 +00:00
|
|
|
},
|
|
|
|
|
2019-01-01 21:19:34 +00:00
|
|
|
/**
|
|
|
|
* Cleans up any existing largeVideo instance.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_resetLargeVideo() {
|
|
|
|
if (largeVideo) {
|
|
|
|
largeVideo.destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
largeVideo = null;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Cleans up filmstrip state. While a separate {@code Filmstrip} exists, its
|
|
|
|
* implementation is mainly for querying and manipulating the DOM while
|
|
|
|
* state mostly remains in {@code VideoLayout}.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_resetFilmstrip() {
|
|
|
|
Object.keys(remoteVideos).forEach(remoteVideoId => {
|
|
|
|
this.removeParticipantContainer(remoteVideoId);
|
|
|
|
delete remoteVideos[remoteVideoId];
|
|
|
|
});
|
|
|
|
|
|
|
|
if (localVideoThumbnail) {
|
|
|
|
localVideoThumbnail.remove();
|
|
|
|
localVideoThumbnail = null;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-05-21 22:10:43 +00:00
|
|
|
/**
|
|
|
|
* Triggers an update of large video if the passed in participant is
|
|
|
|
* currently displayed on large video.
|
|
|
|
*
|
|
|
|
* @param {string} participantId - The participant ID that should trigger an
|
|
|
|
* update of large video if displayed.
|
2018-06-25 17:44:12 +00:00
|
|
|
* @param {boolean} force - Whether or not the large video update should
|
|
|
|
* happen no matter what.
|
2018-05-21 22:10:43 +00:00
|
|
|
* @returns {void}
|
|
|
|
*/
|
2018-06-25 17:44:12 +00:00
|
|
|
_updateLargeVideoIfDisplayed(participantId, force = false) {
|
2018-05-21 22:10:43 +00:00
|
|
|
if (this.isCurrentlyOnLarge(participantId)) {
|
2018-06-25 17:44:12 +00:00
|
|
|
this.updateLargeVideo(participantId, force);
|
2018-05-21 22:10:43 +00:00
|
|
|
}
|
2020-01-24 16:28:47 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles window resizes.
|
|
|
|
*/
|
|
|
|
onResize() {
|
|
|
|
VideoLayout.resizeVideoArea();
|
2017-01-06 01:18:07 +00:00
|
|
|
}
|
2015-12-14 12:26:50 +00:00
|
|
|
};
|
2015-01-07 14:54:03 +00:00
|
|
|
|
2015-12-14 12:26:50 +00:00
|
|
|
export default VideoLayout;
|