Sfoglia il codice sorgente

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 anni fa
parent
commit
13cfea660e

+ 9
- 0
JitsiConference.js Vedi File

@@ -2598,6 +2598,15 @@ JitsiConference.prototype.sendEndpointMessage = function(to, payload) {
2598 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 2611
  * Sends a broadcast message via the data channel.
2603 2612
  * @param payload {object} the payload of the message.

+ 11
- 0
JitsiConferenceEventManager.js Vedi File

@@ -556,6 +556,17 @@ JitsiConferenceEventManager.prototype.setupRTCListeners = function() {
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 570
     rtc.addListener(RTCEvents.LOCAL_UFRAG_CHANGED,
560 571
         (tpc, ufrag) => {
561 572
             if (!tpc.isP2P) {

+ 5
- 0
JitsiConferenceEvents.js Vedi File

@@ -97,6 +97,11 @@ export const DTMF_SUPPORT_CHANGED = 'conference.dtmfSupportChanged';
97 97
  */
98 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 106
  * NOTE This is lib-jitsi-meet internal event and can be removed at any time !
102 107
  *

+ 18
- 0
modules/RTC/BridgeChannel.js Vedi File

@@ -174,6 +174,19 @@ export default class BridgeChannel {
174 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 191
      * Sends message via the channel.
179 192
      * @param {string} to The id of the endpoint that should receive the
@@ -310,6 +323,11 @@ export default class BridgeChannel {
310 323
 
311 324
                 break;
312 325
             }
326
+            case 'EndpointStats': {
327
+                emitter.emit(RTCEvents.ENDPOINT_STATS_RECEIVED, obj.from, obj);
328
+
329
+                break;
330
+            }
313 331
             case 'LastNEndpointsChangeEvent': {
314 332
                 // The new/latest list of last-n endpoint IDs (i.e. endpoints for which the bridge is sending video).
315 333
                 const lastNEndpoints = obj.lastNEndpoints;

+ 11
- 2
modules/RTC/RTC.js Vedi File

@@ -845,8 +845,6 @@ export default class RTC extends Listenable {
845 845
         track.setAudioLevel(audioLevel, tpc);
846 846
     }
847 847
 
848
-    /* eslint-enable max-params */
849
-
850 848
     /**
851 849
      * Sends message via the bridge channel.
852 850
      * @param {string} to The id of the endpoint that should receive the
@@ -863,6 +861,17 @@ export default class RTC extends Listenable {
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 876
      * Selects a new value for "lastN". The requested amount of videos are going
868 877
      * to be delivered after the value is in effect. Set to -1 for unlimited or

+ 12
- 13
modules/connectivity/ConnectionQuality.js Vedi File

@@ -239,6 +239,8 @@ export default class ConnectionQuality {
239 239
 
240 240
         // Listen to DataChannel message from other participants in the
241 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 244
         conference.on(
243 245
             ConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
244 246
             (participant, payload) => {
@@ -248,6 +250,12 @@ export default class ConnectionQuality {
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 259
         // Listen to local statistics events originating from the RTC module
252 260
         // and update the _localStats field.
253 261
         // Oh, and by the way, the resolutions of all remote participants are
@@ -465,19 +473,10 @@ export default class ConnectionQuality {
465 473
         };
466 474
 
467 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 Vedi File

@@ -88,6 +88,11 @@ const RTCEvents = {
88 88
      */
89 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 97
      * Designates an event indicating that the local ICE username fragment of
93 98
      * the jingle session has changed.

Loading…
Annulla
Salva