Browse Source

feat(load-test): Load test startmuted (#8629)

* feat(load-test): Senders unmute themselves if muted by policy.

* feat(load-test): Adds option to skip creating local audio track.

We currently create local audio track even when starting audio muted. Adding the option to control that can load test that for clients or signalling.
master
Дамян Минков 4 years ago
parent
commit
8fcaea9e3d
No account linked to committer's email address
1 changed files with 30 additions and 2 deletions
  1. 30
    2
      resources/load-test/load-test-participant.js

+ 30
- 2
resources/load-test/load-test-participant.js View File

@@ -13,7 +13,10 @@ const {
13 13
     localVideo = config.startWithVideoMuted !== true,
14 14
     remoteVideo = isHuman,
15 15
     remoteAudio = isHuman,
16
-    autoPlayVideo = config.testing.noAutoPlayVideo !== true
16
+    autoPlayVideo = config.testing.noAutoPlayVideo !== true,
17
+
18
+    // Whether to create local audio even if muted
19
+    autoCreateLocalAudio = config.testing.noAutoLocalAudio !== true
17 20
 } = params;
18 21
 
19 22
 const { room: roomName } = parseURIString(window.location.toString());
@@ -149,6 +152,27 @@ function onConferenceJoined() {
149 152
     console.log('Conference joined');
150 153
 }
151 154
 
155
+/**
156
+ * Handles start muted events, when audio and/or video are muted due to
157
+ * startAudioMuted or startVideoMuted policy.
158
+ */
159
+function onStartMuted() {
160
+    // Give it some time, as it may be currently in the process of muting
161
+    setTimeout(() => {
162
+        const localAudioTrack = room.getLocalAudioTrack();
163
+
164
+        if (localAudio && localAudioTrack && localAudioTrack.isMuted()) {
165
+            localAudioTrack.unmute();
166
+        }
167
+
168
+        const localVideoTrack = room.getLocalVideoTrack();
169
+
170
+        if (localVideo && localVideoTrack && localVideoTrack.isMuted()) {
171
+            localVideoTrack.unmute();
172
+        }
173
+    }, 2000);
174
+}
175
+
152 176
 /**
153 177
  *
154 178
  * @param id
@@ -176,6 +200,7 @@ function onUserLeft(id) {
176 200
  */
177 201
 function onConnectionSuccess() {
178 202
     room = connection.initJitsiConference(roomName.toLowerCase(), config);
203
+    room.on(JitsiMeetJS.events.conference.STARTED_MUTED, onStartMuted);
179 204
     room.on(JitsiMeetJS.events.conference.TRACK_ADDED, onRemoteTrack);
180 205
     room.on(JitsiMeetJS.events.conference.CONFERENCE_JOINED, onConferenceJoined);
181 206
     room.on(JitsiMeetJS.events.conference.USER_JOINED, id => {
@@ -190,7 +215,10 @@ function onConnectionSuccess() {
190 215
     if (localVideo) {
191 216
         devices.push('video');
192 217
     }
193
-    devices.push('audio');
218
+
219
+    if (autoCreateLocalAudio) {
220
+        devices.push('audio');
221
+    }
194 222
 
195 223
     if (devices.length > 0) {
196 224
         JitsiMeetJS.createLocalTracks({ devices })

Loading…
Cancel
Save