Skip to content

Commit dbb76bf

Browse files
feat(statistics): add pre call test API
1 parent 8940b5c commit dbb76bf

File tree

5 files changed

+55
-2
lines changed

5 files changed

+55
-2
lines changed

JitsiMeetJS.ts

+11
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import * as E2ePingEvents from './service/e2eping/E2ePingEvents';
3535
import { createGetUserMediaEvent } from './service/statistics/AnalyticsEvents';
3636
import * as RTCStatsEvents from './modules/RTCStats/RTCStatsEvents';
3737
import { VideoType } from './service/RTC/VideoType';
38+
import runPreCallTest, { IceServer, PreCallResult } from './modules/statistics/PreCallTest';
3839

3940
const logger = Logger.getLogger(__filename);
4041

@@ -477,6 +478,16 @@ export default {
477478
NetworkInfo.updateNetworkInfo({ isOnline });
478479
},
479480

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+
480491
/**
481492
* Represents a hub/namespace for utility functionality which may be of
482493
* interest to lib-jitsi-meet clients.

modules/statistics/PreCallTest.ts

+30
Original file line numberDiff line numberDiff line change
@@ -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+
}

package-lock.json

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"dependencies": {
1919
"@jitsi/js-utils": "2.2.1",
2020
"@jitsi/logger": "2.0.2",
21+
"@jitsi/precall-test": "1.0.6",
2122
"@jitsi/rtcstats": "9.7.0",
2223
"@jitsi/sdp-interop": "git+https://github.com/jitsi/sdp-interop#3d49eb4aa26863a3f8d32d7581cdb4321244266b",
2324
"@testrtc/watchrtc-sdk": "1.38.2",

webpack-shared-config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ module.exports = (minimize, analyzeBundle) => {
8080
},
8181
performance: {
8282
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
8585
},
8686
plugins: [
8787
new IgnorePlugin({ resourceRegExp: /^(@xmldom\/xmldom|ws)$/ }),

0 commit comments

Comments
 (0)