From 570cd8089e18d4228b16d2c47db893aa7c236741 Mon Sep 17 00:00:00 2001 From: Boris Grozev Date: Tue, 20 Feb 2024 13:34:09 -0600 Subject: [PATCH] squash: Log number of hidden participants. --- .../jibri/selenium/pageobjects/CallPage.kt | 22 +++++++++++++++++++ .../status_checks/MediaReceivedStatusCheck.kt | 3 ++- .../MediaReceivedStatusCheckTest.kt | 4 +++- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/org/jitsi/jibri/selenium/pageobjects/CallPage.kt b/src/main/kotlin/org/jitsi/jibri/selenium/pageobjects/CallPage.kt index 5d2a64db..a6c6a1ec 100644 --- a/src/main/kotlin/org/jitsi/jibri/selenium/pageobjects/CallPage.kt +++ b/src/main/kotlin/org/jitsi/jibri/selenium/pageobjects/CallPage.kt @@ -229,6 +229,28 @@ class CallPage(driver: RemoteWebDriver) : AbstractPageObject(driver) { } } + /** How many of the participants are hidden or hiddenFromRecorder. */ + fun numHiddenParticipants(): Int { + val result = driver.executeScript( + """ + try { + return APP.conference._room.getParticipants() + .filter(p => (p.isHidden() || p.isHiddenFromRecorder()) + .length; + } catch (e) { + return e.message; + } + """.trimMargin() + ) + return when (result) { + is Number -> result.toInt() + else -> { + logger.error("error running numHiddenParticipants script: $result ${result::class.java}") + 0 + } + } + } + /** * Return true if ICE is connected. */ diff --git a/src/main/kotlin/org/jitsi/jibri/selenium/status_checks/MediaReceivedStatusCheck.kt b/src/main/kotlin/org/jitsi/jibri/selenium/status_checks/MediaReceivedStatusCheck.kt index 50f62ef4..935cd778 100644 --- a/src/main/kotlin/org/jitsi/jibri/selenium/status_checks/MediaReceivedStatusCheck.kt +++ b/src/main/kotlin/org/jitsi/jibri/selenium/status_checks/MediaReceivedStatusCheck.kt @@ -39,13 +39,14 @@ class MediaReceivedStatusCheck( val numParticipants = callPage.getNumParticipants() - 1 val numMutedParticipants = callPage.numRemoteParticipantsMuted() val numJigasiParticipants = callPage.numRemoteParticipantsJigasi() + val numHiddenParticipants = callPage.numHiddenParticipants() // We don't get any mute state for Jigasi participants, so to prevent timing out when only Jigasi participants // may be speaking, always count them as "muted" val allClientsMuted = (numMutedParticipants + numJigasiParticipants) == numParticipants logger.info( "Jibri client receive bitrates: $bitrates, num participants: $numParticipants, " + "numMutedParticipants: $numMutedParticipants, numJigasis: $numJigasiParticipants, " + - "all clients muted? $allClientsMuted" + "numHiddenParticipants: $numHiddenParticipants, all clients muted? $allClientsMuted" ) clientsAllMutedTransitionTime.maybeUpdate(allClientsMuted) val downloadBitrate = bitrates.getOrDefault("download", 0L) as Long diff --git a/src/test/kotlin/org/jitsi/jibri/selenium/status_checks/MediaReceivedStatusCheckTest.kt b/src/test/kotlin/org/jitsi/jibri/selenium/status_checks/MediaReceivedStatusCheckTest.kt index bba24c63..7b8d7335 100644 --- a/src/test/kotlin/org/jitsi/jibri/selenium/status_checks/MediaReceivedStatusCheckTest.kt +++ b/src/test/kotlin/org/jitsi/jibri/selenium/status_checks/MediaReceivedStatusCheckTest.kt @@ -17,7 +17,9 @@ class MediaReceivedStatusCheckTest : ShouldSpec() { override fun isolationMode(): IsolationMode? = IsolationMode.InstancePerLeaf private val clock: FakeClock = spyk() - private val callPage: CallPage = mockk() + private val callPage: CallPage = mockk { + every { numHiddenParticipants() } returns 0 + } private val logger: Logger = mockk(relaxed = true) private val check = MediaReceivedStatusCheck(logger, clock)