Skip to content

Commit

Permalink
Add debug state for visitor codec aggregation.
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanLennox committed Feb 27, 2024
1 parent d85aa96 commit c48563d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import org.jitsi.xmpp.extensions.jitsimeet.VideoMutedExtension
import org.jivesoftware.smack.packet.Presence
import org.jivesoftware.smack.packet.StandardExtensionElement
import org.jivesoftware.smackx.caps.packet.CapsExtension
import org.json.simple.JSONArray
import org.jxmpp.jid.EntityFullJid
import org.jxmpp.jid.Jid

Expand Down Expand Up @@ -276,6 +277,7 @@ class ChatRoomMemberImpl(
this["is_jibri"] = isJibri
this["is_jigasi"] = isJigasi
this["role"] = role.toString()
this["video_codecs"] = JSONArray().apply { videoCodecs?.let { addAll(it) } }
this["stats_id"] = statsId.toString()
this["is_audio_muted"] = isAudioMuted
this["is_video_muted"] = isVideoMuted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1594,6 +1594,7 @@ else if (member.isJigasi())
}
}
o.put("visitor_count", visitorCount);
o.put("visitor_codecs", visitorCodecs.debugState());
o.put("participant_count", participantCount);
o.put("jibri_count", jibriCount);
o.put("jigasi_count", jigasiCount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
*/
package org.jitsi.jicofo.util

import org.jitsi.utils.OrderedJsonObject
import org.jitsi.utils.logging2.Logger
import org.jitsi.utils.logging2.createChildLogger
import org.json.simple.JSONArray

/** Aggregate lists of preferences coming from a large group of people, such that the resulting aggregated
* list consists of preference items supported by everyone, and in a rough consensus of preference order.
Expand Down Expand Up @@ -108,6 +110,21 @@ class PreferenceAggregator(
}
}

fun debugState() = OrderedJsonObject().apply {
synchronized(lock) {
put("count", count)
put(
"ranks",
OrderedJsonObject().apply {
this@PreferenceAggregator.values.asSequence()
.sortedBy { it.value.rankAggregate }
.forEach { put(it.key, it.value.debugState()) }
}
)
put("aggregate", JSONArray().apply { addAll(aggregate) })
}
}

private fun updateAggregate() {
val newAggregate = values.asSequence()
.filter { it.value.count == count }
Expand All @@ -124,5 +141,10 @@ class PreferenceAggregator(
private class ValueInfo {
var count = 0
var rankAggregate = 0

fun debugState() = OrderedJsonObject().apply {
put("count", count)
put("rank_aggregate", rankAggregate)
}
}
}

0 comments on commit c48563d

Please sign in to comment.