Skip to main content

You are viewing Agora Docs forBetaproducts and features. Switch to Docs

Android
iOS
macOS
Web
Windows
Electron
Flutter
React Native
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:

Basic Agora workflow

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 IRtcEngineEventHandler, 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:


_67
// Example implementation in Java
_67
private final IRtcEngineEventHandler iRtcEngineEventHandler = new IRtcEngineEventHandler() {
_67
// Implement the onNetworkQuality callback
_67
@Override
_67
public void onNetworkQuality(int uid, int txQuality, int rxQuality) {
_67
Log.i(TAG, "onNetworkQuality->" + "UID: " + uid + ", TX Quality: " + txQuality + ", RX Quality: " + rxQuality);
_67
}
_67
_67
// Implement the onLocalAudioStateChanged callback
_67
@Override
_67
public void onLocalAudioStateChanged(int state, int error) {
_67
super.onLocalAudioStateChanged(state, error);
_67
Log.i(TAG, "onLocalAudioStateChanged->" + "State: " + state + ", Error: " + error);
_67
}
_67
_67
// Implement the onRemoteAudioStateChanged callback
_67
@Override
_67
public void onRemoteAudioStateChanged(int uid, int state, int reason, int elapsed) {
_67
super.onRemoteAudioStateChanged(uid, state, reason, elapsed);
_67
Log.i(TAG, "onRemoteAudioStateChanged->" + "UID: " + uid + ", State: " + state + ", Reason: " + reason + ", Elapsed: " + elapsed);
_67
}
_67
_67
// Implement the onLocalVideoStateChanged callback
_67
@Override
_67
public void onLocalVideoStateChanged(Constants.VideoSourceType source, int state, int error) {
_67
super.onLocalVideoStateChanged(source, state, error);
_67
Log.i(TAG, "onLocalVideoStateChanged->" + "State: " + state + ", Error: " + error);
_67
}
_67
_67
// Implement the onRemoteVideoStateChanged callback
_67
@Override
_67
public void onRemoteVideoStateChanged(int uid, int remoteVideoState, int reason, int elapsed) {
_67
super.onRemoteVideoStateChanged(uid, remoteVideoState, reason, elapsed);
_67
Log.i(TAG, "onRemoteVideoStateChanged->" + "UID: " + uid + ", State: " + remoteVideoState + ", Reason: " + reason + ", Elapsed: " + elapsed);
_67
}
_67
_67
// Implement the onRemoteAudioStats callback
_67
@Override
_67
public void onRemoteAudioStats(RemoteAudioStats remoteAudioStats) {
_67
Log.i(TAG, "onRemoteAudioStats->" + "Received bitrate: " + remoteAudioStats.receivedBitrate);
_67
}
_67
_67
// Implement the onLocalAudioStats callback
_67
@Override
_67
public void onLocalAudioStats(LocalAudioStats localAudioStats) {
_67
Log.i(TAG, "onLocalAudioStats->" + "Network transport delay: " + localAudioStats.networkTransportDelay);
_67
}
_67
_67
// Implement the onRemoteVideoStats callback
_67
@Override
_67
public void onRemoteVideoStats(RemoteVideoStats remoteVideoStats) {
_67
Log.i(TAG, "onRemoteVideoStats->" + "Received bitrate: " + remoteVideoStats.receivedBitrate);
_67
}
_67
_67
// Implement the onLocalVideoStats callback
_67
@Override
_67
public void onLocalVideoStats(LocalVideoStats localVideoStats) {
_67
Log.i(TAG, "onLocalVideoStats->" + "Sent frame rate: " + localVideoStats.sentFrameRate);
_67
// Log other specific information as needed
_67
}
_67
_67
// Implement the onRtcStats callback
_67
@Override
_67
public void onRtcStats(RtcStats rtcStats) {
_67
Log.i(TAG, "onRtcStats->" + "User count: " + rtcStats.userCount + ", Packet loss rate: " + rtcStats.rxPacketLossRate);
_67
}
_67
};

Reference

Network quality score

ValueEnumerationDescription
0QUALITY_UNKNOWNThe quality is unknown or the user is not receiving a stream.
1QUALITY_EXCELLENTThe quality is excellent.
2QUALITY_GOODThe network quality is good, but the bitrate is slightly lower than excellent.
3QUALITY_POORUsers can feel the communication is slightly impaired.
4QUALITY_BADUsers cannot communicate smoothly.
5QUALITY_VBADThe quality is so bad that users can barely communicate.
6QUALITY_DOWNThe network is down, and users cannot communicate at all.

API reference

Video Calling