2017-05-11 00:19:35 +00:00
|
|
|
/* global $, APP, config, JitsiMeetJS */
|
2016-11-11 15:00:54 +00:00
|
|
|
const logger = require("jitsi-meet-logger").getLogger(__filename);
|
2015-12-25 16:55:45 +00:00
|
|
|
|
2017-05-11 00:19:35 +00:00
|
|
|
import { setLargeVideoHDStatus } from '../../../react/features/base/conference';
|
|
|
|
|
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';
|
2017-01-10 18:51:25 +00:00
|
|
|
import UIEvents from "../../../service/UI/UIEvents";
|
2016-09-21 20:02:19 +00:00
|
|
|
import UIUtil from "../util/UIUtil";
|
|
|
|
import {VideoContainer, VIDEO_CONTAINER_TYPE} from "./VideoContainer";
|
2016-09-28 21:31:40 +00:00
|
|
|
|
|
|
|
import AudioLevels from "../audio_levels/AudioLevels";
|
|
|
|
|
2017-04-03 16:53:04 +00:00
|
|
|
const ParticipantConnectionStatus
|
|
|
|
= JitsiMeetJS.constants.participantConnectionStatus;
|
2017-04-05 15:14:26 +00:00
|
|
|
const DESKTOP_CONTAINER_TYPE = 'desktop';
|
2017-05-11 00:19:35 +00:00
|
|
|
/**
|
|
|
|
* The time interval in milliseconds to check the video resolution of the video
|
|
|
|
* being displayed.
|
|
|
|
*
|
|
|
|
* @type {number}
|
|
|
|
*/
|
|
|
|
const VIDEO_RESOLUTION_POLL_INTERVAL = 2000;
|
2017-04-03 16:53:04 +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 {
|
2016-09-14 21:26:17 +00:00
|
|
|
constructor (emitter) {
|
2016-09-24 15:11:57 +00:00
|
|
|
/**
|
|
|
|
* The map of <tt>LargeContainer</tt>s where the key is the video
|
|
|
|
* container type.
|
|
|
|
* @type {Object.<string, LargeContainer>}
|
|
|
|
*/
|
2015-12-25 16:55:45 +00:00
|
|
|
this.containers = {};
|
2017-01-10 18:51:25 +00:00
|
|
|
this.eventEmitter = emitter;
|
2015-06-23 08:00:46 +00:00
|
|
|
|
2016-03-18 20:00:55 +00:00
|
|
|
this.state = VIDEO_CONTAINER_TYPE;
|
2017-02-08 19:57:55 +00:00
|
|
|
// FIXME: We are passing resizeContainer as parameter which is calling
|
|
|
|
// Container.resize. Probably there's better way to implement this.
|
2016-03-18 20:00:55 +00:00
|
|
|
this.videoContainer = new VideoContainer(
|
2016-09-14 21:26:17 +00:00
|
|
|
() => this.resizeContainer(VIDEO_CONTAINER_TYPE), emitter);
|
2016-03-18 20:00:55 +00:00
|
|
|
this.addContainer(VIDEO_CONTAINER_TYPE, this.videoContainer);
|
2016-03-03 23:38:40 +00:00
|
|
|
|
2016-11-11 17:55:18 +00:00
|
|
|
// use the same video container to handle desktop tracks
|
2017-04-05 15:14:26 +00:00
|
|
|
this.addContainer(DESKTOP_CONTAINER_TYPE, 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
|
|
|
this.$container.hover(
|
|
|
|
e => this.onHoverIn(e),
|
|
|
|
e => this.onHoverOut(e)
|
|
|
|
);
|
2017-05-11 00:19:35 +00:00
|
|
|
|
2017-05-16 20:48:14 +00:00
|
|
|
// Bind event handler so it is only bound once for every instance.
|
|
|
|
this._updateVideoResolutionStatus
|
|
|
|
= this._updateVideoResolutionStatus.bind(this);
|
|
|
|
|
|
|
|
this.videoContainer.addResizeListener(
|
|
|
|
this._updateVideoResolutionStatus);
|
|
|
|
|
|
|
|
if (!JitsiMeetJS.util.RTCUIHelper.isResizeEventSupported()) {
|
|
|
|
/**
|
|
|
|
* An interval for polling if the displayed video resolution is or
|
|
|
|
* is not high-definition. For browsers that do not support video
|
|
|
|
* resize events, polling is the fallback.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @type {timeoutId}
|
|
|
|
*/
|
|
|
|
this._updateVideoResolutionInterval = window.setInterval(
|
|
|
|
this._updateVideoResolutionStatus,
|
|
|
|
VIDEO_RESOLUTION_POLL_INTERVAL);
|
|
|
|
}
|
2017-05-11 00:19:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-05-16 20:48:14 +00:00
|
|
|
* Stops any polling intervals on the instance and and removes any
|
|
|
|
* listeners registered on child components.
|
2017-05-11 00:19:35 +00:00
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
destroy() {
|
|
|
|
window.clearInterval(this._updateVideoResolutionInterval);
|
2017-05-16 20:48:14 +00:00
|
|
|
this.videoContainer.removeResizeListener(
|
|
|
|
this._updateVideoResolutionStatus);
|
2015-12-25 16:55:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
2016-09-22 17:37:14 +00:00
|
|
|
/**
|
|
|
|
* Called when the media connection has been interrupted.
|
|
|
|
*/
|
|
|
|
onVideoInterrupted () {
|
2016-09-24 16:19:58 +00:00
|
|
|
this.enableLocalConnectionProblemFilter(true);
|
2016-09-28 16:29:47 +00:00
|
|
|
this._setLocalConnectionMessage("connection.RECONNECTING");
|
2016-09-22 17:37:14 +00:00
|
|
|
// Show the message only if the video is currently being displayed
|
2016-09-24 18:30:29 +00:00
|
|
|
this.showLocalConnectionMessage(this.state === VIDEO_CONTAINER_TYPE);
|
2016-09-22 17:37:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when the media connection has been restored.
|
|
|
|
*/
|
|
|
|
onVideoRestored () {
|
2016-09-24 16:19:58 +00:00
|
|
|
this.enableLocalConnectionProblemFilter(false);
|
2016-09-24 18:30:29 +00:00
|
|
|
this.showLocalConnectionMessage(false);
|
2016-09-22 17:37:14 +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
|
|
|
|
2016-04-26 20:42:18 +00:00
|
|
|
// Include hide()/fadeOut only if we're switching between users
|
2016-10-13 18:25:47 +00:00
|
|
|
const isUserSwitch = this.newStreamData.id != this.id;
|
|
|
|
const container = this.getContainer(this.state);
|
|
|
|
const preUpdate = isUserSwitch ? container.hide() : Promise.resolve();
|
2016-05-07 01:50:37 +00:00
|
|
|
|
2016-04-26 20:42:18 +00:00
|
|
|
preUpdate.then(() => {
|
2016-10-13 18:25:47 +00:00
|
|
|
const { id, stream, videoType, resolve } = this.newStreamData;
|
2017-04-05 15:14:26 +00:00
|
|
|
const isVideoFromCamera = videoType === VIDEO_CONTAINER_TYPE;
|
|
|
|
|
2016-01-22 15:08:58 +00:00
|
|
|
this.newStreamData = null;
|
|
|
|
|
2016-11-11 15:00:54 +00:00
|
|
|
logger.info("hover in %s", id);
|
2016-03-15 21:03:38 +00:00
|
|
|
this.state = videoType;
|
2016-10-13 18:25:47 +00:00
|
|
|
const container = this.getContainer(this.state);
|
2016-03-15 21:03:38 +00:00
|
|
|
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-09-24 15:11:57 +00:00
|
|
|
// FIXME that does not really make sense, because the videoType
|
|
|
|
// (camera or desktop) is a completely different thing than
|
|
|
|
// the video container type (Etherpad, SharedVideo, VideoContainer).
|
|
|
|
// ----------------------------------------------------------------
|
2017-04-03 16:53:04 +00:00
|
|
|
// If the container is VIDEO_CONTAINER_TYPE, we need to check
|
2016-03-22 19:49:37 +00:00
|
|
|
// its stream whether exist and is muted to set isVideoMuted
|
|
|
|
// in rest of the cases it is false
|
2017-04-05 15:14:26 +00:00
|
|
|
let showAvatar = isVideoFromCamera && (!stream || stream.isMuted());
|
2016-09-24 18:24:18 +00:00
|
|
|
|
|
|
|
// If the user's connection is disrupted then the avatar will be
|
|
|
|
// displayed in case we have no video image cached. That is if
|
|
|
|
// there was a user switch(image is lost on stream detach) or if
|
|
|
|
// the video was not rendered, before the connection has failed.
|
2017-04-03 16:53:04 +00:00
|
|
|
const isConnectionActive = this._isConnectionActive(id);
|
2017-03-21 17:14:13 +00:00
|
|
|
|
2017-04-05 15:14:26 +00:00
|
|
|
if (isVideoFromCamera
|
2017-04-03 16:53:04 +00:00
|
|
|
&& !isConnectionActive
|
2016-10-13 18:25:47 +00:00
|
|
|
&& (isUserSwitch || !container.wasVideoRendered)) {
|
2016-09-24 18:24:18 +00:00
|
|
|
showAvatar = true;
|
|
|
|
}
|
2016-01-21 17:38:54 +00:00
|
|
|
|
2017-04-05 15:14:26 +00:00
|
|
|
// If audio only mode is enabled, always show the avatar for
|
|
|
|
// videos from another participant.
|
|
|
|
if (APP.conference.isAudioOnly()
|
|
|
|
&& (isVideoFromCamera
|
|
|
|
|| videoType === DESKTOP_CONTAINER_TYPE)) {
|
|
|
|
showAvatar = true;
|
|
|
|
}
|
|
|
|
|
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
|
2016-09-24 18:24:18 +00:00
|
|
|
if (showAvatar) {
|
2016-02-17 12:37:06 +00:00
|
|
|
this.showWatermark(true);
|
2016-09-24 18:24:18 +00:00
|
|
|
// If the intention of this switch is to show the avatar
|
|
|
|
// we need to make sure that the video is hidden
|
2016-09-24 15:18:17 +00:00
|
|
|
promise = container.hide();
|
2016-02-12 14:47:42 +00:00
|
|
|
} 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-09-24 18:24:18 +00:00
|
|
|
// show the avatar on large if needed
|
|
|
|
container.showAvatar(showAvatar);
|
|
|
|
|
2016-10-13 18:25:47 +00:00
|
|
|
// Clean up audio level after previous speaker.
|
2016-10-13 13:43:21 +00:00
|
|
|
if (showAvatar) {
|
|
|
|
this.updateLargeVideoAudioLevel(0);
|
2016-09-24 18:24:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure no notification about remote failure is shown as
|
2016-10-13 18:25:47 +00:00
|
|
|
// its UI conflicts with the one for local connection interrupted.
|
2017-04-05 15:14:26 +00:00
|
|
|
// For the purposes of UI indicators, audio only is considered as
|
|
|
|
// an "active" connection.
|
|
|
|
const isConnected
|
|
|
|
= APP.conference.isAudioOnly()
|
|
|
|
|| APP.conference.isConnectionInterrupted()
|
|
|
|
|| isConnectionActive;
|
2017-04-03 16:53:04 +00:00
|
|
|
|
|
|
|
// when isHavingConnectivityIssues, state can be inactive,
|
|
|
|
// interrupted or restoring. We show different message for
|
|
|
|
// interrupted and the rest.
|
|
|
|
const isConnectionInterrupted =
|
|
|
|
APP.conference.getParticipantConnectionStatus(id)
|
|
|
|
=== ParticipantConnectionStatus.INTERRUPTED;
|
2017-03-21 17:14:13 +00:00
|
|
|
|
2016-10-13 18:25:47 +00:00
|
|
|
this.updateParticipantConnStatusIndication(
|
|
|
|
id,
|
2017-03-21 17:14:13 +00:00
|
|
|
isConnected,
|
2017-04-03 16:53:04 +00:00
|
|
|
(isConnectionInterrupted)
|
2017-03-21 17:14:13 +00:00
|
|
|
? "connection.USER_CONNECTION_INTERRUPTED"
|
|
|
|
: "connection.LOW_BANDWIDTH");
|
2016-09-24 18:24:18 +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;
|
2017-01-10 18:51:25 +00:00
|
|
|
this.eventEmitter.emit(UIEvents.LARGE_VIDEO_ID_CHANGED, this.id);
|
2016-01-22 15:08:58 +00:00
|
|
|
this.scheduleLargeVideoUpdate();
|
2015-12-25 16:55:45 +00:00
|
|
|
});
|
|
|
|
}
|
2015-07-29 19:39:09 +00:00
|
|
|
|
2017-04-03 16:53:04 +00:00
|
|
|
/**
|
|
|
|
* Checks whether a participant's peer connection status is active.
|
|
|
|
* There is no JitsiParticipant for local id we skip checking local
|
|
|
|
* participant and report it as having no connectivity issues.
|
|
|
|
*
|
|
|
|
* @param {string} id the id of participant(MUC nickname)
|
|
|
|
* @returns {boolean} <tt>true</tt> when participant connection status is
|
|
|
|
* {@link ParticipantConnectionStatus.ACTIVE} and <tt>false</tt> otherwise.
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
_isConnectionActive(id) {
|
|
|
|
return APP.conference.isLocalId(id)
|
|
|
|
|| APP.conference.getParticipantConnectionStatus(this.id)
|
|
|
|
=== ParticipantConnectionStatus.ACTIVE;
|
|
|
|
}
|
|
|
|
|
2016-09-24 18:24:18 +00:00
|
|
|
/**
|
|
|
|
* Shows/hides notification about participant's connectivity issues to be
|
|
|
|
* shown on the large video area.
|
|
|
|
*
|
|
|
|
* @param {string} id the id of remote participant(MUC nickname)
|
|
|
|
* @param {boolean} isConnected true if the connection is active or false
|
|
|
|
* when the user is having connectivity issues.
|
2017-03-21 17:14:13 +00:00
|
|
|
* @param {string} messageKey the i18n key of the message
|
2016-09-24 18:24:18 +00:00
|
|
|
*
|
|
|
|
* @private
|
|
|
|
*/
|
2017-03-21 17:14:13 +00:00
|
|
|
updateParticipantConnStatusIndication (id, isConnected, messageKey) {
|
2016-09-24 18:24:18 +00:00
|
|
|
|
|
|
|
// Apply grey filter on the large video
|
|
|
|
this.videoContainer.showRemoteConnectionProblemIndicator(!isConnected);
|
|
|
|
|
|
|
|
if (isConnected) {
|
|
|
|
// Hide the message
|
|
|
|
this.showRemoteConnectionMessage(false);
|
|
|
|
} else {
|
|
|
|
// Get user's display name
|
|
|
|
let displayName
|
|
|
|
= APP.conference.getParticipantDisplayName(id);
|
|
|
|
this._setRemoteConnectionMessage(
|
2017-03-21 17:14:13 +00:00
|
|
|
messageKey,
|
2016-09-24 18:24:18 +00:00
|
|
|
{ displayName: displayName });
|
|
|
|
|
|
|
|
// Show it now only if the VideoContainer is on top
|
|
|
|
this.showRemoteConnectionMessage(
|
|
|
|
this.state === VIDEO_CONTAINER_TYPE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
/**
|
2016-09-24 16:19:58 +00:00
|
|
|
* Enables/disables the filter indicating a video problem to the user caused
|
|
|
|
* by the problems with local media connection.
|
2015-08-03 16:21:56 +00:00
|
|
|
*
|
|
|
|
* @param enable <tt>true</tt> to enable, <tt>false</tt> to disable
|
|
|
|
*/
|
2016-09-24 16:19:58 +00:00
|
|
|
enableLocalConnectionProblemFilter (enable) {
|
|
|
|
this.videoContainer.enableLocalConnectionProblemFilter(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-09-28 21:31:40 +00:00
|
|
|
/**
|
|
|
|
* Updates the audio level indicator of the large video.
|
|
|
|
*
|
|
|
|
* @param lvl the new audio level to set
|
|
|
|
*/
|
|
|
|
updateLargeVideoAudioLevel (lvl) {
|
|
|
|
AudioLevels.updateLargeVideoAudioLevel("dominantSpeaker", lvl);
|
|
|
|
}
|
|
|
|
|
2016-02-17 12:37:06 +00:00
|
|
|
/**
|
|
|
|
* Show or hide watermark.
|
|
|
|
* @param {boolean} show
|
|
|
|
*/
|
|
|
|
showWatermark (show) {
|
|
|
|
$('.watermark').css('visibility', show ? 'visible' : 'hidden');
|
|
|
|
}
|
|
|
|
|
2016-09-22 17:37:14 +00:00
|
|
|
/**
|
2016-09-24 18:30:29 +00:00
|
|
|
* Shows/hides the message indicating problems with local media connection.
|
2016-09-22 17:37:14 +00:00
|
|
|
* @param {boolean|null} show(optional) tells whether the message is to be
|
|
|
|
* displayed or not. If missing the condition will be based on the value
|
|
|
|
* obtained from {@link APP.conference.isConnectionInterrupted}.
|
|
|
|
*/
|
2016-09-24 18:30:29 +00:00
|
|
|
showLocalConnectionMessage (show) {
|
2016-09-22 17:37:14 +00:00
|
|
|
if (typeof show !== 'boolean') {
|
|
|
|
show = APP.conference.isConnectionInterrupted();
|
|
|
|
}
|
|
|
|
|
2016-11-04 14:11:32 +00:00
|
|
|
let id = 'localConnectionMessage';
|
2016-11-23 21:04:05 +00:00
|
|
|
|
2016-11-29 21:07:18 +00:00
|
|
|
UIUtil.setVisible(id, show);
|
2016-11-23 21:04:05 +00:00
|
|
|
|
2016-09-22 17:37:14 +00:00
|
|
|
if (show) {
|
2016-09-24 18:24:18 +00:00
|
|
|
// Avatar message conflicts with 'videoConnectionMessage',
|
|
|
|
// so it must be hidden
|
|
|
|
this.showRemoteConnectionMessage(false);
|
2016-09-22 17:37:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-24 18:24:18 +00:00
|
|
|
/**
|
|
|
|
* Shows hides the "avatar" message which is to be displayed either in
|
|
|
|
* the middle of the screen or below the avatar image.
|
|
|
|
*
|
|
|
|
* @param {null|boolean} show (optional) <tt>true</tt> to show the avatar
|
|
|
|
* message or <tt>false</tt> to hide it. If not provided then the connection
|
|
|
|
* status of the user currently on the large video will be obtained form
|
|
|
|
* "APP.conference" and the message will be displayed if the user's
|
|
|
|
* connection is interrupted.
|
|
|
|
*/
|
|
|
|
showRemoteConnectionMessage (show) {
|
|
|
|
if (typeof show !== 'boolean') {
|
2017-04-03 16:53:04 +00:00
|
|
|
show = !this._isConnectionActive(this.id);
|
2016-09-24 18:24:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (show) {
|
|
|
|
$('#remoteConnectionMessage').css({display: "block"});
|
|
|
|
// 'videoConnectionMessage' message conflicts with 'avatarMessage',
|
|
|
|
// so it must be hidden
|
2016-09-24 18:30:29 +00:00
|
|
|
this.showLocalConnectionMessage(false);
|
2016-09-24 18:24:18 +00:00
|
|
|
} else {
|
|
|
|
$('#remoteConnectionMessage').hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates the text which describes that the remote user is having
|
|
|
|
* connectivity issues.
|
|
|
|
*
|
|
|
|
* @param {string} msgKey the translation key which will be used to get
|
|
|
|
* the message text.
|
|
|
|
* @param {object} msgOptions translation options object.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
_setRemoteConnectionMessage (msgKey, msgOptions) {
|
|
|
|
if (msgKey) {
|
|
|
|
$('#remoteConnectionMessage')
|
2016-10-21 17:11:22 +00:00
|
|
|
.attr("data-i18n", msgKey)
|
|
|
|
.attr("data-i18n-options", JSON.stringify(msgOptions));
|
2016-11-02 16:28:44 +00:00
|
|
|
APP.translation.translateElement(
|
|
|
|
$('#remoteConnectionMessage'), msgOptions);
|
2016-09-24 18:24:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this.videoContainer.positionRemoteConnectionMessage();
|
|
|
|
}
|
|
|
|
|
2016-09-24 16:52:38 +00:00
|
|
|
/**
|
2016-09-24 18:30:29 +00:00
|
|
|
* Updated the text which is to be shown on the top of large video, when
|
|
|
|
* local media connection is interrupted.
|
2016-09-24 16:52:38 +00:00
|
|
|
*
|
|
|
|
* @param {string} msgKey the translation key which will be used to get
|
|
|
|
* the message text to be displayed on the large video.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
*/
|
2016-11-02 16:28:44 +00:00
|
|
|
_setLocalConnectionMessage (msgKey) {
|
2016-09-24 18:30:29 +00:00
|
|
|
$('#localConnectionMessage')
|
2016-11-02 16:28:44 +00:00
|
|
|
.attr("data-i18n", msgKey);
|
2016-10-21 17:11:22 +00:00
|
|
|
APP.translation.translateElement($('#localConnectionMessage'));
|
2016-09-24 16:52:38 +00:00
|
|
|
}
|
|
|
|
|
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-09-22 17:37:14 +00:00
|
|
|
// FIXME when video is being replaced with other content we need to hide
|
|
|
|
// companion icons/messages. It would be best if the container would
|
|
|
|
// be taking care of it by itself, but that is a bigger refactoring
|
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-09-24 18:30:29 +00:00
|
|
|
this.showLocalConnectionMessage(false);
|
2016-09-24 18:24:18 +00:00
|
|
|
this.showRemoteConnectionMessage(false);
|
2016-02-17 12:37:06 +00:00
|
|
|
}
|
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-09-22 17:37:14 +00:00
|
|
|
// FIXME when video appears on top of other content we need to
|
|
|
|
// show companion icons/messages. It would be best if
|
|
|
|
// the container would be taking care of it by itself, but that
|
|
|
|
// is a bigger refactoring
|
2016-02-17 12:37:06 +00:00
|
|
|
this.showWatermark(true);
|
2016-09-24 18:24:18 +00:00
|
|
|
// "avatar" and "video connection" can not be displayed both
|
|
|
|
// at the same time, but the latter is of higher priority and it
|
|
|
|
// will hide the avatar one if will be displayed.
|
2017-03-21 17:14:13 +00:00
|
|
|
this.showRemoteConnectionMessage(/* fetch the current state */);
|
2016-09-24 18:30:29 +00:00
|
|
|
this.showLocalConnectionMessage(/* fetch the current state */);
|
2016-02-17 12:37:06 +00:00
|
|
|
}
|
|
|
|
});
|
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);
|
|
|
|
}
|
2017-05-11 00:19:35 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Dispatches an action to update the known resolution state of the
|
|
|
|
* large video.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_updateVideoResolutionStatus() {
|
|
|
|
const { height, width } = this.videoContainer.getStreamSize();
|
2017-05-17 19:57:22 +00:00
|
|
|
const isCurrentlyHD = Math.min(height, width) >= config.minHDHeight;
|
2017-05-11 00:19:35 +00:00
|
|
|
|
|
|
|
APP.store.dispatch(setLargeVideoHDStatus(isCurrentlyHD));
|
|
|
|
}
|
2015-12-25 16:55:45 +00:00
|
|
|
}
|