From 71e290a8ad78daa2873a12fb89148c9cbf08d2c5 Mon Sep 17 00:00:00 2001 From: George Politis Date: Mon, 24 Nov 2014 13:26:43 +0100 Subject: [PATCH] Run simulcastlayerschanged/ing event handlers only if the affected endpoint is in lastN. --- videolayout.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/videolayout.js b/videolayout.js index 4f77b8cf7..fbbd9ba63 100644 --- a/videolayout.js +++ b/videolayout.js @@ -1542,6 +1542,12 @@ var VideoLayout = (function (my) { $(document).bind('simulcastlayerschanging', function (event, endpointSimulcastLayers) { endpointSimulcastLayers.forEach(function (esl) { + + var resource = esl.endpoint; + if (lastNCount < 1 || lastNEndpointsCache.indexOf(resource) === -1) { + return; + } + var primarySSRC = esl.simulcastLayer.primarySSRC; // Get session and stream from primary ssrc. @@ -1589,6 +1595,11 @@ var VideoLayout = (function (my) { $(document).bind('simulcastlayerschanged', function (event, endpointSimulcastLayers) { endpointSimulcastLayers.forEach(function (esl) { + var resource = esl.endpoint; + if (lastNCount < 1 || lastNEndpointsCache.indexOf(resource) === -1) { + return; + } + var primarySSRC = esl.simulcastLayer.primarySSRC; // Get session and stream from primary ssrc. @@ -1644,15 +1655,14 @@ var VideoLayout = (function (my) { focusedVideoSrc = electedStreamUrl; } - var jid = ssrc2jid[primarySSRC]; var videoId; - if(jid == connection.emuc.myroomjid) + if(resource == Strophe.getResourceFromJid(connection.emuc.myroomjid)) { videoId = "localVideoContainer"; } else { - videoId = "participant_" + Strophe.getResourceFromJid(jid); + videoId = "participant_" + resource; } var connectionIndicator = VideoLayout.connectionIndicators[videoId]; if(connectionIndicator)