Skip to main content
Android
iOS
macOS
Web
Windows
Electron
Flutter
React Native
Python
React JS
Unity
Unreal Engine
Unreal (Blueprint)

In-call quality monitoring

During a call, Video SDK triggers callbacks related to the video calling quality. These callbacks enable you to monitor your users' experience, troubleshoot issues, and optimize their overall experience

Understand the tech

After a user joins a channel, Video SDK triggers a series of callbacks every 2 seconds, reporting information such as uplink and downlink network quality, real-time interaction statistics, and statistics of local and remote audio and video streams.

When there is a change in the audio or video state of a user, Video SDK triggers a callback to report the latest state and the reason for the change. The following figure shows the audio transmission process between app clients:

Audio transmission process

Audio transmission process

To monitor the call quality, Agora provides the following call quality notifications:

Network quality

The network quality callback provides insight into the uplink and downlink last mile network quality for each participant in the channel. Last mile refers to the network from your device to Agora server. The Network quality scores are calculated based on factors such as sending or receiving bitrate, network packet loss rate, round-trip delay, and network jitter.

Statistics

The statistics callback, triggered every 2 seconds, reports key metrics such as call duration, the number of participants, system CPU usage, and app CPU usage.

Audio quality

Callbacks related to audio quality cover both local and remote audio streams. You monitor statistics and status changes, to gain insights into the quality of audio streams and any related reasons for status changes.

Video quality

Video quality callbacks provide information on both local and remote video streams. You receive statistics and status change notifications, that enable you to understand the quality of video streams and any related reasons for status changes.

Prerequisites

Ensure that you have implemented the SDK quickstart in your project.

Implement in-call quality monitoring

In RtcEngineEventHandler, implement the following real-time interaction quality statistics callbacks and audio or video state monitoring callbacks to understand user interaction experience:

  • onNetworkQuality: Reports uplink and downlink last mile network quality.
  • onRtcStats: Reports real-time interaction statistics.
  • onLocalAudioStats: Reports statistics for the sent audio stream.
  • onLocalAudioStateChanged: Reports local audio stream state changes.
  • onRemoteAudioStats: Reports statistics for the received remote audio stream.
  • onRemoteAudioStateChanged: Reports remote audio stream state changes.
  • onLocalVideoStats: Reports statistics for the sent video stream.
  • onLocalVideoStateChanged: Reports local video stream state changes.
  • onRemoteVideoStats: Reports statistics for the received remote video stream.
  • onRemoteVideoStateChanged: Reports remote video stream state changes.

In your app, add the following code:

@override
RtcEngineEventHandler getEventHandler() {
return RtcEngineEventHandler(
// Reports the last mile network quality of each user in the channel
onNetworkQuality: (
RtcConnection connection,
int remoteUid,
QualityType txQuality,
QualityType rxQuality,
) {
// Use downlink network quality to update the network status
networkQuality = rxQuality.index;

print(
'onNetworkQuality - Connection: $connection, RemoteUid: $remoteUid, TxQuality: $txQuality, RxQuality: $rxQuality',
);
},
// Reports the statistics of the current call
onRtcStats: (
RtcConnection connection,
RtcStats stats,
) {
counter += 1;
String msg = "";

if (counter == 5) {
msg = "${stats.userCount} user(s)";
} else if (counter == 10) {
msg = "Last mile delay: ${stats.lastmileDelay}";
counter = 0;
}
if (msg.isNotEmpty) print(msg);
},
// Occurs when the remote video stream state changes
onRemoteVideoStateChanged: (
RtcConnection connection,
int remoteUid,
RemoteVideoState state,
RemoteVideoStateReason reason,
int elapsed,
) {
print(
'onRemoteVideoStateChanged - Connection: $connection, RemoteUid: $remoteUid, State: $state, Reason: $reason, Elapsed: $elapsed',
);
},
// Reports the statistics of the video stream sent by each remote user
onRemoteVideoStats: (
RtcConnection connection,
RemoteVideoStats stats,
) {
print(
'onRemoteVideoStats - Connection: $connection, Stats: $stats',
);
},
// Reports statistics of the audio stream from the local user
onLocalAudioStats: (
RtcConnection connection,
LocalAudioStats stats,
) {
print(
'onLocalAudioStats - Connection: $connection, Stats: $stats',
);
},
// Occurs when the local audio state changes
onLocalAudioStateChanged: (
RtcConnection connection,
LocalAudioStreamState state,
LocalAudioStreamError error,
) {
print(
'onLocalAudioStateChanged - Connection: $connection, State: $state, Error: $error',
);
},
// Reports statistics of the audio stream from each remote user
onRemoteAudioStats: (
RtcConnection connection,
RemoteAudioStats stats,
) {
print(
'onRemoteAudioStats - Connection: $connection, Stats: $stats',
);
},
// Occurs when the remote audio state changes
onRemoteAudioStateChanged: (
RtcConnection connection,
int remoteUid,
RemoteAudioState state,
RemoteAudioStateReason reason,
int elapsed,
) {
print(
'onRemoteAudioStateChanged - Connection: $connection, RemoteUid: $remoteUid, State: $state, Reason: $reason, Elapsed: $elapsed',
);
},
// Reports statistics of the video stream from the local user
onLocalVideoStats: (
RtcConnection connection,
LocalVideoStats stats,
) {
print(
'onLocalVideoStats - Connection: $connection, Stats: $stats',
);
},
// Occurs when the local video state changes
onLocalVideoStateChanged: (
RtcConnection connection,
LocalVideoStreamState state,
LocalVideoStreamError error,
) {
print(
'onLocalVideoStateChanged - Connection: $connection, State: $state, Error: $error',
);
},
);
}
Copy

Reference

Network quality score

ValueEnumerationDescription
0qualityUnknownThe network quality is unknown.
1qualityExcellentThe network quality is excellent.
2qualityGoodThe network quality is good, but the bitrate is slightly lower than excellent.
3qualityPoorUsers can feel the communication is slightly impaired.
4qualityBadUsers cannot communicate smoothly.
5qualityVbadThe quality is so bad that users can barely communicate.
6qualityDownThe network is down and users cannot communicate at all.

API reference

Voice Calling