Updated on 2023-11-01 GMT+08:00

Call Quality Monitoring

Function

After joining a room, the SDK triggers the callbacks related to the call quality to report the network quality of the current call and the local and remote audio and video statistics.

API Calling

Call Quality Reporting

After a user joins a room, the network-quality event is triggered when the network quality changes to report the uplink and downlink quality of the user's local network.

The sample code is as follows:
this.client.on('network-quality', (networkQualityInfo) => {
console.info(`network-quality:
uplinkNetworkQuality=${networkQualityInfo.uplinkNetworkQuality}, 
downlinkNetworkQuality = ${networkQualityInfo.downlinkNetworkQuality}`)
})

Obtaining Local Audio Stream Statistics

The getLocalAudioStats callback is used to obtain statistics on audio streams sent by a local device in the current call, including the number of bytes and packets.

The sample code is as follows:

this.client.getLocalAudioStats().then((stats) => {
 console.info(`getLocalAudioStats: ${stats}`)
})

Obtaining Remote Audio Stream Statistics

The getRemoteAudioStats callback is used to obtain the audio stream statistics of remote users in the current call, including the packet loss rate and the number of bytes and received packets.

The sample code is as follows:

this.client.getRemoteAudioStats().then((stats) => {
 console.info(`getRemoteAudioStats: ${stats}`)
})

Obtaining Local Video Stream Statistics

The getLocalVideoStats callback is used to obtain the current local video stream statistics, including the resolution and the number of frames, encoded frames, and sent bytes and packets.

The sample code is as follows:

this.client.getLocalVideoStats().then((stats) => {
 console.info(`getLocalVideoStats: ${stats}`)
})

Obtaining Remote Video Stream Statistics

The getRemoteVideoStats callback is used to obtain the current remote video stream statistics, including the resolution and the number of frames, encoded frames, and sent bytes and packets.

The sample code is as follows:

this.client.getRemoteVideoStats().then((stats) => {
 console.info(`getRemoteVideoStats: ${stats}`)
})

Checking the Client Connection Status

The getConnectionState callback is used to check the client connection status, which can be:

  • CONNECTING
  • CONNECTED
  • RECONNECTING
  • DISCONNECTED

The sample code is as follows:

console.info(`getConnectingState: ${this.client.getConnectionState()}`)

Obtaining the Network Transmission Statistics

The getTransportStats callback is used to obtain the current network transmission statistics, including the number of sent and received bytes, and the current output and input bitrates. This function is available only after the publish API is called.

The sample code is as follows:

this.client.getTransportStats().then(
 (rtt) => {
 console.info('###getTransportStats: bytesSent ' + rtt.bytesSent)
 console.info('###getTransportStats: bytesReceived ' + rtt.bytesReceived)
 console.info('###getTransportStats: sendBitrate ' + rtt.sendBitrate)
 console.info('###getTransportStats: recvBitrate ' + rtt.recvBitrate)
 console.info(`getTransportStats: ${rtt.rtt}`)
 },
 (error) => {
 console.info(`getTransportStats: ${error}`)
})