Quellcode durchsuchen

feat(statistics): add pre call test API

release-8443
Andrei Gavrilescu vor 1 Jahr
Ursprung
Commit
dbb76bfb8d
Es ist kein Account mit der E-Mail-Adresse des Committers verbunden
5 geänderte Dateien mit 55 neuen und 2 gelöschten Zeilen
  1. 11
    0
      JitsiMeetJS.ts
  2. 30
    0
      modules/statistics/PreCallTest.ts
  3. 11
    0
      package-lock.json
  4. 1
    0
      package.json
  5. 2
    2
      webpack-shared-config.js

+ 11
- 0
JitsiMeetJS.ts Datei anzeigen

@@ -35,6 +35,7 @@ import * as E2ePingEvents from './service/e2eping/E2ePingEvents';
35 35
 import { createGetUserMediaEvent } from './service/statistics/AnalyticsEvents';
36 36
 import *  as RTCStatsEvents from './modules/RTCStats/RTCStatsEvents';
37 37
 import { VideoType } from './service/RTC/VideoType';
38
+import runPreCallTest, { IceServer, PreCallResult } from './modules/statistics/PreCallTest';
38 39
 
39 40
 const logger = Logger.getLogger(__filename);
40 41
 
@@ -477,6 +478,16 @@ export default {
477 478
         NetworkInfo.updateNetworkInfo({ isOnline });
478 479
     },
479 480
 
481
+    /**
482
+     * Run a pre-call test to check the network conditions.
483
+     * 
484
+     * @param {IceServer} iceServers  - The ICE servers to use for the test,
485
+     * @returns {Promise<PreCallResult | any>} - A Promise that resolves with the test results or rejects with an error message.
486
+     */
487
+    runPreCallTest(iceServers) {
488
+        return runPreCallTest(iceServers);
489
+    },
490
+
480 491
     /**
481 492
      * Represents a hub/namespace for utility functionality which may be of
482 493
      * interest to lib-jitsi-meet clients.

+ 30
- 0
modules/statistics/PreCallTest.ts Datei anzeigen

@@ -0,0 +1,30 @@
1
+import PreCallTest from '@jitsi/precall-test';
2
+
3
+
4
+export interface PreCallResult {
5
+    throughput: number; // Maximum bandwidth reached in kbps  (kilo bits per second).
6
+    fractionalLoss: number; // Packet loss percentage over all the test traffic.
7
+    rtt: number;  // Round trip time in milliseconds.
8
+    jitter: number;  // Variation in packet arrival times during the transmission of media.
9
+    mediaConnectivity: boolean; // Whether the data channel was able to send data or not.
10
+}
11
+
12
+// Same interface as a PeerConnection configuration object.
13
+export interface IceServer {
14
+    urls: Array<string> | string;
15
+    username?: string;
16
+    credential?: string;
17
+}
18
+
19
+/**
20
+ * Run a pre-call test to check the network conditions. It uses a TURN server to establish
21
+ * a connection between two PeerConnections using the server as a relay. Afterwards it sends 
22
+ * some test traffic through a data channel to measure the network conditions, these are 
23
+ * recorded and returned through a Promise.
24
+ * 
25
+ * @param {Array<IceServer>} - The ICE servers to use for the test, these are passes to the PeerConnection constructor. 
26
+ * @returns {Promise<PreCallResult | any>} - A Promise that resolves with the test results or rejects with an error.
27
+ */
28
+export default async function runPreCallTest(iceServers: Array<IceServer>): Promise<PreCallResult | string> {
29
+    return new PreCallTest().start(iceServers);
30
+}

+ 11
- 0
package-lock.json Datei anzeigen

