Changes lastN event params to leaving and entering endpoint IDs.

Uses leavingIDs to more efficiently iterate over remote videos.
This commit is contained in:
damencho 2017-03-21 16:51:49 -05:00 committed by hristoterezov
parent d383230532
commit e29120a9c1
3 changed files with 28 additions and 20 deletions

View File

@ -1305,8 +1305,9 @@ export default {
}); });
room.on( room.on(
ConferenceEvents.LAST_N_ENDPOINTS_CHANGED, (ids, enteringIds) => { ConferenceEvents.LAST_N_ENDPOINTS_CHANGED,
APP.UI.handleLastNEndpoints(ids, enteringIds); (leavingIds, enteringIds) => {
APP.UI.handleLastNEndpoints(leavingIds, enteringIds);
}); });
room.on( room.on(

View File

@ -837,8 +837,8 @@ UI.markDominantSpeaker = function (id) {
VideoLayout.onDominantSpeakerChanged(id); VideoLayout.onDominantSpeakerChanged(id);
}; };
UI.handleLastNEndpoints = function (ids, enteringIds) { UI.handleLastNEndpoints = function (leavingIds, enteringIds) {
VideoLayout.onLastNEndpointsChanged(ids, enteringIds); VideoLayout.onLastNEndpointsChanged(leavingIds, enteringIds);
}; };
/** /**

View File

@ -687,27 +687,34 @@ var VideoLayout = {
/** /**
* On last N change event. * On last N change event.
* *
* @param lastNEndpoints the list of last N endpoints * @param endpointsLeavingLastN the list currently leaving last N
* endpoints
* @param endpointsEnteringLastN the list currently entering last N * @param endpointsEnteringLastN the list currently entering last N
* endpoints * endpoints
*/ */
onLastNEndpointsChanged (lastNEndpoints, endpointsEnteringLastN) { onLastNEndpointsChanged (endpointsLeavingLastN, endpointsEnteringLastN) {
if (endpointsLeavingLastN) {
endpointsLeavingLastN.forEach(this._updateRemoteVideo, this);
}
Object.keys(remoteVideos).forEach( if (endpointsEnteringLastN) {
id => { endpointsEnteringLastN.forEach(this._updateRemoteVideo, this);
if (lastNEndpoints.length > 0 }
&& lastNEndpoints.indexOf(id) < 0 },
|| endpointsEnteringLastN.length > 0
&& endpointsEnteringLastN.indexOf(id) > 0) {
let remoteVideo = (id) ? remoteVideos[id] : null; /**
* Updates remote video by id if it exists.
* @param {string} id of the remote video
* @private
*/
_updateRemoteVideo(id) {
const remoteVideo = remoteVideos[id];
if (remoteVideo) { if (remoteVideo) {
remoteVideo.updateView(); remoteVideo.updateView();
if (remoteVideo.isCurrentlyOnLargeVideo()) if (remoteVideo.isCurrentlyOnLargeVideo()) {
this.updateLargeVideo(id); this.updateLargeVideo(id);
} }
} }
});
}, },
/** /**