In-call quality monitoring

Updated

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

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 the AgoraRtcEngineDelegate, implement the necessary callbacks to monitor real-time interaction quality and audio or video stream status. Key callbacks include:

  • networkQuality: Reports upstream and downstream last mile network quality.
  • reportRtcStats: Provides real-time interaction statistics.
  • localAudioStats: Reports statistics on sent audio streams.
  • localAudioStateChange: Reports local audio stream state changes.
  • remoteAudioStats: Reports statistics on received remote audio streams.
  • remoteAudioStateChangedOfUid: Reports remote audio stream state changes.
  • localVideoStats: Reports statistics on sent video streams.
  • localVideoStateChangedOfState: Reports local video stream state changes.
  • remoteVideoStats: Reports statistics on received remote video streams.
  • remoteVideoStateChangedOfUid: Reports remote video stream state changes.

In your app, add the following code:

extension JoinChannelVideoMain: AgoraRtcEngineDelegate {
  // Reports upstream and downstream last mile network quality
  func rtcEngine(_ engine: AgoraRtcEngineKit, networkQuality uid: UInt, txQuality: AgoraNetworkQuality, rxQuality: AgoraNetworkQuality) {
    // Add logic to state the network quality
  }

  // Provides real-time interaction statistics
  func rtcEngine(_ engine: AgoraRtcEngineKit, reportRtcStats stats: AgoraChannelStats) {
    // Add your logic here
  }

  // Reports statistics on sent audio streams
  func rtcEngine(_ engine: AgoraRtcEngineKit, localAudioStats stats: AgoraRtcLocalAudioStats) {
    // Handle the local audio stats
  }

  // Reports local audio stream state changes
  func rtcEngine(_ engine: AgoraRtcEngineKit, localAudioStateChange state: AgoraAudioLocalState, error: AgoraAudioLocalError) {
    // Handle local audio state change
  }

  // Reports statistics on received remote audio streams
  func rtcEngine(_ engine: AgoraRtcEngineKit, remoteAudioStats stats: AgoraRtcRemoteAudioStats) {
    // Handle the remote audio stats
  }

  // Reports remote audio stream state changes
  func rtcEngine(_ engine: AgoraRtcEngineKit, remoteAudioStateChangedOfUid uid: UInt, state: AgoraAudioRemoteState, reason: AgoraAudioRemoteStateReason, elapsed: Int) {
    // Handle remote audio state change
  }

  // Reports statistics on sent video streams
  func rtcEngine(_ engine: AgoraRtcEngineKit, localVideoStats stats: AgoraRtcLocalVideoStats) {
    // Handle video stream statistics
  }

  // Reports local video stream state changes
  func rtcEngine(_ engine: AgoraRtcEngineKit, localVideoStateChangedOfState state: AgoraLocalVideoStreamState, error: AgoraLocalVideoStreamError) {
    // Handle local video state change
  }

  // Reports statistics on received remote video streams
  func rtcEngine(_ engine: AgoraRtcEngineKit, remoteVideoStats stats: AgoraRtcRemoteVideoStats) {
    // Handle the remote video stream's statistics
  }

  // Reports remote video stream state changes
  func rtcEngine(_ engine: AgoraRtcEngineKit, remoteVideoStateChangedOfUid uid: UInt, state: AgoraRemoteVideoState, reason: AgoraRemoteVideoStateReason, elapsed: Int) {
    // Handle remote video state change
  }
}

Reference

Network quality score

ValueEnumerationDescription
0AgoraNetworkQualityUnknownNetwork quality is unknown.
1AgoraNetworkQualityExcellentThe network quality is excellent.
2AgoraNetworkQualityGoodThe network quality is good, but the bitrate may be slightly lower than excellent.
3AgoraNetworkQualityPoorThe network quality is average, and users may experience a slight decrease in call quality.
4AgoraNetworkQualityBadThe network quality is poor, and users are unable to make smooth calls.
5AgoraNetworkQualityVBadThe network quality is extremely poor, making it almost impossible for users to make calls.
6AgoraNetworkQualityDownThe network connection is interrupted, and the user is completely unable to make a call.
8AgoraNetworkQualityDetectingLast-mile detection tests are underway.

API reference