From 8fcaea9e3d66467843bce57fe3bfaa84b0f861c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D1=8F=D0=BD=20=D0=9C=D0=B8=D0=BD=D0=BA?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Wed, 17 Feb 2021 10:28:01 -0600 Subject: [PATCH] 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. --- resources/load-test/load-test-participant.js | 32 ++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/resources/load-test/load-test-participant.js b/resources/load-test/load-test-participant.js index dee61342d..65789cde9 100644 --- a/resources/load-test/load-test-participant.js +++ b/resources/load-test/load-test-participant.js @@ -13,7 +13,10 @@ const { localVideo = config.startWithVideoMuted !== true, remoteVideo = isHuman, remoteAudio = isHuman, - autoPlayVideo = config.testing.noAutoPlayVideo !== true + autoPlayVideo = config.testing.noAutoPlayVideo !== true, + + // Whether to create local audio even if muted + autoCreateLocalAudio = config.testing.noAutoLocalAudio !== true } = params; const { room: roomName } = parseURIString(window.location.toString()); @@ -149,6 +152,27 @@ function onConferenceJoined() { console.log('Conference joined'); } +/** + * Handles start muted events, when audio and/or video are muted due to + * startAudioMuted or startVideoMuted policy. + */ +function onStartMuted() { + // Give it some time, as it may be currently in the process of muting + setTimeout(() => { + const localAudioTrack = room.getLocalAudioTrack(); + + if (localAudio && localAudioTrack && localAudioTrack.isMuted()) { + localAudioTrack.unmute(); + } + + const localVideoTrack = room.getLocalVideoTrack(); + + if (localVideo && localVideoTrack && localVideoTrack.isMuted()) { + localVideoTrack.unmute(); + } + }, 2000); +} + /** * * @param id @@ -176,6 +200,7 @@ function onUserLeft(id) { */ function onConnectionSuccess() { room = connection.initJitsiConference(roomName.toLowerCase(), config); + room.on(JitsiMeetJS.events.conference.STARTED_MUTED, onStartMuted); room.on(JitsiMeetJS.events.conference.TRACK_ADDED, onRemoteTrack); room.on(JitsiMeetJS.events.conference.CONFERENCE_JOINED, onConferenceJoined); room.on(JitsiMeetJS.events.conference.USER_JOINED, id => { @@ -190,7 +215,10 @@ function onConnectionSuccess() { if (localVideo) { devices.push('video'); } - devices.push('audio'); + + if (autoCreateLocalAudio) { + devices.push('audio'); + } if (devices.length > 0) { JitsiMeetJS.createLocalTracks({ devices })