testPeerToPeerCallQuality({ videoTrack: MediaStreamTrack, duration?: number }): Promise;


The testPeerToPeerCallQuality() method assesses the quality of a WebRTC connection using a given video track. Connecting to Daily's TURN servers, it captures a number of metrics that are used to indicate the quality of a user's connection. The longer the test runs, the more accurate the results will be. By default, the test runs for 15 seconds. You can customize how long it runs, up to a maximum of 30 seconds. This method is particularly useful during precall checks when a room has not yet been joined. For in-depth network stats during a call, refer to getNetworkStats().

It returns a Promise that resolves to an object providing information about the call quality test results:

  • result: A string indicating the call quality. Can be "good", "bad", "warning", "aborted" or "failed".
  • data: An object containing the data gathered during the trip. This data is used to determine the result.
  • secondsElapsed: A number indicating how long the test has run for.

Also see: stopTestPeerToPeerCallQuality(). This method can be used to interrupt the test.

Note that this check is not indicative of whether a user is "allowed" to join a call based on their result. It's up to you as a developer to decide what to do when a user gets a "bad" or "warning" result.

Test results in detail

An example test result looks like this:

  • maxRoundTripTime (ms) is calculated based on currentRoundTripTime from the candidate-pair report.
  • avgRoundTripTime (ms) is calculated based on currentRoundTripTime from the candidate-pair report.
  • avgRecvPacketLoss(%) is calculated based on packetsLost and packetsReceived from the inbound-rtp video report.
  • avgAvailableOutgoingBitrate (bps) is calculated based on availableOutgoingBitrate from the candidate-pair report. This value is not available on Firefox.
  • avgSendBitsPerSecond (bps) is calculated based on bytesSent from the candidate-pair report.
  • avgRecvBitsPerSecond (bps) is calculated based on bytesReceived from the candidate-pair report.

Meaning of result:

The result is returned when any one of these conditions is met:

  • "good":
    • avgRecvPacketLoss < 5%
    • avgRoundTripTime < 300ms
    • avgRecvBitsPerSecond >= 1,100kbps
  • "warning":
    • avgRecvPacketLoss >= 5% and < 10%
    • avgRoundTripTime >= 300ms and < 600ms
    • avgRecvBitsPerSecond < 1,100kbps and >= 700kbps
  • "bad":
    • avgRecvPacketLoss >= 10%
    • avgRoundTripTime >= 600ms
    • avgRecvBitsPerSecond < 700kbps
  • "failed": a connection to Daily's TURN servers could not be made. Our suggestion is to refer users to our network debugger for a more in-depth test.
  • "aborted": test aborted before data gathering could start. See stopTestPeerToPeerCallQuality().

Example usage of testPeerToPeerCallQuality():

Related methods