2017-12-05 03:27:17 +00:00
|
|
|
/* global $, APP, interfaceConfig */
|
2016-09-21 20:02:19 +00:00
|
|
|
|
2018-02-13 00:29:29 +00:00
|
|
|
/* eslint-disable no-unused-vars */
|
|
|
|
import React from 'react';
|
|
|
|
import ReactDOM from 'react-dom';
|
|
|
|
|
|
|
|
import { browser } from '../../../react/features/base/lib-jitsi-meet';
|
2020-12-08 14:01:16 +00:00
|
|
|
import { isTestModeEnabled } from '../../../react/features/base/testing';
|
2022-04-12 13:19:10 +00:00
|
|
|
import { FILMSTRIP_BREAKPOINT } from '../../../react/features/filmstrip';
|
2020-12-08 14:01:16 +00:00
|
|
|
import { ORIENTATION, LargeVideoBackground, updateLastLargeVideoMediaEvent } from '../../../react/features/large-video';
|
2019-11-14 13:23:45 +00:00
|
|
|
import { LAYOUTS, getCurrentLayout } from '../../../react/features/video-layout';
|
2018-02-13 00:29:29 +00:00
|
|
|
/* eslint-enable no-unused-vars */
|
2020-05-20 10:57:03 +00:00
|
|
|
import UIUtil from '../util/UIUtil';
|
2018-02-13 00:29:29 +00:00
|
|
|
|
2017-04-10 17:59:44 +00:00
|
|
|
import Filmstrip from './Filmstrip';
|
2016-09-21 20:02:19 +00:00
|
|
|
import LargeContainer from './LargeContainer';
|
|
|
|
|
|
|
|
// FIXME should be 'video'
|
2017-08-16 21:36:46 +00:00
|
|
|
export const VIDEO_CONTAINER_TYPE = 'camera';
|
2016-09-21 20:02:19 +00:00
|
|
|
|
|
|
|
const FADE_DURATION_MS = 300;
|
|
|
|
|
2020-12-08 14:01:16 +00:00
|
|
|
/**
|
|
|
|
* List of container events that we are going to process, will be added as listener to the
|
|
|
|
* container for every event in the list. The latest event will be stored in redux.
|
|
|
|
*/
|
|
|
|
const containerEvents = [
|
|
|
|
'abort', 'canplay', 'canplaythrough', 'emptied', 'ended', 'error', 'loadeddata', 'loadedmetadata', 'loadstart',
|
|
|
|
'pause', 'play', 'playing', 'ratechange', 'stalled', 'suspend', 'waiting'
|
|
|
|
];
|
|
|
|
|
2016-09-21 20:02:19 +00:00
|
|
|
/**
|
|
|
|
* Returns an array of the video dimensions, so that it keeps it's aspect
|
|
|
|
* ratio and fits available area with it's larger dimension. This method
|
|
|
|
* ensures that whole video will be visible and can leave empty areas.
|
|
|
|
*
|
2016-11-11 17:55:18 +00:00
|
|
|
* @param videoWidth the width of the video to position
|
|
|
|
* @param videoHeight the height of the video to position
|
|
|
|
* @param videoSpaceWidth the width of the available space
|
|
|
|
* @param videoSpaceHeight the height of the available space
|
2022-03-11 07:21:56 +00:00
|
|
|
* @param subtractFilmstrip whether to subtract the filmstrip or not
|
2016-09-21 20:02:19 +00:00
|
|
|
* @return an array with 2 elements, the video width and the video height
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
function computeDesktopVideoSize( // eslint-disable-line max-params
|
2017-10-02 23:08:07 +00:00
|
|
|
videoWidth,
|
|
|
|
videoHeight,
|
|
|
|
videoSpaceWidth,
|
2022-03-11 07:21:56 +00:00
|
|
|
videoSpaceHeight,
|
|
|
|
subtractFilmstrip) {
|
2019-11-14 13:23:45 +00:00
|
|
|
if (videoWidth === 0 || videoHeight === 0 || videoSpaceWidth === 0 || videoSpaceHeight === 0) {
|
2021-03-16 14:56:54 +00:00
|
|
|
// Avoid NaN values caused by division by 0.
|
2019-11-14 13:23:45 +00:00
|
|
|
return [ 0, 0 ];
|
|
|
|
}
|
2016-09-21 20:02:19 +00:00
|
|
|
|
2019-11-14 13:23:45 +00:00
|
|
|
const aspectRatio = videoWidth / videoHeight;
|
2016-09-21 20:02:19 +00:00
|
|
|
let availableWidth = Math.max(videoWidth, videoSpaceWidth);
|
|
|
|
let availableHeight = Math.max(videoHeight, videoSpaceHeight);
|
|
|
|
|
2017-06-14 23:52:59 +00:00
|
|
|
if (interfaceConfig.VERTICAL_FILMSTRIP) {
|
2022-03-11 07:21:56 +00:00
|
|
|
if (subtractFilmstrip) {
|
|
|
|
// eslint-disable-next-line no-param-reassign
|
|
|
|
videoSpaceWidth -= Filmstrip.getVerticalFilmstripWidth();
|
|
|
|
}
|
2017-06-14 23:52:59 +00:00
|
|
|
} else {
|
|
|
|
// eslint-disable-next-line no-param-reassign
|
|
|
|
videoSpaceHeight -= Filmstrip.getFilmstripHeight();
|
|
|
|
}
|
2016-09-21 20:02:19 +00:00
|
|
|
|
|
|
|
if (availableWidth / aspectRatio >= videoSpaceHeight) {
|
|
|
|
availableHeight = videoSpaceHeight;
|
|
|
|
availableWidth = availableHeight * aspectRatio;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (availableHeight * aspectRatio >= videoSpaceWidth) {
|
|
|
|
availableWidth = videoSpaceWidth;
|
|
|
|
availableHeight = availableWidth / aspectRatio;
|
|
|
|
}
|
|
|
|
|
|
|
|
return [ availableWidth, availableHeight ];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an array of the video dimensions. It respects the
|
|
|
|
* VIDEO_LAYOUT_FIT config, to fit the video to the screen, by hiding some parts
|
|
|
|
* of it, or to fit it to the height or width.
|
|
|
|
*
|
|
|
|
* @param videoWidth the original video width
|
|
|
|
* @param videoHeight the original video height
|
|
|
|
* @param videoSpaceWidth the width of the video space
|
|
|
|
* @param videoSpaceHeight the height of the video space
|
|
|
|
* @return an array with 2 elements, the video width and the video height
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
function computeCameraVideoSize( // eslint-disable-line max-params
|
2017-10-02 23:08:07 +00:00
|
|
|
videoWidth,
|
|
|
|
videoHeight,
|
|
|
|
videoSpaceWidth,
|
|
|
|
videoSpaceHeight,
|
|
|
|
videoLayoutFit) {
|
2019-11-14 13:23:45 +00:00
|
|
|
if (videoWidth === 0 || videoHeight === 0 || videoSpaceWidth === 0 || videoSpaceHeight === 0) {
|
2021-03-16 14:56:54 +00:00
|
|
|
// Avoid NaN values caused by division by 0.
|
2019-11-14 13:23:45 +00:00
|
|
|
return [ 0, 0 ];
|
|
|
|
}
|
|
|
|
|
2017-05-03 16:47:59 +00:00
|
|
|
const aspectRatio = videoWidth / videoHeight;
|
2021-08-26 09:23:19 +00:00
|
|
|
const videoSpaceRatio = videoSpaceWidth / videoSpaceHeight;
|
2017-10-12 23:02:29 +00:00
|
|
|
|
2017-06-09 19:22:07 +00:00
|
|
|
switch (videoLayoutFit) {
|
|
|
|
case 'height':
|
|
|
|
return [ videoSpaceHeight * aspectRatio, videoSpaceHeight ];
|
|
|
|
case 'width':
|
|
|
|
return [ videoSpaceWidth, videoSpaceWidth / aspectRatio ];
|
2021-08-26 09:23:19 +00:00
|
|
|
case 'nocrop':
|
|
|
|
return computeCameraVideoSize(
|
|
|
|
videoWidth,
|
|
|
|
videoHeight,
|
|
|
|
videoSpaceWidth,
|
|
|
|
videoSpaceHeight,
|
|
|
|
videoSpaceRatio < aspectRatio ? 'width' : 'height');
|
2017-06-09 19:22:07 +00:00
|
|
|
case 'both': {
|
|
|
|
const maxZoomCoefficient = interfaceConfig.MAXIMUM_ZOOMING_COEFFICIENT
|
|
|
|
|| Infinity;
|
|
|
|
|
|
|
|
if (videoSpaceRatio === aspectRatio) {
|
2017-10-12 23:02:29 +00:00
|
|
|
return [ videoSpaceWidth, videoSpaceHeight ];
|
2016-09-21 20:02:19 +00:00
|
|
|
}
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
let [ width, height ] = computeCameraVideoSize(
|
2017-06-09 19:22:07 +00:00
|
|
|
videoWidth,
|
|
|
|
videoHeight,
|
|
|
|
videoSpaceWidth,
|
|
|
|
videoSpaceHeight,
|
|
|
|
videoSpaceRatio < aspectRatio ? 'height' : 'width');
|
|
|
|
const maxWidth = videoSpaceWidth * maxZoomCoefficient;
|
|
|
|
const maxHeight = videoSpaceHeight * maxZoomCoefficient;
|
|
|
|
|
|
|
|
if (width > maxWidth) {
|
|
|
|
width = maxWidth;
|
|
|
|
height = width / aspectRatio;
|
|
|
|
} else if (height > maxHeight) {
|
|
|
|
height = maxHeight;
|
|
|
|
width = height * aspectRatio;
|
2016-09-21 20:02:19 +00:00
|
|
|
}
|
2017-10-12 23:02:29 +00:00
|
|
|
|
|
|
|
return [ width, height ];
|
2017-06-09 19:22:07 +00:00
|
|
|
}
|
|
|
|
default:
|
|
|
|
return [ videoWidth, videoHeight ];
|
2016-09-21 20:02:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an array of the video horizontal and vertical indents,
|
|
|
|
* so that if fits its parent.
|
|
|
|
*
|
|
|
|
* @return an array with 2 elements, the horizontal indent and the vertical
|
|
|
|
* indent
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
function getCameraVideoPosition( // eslint-disable-line max-params
|
2017-10-02 23:08:07 +00:00
|
|
|
videoWidth,
|
|
|
|
videoHeight,
|
|
|
|
videoSpaceWidth,
|
|
|
|
videoSpaceHeight) {
|
2016-09-21 20:02:19 +00:00
|
|
|
// Parent height isn't completely calculated when we position the video in
|
|
|
|
// full screen mode and this is why we use the screen height in this case.
|
|
|
|
// Need to think it further at some point and implement it properly.
|
|
|
|
if (UIUtil.isFullScreen()) {
|
2017-10-12 23:02:29 +00:00
|
|
|
// eslint-disable-next-line no-param-reassign
|
2016-09-21 20:02:19 +00:00
|
|
|
videoSpaceHeight = window.innerHeight;
|
|
|
|
}
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
const horizontalIndent = (videoSpaceWidth - videoWidth) / 2;
|
|
|
|
const verticalIndent = (videoSpaceHeight - videoHeight) / 2;
|
2016-09-21 20:02:19 +00:00
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
return { horizontalIndent,
|
|
|
|
verticalIndent };
|
2016-09-21 20:02:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Container for user video.
|
|
|
|
*/
|
|
|
|
export class VideoContainer extends LargeContainer {
|
2017-10-12 23:02:29 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
get $video() {
|
2016-09-21 20:02:19 +00:00
|
|
|
return $('#largeVideo');
|
|
|
|
}
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
get id() {
|
2017-06-15 15:01:32 +00:00
|
|
|
return this.userId;
|
2016-09-21 20:02:19 +00:00
|
|
|
}
|
|
|
|
|
2017-02-08 19:57:55 +00:00
|
|
|
/**
|
|
|
|
* Creates new VideoContainer instance.
|
|
|
|
* @param resizeContainer {Function} function that takes care of the size
|
|
|
|
* of the video container.
|
|
|
|
*/
|
2021-01-21 20:46:47 +00:00
|
|
|
constructor(resizeContainer) {
|
2016-09-21 20:02:19 +00:00
|
|
|
super();
|
|
|
|
this.stream = null;
|
2017-06-15 15:01:32 +00:00
|
|
|
this.userId = null;
|
2016-09-21 20:02:19 +00:00
|
|
|
this.videoType = null;
|
|
|
|
this.localFlipX = true;
|
2017-02-08 19:57:55 +00:00
|
|
|
this.resizeContainer = resizeContainer;
|
2016-09-21 20:02:19 +00:00
|
|
|
|
2018-02-13 00:29:29 +00:00
|
|
|
/**
|
|
|
|
* Whether the background should fit the height of the container
|
|
|
|
* (portrait) or fit the width of the container (landscape).
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @type {string|null}
|
|
|
|
*/
|
|
|
|
this._backgroundOrientation = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Flag indicates whether or not the background should be rendered.
|
|
|
|
* If the background will not be visible then it is hidden to save
|
|
|
|
* on performance.
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
this._hideBackground = true;
|
|
|
|
|
2020-03-02 13:42:25 +00:00
|
|
|
this._isHidden = false;
|
|
|
|
|
2016-09-24 18:24:18 +00:00
|
|
|
/**
|
|
|
|
* Flag indicates whether or not the avatar is currently displayed.
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
this.avatarDisplayed = false;
|
2016-09-21 20:02:19 +00:00
|
|
|
this.$avatar = $('#dominantSpeaker');
|
2016-09-24 18:19:52 +00:00
|
|
|
|
2016-09-24 18:24:18 +00:00
|
|
|
/**
|
|
|
|
* A jQuery selector of the remote connection message.
|
|
|
|
* @type {jQuery|HTMLElement}
|
|
|
|
*/
|
|
|
|
this.$remoteConnectionMessage = $('#remoteConnectionMessage');
|
|
|
|
|
2017-07-31 23:33:22 +00:00
|
|
|
this.$remotePresenceMessage = $('#remotePresenceMessage');
|
|
|
|
|
2016-09-21 20:02:19 +00:00
|
|
|
this.$wrapper = $('#largeVideoWrapper');
|
|
|
|
|
2017-06-20 21:40:18 +00:00
|
|
|
/**
|
|
|
|
* FIXME: currently using parent() because I can't come up with name
|
|
|
|
* for id. We'll need to probably refactor the HTML related to the large
|
|
|
|
* video anyway.
|
|
|
|
*/
|
|
|
|
this.$wrapperParent = this.$wrapper.parent();
|
2019-02-07 03:19:02 +00:00
|
|
|
this.avatarHeight = $('#dominantSpeakerAvatarContainer').height();
|
2020-12-14 21:38:29 +00:00
|
|
|
this.$video[0].onplaying = function(event) {
|
2017-02-08 19:57:55 +00:00
|
|
|
if (typeof resizeContainer === 'function') {
|
|
|
|
resizeContainer(event);
|
2016-09-24 18:19:52 +00:00
|
|
|
}
|
2020-12-14 21:38:29 +00:00
|
|
|
};
|
2017-05-16 20:48:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A Set of functions to invoke when the video element resizes.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
this._resizeListeners = new Set();
|
|
|
|
|
|
|
|
this.$video[0].onresize = this._onResize.bind(this);
|
2020-12-08 14:01:16 +00:00
|
|
|
|
|
|
|
if (isTestModeEnabled(APP.store.getState())) {
|
|
|
|
const cb = name => APP.store.dispatch(updateLastLargeVideoMediaEvent(name));
|
|
|
|
|
|
|
|
containerEvents.forEach(event => {
|
|
|
|
this.$video[0].addEventListener(event, cb.bind(this, event));
|
|
|
|
});
|
|
|
|
}
|
2017-05-16 20:48:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a function to the known subscribers of video element resize
|
|
|
|
* events.
|
|
|
|
*
|
|
|
|
* @param {Function} callback - The subscriber to notify when the video
|
|
|
|
* element resizes.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
addResizeListener(callback) {
|
|
|
|
this._resizeListeners.add(callback);
|
2016-09-21 20:02:19 +00:00
|
|
|
}
|
|
|
|
|
2017-07-10 10:06:48 +00:00
|
|
|
/**
|
|
|
|
* Obtains media stream ID of the underlying {@link JitsiTrack}.
|
|
|
|
* @return {string|null}
|
|
|
|
*/
|
|
|
|
getStreamID() {
|
|
|
|
return this.stream ? this.stream.getId() : null;
|
|
|
|
}
|
|
|
|
|
2016-09-21 20:02:19 +00:00
|
|
|
/**
|
|
|
|
* Get size of video element.
|
|
|
|
* @returns {{width, height}}
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
getStreamSize() {
|
|
|
|
const video = this.$video[0];
|
|
|
|
|
|
|
|
|
2016-09-21 20:02:19 +00:00
|
|
|
return {
|
|
|
|
width: video.videoWidth,
|
|
|
|
height: video.videoHeight
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculate optimal video size for specified container size.
|
|
|
|
* @param {number} containerWidth container width
|
|
|
|
* @param {number} containerHeight container height
|
2022-03-11 07:21:56 +00:00
|
|
|
* @param {number} verticalFilmstripWidth current width of the vertical filmstrip
|
2016-09-21 20:02:19 +00:00
|
|
|
* @returns {{availableWidth, availableHeight}}
|
|
|
|
*/
|
2022-03-11 07:21:56 +00:00
|
|
|
_getVideoSize(containerWidth, containerHeight, verticalFilmstripWidth) {
|
2017-10-12 23:02:29 +00:00
|
|
|
const { width, height } = this.getStreamSize();
|
2017-05-03 16:47:59 +00:00
|
|
|
|
2016-09-21 20:02:19 +00:00
|
|
|
if (this.stream && this.isScreenSharing()) {
|
2017-05-03 16:47:59 +00:00
|
|
|
return computeDesktopVideoSize(width,
|
2016-09-21 20:02:19 +00:00
|
|
|
height,
|
|
|
|
containerWidth,
|
2022-03-11 07:21:56 +00:00
|
|
|
containerHeight,
|
|
|
|
verticalFilmstripWidth < FILMSTRIP_BREAKPOINT);
|
2016-09-21 20:02:19 +00:00
|
|
|
}
|
2017-05-03 16:47:59 +00:00
|
|
|
|
|
|
|
return computeCameraVideoSize(width,
|
|
|
|
height,
|
|
|
|
containerWidth,
|
2017-06-09 19:22:07 +00:00
|
|
|
containerHeight,
|
|
|
|
interfaceConfig.VIDEO_LAYOUT_FIT);
|
2016-09-21 20:02:19 +00:00
|
|
|
}
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
/* eslint-disable max-params */
|
2016-09-21 20:02:19 +00:00
|
|
|
/**
|
|
|
|
* Calculate optimal video position (offset for top left corner)
|
|
|
|
* for specified video size and container size.
|
|
|
|
* @param {number} width video width
|
|
|
|
* @param {number} height video height
|
|
|
|
* @param {number} containerWidth container width
|
|
|
|
* @param {number} containerHeight container height
|
2022-03-11 07:21:56 +00:00
|
|
|
* @param {number} verticalFilmstripWidth current width of the vertical filmstrip
|
2016-09-21 20:02:19 +00:00
|
|
|
* @returns {{horizontalIndent, verticalIndent}}
|
|
|
|
*/
|
2022-03-11 07:21:56 +00:00
|
|
|
getVideoPosition(width, height, containerWidth, containerHeight, verticalFilmstripWidth) {
|
2019-05-08 18:00:02 +00:00
|
|
|
let containerWidthToUse = containerWidth;
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
/* eslint-enable max-params */
|
2016-09-21 20:02:19 +00:00
|
|
|
if (this.stream && this.isScreenSharing()) {
|
2022-03-11 07:21:56 +00:00
|
|
|
if (interfaceConfig.VERTICAL_FILMSTRIP && verticalFilmstripWidth < FILMSTRIP_BREAKPOINT) {
|
2020-02-10 15:27:43 +00:00
|
|
|
containerWidthToUse -= Filmstrip.getVerticalFilmstripWidth();
|
2017-06-14 23:52:59 +00:00
|
|
|
}
|
|
|
|
|
2019-05-08 18:00:02 +00:00
|
|
|
return getCameraVideoPosition(width,
|
2016-09-21 20:02:19 +00:00
|
|
|
height,
|
2019-05-08 18:00:02 +00:00
|
|
|
containerWidthToUse,
|
2016-09-21 20:02:19 +00:00
|
|
|
containerHeight);
|
2017-10-12 23:02:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return getCameraVideoPosition(width,
|
2016-09-21 20:02:19 +00:00
|
|
|
height,
|
2019-05-08 18:00:02 +00:00
|
|
|
containerWidthToUse,
|
2016-09-21 20:02:19 +00:00
|
|
|
containerHeight);
|
2017-10-12 23:02:29 +00:00
|
|
|
|
2016-09-21 20:02:19 +00:00
|
|
|
}
|
|
|
|
|
2016-09-24 18:24:18 +00:00
|
|
|
/**
|
2017-07-31 23:33:22 +00:00
|
|
|
* Updates the positioning of the remote connection presence message and the
|
|
|
|
* connection status message which escribes that the remote user is having
|
|
|
|
* connectivity issues.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
2016-09-24 18:24:18 +00:00
|
|
|
*/
|
2017-07-31 23:33:22 +00:00
|
|
|
positionRemoteStatusMessages() {
|
|
|
|
this._positionParticipantStatus(this.$remoteConnectionMessage);
|
|
|
|
this._positionParticipantStatus(this.$remotePresenceMessage);
|
|
|
|
}
|
2016-09-24 18:24:18 +00:00
|
|
|
|
2017-07-31 23:33:22 +00:00
|
|
|
/**
|
|
|
|
* Modifies the position of the passed in jQuery object so it displays
|
|
|
|
* in the middle of the video container or below the avatar.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_positionParticipantStatus($element) {
|
2016-09-24 18:24:18 +00:00
|
|
|
if (this.avatarDisplayed) {
|
2019-02-07 03:19:02 +00:00
|
|
|
const $avatarImage = $('#dominantSpeakerAvatarContainer');
|
2017-10-12 23:02:29 +00:00
|
|
|
|
2017-07-31 23:33:22 +00:00
|
|
|
$element.css(
|
2016-09-24 18:24:18 +00:00
|
|
|
'top',
|
|
|
|
$avatarImage.offset().top + $avatarImage.height() + 10);
|
|
|
|
} else {
|
2017-10-12 23:02:29 +00:00
|
|
|
const height = $element.height();
|
|
|
|
const parentHeight = $element.parent().height();
|
|
|
|
|
|
|
|
$element.css('top', (parentHeight / 2) - (height / 2));
|
2016-09-24 18:24:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
resize(containerWidth, containerHeight, animate = false) {
|
2017-02-28 05:03:48 +00:00
|
|
|
// XXX Prevent TypeError: undefined is not an object when the Web
|
|
|
|
// browser does not support WebRTC (yet).
|
|
|
|
if (this.$video.length === 0) {
|
|
|
|
return;
|
|
|
|
}
|
2022-03-11 07:21:56 +00:00
|
|
|
const state = APP.store.getState();
|
|
|
|
const currentLayout = getCurrentLayout(state);
|
|
|
|
|
|
|
|
const verticalFilmstripWidth = state['features/filmstrip'].width?.current;
|
2019-11-14 13:23:45 +00:00
|
|
|
|
2022-04-12 13:19:10 +00:00
|
|
|
if (currentLayout === LAYOUTS.TILE_VIEW || currentLayout === LAYOUTS.STAGE_FILMSTRIP_VIEW) {
|
2019-11-14 13:23:45 +00:00
|
|
|
// We don't need to resize the large video since it won't be displayed and we'll resize when returning back
|
|
|
|
// to stage view.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-11-15 12:33:01 +00:00
|
|
|
this.positionRemoteStatusMessages();
|
|
|
|
|
2022-03-11 07:21:56 +00:00
|
|
|
const [ width, height ] = this._getVideoSize(containerWidth, containerHeight, verticalFilmstripWidth);
|
2017-02-28 05:03:48 +00:00
|
|
|
|
2019-11-14 13:23:45 +00:00
|
|
|
if (width === 0 || height === 0) {
|
2021-03-16 14:56:54 +00:00
|
|
|
// We don't need to set 0 for width or height since the visibility is controlled by the visibility css prop
|
2019-11-14 13:23:45 +00:00
|
|
|
// on the largeVideoElementsContainer. Also if the width/height of the video element is 0 the attached
|
|
|
|
// stream won't be played. Normally if we attach a new stream we won't resize the video element until the
|
|
|
|
// stream has been played. But setting width/height to 0 will prevent the video from playing.
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2017-05-10 10:07:00 +00:00
|
|
|
|
2017-06-09 19:22:07 +00:00
|
|
|
if ((containerWidth > width) || (containerHeight > height)) {
|
2019-11-14 13:23:45 +00:00
|
|
|
this._backgroundOrientation = containerWidth > width ? ORIENTATION.LANDSCAPE : ORIENTATION.PORTRAIT;
|
2018-02-13 00:29:29 +00:00
|
|
|
this._hideBackground = false;
|
|
|
|
} else {
|
|
|
|
this._hideBackground = true;
|
2017-05-10 10:07:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-13 00:29:29 +00:00
|
|
|
this._updateBackground();
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
const { horizontalIndent, verticalIndent }
|
2022-03-11 07:21:56 +00:00
|
|
|
= this.getVideoPosition(width, height, containerWidth, containerHeight, verticalFilmstripWidth);
|
2016-09-21 20:02:19 +00:00
|
|
|
|
|
|
|
this.$wrapper.animate({
|
2017-10-12 23:02:29 +00:00
|
|
|
width,
|
|
|
|
height,
|
2016-09-21 20:02:19 +00:00
|
|
|
|
|
|
|
top: verticalIndent,
|
|
|
|
bottom: verticalIndent,
|
|
|
|
|
|
|
|
left: horizontalIndent,
|
|
|
|
right: horizontalIndent
|
|
|
|
}, {
|
|
|
|
queue: false,
|
|
|
|
duration: animate ? 500 : 0
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-05-16 20:48:14 +00:00
|
|
|
/**
|
|
|
|
* Removes a function from the known subscribers of video element resize
|
|
|
|
* events.
|
|
|
|
*
|
|
|
|
* @param {Function} callback - The callback to remove from known
|
|
|
|
* subscribers of video resize events.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
removeResizeListener(callback) {
|
|
|
|
this._resizeListeners.delete(callback);
|
|
|
|
}
|
|
|
|
|
2016-09-21 20:02:19 +00:00
|
|
|
/**
|
|
|
|
* Update video stream.
|
2017-06-15 15:01:32 +00:00
|
|
|
* @param {string} userID
|
2016-09-21 20:02:19 +00:00
|
|
|
* @param {JitsiTrack?} stream new stream
|
|
|
|
* @param {string} videoType video type
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
setStream(userID, stream, videoType) {
|
2017-06-15 15:01:32 +00:00
|
|
|
this.userId = userID;
|
2022-08-05 09:11:09 +00:00
|
|
|
if (this.stream === stream && !stream?.forceStreamToReattach) {
|
2017-02-08 19:57:55 +00:00
|
|
|
// Handles the use case for the remote participants when the
|
|
|
|
// videoType is received with delay after turning on/off the
|
|
|
|
// desktop sharing.
|
2017-10-12 23:02:29 +00:00
|
|
|
if (this.videoType !== videoType) {
|
2017-02-08 19:57:55 +00:00
|
|
|
this.videoType = videoType;
|
|
|
|
this.resizeContainer();
|
|
|
|
}
|
2017-10-12 23:02:29 +00:00
|
|
|
|
2016-09-24 18:19:52 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-08-05 09:11:09 +00:00
|
|
|
if (stream?.forceStreamToReattach) {
|
|
|
|
delete stream.forceStreamToReattach;
|
|
|
|
}
|
|
|
|
|
2016-09-21 20:02:19 +00:00
|
|
|
// detach old stream
|
2022-08-05 09:11:09 +00:00
|
|
|
if (this.stream && this.$video[0]) {
|
2016-09-21 20:02:19 +00:00
|
|
|
this.stream.detach(this.$video[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.stream = stream;
|
|
|
|
this.videoType = videoType;
|
|
|
|
|
|
|
|
if (!stream) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-08-05 09:11:09 +00:00
|
|
|
if (this.$video[0]) {
|
|
|
|
stream.attach(this.$video[0]);
|
2017-05-10 10:07:00 +00:00
|
|
|
|
2022-08-05 09:11:09 +00:00
|
|
|
// Ensure large video gets play() called on it when a new stream is attached to it. This is necessary in the
|
|
|
|
// case of Safari as autoplay doesn't kick-in automatically on Safari 15 and newer versions.
|
|
|
|
browser.isWebKitBased() && this.$video[0].play();
|
2021-11-08 21:28:38 +00:00
|
|
|
|
2022-08-05 09:11:09 +00:00
|
|
|
const flipX = stream.isLocal() && this.localFlipX && !this.isScreenSharing();
|
2018-02-13 00:29:29 +00:00
|
|
|
|
2022-08-05 09:11:09 +00:00
|
|
|
this.$video.css({
|
|
|
|
transform: flipX ? 'scaleX(-1)' : 'none'
|
|
|
|
});
|
|
|
|
this._updateBackground();
|
|
|
|
}
|
2016-09-21 20:02:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Changes the flipX state of the local video.
|
|
|
|
* @param val {boolean} true if flipped.
|
|
|
|
*/
|
|
|
|
setLocalFlipX(val) {
|
|
|
|
this.localFlipX = val;
|
2017-10-12 23:02:29 +00:00
|
|
|
if (!this.$video || !this.stream || !this.stream.isLocal()) {
|
2016-09-21 20:02:19 +00:00
|
|
|
return;
|
2017-10-12 23:02:29 +00:00
|
|
|
}
|
2016-09-21 20:02:19 +00:00
|
|
|
this.$video.css({
|
|
|
|
transform: this.localFlipX ? 'scaleX(-1)' : 'none'
|
|
|
|
});
|
2017-05-10 10:07:00 +00:00
|
|
|
|
2018-02-13 00:29:29 +00:00
|
|
|
this._updateBackground();
|
2016-09-21 20:02:19 +00:00
|
|
|
}
|
|
|
|
|
2017-05-10 10:07:00 +00:00
|
|
|
|
2016-09-21 20:02:19 +00:00
|
|
|
/**
|
|
|
|
* Check if current video stream is screen sharing.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
isScreenSharing() {
|
2016-09-21 20:02:19 +00:00
|
|
|
return this.videoType === 'desktop';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show or hide user avatar.
|
|
|
|
* @param {boolean} show
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
showAvatar(show) {
|
2017-08-16 21:36:46 +00:00
|
|
|
this.$avatar.css('visibility', show ? 'visible' : 'hidden');
|
2016-09-24 18:24:18 +00:00
|
|
|
this.avatarDisplayed = show;
|
2016-09-21 20:02:19 +00:00
|
|
|
|
2017-12-05 03:27:17 +00:00
|
|
|
APP.API.notifyLargeVideoVisibilityChanged(show);
|
2016-09-21 20:02:19 +00:00
|
|
|
}
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
/**
|
|
|
|
* We are doing fadeOut/fadeIn animations on parent div which wraps
|
|
|
|
* largeVideo, because when Temasys plugin is in use it replaces
|
|
|
|
* <video> elements with plugin <object> tag. In Safari jQuery is
|
|
|
|
* unable to store values on this plugin object which breaks all
|
|
|
|
* animation effects performed on it directly.
|
2018-06-27 09:43:13 +00:00
|
|
|
*
|
|
|
|
* TODO: refactor this since Temasys is no longer supported.
|
2017-10-12 23:02:29 +00:00
|
|
|
*/
|
|
|
|
show() {
|
|
|
|
return new Promise(resolve => {
|
2017-06-20 21:40:18 +00:00
|
|
|
this.$wrapperParent.css('visibility', 'visible').fadeTo(
|
2016-09-21 20:02:19 +00:00
|
|
|
FADE_DURATION_MS,
|
|
|
|
1,
|
|
|
|
() => {
|
2020-03-02 13:42:25 +00:00
|
|
|
this._isHidden = false;
|
|
|
|
this._updateBackground();
|
2016-09-21 20:02:19 +00:00
|
|
|
resolve();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
/**
|
2017-11-16 18:26:14 +00:00
|
|
|
*
|
2017-10-12 23:02:29 +00:00
|
|
|
*/
|
|
|
|
hide() {
|
2016-09-21 20:02:19 +00:00
|
|
|
// as the container is hidden/replaced by another container
|
|
|
|
// hide its avatar
|
|
|
|
this.showAvatar(false);
|
2017-10-12 23:02:29 +00:00
|
|
|
|
|
|
|
return new Promise(resolve => {
|
2017-06-20 21:40:18 +00:00
|
|
|
this.$wrapperParent.fadeTo(FADE_DURATION_MS, 0, () => {
|
|
|
|
this.$wrapperParent.css('visibility', 'hidden');
|
2020-03-02 13:42:25 +00:00
|
|
|
this._isHidden = true;
|
|
|
|
this._updateBackground();
|
2016-09-21 20:02:19 +00:00
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return {boolean} switch on dominant speaker event if on stage.
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
stayOnStage() {
|
2016-09-21 20:02:19 +00:00
|
|
|
return false;
|
|
|
|
}
|
2017-01-25 22:53:58 +00:00
|
|
|
|
2017-05-16 20:48:14 +00:00
|
|
|
/**
|
|
|
|
* Callback invoked when the video element changes dimensions.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onResize() {
|
|
|
|
this._resizeListeners.forEach(callback => callback());
|
|
|
|
}
|
2017-05-10 10:07:00 +00:00
|
|
|
|
|
|
|
/**
|
2018-02-13 00:29:29 +00:00
|
|
|
* Attaches and/or updates a React Component to be used as a background for
|
|
|
|
* the large video, to display blurred video and fill up empty space not
|
|
|
|
* taken up by the large video.
|
2017-05-10 10:07:00 +00:00
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2018-02-13 00:29:29 +00:00
|
|
|
_updateBackground() {
|
2018-03-13 21:37:35 +00:00
|
|
|
// Do not the background display on browsers that might experience
|
2018-06-15 21:41:37 +00:00
|
|
|
// performance issues from the presence of the background or if
|
|
|
|
// explicitly disabled.
|
|
|
|
if (interfaceConfig.DISABLE_VIDEO_BACKGROUND
|
2018-05-01 18:38:29 +00:00
|
|
|
|| browser.isFirefox()
|
2021-03-08 15:47:58 +00:00
|
|
|
|| browser.isWebKitBased()) {
|
2018-02-13 00:29:29 +00:00
|
|
|
return;
|
2017-08-28 21:49:24 +00:00
|
|
|
}
|
2018-02-13 00:29:29 +00:00
|
|
|
|
|
|
|
ReactDOM.render(
|
2018-06-15 21:41:37 +00:00
|
|
|
<LargeVideoBackground
|
2020-03-02 13:42:25 +00:00
|
|
|
hidden = { this._hideBackground || this._isHidden }
|
2018-02-13 00:29:29 +00:00
|
|
|
mirror = {
|
|
|
|
this.stream
|
|
|
|
&& this.stream.isLocal()
|
|
|
|
&& this.localFlipX
|
|
|
|
}
|
|
|
|
orientationFit = { this._backgroundOrientation }
|
2018-05-01 18:38:29 +00:00
|
|
|
videoElement = { this.$video && this.$video[0] }
|
2018-02-13 00:29:29 +00:00
|
|
|
videoTrack = { this.stream } />,
|
|
|
|
document.getElementById('largeVideoBackgroundContainer')
|
|
|
|
);
|
2017-05-10 10:07:00 +00:00
|
|
|
}
|
2016-09-21 20:02:19 +00:00
|
|
|
}
|