Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

PreCallTest.ts 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import PreCallTest from '@jitsi/precall-test';
  2. export interface IPreCallResult {
  3. // Maximum bandwidth reached in kbps (kilo bits per second).
  4. fractionalLoss: number;
  5. // Round trip time in milliseconds.
  6. jitter: number;
  7. // Variation in packet arrival times during the transmission of media.
  8. mediaConnectivity: boolean;
  9. // Packet loss percentage over all the test traffic.
  10. rtt: number;
  11. throughput: number; // Whether the data channel was able to send data or not.
  12. }
  13. // Same interface as a PeerConnection configuration object.
  14. export interface IIceServer {
  15. credential?: string;
  16. urls: Array<string> | string;
  17. username?: string;
  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<IIceServer>} - The ICE servers to use for the test, these are passes to the PeerConnection constructor.
  26. * @returns {Promise<IPreCallResult | any>} - A Promise that resolves with the test results or rejects with an error.
  27. */
  28. export default async function runPreCallTest(iceServers: Array<IIceServer>): Promise<IPreCallResult | string> {
  29. const test = new PreCallTest();
  30. return await test.start(iceServers);
  31. }