Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
feat: Optimizes speaker stats to skip occupants with 0 talk time.
damenchoe6cdeb31ff51
diff --git a/resources/prosody-plugins/mod_speakerstats_component.lua b/resources/prosody-plugins/mod_speakerstats_component.luaindex 14c4cbd588..0c7a8c7ac1 100644--- a/resources/prosody-plugins/mod_speakerstats_component.lua+++ b/resources/prosody-plugins/mod_speakerstats_component.lua@@ -6,6 +6,7 @@ local ext_events = module:require "ext_events"local st = require "util.stanza";local socket = require "socket";local json = require "util.json";+local um_is_admin = require "core.usermanager".is_admin;-- we use async to detect Prosody 0.10 and earlierlocal have_async = pcall(require, "util.async");@@ -22,6 +23,10 @@ endlog("info", "Starting speakerstats for %s", muc_component_host);+local function is_admin(jid)+ return um_is_admin(jid, module.host);+end+-- receives messages from client currently connected to the room-- clients indicates their own dominant speaker eventsfunction on_message(event)@@ -126,9 +131,9 @@ end-- Create SpeakerStats object for the joined userfunction occupant_joined(event)- local room = event.room;+ local occupant, room = event.occupant, event.room;- if is_healthcheck_room(room.jid) then+ if is_healthcheck_room(room.jid) or is_admin(occupant.bare_jid) thenreturn;end@@ -145,26 +150,26 @@ function occupant_joined(event)-- skip reporting those without a nick('dominantSpeakerId')-- and skip focus if sneaked into the tableif values.nick ~= nil and values.nick ~= 'focus' then- local resultSpeakerStats = {};- local totalDominantSpeakerTime- = values.totalDominantSpeakerTime;-- -- before sending we need to calculate current dominant speaker- -- state- if values:isDominantSpeaker() then- local timeElapsed = math.floor(- socket.gettime()*1000 - values._dominantSpeakerStart);- totalDominantSpeakerTime = totalDominantSpeakerTime- + timeElapsed;+ local totalDominantSpeakerTime = values.totalDominantSpeakerTime;+ if totalDominantSpeakerTime > 0 or room:get_occupant_jid(jid) == nil then+ -- before sending we need to calculate current dominant speaker state+ if values:isDominantSpeaker() then+ local timeElapsed = math.floor(socket.gettime()*1000 - values._dominantSpeakerStart);+ totalDominantSpeakerTime = totalDominantSpeakerTime + timeElapsed;+ end++ users_json[values.nick] = {+ displayName = values.displayName,+ totalDominantSpeakerTime = totalDominantSpeakerTime+ };end-- resultSpeakerStats.displayName = values.displayName;- resultSpeakerStats.totalDominantSpeakerTime- = totalDominantSpeakerTime;- users_json[values.nick] = resultSpeakerStats;endend+ if next(users_json) == nil then+ return;+ end+local body_json = {};body_json.type = 'speakerstats';body_json.users = users_json;