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(rtcstats): send dominant speaker stats (#9883)
Andrei Gavrilescuf51e65d12946
diff --git a/react/features/rtcstats/RTCStats.js b/react/features/rtcstats/RTCStats.jsindex 714bde54be..b25996eb68 100644--- a/react/features/rtcstats/RTCStats.js+++ b/react/features/rtcstats/RTCStats.js@@ -85,6 +85,16 @@ class RTCStats {this.trace && this.trace.identity('identity', null, identityData);}+ /**+ * Send dominant speaker data, the data will be processed by rtcstats-server and saved in the dump file.+ *+ * @param {Object} dominantSpeakerData - Dominant speaker data to be saved in the rtcstats dump.+ * @returns {void}+ */+ sendDominantSpeakerData(dominantSpeakerData) {+ this.trace && this.trace.statsEntry('dominantSpeaker', null, dominantSpeakerData);+ }+/*** Connect to the rtcstats server instance. Stats (data obtained from getstats) won't be send until the* connect successfully initializes, however calls to GUM are recorded in an internal buffer even if notdiff --git a/react/features/rtcstats/functions.js b/react/features/rtcstats/functions.jsindex d980da3752..1393a15813 100644--- a/react/features/rtcstats/functions.js+++ b/react/features/rtcstats/functions.js@@ -2,6 +2,8 @@import { toState } from '../base/redux';+import RTCStats from './RTCStats';+/*** Checks whether rtcstats is enabled or not.*@@ -19,3 +21,14 @@ export function isRtcstatsEnabled(stateful: Function | Object) {return config?.analytics?.rtcstatsEnabled ?? false;}++/**+ * Can the rtcstats service send data.+ *+ * @param {Function|Object} stateful - The redux store or {@code getState} function.+ * @returns {boolean}+ */+export function canSendRtcstatsData(stateful: Function | Object) {++ return isRtcstatsEnabled(stateful) && RTCStats.isInitialized();+}diff --git a/react/features/rtcstats/middleware.js b/react/features/rtcstats/middleware.jsindex 9b269bce0e..9c3aa96bc7 100644--- a/react/features/rtcstats/middleware.js+++ b/react/features/rtcstats/middleware.js@@ -1,13 +1,13 @@// @flowimport { getAmplitudeIdentity } from '../analytics';-import { CONFERENCE_UNIQUE_ID_SET, getRoomName } from '../base/conference';+import { CONFERENCE_UNIQUE_ID_SET, getConferenceOptions, getRoomName } from '../base/conference';import { LIB_WILL_INIT } from '../base/lib-jitsi-meet';-import { getLocalParticipant } from '../base/participants';+import { DOMINANT_SPEAKER_CHANGED, getLocalParticipant } from '../base/participants';import { MiddlewareRegistry } from '../base/redux';import RTCStats from './RTCStats';-import { isRtcstatsEnabled } from './functions';+import { canSendRtcstatsData, isRtcstatsEnabled } from './functions';import logger from './logger';/**@@ -50,12 +50,15 @@ MiddlewareRegistry.register(store => next => action => {break;}case CONFERENCE_UNIQUE_ID_SET: {- if (isRtcstatsEnabled(state) && RTCStats.isInitialized()) {+ if (canSendRtcstatsData(state)) {+// Once the conference started connect to the rtcstats server and send data.try {RTCStats.connect();const localParticipant = getLocalParticipant(state);+ const options = getConferenceOptions(state);+// Unique identifier for a conference session, not to be confused with meeting name// i.e. If all participants leave a meeting it will have a different value on the next join.@@ -71,7 +74,8 @@ MiddlewareRegistry.register(store => next => action => {// conference with a specific version.RTCStats.sendIdentityData({...getAmplitudeIdentity(),- ...config,+ ...options,+ endpointId: localParticipant?.id,confName: getRoomName(state),displayName: localParticipant?.name,meetingUniqueId@@ -83,6 +87,15 @@ MiddlewareRegistry.register(store => next => action => {}break;}+ case DOMINANT_SPEAKER_CHANGED: {+ if (canSendRtcstatsData(state)) {+ const { id, previousSpeakers } = action.participant;++ RTCStats.sendDominantSpeakerData({ dominantSpeakerEndpoint: id,+ previousSpeakers });+ }+ break;+ }}return next(action);