Browse Source

feat(statistics): add pre call test API

release-8443
Andrei Gavrilescu 1 year ago
parent
commit
dbb76bfb8d
No account linked to committer's email address
5 changed files with 55 additions and 2 deletions
  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 View File

35
 import { createGetUserMediaEvent } from './service/statistics/AnalyticsEvents';
35
 import { createGetUserMediaEvent } from './service/statistics/AnalyticsEvents';
36
 import *  as RTCStatsEvents from './modules/RTCStats/RTCStatsEvents';
36
 import *  as RTCStatsEvents from './modules/RTCStats/RTCStatsEvents';
37
 import { VideoType } from './service/RTC/VideoType';
37
 import { VideoType } from './service/RTC/VideoType';
38
+import runPreCallTest, { IceServer, PreCallResult } from './modules/statistics/PreCallTest';
38
 
39
 
39
 const logger = Logger.getLogger(__filename);
40
 const logger = Logger.getLogger(__filename);
40
 
41
 
477
         NetworkInfo.updateNetworkInfo({ isOnline });
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
      * Represents a hub/namespace for utility functionality which may be of
492
      * Represents a hub/namespace for utility functionality which may be of
482
      * interest to lib-jitsi-meet clients.
493
      * interest to lib-jitsi-meet clients.

+ 30
- 0
modules/statistics/PreCallTest.ts View File

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 View File

12
       "dependencies": {
12
       "dependencies": {
13
         "@jitsi/js-utils": "2.2.1",
13
         "@jitsi/js-utils": "2.2.1",
14
         "@jitsi/logger": "2.0.2",
14
         "@jitsi/logger": "2.0.2",
15
+        "@jitsi/precall-test": "1.0.6",
15
         "@jitsi/rtcstats": "9.7.0",
16
         "@jitsi/rtcstats": "9.7.0",
16
         "@jitsi/sdp-interop": "git+https://github.com/jitsi/sdp-interop#3d49eb4aa26863a3f8d32d7581cdb4321244266b",
17
         "@jitsi/sdp-interop": "git+https://github.com/jitsi/sdp-interop#3d49eb4aa26863a3f8d32d7581cdb4321244266b",
17
         "@testrtc/watchrtc-sdk": "1.38.2",
18
         "@testrtc/watchrtc-sdk": "1.38.2",
2023
       "resolved": "https://registry.npmjs.org/@jitsi/logger/-/logger-2.0.2.tgz",
2024
       "resolved": "https://registry.npmjs.org/@jitsi/logger/-/logger-2.0.2.tgz",
2024
       "integrity": "sha512-qwbpRwuwkBFgh0F5jivq/5fAm46yVoXURc5LCklEs8lAShYVangFEXKW7RLpZuZ5nQnrHrlvU8MswQNREmvahg=="
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
     "node_modules/@jitsi/rtcstats": {
2032
     "node_modules/@jitsi/rtcstats": {
2027
       "version": "9.7.0",
2033
       "version": "9.7.0",
2028
       "resolved": "https://registry.npmjs.org/@jitsi/rtcstats/-/rtcstats-9.7.0.tgz",
2034
       "resolved": "https://registry.npmjs.org/@jitsi/rtcstats/-/rtcstats-9.7.0.tgz",
8685
       "resolved": "https://registry.npmjs.org/@jitsi/logger/-/logger-2.0.2.tgz",
8691
       "resolved": "https://registry.npmjs.org/@jitsi/logger/-/logger-2.0.2.tgz",
8686
       "integrity": "sha512-qwbpRwuwkBFgh0F5jivq/5fAm46yVoXURc5LCklEs8lAShYVangFEXKW7RLpZuZ5nQnrHrlvU8MswQNREmvahg=="
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
     "@jitsi/rtcstats": {
8699
     "@jitsi/rtcstats": {
8689
       "version": "9.7.0",
8700
       "version": "9.7.0",
8690
       "resolved": "https://registry.npmjs.org/@jitsi/rtcstats/-/rtcstats-9.7.0.tgz",
8701
       "resolved": "https://registry.npmjs.org/@jitsi/rtcstats/-/rtcstats-9.7.0.tgz",

+ 1
- 0
package.json View File

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

+ 2
- 2
webpack-shared-config.js View File

80
         },
80
         },
81
         performance: {
81
         performance: {
82
             hints: minimize ? 'error' : false,
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
         plugins: [
86
         plugins: [
87
             new IgnorePlugin({ resourceRegExp: /^(@xmldom\/xmldom|ws)$/ }),
87
             new IgnorePlugin({ resourceRegExp: /^(@xmldom\/xmldom|ws)$/ }),

Loading…
Cancel
Save