# In-call quality monitoring (/en/realtime-media/broadcast-streaming/build/optimize-quality-and-connection/in-call-quality-monitoring/electron)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

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 [#understand-the-tech-5]

    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](https://assets-docs.agora.io/images/video-sdk/in-call-quality.svg)

    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](#network-quality-score) 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 [#prerequisites-5]

    Ensure that you have implemented the [SDK quickstart](../../index) in your project.

    ## Implement in-call quality monitoring [#implement-in-call-quality-monitoring-5]

    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:

    ```javascript
    const EventHandler = {
     // Report real-time interactive statistical information
     onRtcStats: (connection, state) => {
      console.log(`connection:${connection}, state:${state}`);
     },

     // Report statistics on the audio streams sent
     onLocalAudioStats: (connection, state) => {
      console.log(`connection:${connection}, state:${state}`);
     },

     // Report local audio stream status monitoring
     onLocalAudioStateChanged: (connection, state, error) => {
      console.log(`connection:${connection}, state:${state}, error:${error}`);
     },

     // Report statistics on received far-end audio streams
     onRemoteAudioStats: (connection, state) => {
      console.log(`connection:${connection}, state:${state}`);
     },
     // Report remote audio stream status monitoring
     onRemoteAudioStateChanged: (
      connection,
      remoteUid,
      state,
      reason,
      elapsed
     ) => {
      console.log(
       `connection:${connection},remoteUid:${remoteUid}, state:${state}, reason:${reason}, elapsed:${elapsed}`
      );
     },

     // Report statistics on video streams sent
     onLocalVideoStats: (source, stats) => {
      console.log(`source:${source}, stats:${stats}`);
     },
     // Report local video stream status monitoring
     onLocalVideoStateChanged: (source, state, error) => {
      console.log(`source:${source}, state:${state}, error:${error}`);
     },

     // Report statistics on received remote video streams
     onRemoteVideoStats: (connection, stats) => {
      console.log(`connection:${connection}, stats:${stats}`);
     },
     // Report remote video stream status monitoring
     onRemoteVideoStateChanged: (
      connection,
      remoteUid,
      state,
      reason,
      elapsed
     ) => {
      console.log(
       `connection:${connection},remoteUid:${remoteUid}, state:${state}, reason:${reason}, elapsed:${elapsed}`
      );
     },
    };
    // Register event callbacks
    let rtcEngine = createAgoraRtcEngine();
    rtcEngine.registerEventHandler(EventHandler);
    ```

    ## Reference [#reference-5]

    ### Network quality score [#network-quality-score-5]

    | Value | Enumeration        | Description                                                                    |
    | :---: | :----------------- | :----------------------------------------------------------------------------- |
    |   0   | `QualityUnknown`   | The network quality is unknown.                                                |
    |   1   | `QualityExcellent` | The network quality is excellent.                                              |
    |   2   | `QualityGood`      | The network quality is good, but the bitrate is slightly lower than excellent. |
    |   3   | `QualityPoor`      | Users can feel the communication is slightly impaired.                         |
    |   4   | `QualityBad`       | Users cannot communicate smoothly.                                             |
    |   5   | `QualityVbad`      | The quality is so bad that users can barely communicate.                       |
    |   6   | `QualityDown`      | The network is down and users cannot communicate at all.                       |

    ### API reference [#api-reference-5]

    * [`onNetworkQuality`](https://api-ref.agora.io/en/video-sdk/electron/4.x/API/class_irtcengineeventhandler.html#callback_irtcengineeventhandler_onnetworkquality)

    * [`onRemoteAudioStateChanged`](https://api-ref.agora.io/en/video-sdk/electron/4.x/API/class_irtcengineeventhandler.html#callback_irtcengineeventhandler_onremoteaudiostatechanged)

    * [`onRemoteVideoStateChanged`](https://api-ref.agora.io/en/video-sdk/electron/4.x/API/class_irtcengineeventhandler.html#callback_irtcengineeventhandler_onremotevideostatechanged)

    * [`onLocalAudioStateChanged`](https://api-ref.agora.io/en/video-sdk/electron/4.x/API/class_irtcengineeventhandler.html#callback_irtcengineeventhandler_onlocalaudiostatechanged)

    * [`onLocalVideoStateChanged`](https://api-ref.agora.io/en/video-sdk/electron/4.x/API/class_irtcengineeventhandler.html#callback_irtcengineeventhandler_onlocalvideostatechanged)

    * [`onRemoteAudioStats`](https://api-ref.agora.io/en/video-sdk/electron/4.x/API/class_irtcengineeventhandler.html#callback_irtcengineeventhandler_onremoteaudiostats)

    * [`onRemoteVideoStats`](https://api-ref.agora.io/en/video-sdk/electron/4.x/API/class_irtcengineeventhandler.html#callback_irtcengineeventhandler_onremotevideostats)

    * [`onLocalAudioStats`](https://api-ref.agora.io/en/video-sdk/electron/4.x/API/class_irtcengineeventhandler.html#callback_irtcengineeventhandler_onlocalaudiostats)

    * [`onLocalVideoStats`](https://api-ref.agora.io/en/video-sdk/electron/4.x/API/class_irtcengineeventhandler.html#callback_irtcengineeventhandler_onlocalvideostats)

    * [`onRtcStats`](https://api-ref.agora.io/en/video-sdk/electron/4.x/API/class_irtcengineeventhandler.html#callback_irtcengineeventhandler_onrtcstats)

    
  
      
  
      
  
      
  
      
  
