From a8909028c8543a9f5a0132dd6b06b4aeb61f40f7 Mon Sep 17 00:00:00 2001 From: George Politis Date: Thu, 27 Nov 2014 19:28:28 +0100 Subject: [PATCH] Modifies the avatars, lastN and adaptive lastN handling so that they play nicely together. --- avatar.js | 11 ++++++++++- videolayout.js | 15 ++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/avatar.js b/avatar.js index 3a18edb9d..2888f44ae 100644 --- a/avatar.js +++ b/avatar.js @@ -122,7 +122,16 @@ var Avatar = (function(my) { } function isUserMuted(jid) { - if(!mediaStreams[jid] || !mediaStreams[jid][MediaStream.VIDEO_TYPE]) { + // XXX(gp) we may want to rename this method to something like + // isUserStreaming, for example. + if (jid && jid != connection.emuc.myroomjid) { + var resource = Strophe.getResourceFromJid(jid); + if (!VideoLayout.isInLastN(resource)) { + return true; + } + } + + if (!mediaStreams[jid] || !mediaStreams[jid][MediaStream.VIDEO_TYPE]) { return null; } return mediaStreams[jid][MediaStream.VIDEO_TYPE].muted; diff --git a/videolayout.js b/videolayout.js index c2ac6ff5f..e6915be0d 100644 --- a/videolayout.js +++ b/videolayout.js @@ -11,6 +11,12 @@ var VideoLayout = (function (my) { }; my.connectionIndicators = {}; + 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); + }; + my.changeLocalAudio = function(stream) { connection.jingle.localAudio = stream; @@ -597,14 +603,17 @@ var VideoLayout = (function (my) { peerContainer.show(); } - // TODO(gp) add proper avatars handling. if (state == 'show') { - peerContainer.css('-webkit-filter', ''); + // peerContainer.css('-webkit-filter', ''); + var jid = connection.emuc.findJidFromResource(resourceJid); + Avatar.showUserAvatar(jid, false); } else // if (state == 'avatar') { - peerContainer.css('-webkit-filter', 'grayscale(100%)'); + // peerContainer.css('-webkit-filter', 'grayscale(100%)'); + var jid = connection.emuc.findJidFromResource(resourceJid); + Avatar.showUserAvatar(jid, true); } } else if (peerContainer.is(':visible') && isHide)