The Agora Web SDK provides APIs for you to get the audio and video statistics reflecting the overall quality of a call. The statistics include:
Before proceeding, ensure that you have read the quickstart guides and implemented basic real-time audio and video functions in your project.
Last mile refers to the connection between your local device and the Agora edge servers.
After the local user joins the channel, the SDK triggers the AgoraRTCClient.on("network-quality") callback once every two seconds and provides the uplink and downlink last-mile network conditions of the local user.
You can also call AgoraRTCClient.getRemoteNetworkQuality to get the network quality of all the remote users to whom the local user subscribes.
Quality Rating Table
Rating | Description |
---|---|
0 | The network quality is unknown. |
1 | The network quality is excellent. |
2 | The network quality is good, but the bitrate may be slightly lower than optimal. |
3 | Users experience slightly impaired communication. |
4 | Users cannot communicate smoothly. |
5 | The network is so poor that users can barely communicate. |
6 | The network is down and users cannot communicate at all. |
client.on("network-quality", (stats) => {
console.log("downlinkNetworkQuality", stats.downlinkNetworkQuality);
console.log("uplinkNetworkQuality", stats.uplinkNetworkQuality);
});
const remoteNetworkQuality = client.getRemoteNetworkQuality();
Call AgoraRTCClient.getRTCStats to get the statistics of the call. For the statistics description, see AgoraRTCStats.
const clientStats = client.getRTCStats();
Call AgoraRTCClient.getLocalAudioStats to get the statistics of a local audio track, and call AgoraRTCClient.getLocalVideoStats to get the statistics of a local video track. For the statistics description, see LocalAudioTrackStats and LocalVideoTrackStats.
const localStats = {
video: client.getLocalVideoStats(),
audio: client.getLocalAudioStats()
};
Call AgoraRTCClient.getRemoteAudioStats to get the statistics of a remote audio track, and call AgoraRTCClient.getRemoteVideoStats to get the statistics of a remote video track. For the statistics description, see RemoteAudioTrackStats and RemoteVideoTrackStats. See the following picture for the description of the end2EndDelay
, receiveDelay
, and transportDelay
properties. For the description of other properties, see RemoteAudioTrackStats and RemoteVideoTrackStats.
Property | Description |
---|---|
end2EndDelay |
The delay (ms) between a remote client sampling the audio or video and the local client playing the audio or video. Stages 1 + 2 + 3 + 4 + 5 + 6 in the picture above. |
receiveDelay |
The delay (ms) between a remote client sending the audio or video and the local client playing the audio or video. Stages 2 + 3 + 4 + 5 + 6 in the picture above. |
transportDelay |
The delay (ms) between a remote client sending the audio or video and the local client receiving the audio or video. Stages 2 + 3 + 4 in the picture above. |
const remoteTracksStats = {
video: client.getRemoteVideoStats()[uid],
audio: client.getRemoteAudioStats()[uid]
};
The SDK reports exception events in the channel by triggering the exception
callback. Exceptions are not errors, but usually indicate quality issues. This callback also reports recovery from an exception.
code
: The event code.msg
: The event message.uid
: The uid of the user who experiences the exception or recovery event.client.on("exception", function(evt) {
console.log(evt.code, evt.msg, evt.uid);
})
Each exception event has a corresponding recovery event. See the table below for details.
All the above methods must be called after joining the channel.