Kaynağa Gözat

feat(rtcstats): send dominant speaker stats (#9883)

* send dominant speaker stats

* fix lint
master
Andrei Gavrilescu 3 yıl önce
ebeveyn
işleme
f51e65d129
No account linked to committer's email address

+ 10
- 0
react/features/rtcstats/RTCStats.js Dosyayı Görüntüle

@@ -85,6 +85,16 @@ class RTCStats {
85 85
         this.trace && this.trace.identity('identity', null, identityData);
86 86
     }
87 87
 
88
+    /**
89
+     * Send dominant speaker data, the data will be processed by rtcstats-server and saved in the dump file.
90
+     *
91
+     * @param {Object} dominantSpeakerData - Dominant speaker data to be saved in the rtcstats dump.
92
+     * @returns {void}
93
+     */
94
+    sendDominantSpeakerData(dominantSpeakerData) {
95
+        this.trace && this.trace.statsEntry('dominantSpeaker', null, dominantSpeakerData);
96
+    }
97
+
88 98
     /**
89 99
      * Connect to the rtcstats server instance. Stats (data obtained from getstats) won't be send until the
90 100
      * connect successfully initializes, however calls to GUM are recorded in an internal buffer even if not

+ 13
- 0
react/features/rtcstats/functions.js Dosyayı Görüntüle

@@ -2,6 +2,8 @@
2 2
 
3 3
 import { toState } from '../base/redux';
4 4
 
5
+import RTCStats from './RTCStats';
6
+
5 7
 /**
6 8
  * Checks whether rtcstats is enabled or not.
7 9
  *
@@ -19,3 +21,14 @@ export function isRtcstatsEnabled(stateful: Function | Object) {
19 21
 
20 22
     return config?.analytics?.rtcstatsEnabled ?? false;
21 23
 }
24
+
25
+/**
26
+ * Can the rtcstats service send data.
27
+ *
28
+ * @param {Function|Object} stateful - The redux store or {@code getState} function.
29
+ * @returns {boolean}
30
+ */
31
+export function canSendRtcstatsData(stateful: Function | Object) {
32
+
33
+    return isRtcstatsEnabled(stateful) && RTCStats.isInitialized();
34
+}

+ 18
- 5
react/features/rtcstats/middleware.js Dosyayı Görüntüle

@@ -1,13 +1,13 @@
1 1
 // @flow
2 2
 
3 3
 import { getAmplitudeIdentity } from '../analytics';
4
-import { CONFERENCE_UNIQUE_ID_SET, getRoomName } from '../base/conference';
4
+import { CONFERENCE_UNIQUE_ID_SET, getConferenceOptions, getRoomName } from '../base/conference';
5 5
 import { LIB_WILL_INIT } from '../base/lib-jitsi-meet';
6
-import { getLocalParticipant } from '../base/participants';
6
+import { DOMINANT_SPEAKER_CHANGED, getLocalParticipant } from '../base/participants';
7 7
 import { MiddlewareRegistry } from '../base/redux';
8 8
 
9 9
 import RTCStats from './RTCStats';
10
-import { isRtcstatsEnabled } from './functions';
10
+import { canSendRtcstatsData, isRtcstatsEnabled } from './functions';
11 11
 import logger from './logger';
12 12
 
13 13
 /**
@@ -50,12 +50,15 @@ MiddlewareRegistry.register(store => next => action => {
50 50
         break;
51 51
     }
52 52
     case CONFERENCE_UNIQUE_ID_SET: {
53
-        if (isRtcstatsEnabled(state) && RTCStats.isInitialized()) {
53
+        if (canSendRtcstatsData(state)) {
54
+
54 55
             // Once the conference started connect to the rtcstats server and send data.
55 56
             try {
56 57
                 RTCStats.connect();
57 58
 
58 59
                 const localParticipant = getLocalParticipant(state);
60
+                const options = getConferenceOptions(state);
61
+
59 62
 
60 63
                 // Unique identifier for a conference session, not to be confused with meeting name
61 64
                 // 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 => {
71 74
                 // conference with a specific version.
72 75
                 RTCStats.sendIdentityData({
73 76
                     ...getAmplitudeIdentity(),
74
-                    ...config,
77
+                    ...options,
78
+                    endpointId: localParticipant?.id,
75 79
                     confName: getRoomName(state),
76 80
                     displayName: localParticipant?.name,
77 81
                     meetingUniqueId
@@ -83,6 +87,15 @@ MiddlewareRegistry.register(store => next => action => {
83 87
         }
84 88
         break;
85 89
     }
90
+    case DOMINANT_SPEAKER_CHANGED: {
91
+        if (canSendRtcstatsData(state)) {
92
+            const { id, previousSpeakers } = action.participant;
93
+
94
+            RTCStats.sendDominantSpeakerData({ dominantSpeakerEndpoint: id,
95
+                previousSpeakers });
96
+        }
97
+        break;
98
+    }
86 99
     }
87 100
 
88 101
     return next(action);

Loading…
İptal
Kaydet