Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

Load-test: emulate jitsi-meet stage view behavior, if selected. (#8957)

Jonathan Lennox31c0ba448130
diff --git a/resources/load-test/load-test-participant.js b/resources/load-test/load-test-participant.js
index 41a7a7bae3..22c51a89f0 100644
--- a/resources/load-test/load-test-participant.js
+++ b/resources/load-test/load-test-participant.js
@@ -14,6 +14,7 @@ const {
remoteVideo = isHuman,
remoteAudio = isHuman,
autoPlayVideo = config.testing.noAutoPlayVideo !== true,
+ stageView = config.disableTileView
} = params;
let {
@@ -35,6 +36,8 @@ const remoteTracks = {};
let maxFrameHeight = 0;
+let selectedParticipant = null;
+
window.APP = {
conference: {
getStats() {
@@ -85,7 +88,8 @@ window.APP = {
localVideo,
remoteVideo,
remoteAudio,
- autoPlayVideo
+ autoPlayVideo,
+ stageView
};
}
};
@@ -100,12 +104,17 @@ function updateMaxFrameHeight() {
let newMaxFrameHeight;
- if (numParticipants <= 2) {
- newMaxFrameHeight = 720;
- } else if (numParticipants <= 4) {
- newMaxFrameHeight = 360;
- } else {
- newMaxFrameHeight = 180;
+ if (stageView) {
+ newMaxFrameHeight = 2160;
+ }
+ else {
+ if (numParticipants <= 2) {
+ newMaxFrameHeight = 720;
+ } else if (numParticipants <= 4) {
+ newMaxFrameHeight = 360;
+ } else {
+ newMaxFrameHeight = 180;
+ }
}
if (room && maxFrameHeight !== newMaxFrameHeight) {
@@ -137,6 +146,36 @@ function updateLastN() {
room.setLastN(lastN);
}
+/**
+ * Helper function to query whether a participant ID is a valid ID
+ * for stage view.
+ */
+function isValidStageViewParticipant(id) {
+ return (id !== room.myUserId() && room.getParticipantById(id));
+}
+
+/**
+ * Simple emulation of jitsi-meet's stage view participant selection behavior.
+ * Doesn't take into account pinning or screen sharing, and the initial behavior
+ * is slightly different.
+ * @returns Whether the selected participant changed.
+ */
+function selectStageViewParticipant(selected, previous) {
+ let newSelectedParticipant;
+
+ if (isValidStageViewParticipant(selected)) {
+ newSelectedParticipant = selected;
+ }
+ else {
+ newSelectedParticipant = previous.find(isValidStageViewParticipant);
+ }
+ if (newSelectedParticipant && newSelectedParticipant !== selectedParticipant) {
+ selectedParticipant = newSelectedParticipant;
+ return true;
+ }
+ return false;
+}
+
/**
* Simple emulation of jitsi-meet's selectParticipants behavior
*/
@@ -144,9 +183,16 @@ function selectParticipants() {
if (!connected) {
return;
}
- /* jitsi-meet's current Tile View behavior. */
- const ids = room.getParticipants().map(participant => participant.getId());
- room.selectParticipants(ids);
+ if (stageView) {
+ if (selectedParticipant) {
+ room.selectParticipants([selectedParticipant]);
+ }
+ }
+ else {
+ /* jitsi-meet's current Tile View behavior. */
+ const ids = room.getParticipants().map(participant => participant.getId());
+ room.selectParticipants(ids);
+ }
}
/**
@@ -154,8 +200,10 @@ function selectParticipants() {
*/
function setNumberOfParticipants() {
$('#participants').text(numParticipants);
- selectParticipants();
- updateMaxFrameHeight();
+ if (!stageView) {
+ selectParticipants();
+ updateMaxFrameHeight();
+ }
updateLastN();
}
@@ -170,6 +218,17 @@ function onConnectionEstablished() {
updateLastN();
}
+/**
+ * Handles dominant speaker changed.
+ * @param id
+ */
+function onDominantSpeakerChanged(selected, previous) {
+ if (selectStageViewParticipant(selected, previous)) {
+ selectParticipants();
+ }
+ updateMaxFrameHeight();
+}
+
/**
* Handles local tracks.
* @param tracks Array with JitsiTrack objects
@@ -292,6 +351,9 @@ function onConnectionSuccess() {
room.on(JitsiMeetJS.events.conference.CONNECTION_ESTABLISHED, onConnectionEstablished);
room.on(JitsiMeetJS.events.conference.USER_JOINED, onUserJoined);
room.on(JitsiMeetJS.events.conference.USER_LEFT, onUserLeft);
+ if (stageView) {
+ room.on(JitsiMeetJS.events.conference.DOMINANT_SPEAKER_CHANGED, onDominantSpeakerChanged);
+ }
const devices = [];