Skip to content

Commit

Permalink
feat(statistics): add pre call test API
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-gavrilescu authored Oct 3, 2024
1 parent 8940b5c commit dbb76bf
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 2 deletions.
11 changes: 11 additions & 0 deletions JitsiMeetJS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import * as E2ePingEvents from './service/e2eping/E2ePingEvents';
import { createGetUserMediaEvent } from './service/statistics/AnalyticsEvents';
import * as RTCStatsEvents from './modules/RTCStats/RTCStatsEvents';
import { VideoType } from './service/RTC/VideoType';
import runPreCallTest, { IceServer, PreCallResult } from './modules/statistics/PreCallTest';

const logger = Logger.getLogger(__filename);

Expand Down Expand Up @@ -477,6 +478,16 @@ export default {
NetworkInfo.updateNetworkInfo({ isOnline });
},

/**
* Run a pre-call test to check the network conditions.
*
* @param {IceServer} iceServers - The ICE servers to use for the test,
* @returns {Promise<PreCallResult | any>} - A Promise that resolves with the test results or rejects with an error message.
*/
runPreCallTest(iceServers) {
return runPreCallTest(iceServers);
},

/**
* Represents a hub/namespace for utility functionality which may be of
* interest to lib-jitsi-meet clients.
Expand Down
30 changes: 30 additions & 0 deletions modules/statistics/PreCallTest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import PreCallTest from '@jitsi/precall-test';


export interface PreCallResult {
throughput: number; // Maximum bandwidth reached in kbps (kilo bits per second).
fractionalLoss: number; // Packet loss percentage over all the test traffic.
rtt: number; // Round trip time in milliseconds.
jitter: number; // Variation in packet arrival times during the transmission of media.
mediaConnectivity: boolean; // Whether the data channel was able to send data or not.
}

// Same interface as a PeerConnection configuration object.
export interface IceServer {
urls: Array<string> | string;
username?: string;
credential?: string;
}

/**
* Run a pre-call test to check the network conditions. It uses a TURN server to establish
* a connection between two PeerConnections using the server as a relay. Afterwards it sends
* some test traffic through a data channel to measure the network conditions, these are
* recorded and returned through a Promise.
*
* @param {Array<IceServer>} - The ICE servers to use for the test, these are passes to the PeerConnection constructor.
* @returns {Promise<PreCallResult | any>} - A Promise that resolves with the test results or rejects with an error.
*/
export default async function runPreCallTest(iceServers: Array<IceServer>): Promise<PreCallResult | string> {
return new PreCallTest().start(iceServers);
}
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"dependencies": {
"@jitsi/js-utils": "2.2.1",
"@jitsi/logger": "2.0.2",
"@jitsi/precall-test": "1.0.6",
"@jitsi/rtcstats": "9.7.0",
"@jitsi/sdp-interop": "git+https://github.com/jitsi/sdp-interop#3d49eb4aa26863a3f8d32d7581cdb4321244266b",
"@testrtc/watchrtc-sdk": "1.38.2",
Expand Down
4 changes: 2 additions & 2 deletions webpack-shared-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ module.exports = (minimize, analyzeBundle) => {
},
performance: {
hints: minimize ? 'error' : false,
maxAssetSize: 1.08 * 1024 * 1024,
maxEntrypointSize: 1.08 * 1024 * 1024
maxAssetSize: 1.25 * 1024 * 1024,
maxEntrypointSize: 1.25 * 1024 * 1024
},
plugins: [
new IgnorePlugin({ resourceRegExp: /^(@xmldom\/xmldom|ws)$/ }),
Expand Down

0 comments on commit dbb76bf

Please sign in to comment.