@@ -12,6 +12,7 @@
12 12
       "dependencies": {
13 13
         "@jitsi/js-utils": "2.2.1",
14 14
         "@jitsi/logger": "2.0.2",
15
+        "@jitsi/precall-test": "1.0.6",
15 16
         "@jitsi/rtcstats": "9.7.0",
16 17
         "@jitsi/sdp-interop": "git+https://github.com/jitsi/sdp-interop#3d49eb4aa26863a3f8d32d7581cdb4321244266b",
17 18
         "@testrtc/watchrtc-sdk": "1.38.2",
@@ -2023,6 +2024,11 @@
2023 2024
       "resolved": "https://registry.npmjs.org/@jitsi/logger/-/logger-2.0.2.tgz",
2024 2025
       "integrity": "sha512-qwbpRwuwkBFgh0F5jivq/5fAm46yVoXURc5LCklEs8lAShYVangFEXKW7RLpZuZ5nQnrHrlvU8MswQNREmvahg=="
2025 2026
     },
2027
+    "node_modules/@jitsi/precall-test": {
2028
+      "version": "1.0.6",
2029
+      "resolved": "https://registry.npmjs.org/@jitsi/precall-test/-/precall-test-1.0.6.tgz",
2030
+      "integrity": "sha512-L/gnRjnFxpQqvfILXeFoVTHEtwL01zoSKAIqMVxMmaD0ahozML8uztlxRPlYSbKrT31j3Cm1ss9KdSNeO3f9FQ=="
2031
+    },
2026 2032
     "node_modules/@jitsi/rtcstats": {
2027 2033
       "version": "9.7.0",
2028 2034
       "resolved": "https://registry.npmjs.org/@jitsi/rtcstats/-/rtcstats-9.7.0.tgz",
@@ -8685,6 +8691,11 @@
8685 8691
       "resolved": "https://registry.npmjs.org/@jitsi/logger/-/logger-2.0.2.tgz",
8686 8692
       "integrity": "sha512-qwbpRwuwkBFgh0F5jivq/5fAm46yVoXURc5LCklEs8lAShYVangFEXKW7RLpZuZ5nQnrHrlvU8MswQNREmvahg=="
8687 8693
     },
8694
+    "@jitsi/precall-test": {
8695
+      "version": "1.0.6",
8696
+      "resolved": "https://registry.npmjs.org/@jitsi/precall-test/-/precall-test-1.0.6.tgz",
8697
+      "integrity": "sha512-L/gnRjnFxpQqvfILXeFoVTHEtwL01zoSKAIqMVxMmaD0ahozML8uztlxRPlYSbKrT31j3Cm1ss9KdSNeO3f9FQ=="
8698
+    },
8688 8699
     "@jitsi/rtcstats": {
8689 8700
       "version": "9.7.0",
8690 8701
       "resolved": "https://registry.npmjs.org/@jitsi/rtcstats/-/rtcstats-9.7.0.tgz",

+ 1
- 0
package.json Datei anzeigen

@@ -18,6 +18,7 @@
18 18
   "dependencies": {
19 19
     "@jitsi/js-utils": "2.2.1",
20 20
     "@jitsi/logger": "2.0.2",
21
+    "@jitsi/precall-test": "1.0.6",
21 22
     "@jitsi/rtcstats": "9.7.0",
22 23
     "@jitsi/sdp-interop": "git+https://github.com/jitsi/sdp-interop#3d49eb4aa26863a3f8d32d7581cdb4321244266b",
23 24
     "@testrtc/watchrtc-sdk": "1.38.2",

+ 2
- 2
webpack-shared-config.js Datei anzeigen

@@ -80,8 +80,8 @@ module.exports = (minimize, analyzeBundle) => {
80 80
         },
81 81
         performance: {
82 82
             hints: minimize ? 'error' : false,
83
-            maxAssetSize: 1.08 * 1024 * 1024,
84
-            maxEntrypointSize: 1.08 * 1024 * 1024
83
+            maxAssetSize: 1.25 * 1024 * 1024,
84
+            maxEntrypointSize: 1.25 * 1024 * 1024
85 85
         },
86 86
         plugins: [
87 87
             new IgnorePlugin({ resourceRegExp: /^(@xmldom\/xmldom|ws)$/ }),

Laden…
Abbrechen
Speichern