瀏覽代碼

feat(stats): Add a new bridge message "EndpointStats" for stats.

Use the new Colibri message "EndpointStats" for broadcasting the local stats. The bridge then will be able to filter the endpoint stats and send them only to the interested parties instead of broadcasting it to all the endpoints in the call.
dev1
Jaya Allamsetty 4 年之前
父節點
當前提交
13cfea660e

+ 9
- 0
JitsiConference.js 查看文件

2598
     this.rtc.sendChannelMessage(to, payload);
2598
     this.rtc.sendChannelMessage(to, payload);
2599
 };
2599
 };
2600
 
2600
 
2601
+/**
2602
+ * Sends local stats via the bridge channel which then forwards to other endpoints selectively.
2603
+ * @param {Object} payload The payload of the message.
2604
+ * @throws NetworkError/InvalidStateError/Error if the operation fails or if there is no data channel created.
2605
+ */
2606
+JitsiConference.prototype.sendEndpointStatsMessage = function(payload) {
2607
+    this.rtc.sendEndpointStatsMessage(payload);
2608
+};
2609
+
2601
 /**
2610
 /**
2602
  * Sends a broadcast message via the data channel.
2611
  * Sends a broadcast message via the data channel.
2603
  * @param payload {object} the payload of the message.
2612
  * @param payload {object} the payload of the message.

+ 11
- 0
JitsiConferenceEventManager.js 查看文件

556
             }
556
             }
557
         });
557
         });
558
 
558
 
559
+    rtc.addListener(RTCEvents.ENDPOINT_STATS_RECEIVED,
560
+        (from, payload) => {
561
+            const participant = conference.getParticipantById(from);
562
+
563
+            if (participant) {
564
+                conference.eventEmitter.emit(JitsiConferenceEvents.ENDPOINT_STATS_RECEIVED, participant, payload);
565
+            } else {
566
+                logger.warn(`Ignoring ENDPOINT_STATS_RECEIVED for a non-existant participant: ${from}`);
567
+            }
568
+        });
569
+
559
     rtc.addListener(RTCEvents.LOCAL_UFRAG_CHANGED,
570
     rtc.addListener(RTCEvents.LOCAL_UFRAG_CHANGED,
560
         (tpc, ufrag) => {
571
         (tpc, ufrag) => {
561
             if (!tpc.isP2P) {
572
             if (!tpc.isP2P) {

+ 5
- 0
JitsiConferenceEvents.js 查看文件

97
  */
97
  */
98
 export const ENDPOINT_MESSAGE_RECEIVED = 'conference.endpoint_message_received';
98
 export const ENDPOINT_MESSAGE_RECEIVED = 'conference.endpoint_message_received';
99
 
99
 
