Skip to main content

You are looking at Voice Calling v3.x Docs. The newest version is  Voice Calling 4.x

Android
iOS
macOS
Windows C++
Windows C#
Unity
Flutter
React Native
Electron
Cocos Creator
Cocos2d-x

Report In-call Statistics

Introduction

After joining the channel, the SDK triggers the following callbacks related to the call quality once every two seconds. You can see the last mile network quality, local statistics, audio quality, and video quality of the current call.

Ensure that you implement a video call or interactive video streaming in your project. For details, see Start a Call or Start Interactive Live Streaming.

Sample project

Agora provides an open-source sample project that implements the in-call statistics monitoring function on GitHub. You can download the sample project to try it out or refer to the source code.

Network quality report

The onNetworkQuality callback reports the uplink and downlink last mile network quality of each user/host in the current call, see Quality Rating for details. Last mile refers to the network from your device to Agora’s edge server. The uplink last mile quality rating is based on the actual transmission bitrate, the uplink network packet loss rate, the average round-trip delay, and the uplink network jitter; while the downlink last mile quality rating is based on the downlink network packet loss rate, the average round-trip delay, and the downlink network jitter.

  • In the COMMUNICATION profile, you receive network quality reports of all the users (including yours) in the channel once every two seconds.
  • In the LIVE_BROADCASTING profile, if you are the host, you receive network quality reports of all hosts (including yours) in the channel once every two seconds; if you are the audience, you receive the report of all hosts and yourself once every two seconds.
  • The higher the ratio of the actual transmission bitrate to the target transmission bitrate, the better the call quality and the higher the network quality.
  • The average round-trip delay refers to the average value of multiple round-trip delays in the reported interval.

Statistics report

The onRtcStats callback reports call statistics. You can see the duration, the number of users in the channel, the system CPU usage, the application CPU usage, and the following parameters of the current call.

