您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

PreCallTest.ts 1.4KB

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