100
+/**
101
+ * Indicates that a message for the remote endpoint statistics has been received on the bridge channel.
102
+ */
103
+export const ENDPOINT_STATS_RECEIVED = 'conference.endpoint_stats_received';
104
+
100
 /**
105
 /**
101
  * NOTE This is lib-jitsi-meet internal event and can be removed at any time !
106
  * NOTE This is lib-jitsi-meet internal event and can be removed at any time !
102
  *
107
  *

+ 18
- 0
modules/RTC/BridgeChannel.js 查看文件

174
             || this._channel.readyState === WebSocket.OPEN);
174
             || this._channel.readyState === WebSocket.OPEN);
175
     }
175
     }
176
 
176
 
177
+    /**
178
+     * Sends local stats via the bridge channel.
179
+     * @param {Object} payload The payload of the message.
180
+     * @throws NetworkError/InvalidStateError/Error if the operation fails or if there is no data channel created.
181
+     */
182
+    sendEndpointStatsMessage(payload) {
183
+        logger.debug(`Sending endpoint stats ${JSON.stringify(payload)}`);
184
+        this._send({
185
+            colibriClass: 'EndpointStats',
186
+            ...payload
187
+        });
188
+    }
189
+
177
     /**
190
     /**
178
      * Sends message via the channel.
191
      * Sends message via the channel.
179
      * @param {string} to The id of the endpoint that should receive the
192
      * @param {string} to The id of the endpoint that should receive the
310
 
323
 
311
                 break;
324
                 break;
312
             }
325
             }
326
+            case 'EndpointStats': {
327
+                emitter.emit(RTCEvents.ENDPOINT_STATS_RECEIVED, obj.from, obj);
328
+
329
+                break;
330
+            }
313
             case 'LastNEndpointsChangeEvent': {
331
             case 'LastNEndpointsChangeEvent': {
314
                 // The new/latest list of last-n endpoint IDs (i.e. endpoints for which the bridge is sending video).
332
                 // The new/latest list of last-n endpoint IDs (i.e. endpoints for which the bridge is sending video).
315
                 const lastNEndpoints = obj.lastNEndpoints;
333
                 const lastNEndpoints = obj.lastNEndpoints;

+ 11
- 2
modules/RTC/RTC.js 查看文件

845
         track.setAudioLevel(audioLevel, tpc);
845
         track.setAudioLevel(audioLevel, tpc);
846
     }
846
     }
847
 
847
 
848
-    /* eslint-enable max-params */
849
-
850
     /**
848
     /**
851
      * Sends message via the bridge channel.
849
      * Sends message via the bridge channel.
852
      * @param {string} to The id of the endpoint that should receive the
850
      * @param {string} to The id of the endpoint that should receive the
863
         }
861
         }
864
     }
862
     }
865
 
863
 
864
+    /**
865
+     * Sends the local stats via the bridge channel.
866
+     * @param {Object} payload The payload of the message.
867
+     * @throws NetworkError/InvalidStateError/Error if the operation fails or if there is no data channel created.
868
+     */
869
+    sendEndpointStatsMessage(payload) {
870
+        if (this._channel && this._channel.isOpen()) {
871
+            this._channel.sendEndpointStatsMessage(payload);
872
+        }
873
+    }
874
+
866
     /**
875
     /**
867
      * Selects a new value for "lastN". The requested amount of videos are going
876
      * Selects a new value for "lastN". The requested amount of videos are going
868
      * to be delivered after the value is in effect. Set to -1 for unlimited or
877
      * to be delivered after the value is in effect. Set to -1 for unlimited or

+ 12
- 13
modules/connectivity/ConnectionQuality.js 查看文件

239
 
239
 
240
         // Listen to DataChannel message from other participants in the
240
         // Listen to DataChannel message from other participants in the
241
         // conference, and update the _remoteStats field accordingly.
241
         // conference, and update the _remoteStats field accordingly.
242
+        // TODO - Delete this when all the mobile endpoints switch to using the new Colibri
243
+        // message format for sending the endpoint stats.
242
         conference.on(
244
         conference.on(
243
             ConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
245
             ConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
244
             (participant, payload) => {
246
             (participant, payload) => {
248
                 }
250
                 }
249
             });
251
             });
250
 
252
 
253
+        conference.on(
254
+            ConferenceEvents.ENDPOINT_STATS_RECEIVED,
255
+            (participant, payload) => {
256
+                this._updateRemoteStats(participant.getId(), payload);
257
+            });
258
+
251
         // Listen to local statistics events originating from the RTC module
259
         // Listen to local statistics events originating from the RTC module
252
         // and update the _localStats field.
260
         // and update the _localStats field.
253
         // Oh, and by the way, the resolutions of all remote participants are
261
         // Oh, and by the way, the resolutions of all remote participants are
465
         };
473
         };
466
 
474
 
467
         try {
475
         try {
468
-            this._conference.broadcastEndpointMessage({
469
-                type: STATS_MESSAGE_TYPE,
470
-                values: data });
471
-        } catch (e) {
472
-            // We often hit this in the beginning of a call, before the data
473
-            // channel is ready. It is not a big problem, because we will
474
-            // send the statistics again after a few seconds, and the error is
475
-            // already logged elsewhere. So just ignore it.
476
-
477
-            // let errorMsg = "Failed to broadcast local stats";
478
-            // logger.error(errorMsg, e);
479
-            // GlobalOnErrorHandler.callErrorHandler(
480
-            //    new Error(errorMsg + ": " + e));
476
+            this._conference.sendEndpointStatsMessage(data);
477
+        } catch (err) {
478
+            // Ignore the error as we might hit it in the beginning of the call before the channel is ready.
479
+            // The statistics will be sent again after few seconds and error is logged elseware as well.
481
         }
480
         }
482
     }
481
     }
483
 
482
 

+ 5
- 0
service/RTC/RTCEvents.js 查看文件

88
      */
88
      */
89
     ENDPOINT_MESSAGE_RECEIVED: 'rtc.endpoint_message_received',
89
     ENDPOINT_MESSAGE_RECEIVED: 'rtc.endpoint_message_received',
90
 
90
 
91
+    /**
92
+     * Indicates that the remote endpoint stats have been received on data channnel.
93
+     */
94
+    ENDPOINT_STATS_RECEIVED: 'rtc.endpoint_stats_received',
95
+
91
     /**
96
     /**
92
      * Designates an event indicating that the local ICE username fragment of
97
      * Designates an event indicating that the local ICE username fragment of
93
      * the jingle session has changed.
98
      * the jingle session has changed.

Loading…
取消
儲存