ParameterDescriptionComment
txBytes/rxBytesThe total number of bytes sent/received.The number of bytes accumulated since joining the channel.
txAudioBytes/rxAudioByteThe total number of audio bytes sent/received.The number of bytes accumulated since joining the channel.
txVideoBytes/rxVideoBytesThe total number of video bytes sent/received.The number of bytes accumulated since joining the channel.
txKBitRate/rxKBitRateThe bitrate sent/received.The actual bitrate sent/received in the reported interval.
txAudioKBitRate/rxAudioKBitRateThe bitrate sent/received of the audio packet.The actual bitrate sent/received in the reported interval.
txVideoKBitRate/rxVideoKBitRateThe bitrate sent/received of the video packet.The actual bitrate sent/received in the reported interval.
lastmileDelayThe network delay from the local client to Agora’s edge server.
  • This refers to half of the average round-trip delay, and not the one-way network delay from the client to Agora’s edge server or vice versa.
  • The network delay here does not distinguish between the audio and video delay, and is the data obtained by the UDP packet.
  • txPacketLossRateThe packet loss rate from the local client to Agora’s edge server.
  • The larger value between audio’s and video’s uplink packet loss rate.
  • The packet loss rate before using the anti-packet-loss method.
  • rxPacketLossRateThe packet loss rate from Agora’s edge server to the local client.
  • The larger value between audio’s and video’s downlink packet loss rate.
  • The packet loss rate before using the anti-packet-loss method.
  • Sample code


    _3
    public void onRtcStats(RtcStats rtcStats) {
    _3
    statisticsInfo.setRtcStats(rtcStats);
    _3
    }

    Audio quality report

    Statistics of local audio streams

    The onLocalAudioStats callback reports the statistics of the audio streams sent. You can see the number of channels (mono or dual), the sample rate, and the average sending bitrate in the reported interval.

    The SDK triggers this callback once every two seconds. The sample rate refers to the actual sample rate of the audio streams sent in the reported interval.

    Sample code


    _4
    public void onLocalAudioStats(LocalAudioStats localAudioStats) {
    _4
    statisticsInfo.setLocalAudioStats(localAudioStats);
    _4
    updateLocalStats();
    _4
    }

    State changes of local audio streams

    When the state of the local audio stream changes (including the state of the audio recording and encoding), the SDK triggers the onLocalAudioStateChanged callback to report the current state. You can troubleshoot with the error code when exceptions occur.

    Statistics of remote audio streams

    1565945275984

    The onRemoteAudioStats callback reports the audio statistics of each remote user/host in the current call. You can see the quality of the audio stream sent by each remote user/host (see Quality Rating), the number of channels (mono or dual), and the following parameters.

    ParameterDescriptionComment
    networkTransportDelayThe network delay from the sender to the receiver.Stages 2 + 3 + 4 in the figure above
    jitterBufferDelayThe network delay from the receiver to the network jitter buffer.Stage 5 in the figure above
    audioLossRateThe frame loss rate of the received remote audio streams in the reported interval.
  • Stages 2 + 3 + 4 + 5 in the figure above
  • In a reported interval, audio freeze occurs when the audio frame loss rate reaches 4%.
  • receivedSampleRateThe sample rate of the received remote audio streams in the reported interval.
    receivedBitrateThe average bitrate of the received remote audio streams in the reported interval.
    totalFrozenTimeThe total freeze time (ms) of the remote audio streams after the remote user joins the channel.
  • Agora defines totalFrozenTime = The number of times the audio freezes × 2 × 1000 (ms).
  • The total time is the cumulative duration after the remote user joins the channel.
  • frozenRateThe total audio freeze time is a percentage of the total time when the audio is available.When the remote user/host neither stops sending the audio stream nordisables the audio module after joining the channel, the audio is available.
    qoeQualityQuality of experience (QoE) of the local user when receiving a remote audio stream.
    qualityChangedReasonThe reason for poor QoE of the local user when receiving a remote audio stream.
    mosValueThe quality of the remote audio stream as determined by the Agora real-time audio MOS (Mean Opinion Score) measurement system in the reported interval.

    The onRemoteAudioStats callback reports statistics more closely linked to the real-user experience of the audio transmission quality. Even if network packet loss occurs, users may find the overall audio quality acceptable because the audio frame loss rate of the received audio streams may not be high due to the anti-packet-loss and congestion control methods, such as forward error correction (FEC), retransmissions and bandwidth estimation.

    • In the COMMUNICATION profile, you receive the audio stream statistics of all the remote users (excluding yours) in the channel once every two seconds.
    • In the LIVE_BROADCASTING profile, if you are the host, you receive the audio stream statistics of all remote hosts (excluding yours) in the channel once every two seconds; if you are the audience, you receive the statistics of all hosts in the channel once every two seconds.
    • Agora's audio module refers to the audio processing process, and not the actual module in the SDK. When sending audio streams, the audio module refers to the processes of audio sampling, pre-processing, and encoding; when receiving audio streams, the audio module refers to the processes of audio decoding, post-processing, and playback.
    • Users can only turn on/off their own audio modules.
    • By default, the audio freezes at most once in each reported interval.

    Sample code


    _4
    public void onRemoteAudioStats(RemoteAudioStats remoteAudioStats) {
    _4
    statisticsInfo.setRemoteAudioStats(remoteAudioStats);
    _4
    updateRemoteStats();
    _4
    }

    State changes of remote audio streams

    When the state of remote audio stream changes, the SDK triggers the onRemoteAudioStateChanged callback to report the current state and the reason for the state change.

    • In the COMMUNICATION profile, this callback reports to you the audio stream state information of all the remote users (excluding yours) in the channel once every two seconds.
    • In the LIVE_BROADCASTING profile, if you are the host, this callback reports to you the audio stream state information of all the remote hosts(excluding yours) in the channel once every two seconds; if you are the audience, this callback reports to you the audio stream state information of all the remote hosts in the channel once every two seconds.

    Sample code


    _5
    public void onRemoteAudioStateChanged(int uid, int state, int reason, int elapsed)
    _5
    {
    _5
    super.onRemoteAudioStateChanged(uid, state, reason, elapsed);
    _5
    Log.i(TAG, "onRemoteAudioStateChanged->" + uid + ", state->" + state + ", reason->" + reason);
    _5
    }

    Video quality report

    Statistics of local video streams

    The onLocalVideoStats callback reports the statistics of the video streams sent. You can see the dimensions of the encoding frame and the following parameters.

    If you have called the enableDualStreamMode method to enable dual-stream mode, this callback reports the statistics of the high-video streams sent.

    ParameterDescriptionComment
    rendererOutputFrameRateThe output frame rate of the local video renderer.
    encoderOutputFrameRateThe output frame rate of the local video encoder.
    targetBitrateThe target bitrate of the current encoder.This value is estimated by the SDK based on current network conditions.
    targetFrameRateThe target frame rate of the current encoder.
    encodedBitrateThe bitrate of the encoding video.Does not include the bitrate of the retransmission videos.
    sentBitrateThe bitrate of the video sent in the reported interval.Does not include the bitrate of the retransmission videos.
    sentFrameRateThe frame rate of the video sent in the reported interval.Does not include the frame rate of the retransmission videos.
    encodedFrameCountThe total frames of the video sent.The number of frames accumulated since joining the channel.
    codecTypeThe codec type of the local video.
  • VIDEO_CODEC_VP8 = 1: VP8
  • VIDEO_CODEC_H264 = 2: (Default) H.264
  • qualityAdaptIndicationThe local video quality change in terms of targetBitrate and targetFrameRate in thisreported interval.Compared to the video quality in the last statistics (two seconds ago), the video quality change in this reported interval:
  • The quality stays the same.
  • The quality improves.
  • The quality deteriorates.
  • Sample code


    _4
    public void onLocalVideoStats(LocalVideoStats localVideoStats) {
    _4
    statisticsInfo.setLocalVideoStats(localVideoStats);
    _4
    updateLocalStats();
    _4
    }

    State changes of local video streams

    When the state of the local video changes, the SDK triggers the onLocalVideoStateChanged callback to report the current state. You can troubleshoot with the error code when exceptions occur.

    Statistics of remote video streams

    1565945292345

    The onRemoteVideoStats callback reports the video statistics of each remote user/host in the current call. You can see their video dimensions and the following parameters.

    ParameterDescriptionComment
    rxStreamTypeThe type of video streams.High-video streams or low-video streams, see dual-stream mode.
    receivedBitrateThe bitrate of the video received in the reported interval.
    packetLossRateThe packet loss rate of the video received in the reported interval.
  • Stages 2 + 3 + 4 in the figure above
  • The packet loss rate after using the anti-packet-loss method, which is lower than before.
  • decoderOutputFrameRateThe output frame rate of the remote video decoder.
    rendererOutputFrameRateThe output frame rate of the remote video renderer.
    totalFrozenTimeThe total freeze time (ms) of the remote video stream after the remote user joins the channel.In a video call or interactive video streaming session where the frame rate is set to no less than 5 fps, video freeze occurs when the time interval between two adjacent renderable video frames is more than 500 ms.
    frozenRateThe total video freeze time is a percentage of the total time when the video is available.When the remote user/host neither stops sending the video stream nor disables the video module after joining the channel, the video is available.
    • In the COMMUNICATION profile, you receive video stream statistics of all the remote users (excluding yours) in the channel once every two seconds.
    • In the LIVE_BROADCASTING profile, if you are the host, you receive video stream statistics of all the remote hosts (excluding yours) in the channel once every two seconds; if you are the audience, you receive the statistics for all the hosts in the channel once every two seconds.
    • Agora’s video module refers to the video processing process, and not the actual module in the SDK. When sending video streams, the video module refers to the processes of video capturing, pre-processing, and encoding; when receiving video streams, the video module refers to the processes of video decoding, post-processing, and rendering/playing.
    • Users can only turn on/off their own video modules.

    Sample code


    _4
    public void onRemoteVideoStats(RemoteVideoStats remoteVideoStats) {
    _4
    statisticsInfo.setRemoteVideoStats(remoteVideoStats);
    _4
    updateRemoteStats();
    _4
    }

    State changes of remote video streams

    When the state of remote video streams changes, the SDK triggers the onRemoteVideoStateChanged callback to report the current state and the reason for the state change.

    • In the COMMUNICATION profile, this callback reports to you the video stream state information of all the remote users (excluding yours) in the channel once every two seconds.
    • In the LIVE_BROADCASTING profile, if you are the host, this callback reports to you the video stream state information of all the remote hosts (excluding yours) in the channel once every two seconds; if you are the audience, this callback reports to you the video stream state information of all the remote hosts in the channel once every two seconds.

    Sample code


    _5
    public void onRemoteVideoStateChanged(int uid, int state, int reason, int elapsed)
    _5
    {
    _5
    super.onRemoteVideoStateChanged(uid, state, reason, elapsed);
    _5
    Log.i(TAG, "onRemoteVideoStateChanged->" + uid + ", state->" + state + ", reason->" + reason);
    _5
    }

    API reference

    Considerations

    The SDK does not trigger the onLocalAudioStateChanged, onRemoteAudioStateChanged, onLocalVideoStateChanged, and onRemoteVideoStateChanged callbacks once every two seconds. See their respective trigger conditions on this page.

    Voice Calling