瀏覽代碼

feat: report avg RTT for P2P

tags/v0.0.2
paweldomas 8 年之前
父節點
當前提交
cc6b5c8f04
共有 3 個檔案被更改,包括 46 行新增3 行删除
  1. 17
    0
      modules/RTC/RTCBrowserType.js
  2. 23
    0
      modules/statistics/AvgRTPStatsReporter.js
  3. 6
    3
      modules/statistics/RTPStatsCollector.js

+ 17
- 0
modules/RTC/RTCBrowserType.js 查看文件

218
         return !RTCBrowserType.isFirefox();
218
         return !RTCBrowserType.isFirefox();
219
     },
219
     },
220
 
220
 
221
+    /**
222
+     * Checks if the current browser reports round trip time statistics for
223
+     * the ICE candidate pair.
224
+     * @return {boolean}
225
+     */
226
+    supportsRTTStatistics() {
227
+        // Firefox does not seem to report RTT for ICE candidate pair:
228
+        // eslint-disable-next-line max-len
229
+        // https://www.w3.org/TR/webrtc-stats/#dom-rtcicecandidatepairstats-currentroundtriptime
230
+        // It does report mozRTT for RTP streams, but at the time of this
231
+        // writing it's value does not make sense most of the time
232
+        // (is reported as 1):
233
+        // https://bugzilla.mozilla.org/show_bug.cgi?id=1241066
234
+        // For Chrome and others we rely on 'googRtt'.
235
+        return !RTCBrowserType.isFirefox();
236
+    },
237
+
221
     /**
238
     /**
222
      * Whether jitsi-meet supports simulcast on the current browser.
239
      * Whether jitsi-meet supports simulcast on the current browser.
223
      * @returns {boolean}
240
      * @returns {boolean}

+ 23
- 0
modules/statistics/AvgRTPStatsReporter.js 查看文件

184
          */
184
          */
185
         this._avgRemoteFPS = new AverageStatReport('stat.avg.framerate.remote');
185
         this._avgRemoteFPS = new AverageStatReport('stat.avg.framerate.remote');
186
 
186
 
187
+        /**
188
+         * Average round trip time reported by the ICE candidate pair.
189
+         * FIXME currently reported only for P2P
190
+         * @type {AverageStatReport}
191
+         * @private
192
+         */
193
+        this._avgRTT = new AverageStatReport('stat.avg.rtt');
194
+
187
         /**
195
         /**
188
          * Average FPS for local video
196
          * Average FPS for local video
189
          * @type {AverageStatReport}
197
          * @type {AverageStatReport}
281
         this._avgPacketLossTotal.addNext(packetLoss.total);
289
         this._avgPacketLossTotal.addNext(packetLoss.total);
282
         this._avgCQ.addNext(data.connectionQuality);
290
         this._avgCQ.addNext(data.connectionQuality);
283
 
291
 
292
+        if (RTCBrowserType.supportsRTTStatistics()) {
293
+            // FIXME implement JVB end-to-end RTT
294
+            if (isP2P && data.transport && data.transport.length) {
295
+                this._avgRTT.addNext(data.transport[0].rtt);
296
+            } else {
297
+                this._avgRTT.reset();
298
+            }
299
+        }
300
+
284
         if (frameRate) {
301
         if (frameRate) {
285
             this._avgRemoteFPS.addNext(
302
             this._avgRemoteFPS.addNext(
286
                 this._calculateAvgVideoFps(frameRate, false /* remote */));
303
                 this._calculateAvgVideoFps(frameRate, false /* remote */));
304
             this._avgLocalFPS.report(isP2P);
321
             this._avgLocalFPS.report(isP2P);
305
             this._avgCQ.report(isP2P);
322
             this._avgCQ.report(isP2P);
306
 
323
 
324
+            // FIXME implement JVB end-to-end RTT
325
+            if (isP2P && RTCBrowserType.supportsRTTStatistics()) {
326
+                this._avgRTT.report(isP2P);
327
+            }
328
+
307
             this._resetAvgStats();
329
             this._resetAvgStats();
308
         }
330
         }
309
     }
331
     }
358
         this._avgRemoteFPS.reset();
380
         this._avgRemoteFPS.reset();
359
         this._avgLocalFPS.reset();
381
         this._avgLocalFPS.reset();
360
         this._avgCQ.reset();
382
         this._avgCQ.reset();
383
+        this._avgRTT.reset();
361
         this._sampleIdx = 0;
384
         this._sampleIdx = 0;
362
     }
385
     }
363
 
386
 

+ 6
- 3
modules/statistics/RTPStatsCollector.js 查看文件

44
     'googFrameRateReceived': 'googFrameRateReceived',
44
     'googFrameRateReceived': 'googFrameRateReceived',
45
     'googFrameRateSent': 'googFrameRateSent',
45
     'googFrameRateSent': 'googFrameRateSent',
46
     'audioInputLevel': 'audioInputLevel',
46
     'audioInputLevel': 'audioInputLevel',
47
-    'audioOutputLevel': 'audioOutputLevel'
47
+    'audioOutputLevel': 'audioOutputLevel',
48
+    'currentRoundTripTime': 'googRtt'
48
 };
49
 };
49
 KEYS_BY_BROWSER_TYPE[RTCBrowserType.RTC_BROWSER_OPERA]
50
 KEYS_BY_BROWSER_TYPE[RTCBrowserType.RTC_BROWSER_OPERA]
50
     = KEYS_BY_BROWSER_TYPE[RTCBrowserType.RTC_BROWSER_CHROME];
51
     = KEYS_BY_BROWSER_TYPE[RTCBrowserType.RTC_BROWSER_CHROME];
457
         } catch (e) { /* not supported*/ }
458
         } catch (e) { /* not supported*/ }
458
 
459
 
459
         if (now.type === 'googCandidatePair') {
460
         if (now.type === 'googCandidatePair') {
460
-            let active, ip, localip, type;
461
+            let active, ip, localip, rtt, type;
461
 
462
 
462
             try {
463
             try {
463
                 ip = getStatValue(now, 'remoteAddress');
464
                 ip = getStatValue(now, 'remoteAddress');
464
                 type = getStatValue(now, 'transportType');
465
                 type = getStatValue(now, 'transportType');
465
                 localip = getStatValue(now, 'localAddress');
466
                 localip = getStatValue(now, 'localAddress');
466
                 active = getStatValue(now, 'activeConnection');
467
                 active = getStatValue(now, 'activeConnection');
468
+                rtt = getNonNegativeStat(now, 'currentRoundTripTime');
467
             } catch (e) { /* not supported*/ }
469
             } catch (e) { /* not supported*/ }
468
             if (!ip || !type || !localip || active !== 'true') {
470
             if (!ip || !type || !localip || active !== 'true') {
469
                 continue;
471
                 continue;
481
                     ip,
483
                     ip,
482
                     type,
484
                     type,
483
                     localip,
485
                     localip,
484
-                    p2p: this.peerconnection.isP2P
486
+                    p2p: this.peerconnection.isP2P,
487
+                    rtt
485
                 });
488
                 });
486
             }
489
             }
487
             continue;
490
             continue;

Loading…
取消
儲存