2015-12-14 12:26:50 +00:00
|
|
|
/* global $, APP, interfaceConfig */
|
2015-09-11 02:42:15 +00:00
|
|
|
/* jshint -W101 */
|
2015-12-25 16:55:45 +00:00
|
|
|
|
2015-12-14 12:26:50 +00:00
|
|
|
import UIUtil from "../util/UIUtil";
|
|
|
|
import UIEvents from "../../../service/UI/UIEvents";
|
2015-12-25 16:55:45 +00:00
|
|
|
import LargeContainer from './LargeContainer';
|
2016-02-24 21:05:24 +00:00
|
|
|
import FilmStrip from './FilmStrip';
|
2016-01-21 17:38:54 +00:00
|
|
|
import Avatar from "../avatar/Avatar";
|
2016-01-22 15:08:58 +00:00
|
|
|
import {createDeferred} from '../../util/helpers';
|
2015-12-14 12:26:50 +00:00
|
|
|
|
2016-01-22 15:08:58 +00:00
|
|
|
const FADE_DURATION_MS = 300;
|
2015-06-23 08:00:46 +00:00
|
|
|
|
2016-03-18 20:00:55 +00:00
|
|
|
export const VIDEO_CONTAINER_TYPE = "camera";
|
|
|
|
|
2016-01-15 14:59:35 +00:00
|
|
|
/**
|
|
|
|
* Get stream id.
|
|
|
|
* @param {JitsiTrack?} stream
|
|
|
|
*/
|
2016-01-22 15:08:58 +00:00
|
|
|
function getStreamOwnerId(stream) {
|
|
|
|
if (!stream) {
|
2016-01-06 22:39:13 +00:00
|
|
|
return;
|
2016-01-22 15:08:58 +00:00
|
|
|
}
|
|
|
|
if (stream.isLocal()) { // local stream doesn't have method "getParticipantId"
|
2016-07-08 01:44:04 +00:00
|
|
|
return APP.conference.getMyUserId();
|
2015-07-28 21:52:32 +00:00
|
|
|
} else {
|
2015-12-25 16:55:45 +00:00
|
|
|
return stream.getParticipantId();
|
2015-06-23 08:00:46 +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.
|
|
|
|
*
|
|
|
|
* @return an array with 2 elements, the video width and the video height
|
|
|
|
*/
|
|
|
|
function getDesktopVideoSize(videoWidth,
|
|
|
|
videoHeight,
|
|
|
|
videoSpaceWidth,
|
|
|
|
videoSpaceHeight) {
|
|
|
|
|
2015-12-25 16:55:45 +00:00
|
|
|
let aspectRatio = videoWidth / videoHeight;
|
2015-06-23 08:00:46 +00:00
|
|
|
|
2015-12-25 16:55:45 +00:00
|
|
|
let availableWidth = Math.max(videoWidth, videoSpaceWidth);
|
|
|
|
let availableHeight = Math.max(videoHeight, videoSpaceHeight);
|
2015-06-23 08:00:46 +00:00
|
|
|
|
2016-02-24 21:05:24 +00:00
|
|
|
videoSpaceHeight -= FilmStrip.getFilmStripHeight();
|
2015-06-23 08:00:46 +00:00
|
|
|
|
2015-12-25 16:55:45 +00:00
|
|
|
if (availableWidth / aspectRatio >= videoSpaceHeight) {
|
2015-06-23 08:00:46 +00:00
|
|
|
availableHeight = videoSpaceHeight;
|
|
|
|
availableWidth = availableHeight * aspectRatio;
|
|
|
|
}
|
|
|
|
|
2015-12-25 16:55:45 +00:00
|
|
|
if (availableHeight * aspectRatio >= videoSpaceWidth) {
|
2015-06-23 08:00:46 +00:00
|
|
|
availableWidth = videoSpaceWidth;
|
|
|
|
availableHeight = availableWidth / aspectRatio;
|
|
|
|
}
|
|
|
|
|
2016-01-26 19:17:38 +00:00
|
|
|
return [ availableWidth, availableHeight ];
|
2015-06-23 08:00:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2015-10-06 20:02:46 +00:00
|
|
|
* 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.
|
2015-06-23 08:00:46 +00:00
|
|
|
*
|
2015-10-06 20:02:46 +00:00
|
|
|
* @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
|
2015-06-23 08:00:46 +00:00
|
|
|
* @return an array with 2 elements, the video width and the video height
|
|
|
|
*/
|
|
|
|
function getCameraVideoSize(videoWidth,
|
|
|
|
videoHeight,
|
|
|
|
videoSpaceWidth,
|
|
|
|
videoSpaceHeight) {
|
2015-10-06 15:41:46 +00:00
|
|
|
|
2015-12-25 16:55:45 +00:00
|
|
|
let aspectRatio = videoWidth / videoHeight;
|
2015-06-23 08:00:46 +00:00
|
|
|
|
2015-12-25 16:55:45 +00:00
|
|
|
let availableWidth = videoWidth;
|
|
|
|
let availableHeight = videoHeight;
|
2015-06-23 08:00:46 +00:00
|
|
|
|
2015-10-06 15:41:46 +00:00
|
|
|
if (interfaceConfig.VIDEO_LAYOUT_FIT == 'height') {
|
2015-06-23 08:00:46 +00:00
|
|
|
availableHeight = videoSpaceHeight;
|
2015-10-06 15:41:46 +00:00
|
|
|
availableWidth = availableHeight*aspectRatio;
|
2015-06-23 08:00:46 +00:00
|
|
|
}
|
2015-10-06 15:41:46 +00:00
|
|
|
else if (interfaceConfig.VIDEO_LAYOUT_FIT == 'width') {
|
2015-06-23 08:00:46 +00:00
|
|
|
availableWidth = videoSpaceWidth;
|
2015-10-06 15:41:46 +00:00
|
|
|
availableHeight = availableWidth/aspectRatio;
|
2015-06-23 08:00:46 +00:00
|
|
|
}
|
2015-10-06 15:41:46 +00:00
|
|
|
else if (interfaceConfig.VIDEO_LAYOUT_FIT == 'both') {
|
|
|
|
availableWidth = Math.max(videoWidth, videoSpaceWidth);
|
|
|
|
availableHeight = Math.max(videoHeight, videoSpaceHeight);
|
|
|
|
|
|
|
|
if (availableWidth / aspectRatio < videoSpaceHeight) {
|
|
|
|
availableHeight = videoSpaceHeight;
|
|
|
|
availableWidth = availableHeight * aspectRatio;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (availableHeight * aspectRatio < videoSpaceWidth) {
|
|
|
|
availableWidth = videoSpaceWidth;
|
|
|
|
availableHeight = availableWidth / aspectRatio;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-23 08:00:46 +00:00
|
|
|
|
2016-01-26 19:17:38 +00:00
|
|
|
return [ availableWidth, availableHeight ];
|
2015-06-23 08:00:46 +00:00
|
|
|
}
|
|
|
|
|
2015-06-29 14:24:21 +00:00
|
|
|
/**
|
2015-12-25 16:55:45 +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
|
2015-06-29 14:24:21 +00:00
|
|
|
*/
|
2015-12-25 16:55:45 +00:00
|
|
|
function getCameraVideoPosition(videoWidth,
|
|
|
|
videoHeight,
|
|
|
|
videoSpaceWidth,
|
|
|
|
videoSpaceHeight) {
|
|
|
|
// 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()) {
|
|
|
|
videoSpaceHeight = window.innerHeight;
|
2015-06-29 14:24:21 +00:00
|
|
|
}
|
2015-12-25 16:55:45 +00:00
|
|
|
|
|
|
|
let horizontalIndent = (videoSpaceWidth - videoWidth) / 2;
|
|
|
|
let verticalIndent = (videoSpaceHeight - videoHeight) / 2;
|
|
|
|
|
|
|
|
return { horizontalIndent, verticalIndent };
|
2015-06-29 14:24:21 +00:00
|
|
|
}
|
2015-06-23 08:00:46 +00:00
|
|
|
|
2015-07-29 19:39:09 +00:00
|
|
|
/**
|
2015-12-25 16:55:45 +00:00
|
|
|
* Returns an array of the video horizontal and vertical indents.
|
|
|
|
* Centers horizontally and top aligns vertically.
|
|
|
|
*
|
|
|
|
* @return an array with 2 elements, the horizontal indent and the vertical
|
|
|
|
* indent
|
2015-07-29 19:39:09 +00:00
|
|
|
*/
|
2015-12-25 16:55:45 +00:00
|
|
|
function getDesktopVideoPosition(videoWidth,
|
|
|
|
videoHeight,
|
|
|
|
videoSpaceWidth,
|
|
|
|
videoSpaceHeight) {
|
|
|
|
|
|
|
|
let horizontalIndent = (videoSpaceWidth - videoWidth) / 2;
|
|
|
|
|
|
|
|
let verticalIndent = 0;// Top aligned
|
|
|
|
|
|
|
|
return { horizontalIndent, verticalIndent };
|
|
|
|
}
|
|
|
|
|
2016-01-15 14:59:35 +00:00
|
|
|
/**
|
|
|
|
* Container for user video.
|
|
|
|
*/
|
2015-12-25 16:55:45 +00:00
|
|
|
class VideoContainer extends LargeContainer {
|
|
|
|
// FIXME: With Temasys we have to re-select everytime
|
|
|
|
get $video () {
|
|
|
|
return $('#largeVideo');
|
2015-07-23 09:03:29 +00:00
|
|
|
}
|
|
|
|
|
2015-12-25 16:55:45 +00:00
|
|
|
get id () {
|
2016-01-22 15:08:58 +00:00
|
|
|
return getStreamOwnerId(this.stream);
|
2015-12-25 16:55:45 +00:00
|
|
|
}
|
2015-06-23 08:00:46 +00:00
|
|
|
|
2015-12-25 16:55:45 +00:00
|
|
|
constructor (onPlay) {
|
|
|
|
super();
|
|
|
|
this.stream = null;
|
2015-12-30 12:14:56 +00:00
|
|
|
this.videoType = null;
|
2016-05-07 01:50:37 +00:00
|
|
|
this.localFlipX = true;
|
2015-06-23 08:00:46 +00:00
|
|
|
|
2016-02-12 14:47:42 +00:00
|
|
|
this.isVisible = false;
|
|
|
|
|
2016-01-12 23:29:52 +00:00
|
|
|
this.$avatar = $('#dominantSpeaker');
|
2015-12-25 16:55:45 +00:00
|
|
|
this.$wrapper = $('#largeVideoWrapper');
|
2015-06-23 08:00:46 +00:00
|
|
|
|
2016-03-03 23:38:40 +00:00
|
|
|
this.avatarHeight = $("#dominantSpeakerAvatar").height();
|
|
|
|
|
2016-01-26 20:58:58 +00:00
|
|
|
// This does not work with Temasys plugin - has to be a property to be
|
|
|
|
// copied between new <object> elements
|
|
|
|
//this.$video.on('play', onPlay);
|
|
|
|
this.$video[0].onplay = onPlay;
|
2015-12-25 16:55:45 +00:00
|
|
|
}
|
2015-06-23 08:00:46 +00:00
|
|
|
|
2016-01-15 14:59:35 +00:00
|
|
|
/**
|
|
|
|
* Get size of video element.
|
|
|
|
* @returns {{width, height}}
|
|
|
|
*/
|
2015-12-25 16:55:45 +00:00
|
|
|
getStreamSize () {
|
|
|
|
let video = this.$video[0];
|
|
|
|
return {
|
|
|
|
width: video.videoWidth,
|
|
|
|
height: video.videoHeight
|
|
|
|
};
|
|
|
|
}
|
2015-07-22 08:18:54 +00:00
|
|
|
|
2016-01-15 14:59:35 +00:00
|
|
|
/**
|
|
|
|
* Calculate optimal video size for specified container size.
|
|
|
|
* @param {number} containerWidth container width
|
|
|
|
* @param {number} containerHeight container height
|
|
|
|
* @returns {{availableWidth, availableHeight}}
|
|
|
|
*/
|
2015-12-25 16:55:45 +00:00
|
|
|
getVideoSize (containerWidth, containerHeight) {
|
|
|
|
let { width, height } = this.getStreamSize();
|
2015-12-30 12:14:56 +00:00
|
|
|
if (this.stream && this.isScreenSharing()) {
|
2016-01-21 17:38:54 +00:00
|
|
|
return getDesktopVideoSize( width,
|
|
|
|
height,
|
|
|
|
containerWidth,
|
|
|
|
containerHeight);
|
2015-12-25 16:55:45 +00:00
|
|
|
} else {
|
2016-01-21 17:38:54 +00:00
|
|
|
return getCameraVideoSize( width,
|
|
|
|
height,
|
|
|
|
containerWidth,
|
|
|
|
containerHeight);
|
2015-12-25 16:55:45 +00:00
|
|
|
}
|
2015-06-23 08:00:46 +00:00
|
|
|
}
|
|
|
|
|
2016-01-15 14:59:35 +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
|
|
|
|
* @returns {{horizontalIndent, verticalIndent}}
|
|
|
|
*/
|
2015-12-25 16:55:45 +00:00
|
|
|
getVideoPosition (width, height, containerWidth, containerHeight) {
|
2015-12-30 12:14:56 +00:00
|
|
|
if (this.stream && this.isScreenSharing()) {
|
2016-01-21 17:38:54 +00:00
|
|
|
return getDesktopVideoPosition( width,
|
|
|
|
height,
|
|
|
|
containerWidth,
|
|
|
|
containerHeight);
|
2015-12-25 16:55:45 +00:00
|
|
|
} else {
|
2016-01-21 17:38:54 +00:00
|
|
|
return getCameraVideoPosition( width,
|
|
|
|
height,
|
|
|
|
containerWidth,
|
|
|
|
containerHeight);
|
2015-12-25 16:55:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resize (containerWidth, containerHeight, animate = false) {
|
2016-01-26 19:17:38 +00:00
|
|
|
let [width, height]
|
2016-01-21 17:38:54 +00:00
|
|
|
= this.getVideoSize(containerWidth, containerHeight);
|
|
|
|
let { horizontalIndent, verticalIndent }
|
|
|
|
= this.getVideoPosition(width, height,
|
|
|
|
containerWidth, containerHeight);
|
2015-12-25 16:55:45 +00:00
|
|
|
|
|
|
|
// update avatar position
|
2016-03-03 23:38:40 +00:00
|
|
|
let top = containerHeight / 2 - this.avatarHeight / 4 * 3;
|
2016-01-11 20:58:07 +00:00
|
|
|
|
2015-12-25 16:55:45 +00:00
|
|
|
this.$avatar.css('top', top);
|
|
|
|
|
|
|
|
this.$wrapper.animate({
|
2016-01-26 19:17:38 +00:00
|
|
|
width: width,
|
|
|
|
height: height,
|
2015-12-25 16:55:45 +00:00
|
|
|
|
|
|
|
top: verticalIndent,
|
|
|
|
bottom: verticalIndent,
|
|
|
|
|
|
|
|
left: horizontalIndent,
|
|
|
|
right: horizontalIndent
|
|
|
|
}, {
|
|
|
|
queue: false,
|
|
|
|
duration: animate ? 500 : 0
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-01-15 14:59:35 +00:00
|
|
|
/**
|
|
|
|
* Update video stream.
|
|
|
|
* @param {JitsiTrack?} stream new stream
|
|
|
|
* @param {string} videoType video type
|
|
|
|
*/
|
2015-12-30 12:14:56 +00:00
|
|
|
setStream (stream, videoType) {
|
2016-02-18 13:38:57 +00:00
|
|
|
// detach old stream
|
|
|
|
if (this.stream) {
|
|
|
|
this.stream.detach(this.$video[0]);
|
|
|
|
}
|
|
|
|
|
2015-12-25 16:55:45 +00:00
|
|
|
this.stream = stream;
|
2015-12-30 12:14:56 +00:00
|
|
|
this.videoType = videoType;
|
2015-12-25 16:55:45 +00:00
|
|
|
|
2016-02-18 13:38:57 +00:00
|
|
|
if (!stream) {
|
2016-01-29 19:31:58 +00:00
|
|
|
return;
|
2016-02-18 13:38:57 +00:00
|
|
|
}
|
2016-01-29 19:31:58 +00:00
|
|
|
|
2016-02-01 21:00:51 +00:00
|
|
|
stream.attach(this.$video[0]);
|
2016-05-07 01:50:37 +00:00
|
|
|
let flipX = stream.isLocal() && this.localFlipX;
|
2015-12-25 16:55:45 +00:00
|
|
|
this.$video.css({
|
|
|
|
transform: flipX ? 'scaleX(-1)' : 'none'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-05-07 01:50:37 +00:00
|
|
|
/**
|
|
|
|
* Changes the flipX state of the local video.
|
|
|
|
* @param val {boolean} true if flipped.
|
|
|
|
*/
|
|
|
|
setLocalFlipX(val) {
|
|
|
|
this.localFlipX = val;
|
|
|
|
if(!this.$video || !this.stream || !this.stream.isLocal())
|
|
|
|
return;
|
|
|
|
this.$video.css({
|
|
|
|
transform: this.localFlipX ? 'scaleX(-1)' : 'none'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-01-15 14:59:35 +00:00
|
|
|
/**
|
|
|
|
* Check if current video stream is screen sharing.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2015-12-30 12:14:56 +00:00
|
|
|
isScreenSharing () {
|
|
|
|
return this.videoType === 'desktop';
|
|
|
|
}
|
|
|
|
|
2016-01-15 14:59:35 +00:00
|
|
|
/**
|
|
|
|
* Show or hide user avatar.
|
|
|
|
* @param {boolean} show
|
|
|
|
*/
|
2015-12-25 16:55:45 +00:00
|
|
|
showAvatar (show) {
|
2016-09-13 04:11:09 +00:00
|
|
|
// TO FIX: Video background need to be black, so that we don't have a
|
|
|
|
// flickering effect when scrolling between videos and have the screen
|
|
|
|
// move to grey before going back to video. Avatars though can have the
|
|
|
|
// default background set.
|
|
|
|
// In order to fix this code we need to introduce video background or
|
|
|
|
// find a workaround for the video flickering.
|
|
|
|
$("#largeVideoContainer").css("background",
|
|
|
|
(show) ? interfaceConfig.DEFAULT_BACKGROUND : "#000");
|
|
|
|
|
2015-12-25 16:55:45 +00:00
|
|
|
this.$avatar.css("visibility", show ? "visible" : "hidden");
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
|
|
|
|
show () {
|
2016-02-12 14:47:42 +00:00
|
|
|
// its already visible
|
|
|
|
if (this.isVisible) {
|
|
|
|
return Promise.resolve();
|
|
|
|
}
|
|
|
|
|
2015-12-25 16:55:45 +00:00
|
|
|
let $wrapper = this.$wrapper;
|
2016-02-12 14:47:42 +00:00
|
|
|
return new Promise((resolve) => {
|
|
|
|
this.$wrapper.css('visibility', 'visible').fadeTo(
|
|
|
|
FADE_DURATION_MS,
|
|
|
|
1,
|
|
|
|
() => {
|
|
|
|
this.isVisible = true;
|
|
|
|
resolve();
|
|
|
|
}
|
|
|
|
);
|
2015-12-25 16:55:45 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
hide () {
|
2016-03-17 18:29:07 +00:00
|
|
|
// as the container is hidden/replaced by another container
|
|
|
|
// hide its avatar
|
|
|
|
this.showAvatar(false);
|
|
|
|
|
2016-02-12 14:47:42 +00:00
|
|
|
// its already hidden
|
|
|
|
if (!this.isVisible) {
|
|
|
|
return Promise.resolve();
|
|
|
|
}
|
|
|
|
|
|
|
|
return new Promise((resolve) => {
|
|
|
|
this.$wrapper.fadeTo(FADE_DURATION_MS, 0, () => {
|
|
|
|
this.$wrapper.css('visibility', 'hidden');
|
|
|
|
this.isVisible = false;
|
2015-12-25 16:55:45 +00:00
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
});
|
2015-07-29 19:39:09 +00:00
|
|
|
}
|
2016-03-18 03:19:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return {boolean} switch on dominant speaker event if on stage.
|
|
|
|
*/
|
|
|
|
stayOnStage () {
|
|
|
|
return false;
|
|
|
|
}
|
2015-07-29 19:39:09 +00:00
|
|
|
}
|
|
|
|
|
2016-01-15 14:59:35 +00:00
|
|
|
/**
|
|
|
|
* Manager for all Large containers.
|
|
|
|
*/
|
2015-12-25 16:55:45 +00:00
|
|
|
export default class LargeVideoManager {
|
|
|
|
constructor () {
|
|
|
|
this.containers = {};
|
2015-06-23 08:00:46 +00:00
|
|
|
|
2016-03-18 20:00:55 +00:00
|
|
|
this.state = VIDEO_CONTAINER_TYPE;
|
|
|
|
this.videoContainer = new VideoContainer(
|
|
|
|
() => this.resizeContainer(VIDEO_CONTAINER_TYPE));
|
|
|
|
this.addContainer(VIDEO_CONTAINER_TYPE, this.videoContainer);
|
2016-03-03 23:38:40 +00:00
|
|
|
|
2016-03-15 21:03:38 +00:00
|
|
|
// use the same video container to handle and desktop tracks
|
|
|
|
this.addContainer("desktop", this.videoContainer);
|
2015-08-19 08:55:35 +00:00
|
|
|
|
2015-12-25 16:55:45 +00:00
|
|
|
this.width = 0;
|
|
|
|
this.height = 0;
|
2015-06-23 08:00:46 +00:00
|
|
|
|
2015-12-25 16:55:45 +00:00
|
|
|
this.$container = $('#largeVideoContainer');
|
2015-12-14 12:26:50 +00:00
|
|
|
|
2015-12-25 16:55:45 +00:00
|
|
|
this.$container.css({
|
|
|
|
display: 'inline-block'
|
|
|
|
});
|
2015-07-22 08:18:54 +00:00
|
|
|
|
2015-12-25 16:55:45 +00:00
|
|
|
if (interfaceConfig.SHOW_JITSI_WATERMARK) {
|
2016-03-03 23:38:40 +00:00
|
|
|
let leftWatermarkDiv
|
|
|
|
= this.$container.find("div.watermark.leftwatermark");
|
2015-06-23 08:00:46 +00:00
|
|
|
|
2015-12-25 16:55:45 +00:00
|
|
|
leftWatermarkDiv.css({display: 'block'});
|
2015-06-23 08:00:46 +00:00
|
|
|
|
2016-03-03 23:38:40 +00:00
|
|
|
leftWatermarkDiv.parent().attr(
|
|
|
|
'href', interfaceConfig.JITSI_WATERMARK_LINK);
|
2015-06-23 08:00:46 +00:00
|
|
|
}
|
2015-11-13 17:04:49 +00:00
|
|
|
|
2015-12-25 16:55:45 +00:00
|
|
|
if (interfaceConfig.SHOW_BRAND_WATERMARK) {
|
2016-03-03 23:38:40 +00:00
|
|
|
let rightWatermarkDiv
|
|
|
|
= this.$container.find("div.watermark.rightwatermark");
|
2015-12-25 16:55:45 +00:00
|
|
|
|
|
|
|
rightWatermarkDiv.css({
|
|
|
|
display: 'block',
|
|
|
|
backgroundImage: 'url(images/rightwatermark.png)'
|
|
|
|
});
|
|
|
|
|
2016-03-03 23:38:40 +00:00
|
|
|
rightWatermarkDiv.parent().attr(
|
|
|
|
'href', interfaceConfig.BRAND_WATERMARK_LINK);
|
2015-06-23 08:00:46 +00:00
|
|
|
}
|
2015-12-25 16:55:45 +00:00
|
|
|
|
|
|
|
if (interfaceConfig.SHOW_POWERED_BY) {
|
|
|
|
this.$container.children("a.poweredby").css({display: 'block'});
|
2015-06-23 08:00:46 +00:00
|
|
|
}
|
2015-12-25 16:55:45 +00:00
|
|
|
|
|
|
|
this.$container.hover(
|
|
|
|
e => this.onHoverIn(e),
|
|
|
|
e => this.onHoverOut(e)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
onHoverIn (e) {
|
|
|
|
if (!this.state) {
|
2015-07-29 19:39:09 +00:00
|
|
|
return;
|
2015-12-14 12:26:50 +00:00
|
|
|
}
|
2015-12-25 16:55:45 +00:00
|
|
|
let container = this.getContainer(this.state);
|
|
|
|
container.onHoverIn(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
onHoverOut (e) {
|
|
|
|
if (!this.state) {
|
2015-07-29 19:39:09 +00:00
|
|
|
return;
|
2015-12-14 12:26:50 +00:00
|
|
|
}
|
2015-12-25 16:55:45 +00:00
|
|
|
let container = this.getContainer(this.state);
|
|
|
|
container.onHoverOut(e);
|
|
|
|
}
|
2015-07-29 19:39:09 +00:00
|
|
|
|
2015-12-25 16:55:45 +00:00
|
|
|
get id () {
|
2016-03-15 21:03:38 +00:00
|
|
|
let container = this.getContainer(this.state);
|
|
|
|
return container.id;
|
2015-12-25 16:55:45 +00:00
|
|
|
}
|
2015-07-29 19:39:09 +00:00
|
|
|
|
2016-01-22 15:08:58 +00:00
|
|
|
scheduleLargeVideoUpdate () {
|
|
|
|
if (this.updateInProcess || !this.newStreamData) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.updateInProcess = true;
|
2015-07-29 19:39:09 +00:00
|
|
|
|
2015-12-25 16:55:45 +00:00
|
|
|
let container = this.getContainer(this.state);
|
2015-07-29 19:39:09 +00:00
|
|
|
|
2016-04-26 20:42:18 +00:00
|
|
|
// Include hide()/fadeOut only if we're switching between users
|
|
|
|
let preUpdate;
|
|
|
|
if (this.newStreamData.id != this.id) {
|
|
|
|
preUpdate = container.hide();
|
|
|
|
} else {
|
|
|
|
preUpdate = Promise.resolve();
|
|
|
|
}
|
2016-05-07 01:50:37 +00:00
|
|
|
|
2016-04-26 20:42:18 +00:00
|
|
|
preUpdate.then(() => {
|
2016-01-22 15:08:58 +00:00
|
|
|
let {id, stream, videoType, resolve} = this.newStreamData;
|
|
|
|
this.newStreamData = null;
|
|
|
|
|
2015-12-25 16:55:45 +00:00
|
|
|
console.info("hover in %s", id);
|
2016-03-15 21:03:38 +00:00
|
|
|
this.state = videoType;
|
|
|
|
let container = this.getContainer(this.state);
|
|
|
|
container.setStream(stream, videoType);
|
2016-01-21 17:38:54 +00:00
|
|
|
|
|
|
|
// change the avatar url on large
|
2016-01-22 15:08:58 +00:00
|
|
|
this.updateAvatar(Avatar.getAvatarUrl(id));
|
|
|
|
|
2016-03-22 19:49:37 +00:00
|
|
|
// If we the continer is VIDEO_CONTAINER_TYPE, we need to check
|
|
|
|
// its stream whether exist and is muted to set isVideoMuted
|
|
|
|
// in rest of the cases it is false
|
|
|
|
let isVideoMuted = false;
|
|
|
|
if (videoType == VIDEO_CONTAINER_TYPE)
|
|
|
|
isVideoMuted = stream ? stream.isMuted() : true;
|
2016-01-21 17:38:54 +00:00
|
|
|
|
|
|
|
// show the avatar on large if needed
|
2016-03-15 21:03:38 +00:00
|
|
|
container.showAvatar(isVideoMuted);
|
2016-01-21 17:38:54 +00:00
|
|
|
|
2016-02-12 14:47:42 +00:00
|
|
|
let promise;
|
|
|
|
|
2016-01-22 15:08:58 +00:00
|
|
|
// do not show stream if video is muted
|
2016-02-12 14:47:42 +00:00
|
|
|
// but we still should show watermark
|
|
|
|
if (isVideoMuted) {
|
2016-02-17 12:37:06 +00:00
|
|
|
this.showWatermark(true);
|
2016-02-12 14:47:42 +00:00
|
|
|
promise = Promise.resolve();
|
|
|
|
} else {
|
2016-03-15 21:03:38 +00:00
|
|
|
promise = container.show();
|
2016-02-12 14:47:42 +00:00
|
|
|
}
|
2016-01-21 17:38:54 +00:00
|
|
|
|
2016-01-22 15:08:58 +00:00
|
|
|
// resolve updateLargeVideo promise after everything is done
|
|
|
|
promise.then(resolve);
|
|
|
|
|
|
|
|
return promise;
|
|
|
|
}).then(() => {
|
2016-03-03 23:38:40 +00:00
|
|
|
// after everything is done check again if there are any pending
|
|
|
|
// new streams.
|
2016-01-22 15:08:58 +00:00
|
|
|
this.updateInProcess = false;
|
|
|
|
this.scheduleLargeVideoUpdate();
|
2015-12-25 16:55:45 +00:00
|
|
|
});
|
|
|
|
}
|
2015-07-29 19:39:09 +00:00
|
|
|
|
2016-01-25 21:35:40 +00:00
|
|
|
/**
|
|
|
|
* Update large video.
|
|
|
|
* Switches to large video even if previously other container was visible.
|
2016-01-29 19:31:58 +00:00
|
|
|
* @param userID the userID of the participant associated with the stream
|
2016-01-25 21:35:40 +00:00
|
|
|
* @param {JitsiTrack?} stream new stream
|
|
|
|
* @param {string?} videoType new video type
|
|
|
|
* @returns {Promise}
|
|
|
|
*/
|
2016-01-29 19:31:58 +00:00
|
|
|
updateLargeVideo (userID, stream, videoType) {
|
2016-01-22 15:08:58 +00:00
|
|
|
if (this.newStreamData) {
|
|
|
|
this.newStreamData.reject();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.newStreamData = createDeferred();
|
2016-01-29 19:31:58 +00:00
|
|
|
this.newStreamData.id = userID;
|
2016-01-22 15:08:58 +00:00
|
|
|
this.newStreamData.stream = stream;
|
|
|
|
this.newStreamData.videoType = videoType;
|
|
|
|
|
|
|
|
this.scheduleLargeVideoUpdate();
|
|
|
|
|
|
|
|
return this.newStreamData.promise;
|
|
|
|
}
|
|
|
|
|
2016-01-15 14:59:35 +00:00
|
|
|
/**
|
2016-09-08 18:16:23 +00:00
|
|
|
* Update container size.
|
2016-01-15 14:59:35 +00:00
|
|
|
*/
|
2016-09-08 18:16:23 +00:00
|
|
|
updateContainerSize () {
|
|
|
|
this.width = UIUtil.getAvailableVideoWidth();
|
2015-12-25 16:55:45 +00:00
|
|
|
this.height = window.innerHeight;
|
|
|
|
}
|
2015-07-29 19:39:09 +00:00
|
|
|
|
2016-01-15 14:59:35 +00:00
|
|
|
/**
|
|
|
|
* Resize Large container of specified type.
|
|
|
|
* @param {string} type type of container which should be resized.
|
|
|
|
* @param {boolean} [animate=false] if resize process should be animated.
|
|
|
|
*/
|
2015-12-25 16:55:45 +00:00
|
|
|
resizeContainer (type, animate = false) {
|
|
|
|
let container = this.getContainer(type);
|
|
|
|
container.resize(this.width, this.height, animate);
|
|
|
|
}
|
2015-07-29 19:39:09 +00:00
|
|
|
|
2016-01-15 14:59:35 +00:00
|
|
|
/**
|
|
|
|
* Resize all Large containers.
|
|
|
|
* @param {boolean} animate if resize process should be animated.
|
|
|
|
*/
|
2015-12-25 16:55:45 +00:00
|
|
|
resize (animate) {
|
|
|
|
// resize all containers
|
2016-01-19 23:10:44 +00:00
|
|
|
Object.keys(this.containers)
|
|
|
|
.forEach(type => this.resizeContainer(type, animate));
|
2015-12-25 16:55:45 +00:00
|
|
|
|
|
|
|
this.$container.animate({
|
|
|
|
width: this.width,
|
|
|
|
height: this.height
|
|
|
|
}, {
|
|
|
|
queue: false,
|
|
|
|
duration: animate ? 500 : 0
|
|
|
|
});
|
|
|
|
}
|
2015-08-03 15:58:22 +00:00
|
|
|
|
2015-08-03 16:21:56 +00:00
|
|
|
/**
|
|
|
|
* Enables/disables the filter indicating a video problem to the user.
|
|
|
|
*
|
|
|
|
* @param enable <tt>true</tt> to enable, <tt>false</tt> to disable
|
|
|
|
*/
|
2015-12-25 16:55:45 +00:00
|
|
|
enableVideoProblemFilter (enable) {
|
2016-03-15 21:03:38 +00:00
|
|
|
let container = this.getContainer(this.state);
|
|
|
|
container.$video.toggleClass("videoProblemFilter", enable);
|
2015-12-25 16:55:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-01-12 00:14:01 +00:00
|
|
|
* Updates the src of the dominant speaker avatar
|
2015-12-25 16:55:45 +00:00
|
|
|
*/
|
2016-01-19 23:10:44 +00:00
|
|
|
updateAvatar (avatarUrl) {
|
|
|
|
$("#dominantSpeakerAvatar").attr('src', avatarUrl);
|
2015-12-25 16:55:45 +00:00
|
|
|
}
|
|
|
|
|
2016-02-17 12:37:06 +00:00
|
|
|
/**
|
|
|
|
* Show or hide watermark.
|
|
|
|
* @param {boolean} show
|
|
|
|
*/
|
|
|
|
showWatermark (show) {
|
|
|
|
$('.watermark').css('visibility', show ? 'visible' : 'hidden');
|
|
|
|
}
|
|
|
|
|
2016-01-15 14:59:35 +00:00
|
|
|
/**
|
|
|
|
* Add container of specified type.
|
|
|
|
* @param {string} type container type
|
|
|
|
* @param {LargeContainer} container container to add.
|
|
|
|
*/
|
2015-12-25 16:55:45 +00:00
|
|
|
addContainer (type, container) {
|
|
|
|
if (this.containers[type]) {
|
|
|
|
throw new Error(`container of type ${type} already exist`);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.containers[type] = container;
|
|
|
|
this.resizeContainer(type);
|
|
|
|
}
|
|
|
|
|
2016-01-15 14:59:35 +00:00
|
|
|
/**
|
|
|
|
* Get Large container of specified type.
|
|
|
|
* @param {string} type container type.
|
|
|
|
* @returns {LargeContainer}
|
|
|
|
*/
|
2015-12-25 16:55:45 +00:00
|
|
|
getContainer (type) {
|
|
|
|
let container = this.containers[type];
|
|
|
|
|
|
|
|
if (!container) {
|
|
|
|
throw new Error(`container of type ${type} doesn't exist`);
|
|
|
|
}
|
|
|
|
|
|
|
|
return container;
|
|
|
|
}
|
|
|
|
|
2016-01-15 14:59:35 +00:00
|
|
|
/**
|
|
|
|
* Remove Large container of specified type.
|
|
|
|
* @param {string} type container type.
|
|
|
|
*/
|
2015-12-25 16:55:45 +00:00
|
|
|
removeContainer (type) {
|
|
|
|
if (!this.containers[type]) {
|
|
|
|
throw new Error(`container of type ${type} doesn't exist`);
|
|
|
|
}
|
|
|
|
|
|
|
|
delete this.containers[type];
|
|
|
|
}
|
|
|
|
|
2016-01-15 14:59:35 +00:00
|
|
|
/**
|
|
|
|
* Show Large container of specified type.
|
|
|
|
* Does nothing if such container is already visible.
|
|
|
|
* @param {string} type container type.
|
|
|
|
* @returns {Promise}
|
|
|
|
*/
|
2015-12-25 16:55:45 +00:00
|
|
|
showContainer (type) {
|
|
|
|
if (this.state === type) {
|
|
|
|
return Promise.resolve();
|
|
|
|
}
|
|
|
|
|
2016-01-22 15:08:58 +00:00
|
|
|
let oldContainer = this.containers[this.state];
|
2016-03-18 20:00:55 +00:00
|
|
|
if (this.state === VIDEO_CONTAINER_TYPE) {
|
2016-02-17 12:37:06 +00:00
|
|
|
this.showWatermark(false);
|
|
|
|
}
|
2016-01-22 15:08:58 +00:00
|
|
|
oldContainer.hide();
|
2015-12-25 16:55:45 +00:00
|
|
|
|
|
|
|
this.state = type;
|
2016-01-22 15:08:58 +00:00
|
|
|
let container = this.getContainer(type);
|
2015-12-25 16:55:45 +00:00
|
|
|
|
2016-02-17 12:37:06 +00:00
|
|
|
return container.show().then(() => {
|
2016-03-18 20:00:55 +00:00
|
|
|
if (type === VIDEO_CONTAINER_TYPE) {
|
2016-02-17 12:37:06 +00:00
|
|
|
this.showWatermark(true);
|
|
|
|
}
|
|
|
|
});
|
2015-12-25 16:55:45 +00:00
|
|
|
}
|
2016-05-07 01:50:37 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Changes the flipX state of the local video.
|
|
|
|
* @param val {boolean} true if flipped.
|
|
|
|
*/
|
|
|
|
onLocalFlipXChange(val) {
|
|
|
|
this.videoContainer.setLocalFlipX(val);
|
|
|
|
}
|
2015-12-25 16:55:45 +00:00
|
|
|
}
|