2015-01-07 14:54:03 +00:00
|
|
|
var AudioLevels = require("../audio_levels/AudioLevels");
|
|
|
|
var Avatar = require("../avatar/Avatar");
|
|
|
|
var Chat = require("../side_pannels/chat/Chat");
|
|
|
|
var ContactList = require("../side_pannels/contactlist/ContactList");
|
|
|
|
var UIUtil = require("../util/UIUtil");
|
|
|
|
var ConnectionIndicator = require("./ConnectionIndicator");
|
2015-01-22 16:02:37 +00:00
|
|
|
var NicknameHandler = require("../util/NicknameHandler");
|
2015-01-28 14:35:22 +00:00
|
|
|
var MediaStreamType = require("../../../service/RTC/MediaStreamTypes");
|
|
|
|
var UIEvents = require("../../../service/UI/UIEvents");
|
2015-01-07 14:54:03 +00:00
|
|
|
|
|
|
|
var currentDominantSpeaker = null;
|
|
|
|
var lastNCount = config.channelLastN;
|
|
|
|
var localLastNCount = config.channelLastN;
|
|
|
|
var localLastNSet = [];
|
|
|
|
var lastNEndpointsCache = [];
|
|
|
|
var lastNPickupJid = null;
|
|
|
|
var largeVideoState = {
|
|
|
|
updateInProgress: false,
|
|
|
|
newSrc: ''
|
|
|
|
};
|
2015-01-27 12:03:26 +00:00
|
|
|
|
|
|
|
var eventEmitter = null;
|
|
|
|
|
2015-01-20 15:56:00 +00:00
|
|
|
/**
|
|
|
|
* Currently focused video "src"(displayed in large video).
|
|
|
|
* @type {String}
|
|
|
|
*/
|
|
|
|
var focusedVideoInfo = null;
|
2015-01-07 14:54:03 +00:00
|
|
|
|
2015-01-19 09:20:00 +00:00
|
|
|
/**
|
|
|
|
* Indicates if we have muted our audio before the conference has started.
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
var preMuted = false;
|
|
|
|
|
|
|
|
var mutedAudios = {};
|
|
|
|
|
|
|
|
var flipXLocalVideo = true;
|
|
|
|
var currentVideoWidth = null;
|
|
|
|
var currentVideoHeight = null;
|
|
|
|
|
|
|
|
var localVideoSrc = null;
|
|
|
|
|
|
|
|
function videoactive( videoelem) {
|
|
|
|
if (videoelem.attr('id').indexOf('mixedmslabel') === -1) {
|
|
|
|
// ignore mixedmslabela0 and v0
|
|
|
|
|
|
|
|
videoelem.show();
|
|
|
|
VideoLayout.resizeThumbnails();
|
|
|
|
|
|
|
|
var videoParent = videoelem.parent();
|
|
|
|
var parentResourceJid = null;
|
|
|
|
if (videoParent)
|
|
|
|
parentResourceJid
|
|
|
|
= VideoLayout.getPeerContainerResourceJid(videoParent[0]);
|
|
|
|
|
|
|
|
// Update the large video to the last added video only if there's no
|
|
|
|
// current dominant, focused speaker or prezi playing or update it to
|
|
|
|
// the current dominant speaker.
|
|
|
|
if ((!focusedVideoInfo &&
|
|
|
|
!VideoLayout.getDominantSpeakerResourceJid() &&
|
|
|
|
!require("../prezi/Prezi").isPresentationVisible()) ||
|
|
|
|
(parentResourceJid &&
|
|
|
|
VideoLayout.getDominantSpeakerResourceJid() === parentResourceJid)) {
|
|
|
|
VideoLayout.updateLargeVideo(
|
2015-01-28 14:35:22 +00:00
|
|
|
APP.RTC.getVideoSrc(videoelem[0]),
|
2015-01-19 09:20:00 +00:00
|
|
|
1,
|
|
|
|
parentResourceJid);
|
|
|
|
}
|
|
|
|
|
|
|
|
VideoLayout.showModeratorIndicator();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function waitForRemoteVideo(selector, ssrc, stream, jid) {
|
|
|
|
// XXX(gp) so, every call to this function is *always* preceded by a call
|
|
|
|
// to the RTC.attachMediaStream() function but that call is *not* followed
|
|
|
|
// by an update to the videoSrcToSsrc map!
|
|
|
|
//
|
|
|
|
// The above way of doing things results in video SRCs that don't correspond
|
|
|
|
// to any SSRC for a short period of time (to be more precise, for as long
|
|
|
|
// the waitForRemoteVideo takes to complete). This causes problems (see
|
|
|
|
// bellow).
|
|
|
|
//
|
|
|
|
// I'm wondering why we need to do that; i.e. why call RTC.attachMediaStream()
|
|
|
|
// a second time in here and only then update the videoSrcToSsrc map? Why
|
|
|
|
// not simply update the videoSrcToSsrc map when the RTC.attachMediaStream()
|
|
|
|
// is called the first time? I actually do that in the lastN changed event
|
|
|
|
// handler because the "orphan" video SRC is causing troubles there. The
|
|
|
|
// purpose of this method would then be to fire the "videoactive.jingle".
|
|
|
|
//
|
|
|
|
// Food for though I guess :-)
|
|
|
|
|
|
|
|
if (selector.removed || !selector.parent().is(":visible")) {
|
|
|
|
console.warn("Media removed before had started", selector);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (stream.id === 'mixedmslabel') return;
|
|
|
|
|
|
|
|
if (selector[0].currentTime > 0) {
|
2015-01-28 14:35:22 +00:00
|
|
|
var videoStream = APP.simulcast.getReceivingVideoStream(stream);
|
|
|
|
APP.RTC.attachMediaStream(selector, videoStream); // FIXME: why do i have to do this for FF?
|
2015-01-19 09:20:00 +00:00
|
|
|
videoactive(selector);
|
|
|
|
} else {
|
|
|
|
setTimeout(function () {
|
|
|
|
waitForRemoteVideo(selector, ssrc, stream, jid);
|
|
|
|
}, 250);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-09 11:35:48 +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
|
|
|
|
*/
|
|
|
|
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.
|
|
|
|
var isFullScreen = document.fullScreen ||
|
|
|
|
document.mozFullScreen ||
|
|
|
|
document.webkitIsFullScreen;
|
|
|
|
if (isFullScreen)
|
|
|
|
videoSpaceHeight = window.innerHeight;
|
|
|
|
|
|
|
|
var horizontalIndent = (videoSpaceWidth - videoWidth) / 2;
|
|
|
|
var verticalIndent = (videoSpaceHeight - videoHeight) / 2;
|
|
|
|
|
|
|
|
return [horizontalIndent, verticalIndent];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
function getDesktopVideoPosition(videoWidth,
|
|
|
|
videoHeight,
|
|
|
|
videoSpaceWidth,
|
|
|
|
videoSpaceHeight) {
|
|
|
|
|
|
|
|
var horizontalIndent = (videoSpaceWidth - videoWidth) / 2;
|
|
|
|
|
|
|
|
var verticalIndent = 0;// Top aligned
|
|
|
|
|
|
|
|
return [horizontalIndent, verticalIndent];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an array of the video dimensions, so that it covers the screen.
|
|
|
|
* It leaves no empty areas, but some parts of the video might not be visible.
|
|
|
|
*
|
|
|
|
* @return an array with 2 elements, the video width and the video height
|
|
|
|
*/
|
|
|
|
function getCameraVideoSize(videoWidth,
|
|
|
|
videoHeight,
|
|
|
|
videoSpaceWidth,
|
|
|
|
videoSpaceHeight) {
|
|
|
|
if (!videoWidth)
|
|
|
|
videoWidth = currentVideoWidth;
|
|
|
|
if (!videoHeight)
|
|
|
|
videoHeight = currentVideoHeight;
|
|
|
|
|
|
|
|
var aspectRatio = videoWidth / videoHeight;
|
|
|
|
|
|
|
|
var availableWidth = Math.max(videoWidth, videoSpaceWidth);
|
|
|
|
var availableHeight = Math.max(videoHeight, videoSpaceHeight);
|
|
|
|
|
|
|
|
if (availableWidth / aspectRatio < videoSpaceHeight) {
|
|
|
|
availableHeight = videoSpaceHeight;
|
|
|
|
availableWidth = availableHeight * aspectRatio;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (availableHeight * aspectRatio < videoSpaceWidth) {
|
|
|
|
availableWidth = videoSpaceWidth;
|
|
|
|
availableHeight = availableWidth / aspectRatio;
|
|
|
|
}
|
|
|
|
|
|
|
|
return [availableWidth, availableHeight];
|
|
|
|
}
|
|
|
|
|
2015-01-07 14:54:03 +00:00
|
|
|
/**
|
|
|
|
* Sets the display name for the given video span id.
|
|
|
|
*/
|
|
|
|
function setDisplayName(videoSpanId, displayName) {
|
|
|
|
var nameSpan = $('#' + videoSpanId + '>span.displayname');
|
|
|
|
var defaultLocalDisplayName = interfaceConfig.DEFAULT_LOCAL_DISPLAY_NAME;
|
|
|
|
|
|
|
|
// If we already have a display name for this video.
|
|
|
|
if (nameSpan.length > 0) {
|
|
|
|
var nameSpanElement = nameSpan.get(0);
|
|
|
|
|
|
|
|
if (nameSpanElement.id === 'localDisplayName' &&
|
|
|
|
$('#localDisplayName').text() !== displayName) {
|
|
|
|
if (displayName && displayName.length > 0)
|
|
|
|
$('#localDisplayName').html(displayName + ' (me)');
|
|
|
|
else
|
|
|
|
$('#localDisplayName').text(defaultLocalDisplayName);
|
|
|
|
} else {
|
|
|
|
if (displayName && displayName.length > 0)
|
|
|
|
$('#' + videoSpanId + '_name').html(displayName);
|
|
|
|
else
|
|
|
|
$('#' + videoSpanId + '_name').text(interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
var editButton = null;
|
|
|
|
|
|
|
|
nameSpan = document.createElement('span');
|
|
|
|
nameSpan.className = 'displayname';
|
|
|
|
$('#' + videoSpanId)[0].appendChild(nameSpan);
|
|
|
|
|
|
|
|
if (videoSpanId === 'localVideoContainer') {
|
|
|
|
editButton = createEditDisplayNameButton();
|
|
|
|
nameSpan.innerText = defaultLocalDisplayName;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nameSpan.innerText = interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (displayName && displayName.length > 0) {
|
|
|
|
nameSpan.innerText = displayName;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!editButton) {
|
|
|
|
nameSpan.id = videoSpanId + '_name';
|
|
|
|
} else {
|
|
|
|
nameSpan.id = 'localDisplayName';
|
|
|
|
$('#' + videoSpanId)[0].appendChild(editButton);
|
2015-02-06 15:46:50 +00:00
|
|
|
//translates popover of edit button
|
|
|
|
APP.translation.translateElement($("a.displayname"));
|
2015-01-07 14:54:03 +00:00
|
|
|
|
|
|
|
var editableText = document.createElement('input');
|
|
|
|
editableText.className = 'displayname';
|
|
|
|
editableText.type = 'text';
|
|
|
|
editableText.id = 'editDisplayName';
|
|
|
|
|
|
|
|
if (displayName && displayName.length) {
|
|
|
|
editableText.value
|
|
|
|
= displayName.substring(0, displayName.indexOf(' (me)'));
|
|
|
|
}
|
|
|
|
|
|
|
|
editableText.setAttribute('style', 'display:none;');
|
|
|
|
editableText.setAttribute('placeholder', 'ex. Jane Pink');
|
|
|
|
$('#' + videoSpanId)[0].appendChild(editableText);
|
|
|
|
|
|
|
|
$('#localVideoContainer .displayname')
|
|
|
|
.bind("click", function (e) {
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
$('#localDisplayName').hide();
|
|
|
|
$('#editDisplayName').show();
|
|
|
|
$('#editDisplayName').focus();
|
|
|
|
$('#editDisplayName').select();
|
|
|
|
|
|
|
|
$('#editDisplayName').one("focusout", function (e) {
|
|
|
|
VideoLayout.inputDisplayNameHandler(this.value);
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#editDisplayName').on('keydown', function (e) {
|
|
|
|
if (e.keyCode === 13) {
|
|
|
|
e.preventDefault();
|
|
|
|
VideoLayout.inputDisplayNameHandler(this.value);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the selector of video thumbnail container for the user identified by
|
|
|
|
* given <tt>userJid</tt>
|
|
|
|
* @param resourceJid user's Jid for whom we want to get the video container.
|
|
|
|
*/
|
|
|
|
function getParticipantContainer(resourceJid)
|
|
|
|
{
|
|
|
|
if (!resourceJid)
|
|
|
|
return null;
|
|
|
|
|
2015-01-28 14:35:22 +00:00
|
|
|
if (resourceJid === APP.xmpp.myResource())
|
2015-01-07 14:54:03 +00:00
|
|
|
return $("#localVideoContainer");
|
|
|
|
else
|
|
|
|
return $("#participant_" + resourceJid);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the size and position of the given video element.
|
|
|
|
*
|
|
|
|
* @param video the video element to position
|
|
|
|
* @param width the desired video width
|
|
|
|
* @param height the desired video height
|
|
|
|
* @param horizontalIndent the left and right indent
|
|
|
|
* @param verticalIndent the top and bottom indent
|
|
|
|
*/
|
|
|
|
function positionVideo(video,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
horizontalIndent,
|
|
|
|
verticalIndent) {
|
|
|
|
video.width(width);
|
|
|
|
video.height(height);
|
|
|
|
video.css({ top: verticalIndent + 'px',
|
|
|
|
bottom: verticalIndent + 'px',
|
|
|
|
left: horizontalIndent + 'px',
|
|
|
|
right: horizontalIndent + 'px'});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds the remote video menu element for the given <tt>jid</tt> in the
|
|
|
|
* given <tt>parentElement</tt>.
|
|
|
|
*
|
|
|
|
* @param jid the jid indicating the video for which we're adding a menu.
|
|
|
|
* @param parentElement the parent element where this menu will be added
|
|
|
|
*/
|
|
|
|
function addRemoteVideoMenu(jid, parentElement) {
|
|
|
|
var spanElement = document.createElement('span');
|
|
|
|
spanElement.className = 'remotevideomenu';
|
|
|
|
|
|
|
|
parentElement.appendChild(spanElement);
|
|
|
|
|
|
|
|
var menuElement = document.createElement('i');
|
|
|
|
menuElement.className = 'fa fa-angle-down';
|
|
|
|
menuElement.title = 'Remote user controls';
|
|
|
|
spanElement.appendChild(menuElement);
|
|
|
|
|
|
|
|
// <ul class="popupmenu">
|
|
|
|
// <li><a href="#">Mute</a></li>
|
|
|
|
// <li><a href="#">Eject</a></li>
|
|
|
|
// </ul>
|
|
|
|
|
|
|
|
var popupmenuElement = document.createElement('ul');
|
|
|
|
popupmenuElement.className = 'popupmenu';
|
|
|
|
popupmenuElement.id
|
|
|
|
= 'remote_popupmenu_' + Strophe.getResourceFromJid(jid);
|
|
|
|
spanElement.appendChild(popupmenuElement);
|
|
|
|
|
|
|
|
var muteMenuItem = document.createElement('li');
|
|
|
|
var muteLinkItem = document.createElement('a');
|
|
|
|
|
2015-02-06 15:46:50 +00:00
|
|
|
var mutedIndicator = "<i style='float:left;' class='icon-mic-disabled'></i>";
|
2015-01-07 14:54:03 +00:00
|
|
|
|
|
|
|
if (!mutedAudios[jid]) {
|
2015-02-06 15:46:50 +00:00
|
|
|
muteLinkItem.innerHTML = mutedIndicator +
|
|
|
|
" <div style='width: 90px;margin-left: 20px;' data-i18n='videothumbnail.domute'></div>";
|
2015-01-07 14:54:03 +00:00
|
|
|
muteLinkItem.className = 'mutelink';
|
|
|
|
}
|
|
|
|
else {
|
2015-02-06 15:46:50 +00:00
|
|
|
muteLinkItem.innerHTML = mutedIndicator +
|
|
|
|
" <div style='width: 90px;margin-left: 20px;' data-i18n='videothumbnail.muted'></div>";
|
2015-01-07 14:54:03 +00:00
|
|
|
muteLinkItem.className = 'mutelink disabled';
|
|
|
|
}
|
|
|
|
|
|
|
|
muteLinkItem.onclick = function(){
|
|
|
|
if ($(this).attr('disabled') != undefined) {
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
|
|
|
var isMute = mutedAudios[jid] == true;
|
2015-01-28 14:35:22 +00:00
|
|
|
APP.xmpp.setMute(jid, !isMute);
|
2015-01-19 09:20:00 +00:00
|
|
|
|
2015-01-07 14:54:03 +00:00
|
|
|
popupmenuElement.setAttribute('style', 'display:none;');
|
|
|
|
|
|
|
|
if (isMute) {
|
2015-02-06 15:46:50 +00:00
|
|
|
this.innerHTML = mutedIndicator +
|
|
|
|
" <div style='width: 90px;margin-left: 20px;' data-i18n='videothumbnail.muted'></div>";
|
2015-01-07 14:54:03 +00:00
|
|
|
this.className = 'mutelink disabled';
|
|
|
|
}
|
|
|
|
else {
|
2015-02-06 15:46:50 +00:00
|
|
|
this.innerHTML = mutedIndicator +
|
|
|
|
" <div style='width: 90px;margin-left: 20px;' data-i18n='videothumbnail.domute'></div>";
|
2015-01-07 14:54:03 +00:00
|
|
|
this.className = 'mutelink';
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
muteMenuItem.appendChild(muteLinkItem);
|
|
|
|
popupmenuElement.appendChild(muteMenuItem);
|
|
|
|
|
2015-02-06 15:46:50 +00:00
|
|
|
var ejectIndicator = "<i style='float:left;' class='fa fa-eject'></i>";
|
2015-01-07 14:54:03 +00:00
|
|
|
|
|
|
|
var ejectMenuItem = document.createElement('li');
|
|
|
|
var ejectLinkItem = document.createElement('a');
|
2015-02-06 15:46:50 +00:00
|
|
|
var ejectText = "<div style='width: 90px;margin-left: 20px;' data-i18n='videothumbnail.kick'> </div>";
|
|
|
|
ejectLinkItem.innerHTML = ejectIndicator + ' ' + ejectText;
|
2015-01-07 14:54:03 +00:00
|
|
|
ejectLinkItem.onclick = function(){
|
2015-01-28 14:35:22 +00:00
|
|
|
APP.xmpp.eject(jid);
|
2015-01-07 14:54:03 +00:00
|
|
|
popupmenuElement.setAttribute('style', 'display:none;');
|
2014-10-06 11:35:22 +00:00
|
|
|
};
|
2014-11-21 13:29:05 +00:00
|
|
|
|
2015-01-07 14:54:03 +00:00
|
|
|
ejectMenuItem.appendChild(ejectLinkItem);
|
|
|
|
popupmenuElement.appendChild(ejectMenuItem);
|
|
|
|
|
|
|
|
var paddingSpan = document.createElement('span');
|
|
|
|
paddingSpan.className = 'popupmenuPadding';
|
|
|
|
popupmenuElement.appendChild(paddingSpan);
|
2015-02-06 15:46:50 +00:00
|
|
|
APP.translation.translateElement($("#" + popupmenuElement.id + " > li > a > div"));
|
2015-01-07 14:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes remote video menu element from video element identified by
|
|
|
|
* given <tt>videoElementId</tt>.
|
|
|
|
*
|
|
|
|
* @param videoElementId the id of local or remote video element.
|
|
|
|
*/
|
|
|
|
function removeRemoteVideoMenu(videoElementId) {
|
|
|
|
var menuSpan = $('#' + videoElementId + '>span.remotevideomenu');
|
|
|
|
if (menuSpan.length) {
|
|
|
|
menuSpan.remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates the data for the indicator
|
|
|
|
* @param id the id of the indicator
|
|
|
|
* @param percent the percent for connection quality
|
|
|
|
* @param object the data
|
|
|
|
*/
|
|
|
|
function updateStatsIndicator(id, percent, object) {
|
|
|
|
if(VideoLayout.connectionIndicators[id])
|
|
|
|
VideoLayout.connectionIndicators[id].updateConnectionQuality(percent, object);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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) {
|
|
|
|
if (!videoWidth)
|
|
|
|
videoWidth = currentVideoWidth;
|
|
|
|
if (!videoHeight)
|
|
|
|
videoHeight = currentVideoHeight;
|
|
|
|
|
|
|
|
var aspectRatio = videoWidth / videoHeight;
|
|
|
|
|
|
|
|
var availableWidth = Math.max(videoWidth, videoSpaceWidth);
|
|
|
|
var availableHeight = Math.max(videoHeight, videoSpaceHeight);
|
|
|
|
|
|
|
|
videoSpaceHeight -= $('#remoteVideos').outerHeight();
|
|
|
|
|
|
|
|
if (availableWidth / aspectRatio >= videoSpaceHeight)
|
|
|
|
{
|
|
|
|
availableHeight = videoSpaceHeight;
|
|
|
|
availableWidth = availableHeight * aspectRatio;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (availableHeight * aspectRatio >= videoSpaceWidth)
|
|
|
|
{
|
|
|
|
availableWidth = videoSpaceWidth;
|
|
|
|
availableHeight = availableWidth / aspectRatio;
|
|
|
|
}
|
|
|
|
|
|
|
|
return [availableWidth, availableHeight];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates the edit display name button.
|
|
|
|
*
|
|
|
|
* @returns the edit button
|
|
|
|
*/
|
|
|
|
function createEditDisplayNameButton() {
|
|
|
|
var editButton = document.createElement('a');
|
|
|
|
editButton.className = 'displayname';
|
2015-01-23 12:01:44 +00:00
|
|
|
UIUtil.setTooltip(editButton,
|
2015-02-06 15:46:50 +00:00
|
|
|
"videothumbnail.editnickname",
|
2015-01-07 14:54:03 +00:00
|
|
|
"top");
|
|
|
|
editButton.innerHTML = '<i class="fa fa-pencil"></i>';
|
|
|
|
|
|
|
|
return editButton;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates the element indicating the moderator(owner) of the conference.
|
|
|
|
*
|
|
|
|
* @param parentElement the parent element where the owner indicator will
|
|
|
|
* be added
|
|
|
|
*/
|
|
|
|
function createModeratorIndicatorElement(parentElement) {
|
|
|
|
var moderatorIndicator = document.createElement('i');
|
|
|
|
moderatorIndicator.className = 'fa fa-star';
|
|
|
|
parentElement.appendChild(moderatorIndicator);
|
|
|
|
|
2015-01-23 12:01:44 +00:00
|
|
|
UIUtil.setTooltip(parentElement,
|
2015-02-06 15:46:50 +00:00
|
|
|
"videothumbnail.moderator",
|
2015-01-07 14:54:03 +00:00
|
|
|
"top");
|
|
|
|
}
|
|
|
|
|
2014-11-21 13:29:05 +00:00
|
|
|
|
2015-01-07 14:54:03 +00:00
|
|
|
var VideoLayout = (function (my) {
|
2014-10-16 15:11:26 +00:00
|
|
|
my.connectionIndicators = {};
|
2014-06-12 18:33:57 +00:00
|
|
|
|
2015-01-09 12:19:48 +00:00
|
|
|
// By default we use camera
|
|
|
|
my.getVideoSize = getCameraVideoSize;
|
|
|
|
my.getVideoPosition = getCameraVideoPosition;
|
|
|
|
|
2015-01-27 12:03:26 +00:00
|
|
|
my.init = function (emitter) {
|
2015-01-19 09:20:00 +00:00
|
|
|
// Listen for large video size updates
|
|
|
|
document.getElementById('largeVideo')
|
|
|
|
.addEventListener('loadedmetadata', function (e) {
|
|
|
|
currentVideoWidth = this.videoWidth;
|
|
|
|
currentVideoHeight = this.videoHeight;
|
|
|
|
VideoLayout.positionLarge(currentVideoWidth, currentVideoHeight);
|
|
|
|
});
|
2015-01-27 12:03:26 +00:00
|
|
|
eventEmitter = emitter;
|
2015-01-19 09:20:00 +00:00
|
|
|
};
|
|
|
|
|
2014-11-27 18:28:28 +00:00
|
|
|
my.isInLastN = function(resource) {
|
|
|
|
return lastNCount < 0 // lastN is disabled, return true
|
|
|
|
|| (lastNCount > 0 && lastNEndpointsCache.length == 0) // lastNEndpoints cache not built yet, return true
|
|
|
|
|| (lastNEndpointsCache && lastNEndpointsCache.indexOf(resource) !== -1);
|
|
|
|
};
|
|
|
|
|
2014-11-21 14:50:16 +00:00
|
|
|
my.changeLocalStream = function (stream) {
|
2015-01-13 13:11:05 +00:00
|
|
|
VideoLayout.changeLocalVideo(stream);
|
2014-12-04 15:02:48 +00:00
|
|
|
};
|
2014-06-12 18:33:57 +00:00
|
|
|
|
2014-11-21 14:50:16 +00:00
|
|
|
my.changeLocalAudio = function(stream) {
|
2015-01-28 14:35:22 +00:00
|
|
|
APP.RTC.attachMediaStream($('#localAudio'), stream.getOriginalStream());
|
2014-11-21 14:50:16 +00:00
|
|
|
document.getElementById('localAudio').autoplay = true;
|
|
|
|
document.getElementById('localAudio').volume = 0;
|
2014-11-28 15:20:43 +00:00
|
|
|
if (preMuted) {
|
2015-01-28 14:35:22 +00:00
|
|
|
if(!APP.UI.setAudioMuted(true))
|
2015-01-19 09:20:00 +00:00
|
|
|
{
|
|
|
|
preMuted = mute;
|
|
|
|
}
|
2014-11-28 15:20:43 +00:00
|
|
|
preMuted = false;
|
|
|
|
}
|
2014-06-12 18:33:57 +00:00
|
|
|
};
|
|
|
|
|
2015-01-13 13:11:05 +00:00
|
|
|
my.changeLocalVideo = function(stream) {
|
|
|
|
var flipX = true;
|
2015-01-20 15:56:00 +00:00
|
|
|
if(stream.videoType == "screen")
|
2015-01-13 13:11:05 +00:00
|
|
|
flipX = false;
|
2014-06-12 18:33:57 +00:00
|
|
|
var localVideo = document.createElement('video');
|
2015-01-13 13:11:05 +00:00
|
|
|
localVideo.id = 'localVideo_' +
|
2015-01-28 14:35:22 +00:00
|
|
|
APP.RTC.getStreamID(stream.getOriginalStream());
|
2014-06-12 18:33:57 +00:00
|
|
|
localVideo.autoplay = true;
|
|
|
|
localVideo.volume = 0; // is it required if audio is separated ?
|
|
|
|
localVideo.oncontextmenu = function () { return false; };
|
|
|
|
|
|
|
|
var localVideoContainer = document.getElementById('localVideoWrapper');
|
|
|
|
localVideoContainer.appendChild(localVideo);
|
|
|
|
|
2014-08-27 07:20:05 +00:00
|
|
|
// Set default display name.
|
|
|
|
setDisplayName('localVideoContainer');
|
|
|
|
|
2014-10-16 15:11:26 +00:00
|
|
|
if(!VideoLayout.connectionIndicators["localVideoContainer"]) {
|
|
|
|
VideoLayout.connectionIndicators["localVideoContainer"]
|
2015-01-07 14:54:03 +00:00
|
|
|
= new ConnectionIndicator($("#localVideoContainer")[0], null, VideoLayout);
|
2014-10-16 15:11:26 +00:00
|
|
|
}
|
|
|
|
|
2015-01-07 14:54:03 +00:00
|
|
|
AudioLevels.updateAudioLevelCanvas(null, VideoLayout);
|
2014-07-22 13:12:48 +00:00
|
|
|
|
2014-06-12 18:33:57 +00:00
|
|
|
var localVideoSelector = $('#' + localVideo.id);
|
2015-01-28 14:35:22 +00:00
|
|
|
|
|
|
|
function localVideoClick(event) {
|
2014-12-04 16:03:45 +00:00
|
|
|
event.stopPropagation();
|
|
|
|
VideoLayout.handleVideoThumbClicked(
|
2015-01-28 14:35:22 +00:00
|
|
|
APP.RTC.getVideoSrc(localVideo),
|
2014-12-04 16:03:45 +00:00
|
|
|
false,
|
2015-01-28 14:35:22 +00:00
|
|
|
APP.xmpp.myResource());
|
|
|
|
}
|
|
|
|
// Add click handler to both video and video wrapper elements in case
|
|
|
|
// there's no video.
|
|
|
|
localVideoSelector.click(localVideoClick);
|
|
|
|
$('#localVideoContainer').click(localVideoClick);
|
2014-07-01 10:31:13 +00:00
|
|
|
|
2014-06-12 18:33:57 +00:00
|
|
|
// Add hover handler
|
|
|
|
$('#localVideoContainer').hover(
|
|
|
|
function() {
|
|
|
|
VideoLayout.showDisplayName('localVideoContainer', true);
|
|
|
|
},
|
|
|
|
function() {
|
2014-07-01 10:31:13 +00:00
|
|
|
if (!VideoLayout.isLargeVideoVisible()
|
2015-01-28 14:35:22 +00:00
|
|
|
|| APP.RTC.getVideoSrc(localVideo) !== APP.RTC.getVideoSrc($('#largeVideo')[0]))
|
2014-06-12 18:33:57 +00:00
|
|
|
VideoLayout.showDisplayName('localVideoContainer', false);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
// Add stream ended handler
|
2015-01-13 13:11:05 +00:00
|
|
|
stream.getOriginalStream().onended = function () {
|
2014-06-12 18:33:57 +00:00
|
|
|
localVideoContainer.removeChild(localVideo);
|
2015-01-28 14:35:22 +00:00
|
|
|
VideoLayout.updateRemovedVideo(APP.RTC.getVideoSrc(localVideo));
|
2014-06-12 18:33:57 +00:00
|
|
|
};
|
|
|
|
// Flip video x axis if needed
|
|
|
|
flipXLocalVideo = flipX;
|
|
|
|
if (flipX) {
|
|
|
|
localVideoSelector.addClass("flipVideoX");
|
|
|
|
}
|
|
|
|
// Attach WebRTC stream
|
2015-01-28 14:35:22 +00:00
|
|
|
var videoStream = APP.simulcast.getLocalVideoStream();
|
|
|
|
APP.RTC.attachMediaStream(localVideoSelector, videoStream);
|
2014-06-12 18:33:57 +00:00
|
|
|
|
2015-01-28 14:35:22 +00:00
|
|
|
localVideoSrc = APP.RTC.getVideoSrc(localVideo);
|
2014-11-21 13:29:05 +00:00
|
|
|
|
2015-01-28 14:35:22 +00:00
|
|
|
var myResourceJid = APP.xmpp.myResource();
|
2015-01-19 09:20:00 +00:00
|
|
|
|
2014-11-21 13:29:05 +00:00
|
|
|
VideoLayout.updateLargeVideo(localVideoSrc, 0,
|
|
|
|
myResourceJid);
|
2014-08-22 15:37:11 +00:00
|
|
|
|
2014-06-12 18:33:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2014-06-19 13:40:54 +00:00
|
|
|
* Checks if removed video is currently displayed and tries to display
|
|
|
|
* another one instead.
|
2014-06-12 18:33:57 +00:00
|
|
|
* @param removedVideoSrc src stream identifier of the video.
|
|
|
|
*/
|
2014-08-22 15:37:11 +00:00
|
|
|
my.updateRemovedVideo = function(removedVideoSrc) {
|
2015-01-28 14:35:22 +00:00
|
|
|
if (removedVideoSrc === APP.RTC.getVideoSrc($('#largeVideo')[0])) {
|
2014-06-12 18:33:57 +00:00
|
|
|
// this is currently displayed as large
|
|
|
|
// pick the last visible video in the row
|
|
|
|
// if nobody else is left, this picks the local video
|
2014-06-19 13:40:54 +00:00
|
|
|
var pick
|
|
|
|
= $('#remoteVideos>span[id!="mixedstream"]:visible:last>video')
|
|
|
|
.get(0);
|
2014-06-12 18:33:57 +00:00
|
|
|
|
|
|
|
if (!pick) {
|
|
|
|
console.info("Last visible video no longer exists");
|
|
|
|
pick = $('#remoteVideos>span[id!="mixedstream"]>video').get(0);
|
2014-08-22 15:37:11 +00:00
|
|
|
|
2015-01-28 14:35:22 +00:00
|
|
|
if (!pick || !APP.RTC.getVideoSrc(pick)) {
|
2014-06-12 18:33:57 +00:00
|
|
|
// Try local video
|
|
|
|
console.info("Fallback to local video...");
|
|
|
|
pick = $('#remoteVideos>span>span>video').get(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// mute if localvideo
|
|
|
|
if (pick) {
|
2014-11-21 13:29:05 +00:00
|
|
|
var container = pick.parentNode;
|
|
|
|
var jid = null;
|
|
|
|
if(container)
|
2014-11-24 16:14:35 +00:00
|
|
|
{
|
|
|
|
if(container.id == "localVideoWrapper")
|
|
|
|
{
|
2015-01-28 14:35:22 +00:00
|
|
|
jid = APP.xmpp.myResource();
|
2014-11-24 16:14:35 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
jid = VideoLayout.getPeerContainerResourceJid(container);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-28 14:35:22 +00:00
|
|
|
VideoLayout.updateLargeVideo(APP.RTC.getVideoSrc(pick), pick.volume, jid);
|
2014-06-12 18:33:57 +00:00
|
|
|
} else {
|
|
|
|
console.warn("Failed to elect large video");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2015-01-07 14:54:03 +00:00
|
|
|
|
|
|
|
my.onRemoteStreamAdded = function (stream) {
|
|
|
|
var container;
|
|
|
|
var remotes = document.getElementById('remoteVideos');
|
|
|
|
|
|
|
|
if (stream.peerjid) {
|
|
|
|
VideoLayout.ensurePeerContainerExists(stream.peerjid);
|
|
|
|
|
|
|
|
container = document.getElementById(
|
|
|
|
'participant_' + Strophe.getResourceFromJid(stream.peerjid));
|
|
|
|
} else {
|
|
|
|
var id = stream.getOriginalStream().id;
|
|
|
|
if (id !== 'mixedmslabel'
|
|
|
|
// FIXME: default stream is added always with new focus
|
|
|
|
// (to be investigated)
|
|
|
|
&& id !== 'default') {
|
|
|
|
console.error('can not associate stream',
|
|
|
|
id,
|
|
|
|
'with a participant');
|
|
|
|
// We don't want to add it here since it will cause troubles
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// FIXME: for the mixed ms we dont need a video -- currently
|
|
|
|
container = document.createElement('span');
|
|
|
|
container.id = 'mixedstream';
|
|
|
|
container.className = 'videocontainer';
|
|
|
|
remotes.appendChild(container);
|
2015-01-23 12:01:44 +00:00
|
|
|
UIUtil.playSoundNotification('userJoined');
|
2015-01-07 14:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (container) {
|
|
|
|
VideoLayout.addRemoteStreamElement( container,
|
|
|
|
stream.sid,
|
|
|
|
stream.getOriginalStream(),
|
|
|
|
stream.peerjid,
|
|
|
|
stream.ssrc);
|
|
|
|
}
|
|
|
|
}
|
2014-06-12 18:33:57 +00:00
|
|
|
|
2014-11-21 13:29:05 +00:00
|
|
|
my.getLargeVideoState = function () {
|
|
|
|
return largeVideoState;
|
2014-12-04 16:03:45 +00:00
|
|
|
};
|
2014-11-21 13:29:05 +00:00
|
|
|
|
2014-06-12 18:33:57 +00:00
|
|
|
/**
|
|
|
|
* Updates the large video with the given new video source.
|
|
|
|
*/
|
2014-12-04 16:03:45 +00:00
|
|
|
my.updateLargeVideo = function(newSrc, vol, resourceJid) {
|
2014-06-12 18:33:57 +00:00
|
|
|
console.log('hover in', newSrc);
|
|
|
|
|
2015-01-28 14:35:22 +00:00
|
|
|
if (APP.RTC.getVideoSrc($('#largeVideo')[0]) !== newSrc) {
|
2014-06-12 18:33:57 +00:00
|
|
|
|
2014-12-12 09:32:16 +00:00
|
|
|
$('#activeSpeaker').css('visibility', 'hidden');
|
2014-10-06 11:35:22 +00:00
|
|
|
// Due to the simulcast the localVideoSrc may have changed when the
|
|
|
|
// fadeOut event triggers. In that case the getJidFromVideoSrc and
|
|
|
|
// isVideoSrcDesktop methods will not function correctly.
|
|
|
|
//
|
|
|
|
// Also, again due to the simulcast, the updateLargeVideo method can
|
|
|
|
// be called multiple times almost simultaneously. Therefore, we
|
|
|
|
// store the state here and update only once.
|
|
|
|
|
|
|
|
largeVideoState.newSrc = newSrc;
|
|
|
|
largeVideoState.isVisible = $('#largeVideo').is(':visible');
|
2015-01-28 14:35:22 +00:00
|
|
|
largeVideoState.isDesktop = APP.RTC.isVideoSrcDesktop(resourceJid);
|
2015-01-20 15:56:00 +00:00
|
|
|
if(largeVideoState.userResourceJid) {
|
2014-12-04 16:03:45 +00:00
|
|
|
largeVideoState.oldResourceJid = largeVideoState.userResourceJid;
|
|
|
|
} else {
|
|
|
|
largeVideoState.oldResourceJid = null;
|
2014-11-24 16:14:35 +00:00
|
|
|
}
|
2014-12-04 16:03:45 +00:00
|
|
|
largeVideoState.userResourceJid = resourceJid;
|
2014-10-06 11:35:22 +00:00
|
|
|
|
|
|
|
// Screen stream is already rotated
|
|
|
|
largeVideoState.flipX = (newSrc === localVideoSrc) && flipXLocalVideo;
|
|
|
|
|
2014-10-26 19:57:13 +00:00
|
|
|
var userChanged = false;
|
2014-12-04 16:03:45 +00:00
|
|
|
if (largeVideoState.oldResourceJid !== largeVideoState.userResourceJid) {
|
2014-10-26 19:57:13 +00:00
|
|
|
userChanged = true;
|
2014-10-06 11:35:22 +00:00
|
|
|
// we want the notification to trigger even if userJid is undefined,
|
|
|
|
// or null.
|
2015-01-27 12:03:26 +00:00
|
|
|
eventEmitter.emit(UIEvents.SELECTED_ENDPOINT,
|
|
|
|
largeVideoState.userResourceJid);
|
2014-10-06 11:35:22 +00:00
|
|
|
}
|
2014-09-12 17:54:40 +00:00
|
|
|
|
2014-10-06 11:35:22 +00:00
|
|
|
if (!largeVideoState.updateInProgress) {
|
|
|
|
largeVideoState.updateInProgress = true;
|
2014-09-16 13:43:41 +00:00
|
|
|
|
2014-10-06 11:35:22 +00:00
|
|
|
var doUpdate = function () {
|
2014-07-01 10:31:13 +00:00
|
|
|
|
2014-12-04 16:03:45 +00:00
|
|
|
Avatar.updateActiveSpeakerAvatarSrc(
|
2015-01-28 14:35:22 +00:00
|
|
|
APP.xmpp.findJidFromResource(
|
2014-12-04 16:03:45 +00:00
|
|
|
largeVideoState.userResourceJid));
|
2014-10-31 11:47:12 +00:00
|
|
|
|
2014-12-04 16:03:45 +00:00
|
|
|
if (!userChanged && largeVideoState.preload &&
|
|
|
|
largeVideoState.preload !== null &&
|
2015-01-28 14:35:22 +00:00
|
|
|
APP.RTC.getVideoSrc($(largeVideoState.preload)[0]) === newSrc)
|
2014-11-21 13:29:05 +00:00
|
|
|
{
|
2014-10-26 19:57:13 +00:00
|
|
|
|
|
|
|
console.info('Switching to preloaded video');
|
|
|
|
var attributes = $('#largeVideo').prop("attributes");
|
|
|
|
|
|
|
|
// loop through largeVideo attributes and apply them on
|
|
|
|
// preload.
|
|
|
|
$.each(attributes, function () {
|
2014-12-04 16:03:45 +00:00
|
|
|
if (this.name !== 'id' && this.name !== 'src') {
|
2014-10-26 19:57:13 +00:00
|
|
|
largeVideoState.preload.attr(this.name, this.value);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
largeVideoState.preload.appendTo($('#largeVideoContainer'));
|
|
|
|
$('#largeVideo').attr('id', 'previousLargeVideo');
|
|
|
|
largeVideoState.preload.attr('id', 'largeVideo');
|
|
|
|
$('#previousLargeVideo').remove();
|
|
|
|
|
|
|
|
largeVideoState.preload.on('loadedmetadata', function (e) {
|
|
|
|
currentVideoWidth = this.videoWidth;
|
|
|
|
currentVideoHeight = this.videoHeight;
|
|
|
|
VideoLayout.positionLarge(currentVideoWidth, currentVideoHeight);
|
|
|
|
});
|
|
|
|
largeVideoState.preload = null;
|
|
|
|
largeVideoState.preload_ssrc = 0;
|
|
|
|
} else {
|
2015-01-28 14:35:22 +00:00
|
|
|
APP.RTC.setVideoSrc($('#largeVideo')[0], largeVideoState.newSrc);
|
2014-10-26 19:57:13 +00:00
|
|
|
}
|
2014-06-12 18:33:57 +00:00
|
|
|
|
2014-10-06 11:35:22 +00:00
|
|
|
var videoTransform = document.getElementById('largeVideo')
|
|
|
|
.style.webkitTransform;
|
2014-06-12 18:33:57 +00:00
|
|
|
|
2014-10-06 11:35:22 +00:00
|
|
|
if (largeVideoState.flipX && videoTransform !== 'scaleX(-1)') {
|
|
|
|
document.getElementById('largeVideo').style.webkitTransform
|
|
|
|
= "scaleX(-1)";
|
|
|
|
}
|
|
|
|
else if (!largeVideoState.flipX && videoTransform === 'scaleX(-1)') {
|
|
|
|
document.getElementById('largeVideo').style.webkitTransform
|
|
|
|
= "none";
|
|
|
|
}
|
2014-06-12 18:33:57 +00:00
|
|
|
|
2014-10-06 11:35:22 +00:00
|
|
|
// Change the way we'll be measuring and positioning large video
|
|
|
|
|
2015-01-09 12:19:48 +00:00
|
|
|
VideoLayout.getVideoSize = largeVideoState.isDesktop
|
2014-10-06 11:35:22 +00:00
|
|
|
? getDesktopVideoSize
|
|
|
|
: getCameraVideoSize;
|
2015-01-09 12:19:48 +00:00
|
|
|
VideoLayout.getVideoPosition = largeVideoState.isDesktop
|
2014-10-06 11:35:22 +00:00
|
|
|
? getDesktopVideoPosition
|
|
|
|
: getCameraVideoPosition;
|
|
|
|
|
2014-10-16 15:11:26 +00:00
|
|
|
|
2014-10-17 11:16:37 +00:00
|
|
|
// Only if the large video is currently visible.
|
|
|
|
// Disable previous dominant speaker video.
|
2014-12-04 16:03:45 +00:00
|
|
|
if (largeVideoState.oldResourceJid) {
|
|
|
|
VideoLayout.enableDominantSpeaker(
|
|
|
|
largeVideoState.oldResourceJid,
|
|
|
|
false);
|
2014-10-17 11:16:37 +00:00
|
|
|
}
|
2014-10-16 15:11:26 +00:00
|
|
|
|
2014-10-17 11:16:37 +00:00
|
|
|
// Enable new dominant speaker in the remote videos section.
|
2014-12-04 16:03:45 +00:00
|
|
|
if (largeVideoState.userResourceJid) {
|
|
|
|
VideoLayout.enableDominantSpeaker(
|
|
|
|
largeVideoState.userResourceJid,
|
|
|
|
true);
|
2014-10-17 11:16:37 +00:00
|
|
|
}
|
2014-10-16 15:11:26 +00:00
|
|
|
|
2014-10-26 19:57:13 +00:00
|
|
|
if (userChanged && largeVideoState.isVisible) {
|
2014-10-17 11:16:37 +00:00
|
|
|
// using "this" should be ok because we're called
|
|
|
|
// from within the fadeOut event.
|
|
|
|
$(this).fadeIn(300);
|
2014-07-01 10:31:13 +00:00
|
|
|
}
|
2014-10-17 11:16:37 +00:00
|
|
|
|
2014-10-31 11:47:12 +00:00
|
|
|
if(userChanged) {
|
2014-12-04 16:03:45 +00:00
|
|
|
Avatar.showUserAvatar(
|
2015-01-28 14:35:22 +00:00
|
|
|
APP.xmpp.findJidFromResource(
|
2014-12-04 16:03:45 +00:00
|
|
|
largeVideoState.oldResourceJid));
|
2014-10-31 11:47:12 +00:00
|
|
|
}
|
|
|
|
|
2014-10-17 11:16:37 +00:00
|
|
|
largeVideoState.updateInProgress = false;
|
2014-10-06 11:35:22 +00:00
|
|
|
};
|
2014-07-01 10:31:13 +00:00
|
|
|
|
2014-10-26 19:57:13 +00:00
|
|
|
if (userChanged) {
|
2014-10-06 11:35:22 +00:00
|
|
|
$('#largeVideo').fadeOut(300, doUpdate);
|
|
|
|
} else {
|
2014-10-21 08:07:49 +00:00
|
|
|
doUpdate();
|
2014-07-01 10:31:13 +00:00
|
|
|
}
|
2014-10-06 11:35:22 +00:00
|
|
|
}
|
2014-12-04 16:03:45 +00:00
|
|
|
} else {
|
|
|
|
Avatar.showUserAvatar(
|
2015-01-28 14:35:22 +00:00
|
|
|
APP.xmpp.findJidFromResource(
|
2014-12-04 16:03:45 +00:00
|
|
|
largeVideoState.userResourceJid));
|
2014-06-12 18:33:57 +00:00
|
|
|
}
|
2014-11-28 14:02:48 +00:00
|
|
|
|
2014-06-12 18:33:57 +00:00
|
|
|
};
|
|
|
|
|
2014-12-04 16:03:45 +00:00
|
|
|
my.handleVideoThumbClicked = function(videoSrc,
|
|
|
|
noPinnedEndpointChangedEvent,
|
|
|
|
resourceJid) {
|
2014-06-12 18:33:57 +00:00
|
|
|
// Restore style for previously focused video
|
2014-11-21 13:29:05 +00:00
|
|
|
var oldContainer = null;
|
2014-12-04 16:03:45 +00:00
|
|
|
if(focusedVideoInfo) {
|
2014-11-28 14:02:48 +00:00
|
|
|
var focusResourceJid = focusedVideoInfo.resourceJid;
|
2014-12-04 16:03:45 +00:00
|
|
|
oldContainer = getParticipantContainer(focusResourceJid);
|
2014-11-21 13:29:05 +00:00
|
|
|
}
|
2014-06-12 18:33:57 +00:00
|
|
|
|
|
|
|
if (oldContainer) {
|
|
|
|
oldContainer.removeClass("videoContainerFocused");
|
|
|
|
}
|
|
|
|
|
2014-11-24 11:00:15 +00:00
|
|
|
// Unlock current focused.
|
2014-12-04 16:03:45 +00:00
|
|
|
if (focusedVideoInfo && focusedVideoInfo.src === videoSrc)
|
2014-06-12 18:33:57 +00:00
|
|
|
{
|
2014-12-04 16:03:45 +00:00
|
|
|
focusedVideoInfo = null;
|
2014-07-16 14:35:54 +00:00
|
|
|
var dominantSpeakerVideo = null;
|
|
|
|
// Enable the currently set dominant speaker.
|
|
|
|
if (currentDominantSpeaker) {
|
|
|
|
dominantSpeakerVideo
|
|
|
|
= $('#participant_' + currentDominantSpeaker + '>video')
|
2014-07-03 07:28:25 +00:00
|
|
|
.get(0);
|
2014-07-01 10:31:13 +00:00
|
|
|
|
2014-08-22 15:37:11 +00:00
|
|
|
if (dominantSpeakerVideo) {
|
2014-12-04 16:03:45 +00:00
|
|
|
VideoLayout.updateLargeVideo(
|
2015-01-28 14:35:22 +00:00
|
|
|
APP.RTC.getVideoSrc(dominantSpeakerVideo),
|
2014-12-04 16:03:45 +00:00
|
|
|
1,
|
|
|
|
currentDominantSpeaker);
|
2014-08-22 15:37:11 +00:00
|
|
|
}
|
2014-06-24 11:59:14 +00:00
|
|
|
}
|
|
|
|
|
2014-11-24 14:58:50 +00:00
|
|
|
if (!noPinnedEndpointChangedEvent) {
|
2015-01-27 12:03:26 +00:00
|
|
|
eventEmitter.emit(UIEvents.PINNED_ENDPOINT);
|
2014-11-24 14:58:50 +00:00
|
|
|
}
|
2014-06-12 18:33:57 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Lock new video
|
2014-12-04 16:03:45 +00:00
|
|
|
focusedVideoInfo = {
|
2014-11-21 13:29:05 +00:00
|
|
|
src: videoSrc,
|
2014-11-28 14:02:48 +00:00
|
|
|
resourceJid: resourceJid
|
2014-11-21 13:29:05 +00:00
|
|
|
};
|
2014-06-12 18:33:57 +00:00
|
|
|
|
2014-07-01 10:31:13 +00:00
|
|
|
// Update focused/pinned interface.
|
2014-12-04 16:03:45 +00:00
|
|
|
if (resourceJid)
|
2014-06-12 18:33:57 +00:00
|
|
|
{
|
2014-12-04 16:03:45 +00:00
|
|
|
var container = getParticipantContainer(resourceJid);
|
2014-06-12 18:33:57 +00:00
|
|
|
container.addClass("videoContainerFocused");
|
2014-11-20 15:51:05 +00:00
|
|
|
|
2014-11-24 14:58:50 +00:00
|
|
|
if (!noPinnedEndpointChangedEvent) {
|
2015-01-27 12:03:26 +00:00
|
|
|
eventEmitter.emit(UIEvents.PINNED_ENDPOINT, resourceJid);
|
2014-11-24 14:58:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-28 14:02:48 +00:00
|
|
|
if ($('#largeVideo').attr('src') === videoSrc &&
|
|
|
|
VideoLayout.isLargeVideoOnTop()) {
|
2014-11-24 14:58:50 +00:00
|
|
|
return;
|
2014-06-12 18:33:57 +00:00
|
|
|
}
|
|
|
|
|
2014-07-01 10:31:13 +00:00
|
|
|
// Triggers a "video.selected" event. The "false" parameter indicates
|
|
|
|
// this isn't a prezi.
|
2014-09-16 13:43:41 +00:00
|
|
|
$(document).trigger("video.selected", [false]);
|
2014-06-12 18:33:57 +00:00
|
|
|
|
2014-12-04 16:03:45 +00:00
|
|
|
VideoLayout.updateLargeVideo(videoSrc, 1, resourceJid);
|
2014-06-12 18:33:57 +00:00
|
|
|
|
|
|
|
$('audio').each(function (idx, el) {
|
|
|
|
if (el.id.indexOf('mixedmslabel') !== -1) {
|
|
|
|
el.volume = 0;
|
|
|
|
el.volume = 1;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Positions the large video.
|
|
|
|
*
|
|
|
|
* @param videoWidth the stream video width
|
|
|
|
* @param videoHeight the stream video height
|
|
|
|
*/
|
|
|
|
my.positionLarge = function (videoWidth, videoHeight) {
|
|
|
|
var videoSpaceWidth = $('#videospace').width();
|
|
|
|
var videoSpaceHeight = window.innerHeight;
|
|
|
|
|
2015-01-09 12:19:48 +00:00
|
|
|
var videoSize = VideoLayout.getVideoSize(videoWidth,
|
2014-06-12 18:33:57 +00:00
|
|
|
videoHeight,
|
|
|
|
videoSpaceWidth,
|
|
|
|
videoSpaceHeight);
|
|
|
|
|
|
|
|
var largeVideoWidth = videoSize[0];
|
|
|
|
var largeVideoHeight = videoSize[1];
|
|
|
|
|
2015-01-09 12:19:48 +00:00
|
|
|
var videoPosition = VideoLayout.getVideoPosition(largeVideoWidth,
|
2014-06-12 18:33:57 +00:00
|
|
|
largeVideoHeight,
|
|
|
|
videoSpaceWidth,
|
|
|
|
videoSpaceHeight);
|
|
|
|
|
|
|
|
var horizontalIndent = videoPosition[0];
|
|
|
|
var verticalIndent = videoPosition[1];
|
|
|
|
|
|
|
|
positionVideo($('#largeVideo'),
|
|
|
|
largeVideoWidth,
|
|
|
|
largeVideoHeight,
|
|
|
|
horizontalIndent, verticalIndent);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows/hides the large video.
|
|
|
|
*/
|
|
|
|
my.setLargeVideoVisible = function(isVisible) {
|
2014-12-04 16:03:45 +00:00
|
|
|
var resourceJid = largeVideoState.userResourceJid;
|
2014-07-01 10:31:13 +00:00
|
|
|
|
2014-06-12 18:33:57 +00:00
|
|
|
if (isVisible) {
|
|
|
|
$('#largeVideo').css({visibility: 'visible'});
|
|
|
|
$('.watermark').css({visibility: 'visible'});
|
2014-07-16 14:35:54 +00:00
|
|
|
VideoLayout.enableDominantSpeaker(resourceJid, true);
|
2014-06-12 18:33:57 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$('#largeVideo').css({visibility: 'hidden'});
|
2014-12-12 09:32:16 +00:00
|
|
|
$('#activeSpeaker').css('visibility', 'hidden');
|
2014-06-12 18:33:57 +00:00
|
|
|
$('.watermark').css({visibility: 'hidden'});
|
2014-07-16 14:35:54 +00:00
|
|
|
VideoLayout.enableDominantSpeaker(resourceJid, false);
|
2014-11-28 14:02:48 +00:00
|
|
|
if(focusedVideoInfo) {
|
|
|
|
var focusResourceJid = focusedVideoInfo.resourceJid;
|
|
|
|
var oldContainer = getParticipantContainer(focusResourceJid);
|
2014-12-04 16:03:45 +00:00
|
|
|
|
2014-11-28 14:02:48 +00:00
|
|
|
if (oldContainer && oldContainer.length > 0) {
|
|
|
|
oldContainer.removeClass("videoContainerFocused");
|
|
|
|
}
|
|
|
|
focusedVideoInfo = null;
|
|
|
|
if(focusResourceJid) {
|
|
|
|
Avatar.showUserAvatar(
|
2015-01-28 14:35:22 +00:00
|
|
|
APP.xmpp.findJidFromResource(focusResourceJid));
|
2014-11-28 14:02:48 +00:00
|
|
|
}
|
2014-12-04 16:03:45 +00:00
|
|
|
}
|
2014-06-12 18:33:57 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-07-01 10:31:13 +00:00
|
|
|
/**
|
|
|
|
* Indicates if the large video is currently visible.
|
|
|
|
*
|
|
|
|
* @return <tt>true</tt> if visible, <tt>false</tt> - otherwise
|
|
|
|
*/
|
|
|
|
my.isLargeVideoVisible = function() {
|
|
|
|
return $('#largeVideo').is(':visible');
|
|
|
|
};
|
2014-06-12 18:33:57 +00:00
|
|
|
|
2014-11-28 14:02:48 +00:00
|
|
|
my.isLargeVideoOnTop = function () {
|
2015-01-07 14:54:03 +00:00
|
|
|
var Etherpad = require("../etherpad/Etherpad");
|
|
|
|
var Prezi = require("../prezi/Prezi");
|
2014-11-28 14:02:48 +00:00
|
|
|
return !Prezi.isPresentationVisible() && !Etherpad.isVisible();
|
|
|
|
};
|
|
|
|
|
2014-06-12 18:33:57 +00:00
|
|
|
/**
|
|
|
|
* Checks if container for participant identified by given peerJid exists
|
|
|
|
* in the document and creates it eventually.
|
|
|
|
*
|
|
|
|
* @param peerJid peer Jid to check.
|
2014-10-31 11:47:12 +00:00
|
|
|
* @param userId user email or id for setting the avatar
|
2014-08-22 15:37:11 +00:00
|
|
|
*
|
|
|
|
* @return Returns <tt>true</tt> if the peer container exists,
|
|
|
|
* <tt>false</tt> - otherwise
|
2014-06-12 18:33:57 +00:00
|
|
|
*/
|
2014-10-31 11:47:12 +00:00
|
|
|
my.ensurePeerContainerExists = function(peerJid, userId) {
|
|
|
|
ContactList.ensureAddContact(peerJid, userId);
|
2014-08-22 15:37:11 +00:00
|
|
|
|
|
|
|
var resourceJid = Strophe.getResourceFromJid(peerJid);
|
|
|
|
|
|
|
|
var videoSpanId = 'participant_' + resourceJid;
|
2014-06-12 18:33:57 +00:00
|
|
|
|
2015-01-07 09:38:15 +00:00
|
|
|
if (!$('#' + videoSpanId).length) {
|
2014-10-31 11:47:12 +00:00
|
|
|
var container =
|
|
|
|
VideoLayout.addRemoteVideoContainer(peerJid, videoSpanId, userId);
|
|
|
|
Avatar.setUserAvatar(peerJid, userId);
|
2014-08-27 07:20:05 +00:00
|
|
|
// Set default display name.
|
|
|
|
setDisplayName(videoSpanId);
|
|
|
|
|
2015-01-07 14:54:03 +00:00
|
|
|
VideoLayout.connectionIndicators[videoSpanId] =
|
|
|
|
new ConnectionIndicator(container, peerJid, VideoLayout);
|
2014-10-16 15:11:26 +00:00
|
|
|
|
2014-08-22 15:37:11 +00:00
|
|
|
var nickfield = document.createElement('span');
|
|
|
|
nickfield.className = "nick";
|
|
|
|
nickfield.appendChild(document.createTextNode(resourceJid));
|
|
|
|
container.appendChild(nickfield);
|
|
|
|
|
|
|
|
// In case this is not currently in the last n we don't show it.
|
2014-11-19 10:08:38 +00:00
|
|
|
if (localLastNCount
|
|
|
|
&& localLastNCount > 0
|
|
|
|
&& $('#remoteVideos>span').length >= localLastNCount + 2) {
|
|
|
|
showPeerContainer(resourceJid, 'hide');
|
2014-08-22 15:37:11 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
VideoLayout.resizeThumbnails();
|
|
|
|
}
|
2014-06-12 18:33:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
my.addRemoteVideoContainer = function(peerJid, spanId) {
|
|
|
|
var container = document.createElement('span');
|
|
|
|
container.id = spanId;
|
|
|
|
container.className = 'videocontainer';
|
|
|
|
var remotes = document.getElementById('remoteVideos');
|
2015-02-06 15:46:50 +00:00
|
|
|
remotes.appendChild(container);
|
2014-06-12 18:33:57 +00:00
|
|
|
// If the peerJid is null then this video span couldn't be directly
|
|
|
|
// associated with a participant (this could happen in the case of prezi).
|
2015-01-28 14:35:22 +00:00
|
|
|
if (APP.xmpp.isModerator() && peerJid !== null)
|
2014-06-12 18:33:57 +00:00
|
|
|
addRemoteVideoMenu(peerJid, container);
|
2015-01-07 14:54:03 +00:00
|
|
|
AudioLevels.updateAudioLevelCanvas(peerJid, VideoLayout);
|
2014-07-22 13:12:48 +00:00
|
|
|
|
2014-06-12 18:33:57 +00:00
|
|
|
return container;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2014-08-22 15:37:11 +00:00
|
|
|
* Creates an audio or video stream element.
|
|
|
|
*/
|
|
|
|
my.createStreamElement = function (sid, stream) {
|
|
|
|
var isVideo = stream.getVideoTracks().length > 0;
|
|
|
|
|
|
|
|
var element = isVideo
|
|
|
|
? document.createElement('video')
|
|
|
|
: document.createElement('audio');
|
|
|
|
var id = (isVideo ? 'remoteVideo_' : 'remoteAudio_')
|
2015-01-28 14:35:22 +00:00
|
|
|
+ sid + '_' + APP.RTC.getStreamID(stream);
|
2014-08-22 15:37:11 +00:00
|
|
|
|
|
|
|
element.id = id;
|
|
|
|
element.autoplay = true;
|
|
|
|
element.oncontextmenu = function () { return false; };
|
|
|
|
|
|
|
|
return element;
|
|
|
|
};
|
|
|
|
|
|
|
|
my.addRemoteStreamElement
|
|
|
|
= function (container, sid, stream, peerJid, thessrc) {
|
|
|
|
var newElementId = null;
|
|
|
|
|
|
|
|
var isVideo = stream.getVideoTracks().length > 0;
|
|
|
|
|
|
|
|
if (container) {
|
|
|
|
var streamElement = VideoLayout.createStreamElement(sid, stream);
|
|
|
|
newElementId = streamElement.id;
|
|
|
|
|
|
|
|
container.appendChild(streamElement);
|
|
|
|
|
|
|
|
var sel = $('#' + newElementId);
|
|
|
|
sel.hide();
|
|
|
|
|
|
|
|
// If the container is currently visible we attach the stream.
|
|
|
|
if (!isVideo
|
|
|
|
|| (container.offsetParent !== null && isVideo)) {
|
2015-01-28 14:35:22 +00:00
|
|
|
var videoStream = APP.simulcast.getReceivingVideoStream(stream);
|
|
|
|
APP.RTC.attachMediaStream(sel, videoStream);
|
2014-08-22 15:37:11 +00:00
|
|
|
|
|
|
|
if (isVideo)
|
2014-11-21 13:29:05 +00:00
|
|
|
waitForRemoteVideo(sel, thessrc, stream, peerJid);
|
2014-08-22 15:37:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stream.onended = function () {
|
|
|
|
console.log('stream ended', this);
|
|
|
|
|
2014-10-10 07:12:13 +00:00
|
|
|
VideoLayout.removeRemoteStreamElement(
|
|
|
|
stream, isVideo, container);
|
2014-08-22 15:37:11 +00:00
|
|
|
|
2014-12-03 11:36:52 +00:00
|
|
|
// NOTE(gp) it seems that under certain circumstances, the
|
|
|
|
// onended event is not fired and thus the contact list is not
|
|
|
|
// updated.
|
|
|
|
//
|
|
|
|
// The onended event of a stream should be fired when the SSRCs
|
|
|
|
// corresponding to that stream are removed from the SDP; but
|
|
|
|
// this doesn't seem to always be the case, resulting in ghost
|
|
|
|
// contacts.
|
|
|
|
//
|
|
|
|
// In an attempt to fix the ghost contacts problem, I'm moving
|
|
|
|
// the removeContact() method call in app.js, inside the
|
|
|
|
// 'muc.left' event handler.
|
|
|
|
|
|
|
|
//if (peerJid)
|
|
|
|
// ContactList.removeContact(peerJid);
|
2014-08-22 15:37:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Add click handler.
|
|
|
|
container.onclick = function (event) {
|
|
|
|
/*
|
|
|
|
* FIXME It turns out that videoThumb may not exist (if there is
|
|
|
|
* no actual video).
|
|
|
|
*/
|
|
|
|
var videoThumb = $('#' + container.id + '>video').get(0);
|
2014-11-28 14:02:48 +00:00
|
|
|
if (videoThumb) {
|
2014-12-04 16:03:45 +00:00
|
|
|
VideoLayout.handleVideoThumbClicked(
|
2015-01-28 14:35:22 +00:00
|
|
|
APP.RTC.getVideoSrc(videoThumb),
|
2014-12-04 16:03:45 +00:00
|
|
|
false,
|
|
|
|
Strophe.getResourceFromJid(peerJid));
|
2014-11-28 14:02:48 +00:00
|
|
|
}
|
2014-08-22 15:37:11 +00:00
|
|
|
|
2014-11-28 14:02:48 +00:00
|
|
|
event.stopPropagation();
|
2014-08-22 15:37:11 +00:00
|
|
|
event.preventDefault();
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Add hover handler
|
|
|
|
$(container).hover(
|
|
|
|
function() {
|
|
|
|
VideoLayout.showDisplayName(container.id, true);
|
|
|
|
},
|
|
|
|
function() {
|
|
|
|
var videoSrc = null;
|
|
|
|
if ($('#' + container.id + '>video')
|
|
|
|
&& $('#' + container.id + '>video').length > 0) {
|
2015-01-28 14:35:22 +00:00
|
|
|
videoSrc = APP.RTC.getVideoSrc($('#' + container.id + '>video').get(0));
|
2014-08-22 15:37:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// If the video has been "pinned" by the user we want to
|
|
|
|
// keep the display name on place.
|
|
|
|
if (!VideoLayout.isLargeVideoVisible()
|
2015-01-28 14:35:22 +00:00
|
|
|
|| videoSrc !== APP.RTC.getVideoSrc($('#largeVideo')[0]))
|
2014-08-22 15:37:11 +00:00
|
|
|
VideoLayout.showDisplayName(container.id, false);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return newElementId;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes the remote stream element corresponding to the given stream and
|
|
|
|
* parent container.
|
|
|
|
*
|
|
|
|
* @param stream the stream
|
2014-10-10 07:12:13 +00:00
|
|
|
* @param isVideo <tt>true</tt> if given <tt>stream</tt> is a video one.
|
2014-08-22 15:37:11 +00:00
|
|
|
* @param container
|
|
|
|
*/
|
2014-10-10 07:12:13 +00:00
|
|
|
my.removeRemoteStreamElement = function (stream, isVideo, container) {
|
2014-08-22 15:37:11 +00:00
|
|
|
if (!container)
|
|
|
|
return;
|
|
|
|
|
|
|
|
var select = null;
|
|
|
|
var removedVideoSrc = null;
|
2014-10-10 07:12:13 +00:00
|
|
|
if (isVideo) {
|
2014-08-22 15:37:11 +00:00
|
|
|
select = $('#' + container.id + '>video');
|
2015-01-28 14:35:22 +00:00
|
|
|
removedVideoSrc = APP.RTC.getVideoSrc(select.get(0));
|
2014-08-22 15:37:11 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
select = $('#' + container.id + '>audio');
|
|
|
|
|
|
|
|
|
|
|
|
// Mark video as removed to cancel waiting loop(if video is removed
|
|
|
|
// before has started)
|
|
|
|
select.removed = true;
|
|
|
|
select.remove();
|
|
|
|
|
|
|
|
var audioCount = $('#' + container.id + '>audio').length;
|
|
|
|
var videoCount = $('#' + container.id + '>video').length;
|
|
|
|
|
|
|
|
if (!audioCount && !videoCount) {
|
|
|
|
console.log("Remove whole user", container.id);
|
2014-10-16 15:11:26 +00:00
|
|
|
if(VideoLayout.connectionIndicators[container.id])
|
|
|
|
VideoLayout.connectionIndicators[container.id].remove();
|
2014-08-22 15:37:11 +00:00
|
|
|
// Remove whole container
|
|
|
|
container.remove();
|
2014-10-16 15:11:26 +00:00
|
|
|
|
2015-01-23 12:01:44 +00:00
|
|
|
UIUtil.playSoundNotification('userLeft');
|
2014-08-22 15:37:11 +00:00
|
|
|
VideoLayout.resizeThumbnails();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (removedVideoSrc)
|
|
|
|
VideoLayout.updateRemovedVideo(removedVideoSrc);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show/hide peer container for the given resourceJid.
|
|
|
|
*/
|
2014-11-19 10:08:38 +00:00
|
|
|
function showPeerContainer(resourceJid, state) {
|
2014-08-22 15:37:11 +00:00
|
|
|
var peerContainer = $('#participant_' + resourceJid);
|
|
|
|
|
|
|
|
if (!peerContainer)
|
|
|
|
return;
|
|
|
|
|
2014-11-19 10:08:38 +00:00
|
|
|
var isHide = state === 'hide';
|
|
|
|
var resizeThumbnails = false;
|
|
|
|
|
|
|
|
if (!isHide) {
|
|
|
|
if (!peerContainer.is(':visible')) {
|
|
|
|
resizeThumbnails = true;
|
|
|
|
peerContainer.show();
|
|
|
|
}
|
|
|
|
|
2015-01-28 14:35:22 +00:00
|
|
|
var jid = APP.xmpp.findJidFromResource(resourceJid);
|
2014-11-19 10:08:38 +00:00
|
|
|
if (state == 'show')
|
|
|
|
{
|
2014-11-27 18:28:28 +00:00
|
|
|
// peerContainer.css('-webkit-filter', '');
|
2015-01-28 14:35:22 +00:00
|
|
|
|
2014-11-27 18:28:28 +00:00
|
|
|
Avatar.showUserAvatar(jid, false);
|
2014-11-19 10:08:38 +00:00
|
|
|
}
|
|
|
|
else // if (state == 'avatar')
|
|
|
|
{
|
2014-11-27 18:28:28 +00:00
|
|
|
// peerContainer.css('-webkit-filter', 'grayscale(100%)');
|
|
|
|
Avatar.showUserAvatar(jid, true);
|
2014-11-19 10:08:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (peerContainer.is(':visible') && isHide)
|
2014-10-16 15:11:26 +00:00
|
|
|
{
|
2014-11-19 10:08:38 +00:00
|
|
|
resizeThumbnails = true;
|
2014-08-22 15:37:11 +00:00
|
|
|
peerContainer.hide();
|
2014-10-16 15:11:26 +00:00
|
|
|
if(VideoLayout.connectionIndicators['participant_' + resourceJid])
|
|
|
|
VideoLayout.connectionIndicators['participant_' + resourceJid].hide();
|
|
|
|
}
|
2014-10-02 13:58:08 +00:00
|
|
|
|
2014-11-19 10:08:38 +00:00
|
|
|
if (resizeThumbnails) {
|
|
|
|
VideoLayout.resizeThumbnails();
|
|
|
|
}
|
2014-10-02 13:58:08 +00:00
|
|
|
|
2014-11-24 14:58:50 +00:00
|
|
|
// We want to be able to pin a participant from the contact list, even
|
|
|
|
// if he's not in the lastN set!
|
|
|
|
// ContactList.setClickable(resourceJid, !isHide);
|
2014-10-06 10:29:48 +00:00
|
|
|
|
2014-08-22 15:37:11 +00:00
|
|
|
};
|
|
|
|
|
2014-10-22 09:03:07 +00:00
|
|
|
my.inputDisplayNameHandler = function (name) {
|
2015-01-22 16:02:37 +00:00
|
|
|
NicknameHandler.setNickname(name);
|
2014-10-22 09:03:07 +00:00
|
|
|
|
|
|
|
if (!$('#localDisplayName').is(":visible")) {
|
2015-01-22 16:02:37 +00:00
|
|
|
if (NicknameHandler.getNickname())
|
|
|
|
$('#localDisplayName').text(NicknameHandler.getNickname() + " (me)");
|
2014-10-22 09:03:07 +00:00
|
|
|
else
|
|
|
|
$('#localDisplayName')
|
2014-10-31 11:47:12 +00:00
|
|
|
.text(interfaceConfig.DEFAULT_LOCAL_DISPLAY_NAME);
|
2014-10-22 09:03:07 +00:00
|
|
|
$('#localDisplayName').show();
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#editDisplayName').hide();
|
|
|
|
};
|
|
|
|
|
2014-06-12 18:33:57 +00:00
|
|
|
/**
|
|
|
|
* Shows/hides the display name on the remote video.
|
|
|
|
* @param videoSpanId the identifier of the video span element
|
|
|
|
* @param isShow indicates if the display name should be shown or hidden
|
|
|
|
*/
|
|
|
|
my.showDisplayName = function(videoSpanId, isShow) {
|
2014-08-22 15:37:11 +00:00
|
|
|
var nameSpan = $('#' + videoSpanId + '>span.displayname').get(0);
|
2014-06-12 18:33:57 +00:00
|
|
|
if (isShow) {
|
|
|
|
if (nameSpan && nameSpan.innerHTML && nameSpan.innerHTML.length)
|
|
|
|
nameSpan.setAttribute("style", "display:inline-block;");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (nameSpan)
|
|
|
|
nameSpan.setAttribute("style", "display:none;");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-08-22 14:20:33 +00:00
|
|
|
/**
|
|
|
|
* Shows the presence status message for the given video.
|
|
|
|
*/
|
|
|
|
my.setPresenceStatus = function (videoSpanId, statusMsg) {
|
|
|
|
|
|
|
|
if (!$('#' + videoSpanId).length) {
|
|
|
|
// No container
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var statusSpan = $('#' + videoSpanId + '>span.status');
|
|
|
|
if (!statusSpan.length) {
|
|
|
|
//Add status span
|
|
|
|
statusSpan = document.createElement('span');
|
|
|
|
statusSpan.className = 'status';
|
|
|
|
statusSpan.id = videoSpanId + '_status';
|
|
|
|
$('#' + videoSpanId)[0].appendChild(statusSpan);
|
|
|
|
|
|
|
|
statusSpan = $('#' + videoSpanId + '>span.status');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Display status
|
|
|
|
if (statusMsg && statusMsg.length) {
|
|
|
|
$('#' + videoSpanId + '_status').text(statusMsg);
|
|
|
|
statusSpan.get(0).setAttribute("style", "display:inline-block;");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Hide
|
|
|
|
statusSpan.get(0).setAttribute("style", "display:none;");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-06-12 18:33:57 +00:00
|
|
|
/**
|
2014-11-28 15:17:53 +00:00
|
|
|
* Shows a visual indicator for the moderator of the conference.
|
2014-06-12 18:33:57 +00:00
|
|
|
*/
|
2014-11-28 15:17:53 +00:00
|
|
|
my.showModeratorIndicator = function () {
|
2015-01-07 09:38:15 +00:00
|
|
|
|
2015-01-28 14:35:22 +00:00
|
|
|
var isModerator = APP.xmpp.isModerator();
|
2015-01-07 09:38:15 +00:00
|
|
|
if (isModerator) {
|
2014-06-12 18:33:57 +00:00
|
|
|
var indicatorSpan = $('#localVideoContainer .focusindicator');
|
|
|
|
|
|
|
|
if (indicatorSpan.children().length === 0)
|
|
|
|
{
|
2014-11-28 15:17:53 +00:00
|
|
|
createModeratorIndicatorElement(indicatorSpan[0]);
|
2015-02-06 15:46:50 +00:00
|
|
|
//translates text in focus indicator
|
|
|
|
APP.translation.translateElement($('#localVideoContainer .focusindicator'));
|
2014-06-12 18:33:57 +00:00
|
|
|
}
|
2014-12-16 13:54:13 +00:00
|
|
|
}
|
2015-01-19 09:20:00 +00:00
|
|
|
|
2015-01-28 14:35:22 +00:00
|
|
|
var members = APP.xmpp.getMembers();
|
2015-01-19 09:20:00 +00:00
|
|
|
|
|
|
|
Object.keys(members).forEach(function (jid) {
|
2014-12-16 13:54:13 +00:00
|
|
|
|
2015-01-07 09:38:15 +00:00
|
|
|
if (Strophe.getResourceFromJid(jid) === 'focus') {
|
|
|
|
// Skip server side focus
|
|
|
|
return;
|
|
|
|
}
|
2014-12-16 13:54:13 +00:00
|
|
|
|
2015-01-07 09:38:15 +00:00
|
|
|
var resourceJid = Strophe.getResourceFromJid(jid);
|
|
|
|
var videoSpanId = 'participant_' + resourceJid;
|
|
|
|
var videoContainer = document.getElementById(videoSpanId);
|
|
|
|
|
|
|
|
if (!videoContainer) {
|
|
|
|
console.error("No video container for " + jid);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-01-19 09:20:00 +00:00
|
|
|
var member = members[jid];
|
2015-01-07 09:38:15 +00:00
|
|
|
|
|
|
|
if (member.role === 'moderator') {
|
|
|
|
// Remove menu if peer is moderator
|
|
|
|
var menuSpan = $('#' + videoSpanId + '>span.remotevideomenu');
|
2014-12-16 13:54:13 +00:00
|
|
|
if (menuSpan.length) {
|
2015-01-07 09:38:15 +00:00
|
|
|
removeRemoteVideoMenu(videoSpanId);
|
2014-12-16 13:54:13 +00:00
|
|
|
}
|
2015-01-07 09:38:15 +00:00
|
|
|
// Show moderator indicator
|
2014-12-16 13:54:13 +00:00
|
|
|
var indicatorSpan
|
2015-01-07 09:38:15 +00:00
|
|
|
= $('#' + videoSpanId + ' .focusindicator');
|
2014-07-14 11:54:26 +00:00
|
|
|
|
2014-12-16 13:54:13 +00:00
|
|
|
if (!indicatorSpan || indicatorSpan.length === 0) {
|
|
|
|
indicatorSpan = document.createElement('span');
|
|
|
|
indicatorSpan.className = 'focusindicator';
|
2014-06-12 18:33:57 +00:00
|
|
|
|
2015-01-07 09:38:15 +00:00
|
|
|
videoContainer.appendChild(indicatorSpan);
|
2014-12-16 13:54:13 +00:00
|
|
|
|
|
|
|
createModeratorIndicatorElement(indicatorSpan);
|
2015-02-06 15:46:50 +00:00
|
|
|
//translates text in focus indicators
|
|
|
|
APP.translation.translateElement($('#' + videoSpanId + ' .focusindicator'));
|
2014-11-28 15:17:53 +00:00
|
|
|
}
|
2015-01-07 09:38:15 +00:00
|
|
|
} else if (isModerator) {
|
|
|
|
// We are moderator, but user is not - add menu
|
|
|
|
if ($('#remote_popupmenu_' + resourceJid).length <= 0) {
|
|
|
|
addRemoteVideoMenu(
|
|
|
|
jid,
|
|
|
|
document.getElementById('participant_' + resourceJid));
|
|
|
|
}
|
2014-12-16 13:54:13 +00:00
|
|
|
}
|
|
|
|
});
|
2014-06-12 18:33:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows video muted indicator over small videos.
|
|
|
|
*/
|
|
|
|
my.showVideoIndicator = function(videoSpanId, isMuted) {
|
|
|
|
var videoMutedSpan = $('#' + videoSpanId + '>span.videoMuted');
|
|
|
|
|
|
|
|
if (isMuted === 'false') {
|
|
|
|
if (videoMutedSpan.length > 0) {
|
|
|
|
videoMutedSpan.remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2014-10-01 08:36:23 +00:00
|
|
|
if(videoMutedSpan.length == 0) {
|
|
|
|
videoMutedSpan = document.createElement('span');
|
|
|
|
videoMutedSpan.className = 'videoMuted';
|
2014-06-12 18:33:57 +00:00
|
|
|
|
2014-10-01 08:36:23 +00:00
|
|
|
$('#' + videoSpanId)[0].appendChild(videoMutedSpan);
|
2014-06-12 18:33:57 +00:00
|
|
|
|
2014-10-01 08:36:23 +00:00
|
|
|
var mutedIndicator = document.createElement('i');
|
|
|
|
mutedIndicator.className = 'icon-camera-disabled';
|
2015-01-23 12:01:44 +00:00
|
|
|
UIUtil.setTooltip(mutedIndicator,
|
2015-02-06 15:46:50 +00:00
|
|
|
"videothumbnail.videomute",
|
2014-06-18 11:42:31 +00:00
|
|
|
"top");
|
2014-10-01 08:36:23 +00:00
|
|
|
videoMutedSpan.appendChild(mutedIndicator);
|
2015-02-06 15:46:50 +00:00
|
|
|
//translate texts for muted indicator
|
2015-02-13 16:28:35 +00:00
|
|
|
APP.translation.translateElement($('#' + videoSpanId + " > span > i"));
|
2014-10-01 08:36:23 +00:00
|
|
|
}
|
2014-10-17 13:51:23 +00:00
|
|
|
|
|
|
|
VideoLayout.updateMutePosition(videoSpanId);
|
|
|
|
|
2014-06-12 18:33:57 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-10-17 13:51:23 +00:00
|
|
|
my.updateMutePosition = function (videoSpanId) {
|
|
|
|
var audioMutedSpan = $('#' + videoSpanId + '>span.audioMuted');
|
|
|
|
var connectionIndicator = $('#' + videoSpanId + '>div.connectionindicator');
|
|
|
|
var videoMutedSpan = $('#' + videoSpanId + '>span.videoMuted');
|
|
|
|
if(connectionIndicator.length > 0
|
|
|
|
&& connectionIndicator[0].style.display != "none") {
|
|
|
|
audioMutedSpan.css({right: "23px"});
|
|
|
|
videoMutedSpan.css({right: ((audioMutedSpan.length > 0? 23 : 0) + 30) + "px"});
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
audioMutedSpan.css({right: "0px"});
|
|
|
|
videoMutedSpan.css({right: (audioMutedSpan.length > 0? 30 : 0) + "px"});
|
|
|
|
}
|
|
|
|
}
|
2014-06-12 18:33:57 +00:00
|
|
|
/**
|
|
|
|
* Shows audio muted indicator over small videos.
|
2014-10-13 08:29:07 +00:00
|
|
|
* @param {string} isMuted
|
2014-06-12 18:33:57 +00:00
|
|
|
*/
|
|
|
|
my.showAudioIndicator = function(videoSpanId, isMuted) {
|
|
|
|
var audioMutedSpan = $('#' + videoSpanId + '>span.audioMuted');
|
|
|
|
|
|
|
|
if (isMuted === 'false') {
|
|
|
|
if (audioMutedSpan.length > 0) {
|
2014-09-15 12:42:42 +00:00
|
|
|
audioMutedSpan.popover('hide');
|
2014-06-12 18:33:57 +00:00
|
|
|
audioMutedSpan.remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2014-10-17 13:51:23 +00:00
|
|
|
if(audioMutedSpan.length == 0 ) {
|
|
|
|
audioMutedSpan = document.createElement('span');
|
|
|
|
audioMutedSpan.className = 'audioMuted';
|
2015-01-23 12:01:44 +00:00
|
|
|
UIUtil.setTooltip(audioMutedSpan,
|
2015-02-06 15:46:50 +00:00
|
|
|
"videothumbnail.mute",
|
2014-10-17 13:51:23 +00:00
|
|
|
"top");
|
2014-06-18 11:42:31 +00:00
|
|
|
|
2014-10-17 13:51:23 +00:00
|
|
|
$('#' + videoSpanId)[0].appendChild(audioMutedSpan);
|
2015-02-06 15:46:50 +00:00
|
|
|
APP.translation.translateElement($('#' + videoSpanId + " > span"));
|
2014-10-17 13:51:23 +00:00
|
|
|
var mutedIndicator = document.createElement('i');
|
|
|
|
mutedIndicator.className = 'icon-mic-disabled';
|
|
|
|
audioMutedSpan.appendChild(mutedIndicator);
|
2014-06-12 18:33:57 +00:00
|
|
|
|
2014-10-17 13:51:23 +00:00
|
|
|
}
|
|
|
|
VideoLayout.updateMutePosition(videoSpanId);
|
2014-06-12 18:33:57 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-10-13 08:29:07 +00:00
|
|
|
/*
|
|
|
|
* Shows or hides the audio muted indicator over the local thumbnail video.
|
|
|
|
* @param {boolean} isMuted
|
|
|
|
*/
|
|
|
|
my.showLocalAudioIndicator = function(isMuted) {
|
|
|
|
VideoLayout.showAudioIndicator('localVideoContainer', isMuted.toString());
|
|
|
|
};
|
|
|
|
|
2014-06-12 18:33:57 +00:00
|
|
|
/**
|
|
|
|
* Resizes the large video container.
|
|
|
|
*/
|
|
|
|
my.resizeLargeVideoContainer = function () {
|
|
|
|
Chat.resizeChat();
|
|
|
|
var availableHeight = window.innerHeight;
|
2015-01-07 14:54:03 +00:00
|
|
|
var availableWidth = UIUtil.getAvailableVideoWidth();
|
2014-06-12 18:33:57 +00:00
|
|
|
|
|
|
|
if (availableWidth < 0 || availableHeight < 0) return;
|
|
|
|
|
|
|
|
$('#videospace').width(availableWidth);
|
|
|
|
$('#videospace').height(availableHeight);
|
|
|
|
$('#largeVideoContainer').width(availableWidth);
|
|
|
|
$('#largeVideoContainer').height(availableHeight);
|
|
|
|
|
2014-12-10 09:52:40 +00:00
|
|
|
var avatarSize = interfaceConfig.ACTIVE_SPEAKER_AVATAR_SIZE;
|
2014-12-12 09:32:16 +00:00
|
|
|
var top = availableHeight / 2 - avatarSize / 4 * 3;
|
|
|
|
$('#activeSpeaker').css('top', top);
|
2014-10-31 11:47:12 +00:00
|
|
|
|
2014-06-12 18:33:57 +00:00
|
|
|
VideoLayout.resizeThumbnails();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resizes thumbnails.
|
|
|
|
*/
|
|
|
|
my.resizeThumbnails = function() {
|
2014-07-14 10:33:57 +00:00
|
|
|
var videoSpaceWidth = $('#remoteVideos').width();
|
|
|
|
|
|
|
|
var thumbnailSize = VideoLayout.calculateThumbnailSize(videoSpaceWidth);
|
2014-06-12 18:33:57 +00:00
|
|
|
var width = thumbnailSize[0];
|
|
|
|
var height = thumbnailSize[1];
|
|
|
|
|
|
|
|
// size videos so that while keeping AR and max height, we have a
|
|
|
|
// nice fit
|
|
|
|
$('#remoteVideos').height(height);
|
|
|
|
$('#remoteVideos>span').width(width);
|
|
|
|
$('#remoteVideos>span').height(height);
|
2014-07-22 13:12:48 +00:00
|
|
|
|
2014-10-31 11:47:12 +00:00
|
|
|
$('.userAvatar').css('left', (width - height) / 2);
|
|
|
|
|
2015-01-27 12:03:26 +00:00
|
|
|
|
|
|
|
|
2014-07-22 13:12:48 +00:00
|
|
|
$(document).trigger("remotevideo.resized", [width, height]);
|
2014-06-12 18:33:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2014-07-16 14:35:54 +00:00
|
|
|
* Enables the dominant speaker UI.
|
2014-06-12 18:33:57 +00:00
|
|
|
*
|
|
|
|
* @param resourceJid the jid indicating the video element to
|
|
|
|
* activate/deactivate
|
2014-07-16 14:35:54 +00:00
|
|
|
* @param isEnable indicates if the dominant speaker should be enabled or
|
2014-06-12 18:33:57 +00:00
|
|
|
* disabled
|
|
|
|
*/
|
2014-07-16 14:35:54 +00:00
|
|
|
my.enableDominantSpeaker = function(resourceJid, isEnable) {
|
2014-06-19 13:40:54 +00:00
|
|
|
|
2014-06-12 18:33:57 +00:00
|
|
|
var videoSpanId = null;
|
2014-07-01 10:31:13 +00:00
|
|
|
var videoContainerId = null;
|
2014-06-12 18:33:57 +00:00
|
|
|
if (resourceJid
|
2015-01-28 14:35:22 +00:00
|
|
|
=== APP.xmpp.myResource()) {
|
2014-06-12 18:33:57 +00:00
|
|
|
videoSpanId = 'localVideoWrapper';
|
2014-07-01 10:31:13 +00:00
|
|
|
videoContainerId = 'localVideoContainer';
|
|
|
|
}
|
|
|
|
else {
|
2014-06-12 18:33:57 +00:00
|
|
|
videoSpanId = 'participant_' + resourceJid;
|
2014-07-01 10:31:13 +00:00
|
|
|
videoContainerId = videoSpanId;
|
|
|
|
}
|
2014-06-12 18:33:57 +00:00
|
|
|
|
2014-10-06 11:35:22 +00:00
|
|
|
var displayName = resourceJid;
|
|
|
|
var nameSpan = $('#' + videoContainerId + '>span.displayname');
|
|
|
|
if (nameSpan.length > 0)
|
2014-12-03 20:44:03 +00:00
|
|
|
displayName = nameSpan.html();
|
2014-10-06 11:35:22 +00:00
|
|
|
|
|
|
|
console.log("UI enable dominant speaker",
|
|
|
|
displayName,
|
|
|
|
resourceJid,
|
|
|
|
isEnable);
|
|
|
|
|
2014-07-01 10:31:13 +00:00
|
|
|
videoSpan = document.getElementById(videoContainerId);
|
2014-06-12 18:33:57 +00:00
|
|
|
|
|
|
|
if (!videoSpan) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-06-18 14:45:31 +00:00
|
|
|
var video = $('#' + videoSpanId + '>video');
|
2014-06-12 18:33:57 +00:00
|
|
|
|
2014-06-18 14:45:31 +00:00
|
|
|
if (video && video.length > 0) {
|
2014-06-12 18:33:57 +00:00
|
|
|
if (isEnable) {
|
2014-11-28 14:02:48 +00:00
|
|
|
var isLargeVideoVisible = VideoLayout.isLargeVideoOnTop();
|
|
|
|
VideoLayout.showDisplayName(videoContainerId, isLargeVideoVisible);
|
2014-06-12 18:33:57 +00:00
|
|
|
|
2014-07-16 14:35:54 +00:00
|
|
|
if (!videoSpan.classList.contains("dominantspeaker"))
|
|
|
|
videoSpan.classList.add("dominantspeaker");
|
2014-06-12 18:33:57 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-07-01 10:31:13 +00:00
|
|
|
VideoLayout.showDisplayName(videoContainerId, false);
|
|
|
|
|
2014-07-16 14:35:54 +00:00
|
|
|
if (videoSpan.classList.contains("dominantspeaker"))
|
|
|
|
videoSpan.classList.remove("dominantspeaker");
|
2014-06-12 18:33:57 +00:00
|
|
|
}
|
2014-11-28 14:02:48 +00:00
|
|
|
|
|
|
|
Avatar.showUserAvatar(
|
2015-01-28 14:35:22 +00:00
|
|
|
APP.xmpp.findJidFromResource(resourceJid));
|
2014-06-12 18:33:57 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculates the thumbnail size.
|
2014-08-22 15:37:11 +00:00
|
|
|
*
|
|
|
|
* @param videoSpaceWidth the width of the video space
|
2014-06-12 18:33:57 +00:00
|
|
|
*/
|
2014-07-14 10:33:57 +00:00
|
|
|
my.calculateThumbnailSize = function (videoSpaceWidth) {
|
2014-06-12 18:33:57 +00:00
|
|
|
// Calculate the available height, which is the inner window height minus
|
|
|
|
// 39px for the header minus 2px for the delimiter lines on the top and
|
|
|
|
// bottom of the large video, minus the 36px space inside the remoteVideos
|
|
|
|
// container used for highlighting shadow.
|
|
|
|
var availableHeight = 100;
|
|
|
|
|
2014-10-02 08:24:21 +00:00
|
|
|
var numvids = $('#remoteVideos>span:visible').length;
|
2014-11-19 10:08:38 +00:00
|
|
|
if (localLastNCount && localLastNCount > 0) {
|
|
|
|
numvids = Math.min(localLastNCount + 1, numvids);
|
2014-10-02 08:24:21 +00:00
|
|
|
}
|
2014-06-12 18:33:57 +00:00
|
|
|
|
2014-07-14 10:33:57 +00:00
|
|
|
// Remove the 3px borders arround videos and border around the remote
|
2014-09-30 14:41:47 +00:00
|
|
|
// videos area and the 4 pixels between the local video and the others
|
|
|
|
//TODO: Find out where the 4 pixels come from and remove them
|
|
|
|
var availableWinWidth = videoSpaceWidth - 2 * 3 * numvids - 70 - 4;
|
2014-07-14 10:33:57 +00:00
|
|
|
|
2014-06-12 18:33:57 +00:00
|
|
|
var availableWidth = availableWinWidth / numvids;
|
|
|
|
var aspectRatio = 16.0 / 9.0;
|
|
|
|
var maxHeight = Math.min(160, availableHeight);
|
|
|
|
availableHeight = Math.min(maxHeight, availableWidth / aspectRatio);
|
|
|
|
if (availableHeight < availableWidth / aspectRatio) {
|
|
|
|
availableWidth = Math.floor(availableHeight * aspectRatio);
|
|
|
|
}
|
|
|
|
|
|
|
|
return [availableWidth, availableHeight];
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates the remote video menu.
|
|
|
|
*
|
|
|
|
* @param jid the jid indicating the video for which we're adding a menu.
|
|
|
|
* @param isMuted indicates the current mute state
|
|
|
|
*/
|
|
|
|
my.updateRemoteVideoMenu = function(jid, isMuted) {
|
|
|
|
var muteMenuItem
|
|
|
|
= $('#remote_popupmenu_'
|
|
|
|
+ Strophe.getResourceFromJid(jid)
|
|
|
|
+ '>li>a.mutelink');
|
|
|
|
|
|
|
|
var mutedIndicator = "<i class='icon-mic-disabled'></i>";
|
|
|
|
|
|
|
|
if (muteMenuItem.length) {
|
|
|
|
var muteLink = muteMenuItem.get(0);
|
|
|
|
|
|
|
|
if (isMuted === 'true') {
|
|
|
|
muteLink.innerHTML = mutedIndicator + ' Muted';
|
|
|
|
muteLink.className = 'mutelink disabled';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
muteLink.innerHTML = mutedIndicator + ' Mute';
|
|
|
|
muteLink.className = 'mutelink';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-06-24 11:59:14 +00:00
|
|
|
/**
|
2014-07-16 14:35:54 +00:00
|
|
|
* Returns the current dominant speaker resource jid.
|
2014-06-24 11:59:14 +00:00
|
|
|
*/
|
2014-07-16 14:35:54 +00:00
|
|
|
my.getDominantSpeakerResourceJid = function () {
|
|
|
|
return currentDominantSpeaker;
|
2014-06-24 11:59:14 +00:00
|
|
|
};
|
|
|
|
|
2014-08-22 15:37:11 +00:00
|
|
|
/**
|
|
|
|
* Returns the corresponding resource jid to the given peer container
|
|
|
|
* DOM element.
|
|
|
|
*
|
|
|
|
* @return the corresponding resource jid to the given peer container
|
|
|
|
* DOM element
|
|
|
|
*/
|
|
|
|
my.getPeerContainerResourceJid = function (containerElement) {
|
|
|
|
var i = containerElement.id.indexOf('participant_');
|
|
|
|
|
|
|
|
if (i >= 0)
|
|
|
|
return containerElement.id.substring(i + 12);
|
|
|
|
};
|
|
|
|
|
2014-11-24 14:58:50 +00:00
|
|
|
/**
|
|
|
|
* On contact list item clicked.
|
|
|
|
*/
|
|
|
|
$(ContactList).bind('contactclicked', function(event, jid) {
|
|
|
|
if (!jid) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var resource = Strophe.getResourceFromJid(jid);
|
|
|
|
var videoContainer = $("#participant_" + resource);
|
|
|
|
if (videoContainer.length > 0) {
|
|
|
|
var videoThumb = $('video', videoContainer).get(0);
|
|
|
|
// It is not always the case that a videoThumb exists (if there is
|
|
|
|
// no actual video).
|
|
|
|
if (videoThumb) {
|
|
|
|
if (videoThumb.src && videoThumb.src != '') {
|
|
|
|
|
|
|
|
// We have a video src, great! Let's update the large video
|
|
|
|
// now.
|
|
|
|
|
2014-12-04 16:03:45 +00:00
|
|
|
VideoLayout.handleVideoThumbClicked(
|
|
|
|
videoThumb.src,
|
|
|
|
false,
|
|
|
|
Strophe.getResourceFromJid(jid));
|
2014-11-24 14:58:50 +00:00
|
|
|
} else {
|
|
|
|
|
|
|
|
// If we don't have a video src for jid, there's absolutely
|
|
|
|
// no point in calling handleVideoThumbClicked; Quite
|
|
|
|
// simply, it won't work because it needs an src to attach
|
|
|
|
// to the large video.
|
|
|
|
//
|
|
|
|
// Instead, we trigger the pinned endpoint changed event to
|
|
|
|
// let the bridge adjust its lastN set for myjid and store
|
|
|
|
// the pinned user in the lastNPickupJid variable to be
|
|
|
|
// picked up later by the lastN changed event handler.
|
|
|
|
|
|
|
|
lastNPickupJid = jid;
|
2015-01-27 12:03:26 +00:00
|
|
|
eventEmitter.emit(UIEvents.PINNED_ENDPOINT,
|
|
|
|
Strophe.getResourceFromJid(jid));
|
2014-11-24 14:58:50 +00:00
|
|
|
}
|
2015-01-28 14:35:22 +00:00
|
|
|
} else if (jid == APP.xmpp.myJid()) {
|
2014-11-24 14:58:50 +00:00
|
|
|
$("#localVideoContainer").click();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-06-27 16:27:24 +00:00
|
|
|
/**
|
|
|
|
* On audio muted event.
|
|
|
|
*/
|
2014-06-12 18:33:57 +00:00
|
|
|
$(document).bind('audiomuted.muc', function (event, jid, isMuted) {
|
2014-11-28 15:17:53 +00:00
|
|
|
/*
|
|
|
|
// FIXME: but focus can not mute in this case ? - check
|
2015-01-19 09:20:00 +00:00
|
|
|
if (jid === xmpp.myJid()) {
|
2014-11-28 15:17:53 +00:00
|
|
|
|
2014-10-13 08:29:07 +00:00
|
|
|
// The local mute indicator is controlled locally
|
|
|
|
return;
|
2014-11-28 15:17:53 +00:00
|
|
|
}*/
|
|
|
|
var videoSpanId = null;
|
2015-01-28 14:35:22 +00:00
|
|
|
if (jid === APP.xmpp.myJid()) {
|
2014-11-28 15:17:53 +00:00
|
|
|
videoSpanId = 'localVideoContainer';
|
|
|
|
} else {
|
|
|
|
VideoLayout.ensurePeerContainerExists(jid);
|
|
|
|
videoSpanId = 'participant_' + Strophe.getResourceFromJid(jid);
|
2014-06-12 18:33:57 +00:00
|
|
|
}
|
|
|
|
|
2014-11-28 15:20:43 +00:00
|
|
|
mutedAudios[jid] = isMuted;
|
2014-10-13 08:29:07 +00:00
|
|
|
|
2015-01-28 14:35:22 +00:00
|
|
|
if (APP.xmpp.isModerator()) {
|
2014-06-12 18:33:57 +00:00
|
|
|
VideoLayout.updateRemoteVideoMenu(jid, isMuted);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (videoSpanId)
|
|
|
|
VideoLayout.showAudioIndicator(videoSpanId, isMuted);
|
|
|
|
});
|
|
|
|
|
2014-06-27 16:27:24 +00:00
|
|
|
/**
|
|
|
|
* On video muted event.
|
|
|
|
*/
|
2015-01-13 09:33:45 +00:00
|
|
|
$(document).bind('videomuted.muc', function (event, jid, value) {
|
|
|
|
var isMuted = (value === "true");
|
2015-01-28 14:35:22 +00:00
|
|
|
if(!APP.RTC.muteRemoteVideoStream(jid, isMuted))
|
2014-12-19 13:59:08 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
Avatar.showUserAvatar(jid, isMuted);
|
2014-06-12 18:33:57 +00:00
|
|
|
var videoSpanId = null;
|
2015-01-28 14:35:22 +00:00
|
|
|
if (jid === APP.xmpp.myJid()) {
|
2014-06-12 18:33:57 +00:00
|
|
|
videoSpanId = 'localVideoContainer';
|
|
|
|
} else {
|
|
|
|
VideoLayout.ensurePeerContainerExists(jid);
|
|
|
|
videoSpanId = 'participant_' + Strophe.getResourceFromJid(jid);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (videoSpanId)
|
2015-01-13 09:33:45 +00:00
|
|
|
VideoLayout.showVideoIndicator(videoSpanId, value);
|
2014-06-12 18:33:57 +00:00
|
|
|
});
|
|
|
|
|
2014-08-22 15:37:11 +00:00
|
|
|
/**
|
|
|
|
* Display name changed.
|
|
|
|
*/
|
2015-01-19 09:20:00 +00:00
|
|
|
my.onDisplayNameChanged =
|
|
|
|
function (jid, displayName, status) {
|
2014-08-22 15:37:11 +00:00
|
|
|
if (jid === 'localVideoContainer'
|
2015-01-28 14:35:22 +00:00
|
|
|
|| jid === APP.xmpp.myJid()) {
|
2014-08-22 15:37:11 +00:00
|
|
|
setDisplayName('localVideoContainer',
|
|
|
|
displayName);
|
|
|
|
} else {
|
|
|
|
VideoLayout.ensurePeerContainerExists(jid);
|
|
|
|
setDisplayName(
|
|
|
|
'participant_' + Strophe.getResourceFromJid(jid),
|
|
|
|
displayName,
|
|
|
|
status);
|
|
|
|
}
|
2014-10-27 13:24:09 +00:00
|
|
|
|
2015-01-19 09:20:00 +00:00
|
|
|
};
|
2014-08-22 15:37:11 +00:00
|
|
|
|
2014-06-24 11:59:14 +00:00
|
|
|
/**
|
2014-07-16 14:35:54 +00:00
|
|
|
* On dominant speaker changed event.
|
2014-06-24 11:59:14 +00:00
|
|
|
*/
|
2015-01-27 09:56:22 +00:00
|
|
|
my.onDominantSpeakerChanged = function (resourceJid) {
|
2014-06-27 16:27:24 +00:00
|
|
|
// We ignore local user events.
|
|
|
|
if (resourceJid
|
2015-01-28 14:35:22 +00:00
|
|
|
=== APP.xmpp.myResource())
|
2014-06-27 16:27:24 +00:00
|
|
|
return;
|
2014-06-24 11:59:14 +00:00
|
|
|
|
2014-07-16 14:35:54 +00:00
|
|
|
// Update the current dominant speaker.
|
2014-09-03 08:57:41 +00:00
|
|
|
if (resourceJid !== currentDominantSpeaker) {
|
|
|
|
var oldSpeakerVideoSpanId = "participant_" + currentDominantSpeaker,
|
|
|
|
newSpeakerVideoSpanId = "participant_" + resourceJid;
|
2014-09-18 12:39:40 +00:00
|
|
|
if($("#" + oldSpeakerVideoSpanId + ">span.displayname").text() ===
|
|
|
|
interfaceConfig.DEFAULT_DOMINANT_SPEAKER_DISPLAY_NAME) {
|
2014-09-03 08:57:41 +00:00
|
|
|
setDisplayName(oldSpeakerVideoSpanId, null);
|
|
|
|
}
|
2014-09-18 12:39:40 +00:00
|
|
|
if($("#" + newSpeakerVideoSpanId + ">span.displayname").text() ===
|
|
|
|
interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME) {
|
|
|
|
setDisplayName(newSpeakerVideoSpanId,
|
|
|
|
interfaceConfig.DEFAULT_DOMINANT_SPEAKER_DISPLAY_NAME);
|
2014-09-03 08:57:41 +00:00
|
|
|
}
|
2014-07-16 14:35:54 +00:00
|
|
|
currentDominantSpeaker = resourceJid;
|
2014-09-03 08:57:41 +00:00
|
|
|
} else {
|
2014-06-24 11:59:14 +00:00
|
|
|
return;
|
2014-09-03 08:57:41 +00:00
|
|
|
}
|
2014-06-24 11:59:14 +00:00
|
|
|
|
2014-08-22 15:37:11 +00:00
|
|
|
// Obtain container for new dominant speaker.
|
|
|
|
var container = document.getElementById(
|
|
|
|
'participant_' + resourceJid);
|
|
|
|
|
2014-06-24 11:59:14 +00:00
|
|
|
// Local video will not have container found, but that's ok
|
|
|
|
// since we don't want to switch to local video.
|
2014-12-04 16:03:45 +00:00
|
|
|
if (container && !focusedVideoInfo)
|
2014-06-24 11:59:14 +00:00
|
|
|
{
|
|
|
|
var video = container.getElementsByTagName("video");
|
2014-08-22 15:37:11 +00:00
|
|
|
|
|
|
|
// Update the large video if the video source is already available,
|
|
|
|
// otherwise wait for the "videoactive.jingle" event.
|
|
|
|
if (video.length && video[0].currentTime > 0)
|
2015-01-28 14:35:22 +00:00
|
|
|
VideoLayout.updateLargeVideo(APP.RTC.getVideoSrc(video[0]), resourceJid);
|
2014-08-22 15:37:11 +00:00
|
|
|
}
|
2015-01-27 09:56:22 +00:00
|
|
|
};
|
2014-08-22 15:37:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* On last N change event.
|
|
|
|
*
|
|
|
|
* @param lastNEndpoints the list of last N endpoints
|
|
|
|
* @param endpointsEnteringLastN the list currently entering last N
|
|
|
|
* endpoints
|
|
|
|
*/
|
2015-01-27 09:56:22 +00:00
|
|
|
my.onLastNEndpointsChanged = function ( lastNEndpoints,
|
2014-08-22 15:37:11 +00:00
|
|
|
endpointsEnteringLastN,
|
|
|
|
stream) {
|
|
|
|
if (lastNCount !== lastNEndpoints.length)
|
|
|
|
lastNCount = lastNEndpoints.length;
|
|
|
|
|
|
|
|
lastNEndpointsCache = lastNEndpoints;
|
|
|
|
|
2014-11-19 10:08:38 +00:00
|
|
|
// Say A, B, C, D, E, and F are in a conference and LastN = 3.
|
|
|
|
//
|
|
|
|
// If LastN drops to, say, 2, because of adaptivity, then E should see
|
|
|
|
// thumbnails for A, B and C. A and B are in E's server side LastN set,
|
|
|
|
// so E sees them. C is only in E's local LastN set.
|
|
|
|
//
|
|
|
|
// If F starts talking and LastN = 3, then E should see thumbnails for
|
|
|
|
// F, A, B. B gets "ejected" from E's server side LastN set, but it
|
|
|
|
// enters E's local LastN ejecting C.
|
|
|
|
|
|
|
|
// Increase the local LastN set size, if necessary.
|
|
|
|
if (lastNCount > localLastNCount) {
|
|
|
|
localLastNCount = lastNCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update the local LastN set preserving the order in which the
|
|
|
|
// endpoints appeared in the LastN/local LastN set.
|
|
|
|
|
|
|
|
var nextLocalLastNSet = lastNEndpoints.slice(0);
|
|
|
|
for (var i = 0; i < localLastNSet.length; i++) {
|
|
|
|
if (nextLocalLastNSet.length >= localLastNCount) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
var resourceJid = localLastNSet[i];
|
|
|
|
if (nextLocalLastNSet.indexOf(resourceJid) === -1) {
|
|
|
|
nextLocalLastNSet.push(resourceJid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
localLastNSet = nextLocalLastNSet;
|
|
|
|
|
2014-11-24 14:58:50 +00:00
|
|
|
var updateLargeVideo = false;
|
|
|
|
|
2014-11-19 10:08:38 +00:00
|
|
|
// Handle LastN/local LastN changes.
|
2014-08-22 15:37:11 +00:00
|
|
|
$('#remoteVideos>span').each(function( index, element ) {
|
|
|
|
var resourceJid = VideoLayout.getPeerContainerResourceJid(element);
|
|
|
|
|
2014-11-19 10:08:38 +00:00
|
|
|
var isReceived = true;
|
2014-08-22 15:37:11 +00:00
|
|
|
if (resourceJid
|
2014-11-19 10:08:38 +00:00
|
|
|
&& lastNEndpoints.indexOf(resourceJid) < 0
|
|
|
|
&& localLastNSet.indexOf(resourceJid) < 0) {
|
2014-08-22 15:37:11 +00:00
|
|
|
console.log("Remove from last N", resourceJid);
|
2014-11-19 10:08:38 +00:00
|
|
|
showPeerContainer(resourceJid, 'hide');
|
|
|
|
isReceived = false;
|
|
|
|
} else if (resourceJid
|
|
|
|
&& $('#participant_' + resourceJid).is(':visible')
|
|
|
|
&& lastNEndpoints.indexOf(resourceJid) < 0
|
|
|
|
&& localLastNSet.indexOf(resourceJid) >= 0) {
|
|
|
|
showPeerContainer(resourceJid, 'avatar');
|
|
|
|
isReceived = false;
|
|
|
|
}
|
2014-11-20 15:40:58 +00:00
|
|
|
|
2014-11-19 10:08:38 +00:00
|
|
|
if (!isReceived) {
|
2014-11-20 15:40:58 +00:00
|
|
|
// resourceJid has dropped out of the server side lastN set, so
|
|
|
|
// it is no longer being received. If resourceJid was being
|
|
|
|
// displayed in the large video we have to switch to another
|
|
|
|
// user.
|
2014-12-04 16:03:45 +00:00
|
|
|
var largeVideoResource = largeVideoState.userResourceJid;
|
2014-11-24 14:58:50 +00:00
|
|
|
if (!updateLargeVideo && resourceJid === largeVideoResource) {
|
|
|
|
updateLargeVideo = true;
|
2014-11-20 15:40:58 +00:00
|
|
|
}
|
2014-06-24 11:59:14 +00:00
|
|
|
}
|
2014-08-22 15:37:11 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
if (!endpointsEnteringLastN || endpointsEnteringLastN.length < 0)
|
|
|
|
endpointsEnteringLastN = lastNEndpoints;
|
|
|
|
|
|
|
|
if (endpointsEnteringLastN && endpointsEnteringLastN.length > 0) {
|
|
|
|
endpointsEnteringLastN.forEach(function (resourceJid) {
|
|
|
|
|
2014-11-19 10:08:38 +00:00
|
|
|
var isVisible = $('#participant_' + resourceJid).is(':visible');
|
|
|
|
showPeerContainer(resourceJid, 'show');
|
|
|
|
if (!isVisible) {
|
2014-08-22 15:37:11 +00:00
|
|
|
console.log("Add to last N", resourceJid);
|
|
|
|
|
2015-01-28 14:35:22 +00:00
|
|
|
var jid = APP.xmpp.findJidFromResource(resourceJid);
|
|
|
|
var mediaStream = APP.RTC.remoteStreams[jid][MediaStreamType.VIDEO_TYPE];
|
2014-10-31 11:47:12 +00:00
|
|
|
var sel = $('#participant_' + resourceJid + '>video');
|
2014-11-24 14:58:50 +00:00
|
|
|
|
2015-01-28 14:35:22 +00:00
|
|
|
var videoStream = APP.simulcast.getReceivingVideoStream(
|
2014-10-31 11:47:12 +00:00
|
|
|
mediaStream.stream);
|
2015-01-28 14:35:22 +00:00
|
|
|
APP.RTC.attachMediaStream(sel, videoStream);
|
2014-10-31 11:47:12 +00:00
|
|
|
if (lastNPickupJid == mediaStream.peerjid) {
|
|
|
|
// Clean up the lastN pickup jid.
|
|
|
|
lastNPickupJid = null;
|
2014-11-24 14:58:50 +00:00
|
|
|
|
2014-10-31 11:47:12 +00:00
|
|
|
// Don't fire the events again, they've already
|
|
|
|
// been fired in the contact list click handler.
|
2014-12-04 16:03:45 +00:00
|
|
|
VideoLayout.handleVideoThumbClicked(
|
|
|
|
$(sel).attr('src'),
|
|
|
|
false,
|
|
|
|
Strophe.getResourceFromJid(mediaStream.peerjid));
|
2014-11-24 14:58:50 +00:00
|
|
|
|
2014-10-31 11:47:12 +00:00
|
|
|
updateLargeVideo = false;
|
|
|
|
}
|
2014-12-01 12:12:04 +00:00
|
|
|
waitForRemoteVideo(sel, mediaStream.ssrc, mediaStream.stream, resourceJid);
|
2014-08-22 15:37:11 +00:00
|
|
|
}
|
2014-10-31 11:47:12 +00:00
|
|
|
})
|
2014-08-22 15:37:11 +00:00
|
|
|
}
|
2014-11-24 14:58:50 +00:00
|
|
|
|
|
|
|
// The endpoint that was being shown in the large video has dropped out
|
|
|
|
// of the lastN set and there was no lastN pickup jid. We need to update
|
|
|
|
// the large video now.
|
|
|
|
|
|
|
|
if (updateLargeVideo) {
|
|
|
|
|
|
|
|
var resource, container, src;
|
|
|
|
var myResource
|
2015-01-28 14:35:22 +00:00
|
|
|
= APP.xmpp.myResource();
|
2014-11-24 14:58:50 +00:00
|
|
|
|
|
|
|
// Find out which endpoint to show in the large video.
|
|
|
|
for (var i = 0; i < lastNEndpoints.length; i++) {
|
|
|
|
resource = lastNEndpoints[i];
|
|
|
|
if (!resource || resource === myResource)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
container = $("#participant_" + resource);
|
|
|
|
if (container.length == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
src = $('video', container).attr('src');
|
|
|
|
if (!src)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// videoSrcToSsrc needs to be update for this call to succeed.
|
|
|
|
VideoLayout.updateLargeVideo(src);
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2015-01-27 09:56:22 +00:00
|
|
|
};
|
2014-08-22 15:37:11 +00:00
|
|
|
|
2015-01-27 09:56:22 +00:00
|
|
|
my.onSimulcastLayersChanging = function (endpointSimulcastLayers) {
|
2014-10-26 19:57:13 +00:00
|
|
|
endpointSimulcastLayers.forEach(function (esl) {
|
2014-11-24 12:26:43 +00:00
|
|
|
|
|
|
|
var resource = esl.endpoint;
|
2014-11-28 16:00:16 +00:00
|
|
|
|
|
|
|
// if lastN is enabled *and* the endpoint is *not* in the lastN set,
|
|
|
|
// then ignore the event (= do not preload anything).
|
|
|
|
//
|
|
|
|
// The bridge could probably stop sending this message if it's for
|
|
|
|
// an endpoint that's not in lastN.
|
|
|
|
|
|
|
|
if (lastNCount != -1
|
|
|
|
&& (lastNCount < 1 || lastNEndpointsCache.indexOf(resource) === -1)) {
|
2014-11-24 12:26:43 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-10-26 19:57:13 +00:00
|
|
|
var primarySSRC = esl.simulcastLayer.primarySSRC;
|
|
|
|
|
2014-10-31 10:17:41 +00:00
|
|
|
// Get session and stream from primary ssrc.
|
2015-01-28 14:35:22 +00:00
|
|
|
var res = APP.simulcast.getReceivingVideoStreamBySSRC(primarySSRC);
|
2015-01-19 09:20:00 +00:00
|
|
|
var sid = res.sid;
|
2014-10-31 10:17:41 +00:00
|
|
|
var electedStream = res.stream;
|
2014-10-26 19:57:13 +00:00
|
|
|
|
2015-01-19 09:20:00 +00:00
|
|
|
if (sid && electedStream) {
|
2015-01-28 14:35:22 +00:00
|
|
|
var msid = APP.simulcast.getRemoteVideoStreamIdBySSRC(primarySSRC);
|
2014-10-31 10:17:41 +00:00
|
|
|
|
2015-01-19 09:20:00 +00:00
|
|
|
console.info([esl, primarySSRC, msid, sid, electedStream]);
|
2014-10-26 19:57:13 +00:00
|
|
|
|
2015-01-28 14:35:22 +00:00
|
|
|
var preload = (Strophe.getResourceFromJid(APP.xmpp.getJidFromSSRC(primarySSRC)) == largeVideoState.userResourceJid);
|
2014-10-26 19:57:13 +00:00
|
|
|
|
|
|
|
if (preload) {
|
|
|
|
if (largeVideoState.preload)
|
|
|
|
{
|
|
|
|
$(largeVideoState.preload).remove();
|
|
|
|
}
|
|
|
|
console.info('Preloading remote video');
|
|
|
|
largeVideoState.preload = $('<video autoplay></video>');
|
|
|
|
// ssrcs are unique in an rtp session
|
|
|
|
largeVideoState.preload_ssrc = primarySSRC;
|
|
|
|
|
2015-01-28 14:35:22 +00:00
|
|
|
APP.RTC.attachMediaStream(largeVideoState.preload, electedStream)
|
2014-10-26 19:57:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2015-01-19 09:20:00 +00:00
|
|
|
console.error('Could not find a stream or a session.', sid, electedStream);
|
2014-10-26 19:57:13 +00:00
|
|
|
}
|
|
|
|
});
|
2015-01-27 09:56:22 +00:00
|
|
|
};
|
2014-10-26 19:57:13 +00:00
|
|
|
|
2014-08-21 09:58:33 +00:00
|
|
|
/**
|
|
|
|
* On simulcast layers changed event.
|
|
|
|
*/
|
2015-01-27 09:56:22 +00:00
|
|
|
my.onSimulcastLayersChanged = function (endpointSimulcastLayers) {
|
2014-08-21 09:58:33 +00:00
|
|
|
endpointSimulcastLayers.forEach(function (esl) {
|
|
|
|
|
2014-11-24 12:26:43 +00:00
|
|
|
var resource = esl.endpoint;
|
2014-11-28 16:00:16 +00:00
|
|
|
|
|
|
|
// if lastN is enabled *and* the endpoint is *not* in the lastN set,
|
|
|
|
// then ignore the event (= do not change large video/thumbnail
|
|
|
|
// SRCs).
|
|
|
|
//
|
2014-11-28 16:06:36 +00:00
|
|
|
// Note that even if we ignore the "changed" event in this event
|
2014-11-28 16:00:16 +00:00
|
|
|
// handler, the bridge must continue sending these events because
|
2014-11-28 16:06:36 +00:00
|
|
|
// the simulcast code in simulcast.js uses it to know what's going
|
|
|
|
// to be streamed by the bridge when/if the endpoint gets back into
|
|
|
|
// the lastN set.
|
2014-11-28 16:00:16 +00:00
|
|
|
|
|
|
|
if (lastNCount != -1
|
|
|
|
&& (lastNCount < 1 || lastNEndpointsCache.indexOf(resource) === -1)) {
|
2014-11-24 12:26:43 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-08-21 09:58:33 +00:00
|
|
|
var primarySSRC = esl.simulcastLayer.primarySSRC;
|
|
|
|
|
2014-10-31 10:17:41 +00:00
|
|
|
// Get session and stream from primary ssrc.
|
2015-01-28 14:35:22 +00:00
|
|
|
var res = APP.simulcast.getReceivingVideoStreamBySSRC(primarySSRC);
|
2015-01-19 09:20:00 +00:00
|
|
|
var sid = res.sid;
|
2014-10-31 10:17:41 +00:00
|
|
|
var electedStream = res.stream;
|
2014-08-21 09:58:33 +00:00
|
|
|
|
2015-01-19 09:20:00 +00:00
|
|
|
if (sid && electedStream) {
|
2015-01-28 14:35:22 +00:00
|
|
|
var msid = APP.simulcast.getRemoteVideoStreamIdBySSRC(primarySSRC);
|
2014-10-31 10:17:41 +00:00
|
|
|
|
2014-08-21 09:58:33 +00:00
|
|
|
console.info('Switching simulcast substream.');
|
2015-01-19 09:20:00 +00:00
|
|
|
console.info([esl, primarySSRC, msid, sid, electedStream]);
|
2014-08-21 09:58:33 +00:00
|
|
|
|
|
|
|
var msidParts = msid.split(' ');
|
2015-01-19 09:20:00 +00:00
|
|
|
var selRemoteVideo = $(['#', 'remoteVideo_', sid, '_', msidParts[0]].join(''));
|
2014-08-21 09:58:33 +00:00
|
|
|
|
2015-01-28 14:35:22 +00:00
|
|
|
var updateLargeVideo = (Strophe.getResourceFromJid(APP.xmpp.getJidFromSSRC(primarySSRC))
|
2014-12-04 16:03:45 +00:00
|
|
|
== largeVideoState.userResourceJid);
|
|
|
|
var updateFocusedVideoSrc = (focusedVideoInfo && focusedVideoInfo.src && focusedVideoInfo.src != '' &&
|
2015-01-28 14:35:22 +00:00
|
|
|
(APP.RTC.getVideoSrc(selRemoteVideo[0]) == focusedVideoInfo.src));
|
2014-08-21 09:58:33 +00:00
|
|
|
|
2014-10-26 19:57:13 +00:00
|
|
|
var electedStreamUrl;
|
|
|
|
if (largeVideoState.preload_ssrc == primarySSRC)
|
|
|
|
{
|
2015-01-28 14:35:22 +00:00
|
|
|
APP.RTC.setVideoSrc(selRemoteVideo[0], APP.RTC.getVideoSrc(largeVideoState.preload[0]));
|
2014-10-26 19:57:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-10-27 11:09:24 +00:00
|
|
|
if (largeVideoState.preload
|
|
|
|
&& largeVideoState.preload != null) {
|
|
|
|
$(largeVideoState.preload).remove();
|
|
|
|
}
|
|
|
|
|
|
|
|
largeVideoState.preload_ssrc = 0;
|
|
|
|
|
2015-01-28 14:35:22 +00:00
|
|
|
APP.RTC.attachMediaStream(selRemoteVideo, electedStream);
|
2014-10-26 19:57:13 +00:00
|
|
|
}
|
|
|
|
|
2015-01-28 14:35:22 +00:00
|
|
|
var jid = APP.xmpp.getJidFromSSRC(primarySSRC);
|
2014-08-21 09:58:33 +00:00
|
|
|
|
|
|
|
if (updateLargeVideo) {
|
2015-01-28 14:35:22 +00:00
|
|
|
VideoLayout.updateLargeVideo(APP.RTC.getVideoSrc(selRemoteVideo[0]), null,
|
2014-11-21 13:29:05 +00:00
|
|
|
Strophe.getResourceFromJid(jid));
|
2014-08-21 09:58:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (updateFocusedVideoSrc) {
|
2015-01-28 14:35:22 +00:00
|
|
|
focusedVideoInfo.src = APP.RTC.getVideoSrc(selRemoteVideo[0]);
|
2014-08-21 09:58:33 +00:00
|
|
|
}
|
2014-10-31 10:10:53 +00:00
|
|
|
|
2014-10-21 09:19:17 +00:00
|
|
|
var videoId;
|
2015-01-28 14:35:22 +00:00
|
|
|
if(resource == APP.xmpp.myResource())
|
2014-10-21 09:19:17 +00:00
|
|
|
{
|
|
|
|
videoId = "localVideoContainer";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-11-24 12:26:43 +00:00
|
|
|
videoId = "participant_" + resource;
|
2014-10-21 09:19:17 +00:00
|
|
|
}
|
|
|
|
var connectionIndicator = VideoLayout.connectionIndicators[videoId];
|
|
|
|
if(connectionIndicator)
|
|
|
|
connectionIndicator.updatePopoverData();
|
2014-08-21 09:58:33 +00:00
|
|
|
|
|
|
|
} else {
|
2015-01-19 09:20:00 +00:00
|
|
|
console.error('Could not find a stream or a sid.', sid, electedStream);
|
2014-08-21 09:58:33 +00:00
|
|
|
}
|
|
|
|
});
|
2015-01-27 09:56:22 +00:00
|
|
|
};
|
2014-08-21 09:58:33 +00:00
|
|
|
|
2014-10-16 15:11:26 +00:00
|
|
|
/**
|
|
|
|
* Updates local stats
|
|
|
|
* @param percent
|
|
|
|
* @param object
|
|
|
|
*/
|
|
|
|
my.updateLocalConnectionStats = function (percent, object) {
|
|
|
|
var resolution = null;
|
|
|
|
if(object.resolution !== null)
|
|
|
|
{
|
|
|
|
resolution = object.resolution;
|
2015-01-28 14:35:22 +00:00
|
|
|
object.resolution = resolution[APP.xmpp.myJid()];
|
|
|
|
delete resolution[APP.xmpp.myJid()];
|
2014-10-16 15:11:26 +00:00
|
|
|
}
|
|
|
|
updateStatsIndicator("localVideoContainer", percent, object);
|
|
|
|
for(var jid in resolution)
|
|
|
|
{
|
|
|
|
if(resolution[jid] === null)
|
|
|
|
continue;
|
|
|
|
var id = 'participant_' + Strophe.getResourceFromJid(jid);
|
|
|
|
if(VideoLayout.connectionIndicators[id])
|
|
|
|
{
|
|
|
|
VideoLayout.connectionIndicators[id].updateResolution(resolution[jid]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates remote stats.
|
|
|
|
* @param jid the jid associated with the stats
|
|
|
|
* @param percent the connection quality percent
|
|
|
|
* @param object the stats data
|
|
|
|
*/
|
|
|
|
my.updateConnectionStats = function (jid, percent, object) {
|
|
|
|
var resourceJid = Strophe.getResourceFromJid(jid);
|
|
|
|
|
|
|
|
var videoSpanId = 'participant_' + resourceJid;
|
|
|
|
updateStatsIndicator(videoSpanId, percent, object);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes the connection
|
|
|
|
* @param jid
|
|
|
|
*/
|
|
|
|
my.removeConnectionIndicator = function (jid) {
|
|
|
|
if(VideoLayout.connectionIndicators['participant_' + Strophe.getResourceFromJid(jid)])
|
|
|
|
VideoLayout.connectionIndicators['participant_' + Strophe.getResourceFromJid(jid)].remove();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hides the connection indicator
|
|
|
|
* @param jid
|
|
|
|
*/
|
|
|
|
my.hideConnectionIndicator = function (jid) {
|
|
|
|
if(VideoLayout.connectionIndicators['participant_' + Strophe.getResourceFromJid(jid)])
|
|
|
|
VideoLayout.connectionIndicators['participant_' + Strophe.getResourceFromJid(jid)].hide();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hides all the indicators
|
|
|
|
*/
|
|
|
|
my.onStatsStop = function () {
|
|
|
|
for(var indicator in VideoLayout.connectionIndicators)
|
|
|
|
{
|
|
|
|
VideoLayout.connectionIndicators[indicator].hideIndicator();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-01-20 15:56:00 +00:00
|
|
|
my.participantLeft = function (jid) {
|
|
|
|
// Unlock large video
|
|
|
|
if (focusedVideoInfo && focusedVideoInfo.jid === jid)
|
|
|
|
{
|
|
|
|
console.info("Focused video owner has left the conference");
|
|
|
|
focusedVideoInfo = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-12 18:33:57 +00:00
|
|
|
return my;
|
2014-06-27 16:27:24 +00:00
|
|
|
}(VideoLayout || {}));
|
2015-01-07 14:54:03 +00:00
|
|
|
|
|
|
|
module.exports = VideoLayout;
|