# Pre-call tests (/en/realtime-media/video/build/manage-connection-and-quality/pre-call-tests/unreal)

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

In video calling implementations that demand high communication quality, pre-call detection helps identify and troubleshoot issues beforehand, ensuring seamless real-time interaction.

This page shows you how to use Video SDK to run pre-call tests to identify and troubleshoot communication quality issues in your app.

## Understand the tech [#understand-the-tech]

Pre-call testing typically covers two aspects:

* **Equipment quality test**

  To test whether the local microphone, speaker, and camera are working properly, you run an echo test. The basic process of conducting an echo test is as follows:

* **Network quality analysis**

  The quality of the last mile network affects the smoothness and clarity of the audio and video that the user sends and receives. Last mile refers to the last leg of communication network between the edge server of the Agora SDRTN® and the end-user devices. Network quality analysis enables you to get feedback on the available bandwidth, packet loss rate, network jitter, and round-trip delay of the upstream and downstream last-mile networks. The following figure shows the basic process of running a last-mile probe test.

<Accordions>
  <Accordion title="Pre-call echo test">
    ![Echo Test](https://assets-docs.agora.io/images/video-sdk/pre-call-echo-test.svg)
  </Accordion>

  <Accordion title="Pre-call last mile test">
    ![Last Mile Test](https://assets-docs.agora.io/images/video-sdk/pre-call-last-mile-test.svg)
  </Accordion>
</Accordions>

      
  
<CalloutContainer type="info">
  <CalloutTitle>
    information
  </CalloutTitle>

  <CalloutDescription>
    Best practice is to run the device test first and then perform a network test.
  </CalloutDescription>
</CalloutContainer>

## Prerequisites [#prerequisites]

Ensure that you have implemented the [SDK quickstart](/en/realtime-media/video/get-started-sdk) project and that your app has obtained permissions to use the relevant devices.

## Implement pre-call testing [#implement-pre-call-testing]

This section shows you how to implement pre-call testing in your project.

      
  
      
  
      
  
      
  
      
  
      
  
      
    ### Equipment quality test [#equipment-quality-test-6]

    The SDK provides the `startEchoTest` method to test the network connection and whether the audio and video devices are working properly. Refer to the following steps to implement the device quality test:

    1. Before joining a channel, call `startEchoTest`. Specify the `intervalInSeconds` parameter to set the delay time for the echo test. The value range is 2-10 seconds and the default value is 10.

    2. After starting the test, speak into the microphone. The user's audio is played back after a short delay. If the playback is normal, it means that the user's devices and upstream and downstream network are working normally.

    3. To stop the test, call `stopEchoTest`, and then call `joinChannelByToken` to join a channel.

    To implement running an echo test in your app, refer to the following code:

    ```cpp
    // Start the echo test
    // Only the host can call startEchoTest
    rtcEngine.startEchoTest(10);

    // Wait and check if you can hear your own voice played back

    // Stop the echo test
    // You must call stopEchoTest to end the echo test. Otherwise, you will not be able to do another echo test or join the channel
    rtcEngine.stopEchoTest
    ```

    #### Audio recording device test [#audio-recording-device-test-3]

    To test whether a local audio recording device, such as a microphone, is working properly, refer to the following steps.

    1. Call `startRecordingDeviceTest` and set the `indicationInterval` parameter to the time interval after which the callback is triggered.

    2. After starting the test, speak into the microphone. The SDK reports `uid = 0`, and the volume information of the device in the `onAudioVolumeIndication` callback.

    3. When you are done testing, call `stopRecordingDeviceTest` to stop the test.

       <CalloutContainer type="info">
         <CalloutTitle>
           Information
         </CalloutTitle>

         <CalloutDescription>
           Best practice is to set the `indicationInterval` parameter to more than `200` milliseconds and not less than `10` milliseconds, otherwise the `onAudioVolumeIndication` callback may not be received.
         </CalloutDescription>
       </CalloutContainer>

    To implement running a recording device test in your app, refer to the following code:

    ```cpp
    // Select an audio capture device
    lpDeviceManager->setRecordingDevice(strDeviceID);

    // Implement the audio volume callback
    virtual void onAudioVolumeIndication(const AudioVolumeInfo* speakers,
                                         unsigned int speakerNumber,
                                         int totalVolume) {
       (void)speakers;
       (void)speakerNumber;
       (void)totalVolume;
    }

    // Start audio capture device test
    (*lpDeviceManager)->startRecordingDeviceTest(1000);

    // Stop the audio capture device test
    (*lpDeviceManager)->stopRecordingDeviceTest();
    ```

    #### Audio playback device test [#audio-playback-device-test-3]

    To test that the local audio playback device is working properly, refer to the following steps:

    1. Call `startPlaybackDeviceTest` and set the `audioFileName` parameter to the absolute path of the audio file to be played.

    2. If the user hears the audio, the playback device is working properly. The SDK triggers the `onAudioVolumeIndication` callback to report `uid = 1` and the volume information of the playback device.

    3. When you are done testing, call `stopPlaybackDeviceTest` to stop the test.

    To implement running a playback device test in your app, refer to the following code:

    ```cpp
    // Select an audio playback device
    lpDeviceManager->setPlaybackDevice(strDeviceID);

    // Specify the absolute path of the audio file to start the playback device test
    (*lpDeviceManager)->startPlaybackDeviceTest(filePath);

    // Stop the audio playback device test
    (*lpDeviceManager)->stopPlaybackDeviceTest();
    ```

    #### Audio device loopback test [#audio-device-loopback-test-3]

    To test if the local audio device loop is working properly, refer to the following steps:

    1. Call `startAudioDeviceLoopbackTest` and set the `indicationInterval` parameter to the time interval after which the callback is triggered.

    2. After starting the test, speak into the microphone. The microphone captures the sound and then plays it on the playback device. The SDK returns two `onAudioVolumeIndication` callbacks to report the volume information of the audio capture device with `uid= 0`, and the audio playback device with `uid= 1`, respectively.

    3. When you are done testing, call `stopAudioDeviceLoopbackTest` to stop the recording device test.

       <CalloutContainer type="info">
         <CalloutTitle>
           Information
         </CalloutTitle>

         <CalloutDescription>
           Best practice is to set the `indicationInterval` parameter to more than `200` milliseconds and not less than `10` milliseconds, otherwise the `onAudioVolumeIndication` callback may not be received.
         </CalloutDescription>
       </CalloutContainer>

    ### Network quality analysis [#network-quality-analysis-6]

    The SDK provides the `startLastmileProbeTest` method to probe the last-mile network quality before joining a channel. The method returns information about the network quality score and network statistics. Take the following steps to run a last-mile network quality probe test:

    1. Before joining a channel or switching user roles, call `startLastmileProbeTest` to start the network test. Set the probe configuration and the expected maximum bitrate in `LastmileProbeConfig`.

    2. After you start the test, the SDK triggers the following callbacks:

       * `onLastmileQuality`: This callback is triggered two seconds after `startLastmileProbeTest` is called. It provides feedback on the upstream and downstream network quality through a subjective `quality` score.

       * `onLastmileProbeResult`: This callback is triggered 30 seconds after `startLastmileProbeTest` is called. It returns objective real-time network statistics, including `packetLossRate`, network `jitter`, and `availableBandwidth`.

    3. Call `stopLastmileProbeTest` to stop last-mile network testing.

    To implement network quality testing in your app, refer to the following code:

    ```cpp
    // Register the callback interface
    // This callback occurs approximately 2 seconds after starting Last-mile network probe test
    void onLastmileQuality(int quality) {
    }

    // This callback occurs approximately 30 seconds after starting Last-mile network probe test
    void onLastmileProbeResult(LastmileProbeResult) {
        // (1) Optionally, you can end the test inside the callback. Agora recommends not calling other API methods until the testing is completed
        lpAgoraEngine->stopLastmileProbeTest();
    }

    // Configure a LastmileProbeConfig instance
    LastmileProbeConfig config;
    // Enable detection of uplink network quality
    config.probeUplink = true;
    // Enable detection of downlink network quality
    config.probeDownlink = true;
    // Desired maximum transmit bitrate in bps, range [100000,5000000].
    config.expectedUplinkBitrate = 100000;
    // Desired maximum receive bitrate in bps, range [100000,5000000].
    config.expectedDownlinkBitrate = 100000;
    // Start last-mile network probing before joining a channel.
    lpAgoraEngine->startLastmileProbeTest(config);

    // (2) You can also choose to end the test at another time. Agora does not recommend calling any other API methods until testing is complete.
    lpAgoraEngine->stopLastmileProbeTest();
    ```

    
  
      
  
      
  
      
  
## Reference [#reference]

This section contains content that completes the information on this page, or points you to documentation that explains other aspects to this product.

### Troubleshooting device and network issues [#troubleshooting-device-and-network-issues]

If you encounter problems while running pre-call tests, first ensure that you have implemented the API calls properly. To troubleshoot device and network issues, refer to the following table:

| Problem                                                                           | Solution                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| :-------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Can't hear sound when testing audio devices.                                      | - Check that the recording device and the playback device are working properly, and are not occupied by other programs.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| Cannot see the screen when testing video devices.                                 | - Check that the video device is working properly and not occupied by other programs.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| Poor uplink network quality detected (packet loss > 5%; network jitter > 100ms)   | - Check that the local network is working properly.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| Poor downlink network quality detected (packet loss > 5%; network jitter > 100ms) | * Check that the local network is working properly.
* Ensure that the total bandwidth of the local subscription does not exceed the available downstream bandwidth by:
  * Reducing the number of subscribed audio and video streams on the receiving end or reducing the bitrate of published audio and video streams on the sending end.
  * Enabling dual-stream mode on the sending side and requesting to receive small streams on the receiving side to reduce bandwidth consumption.
  * Enabling the video stream fallback function or the multiple streams by priority fallback function at the receiving end. |

      
  
      
  
      
  
      
  
      
  
This feature guide is not available yet for JavaScript.

      
  
      
  
      
    ### Sample project [#sample-project-3]

    Agora provides an open-source Web [sample project](https://github.com/AgoraIO-Extensions/Agora-Unreal-RTC-SDK/tree/main/Agora-Unreal-SDK-CPP-Example) for your reference. Download and explore this project for a more detailed example.

    ### API reference [#api-reference-7]

    * [`startRecordingDeviceTest`](https://api-ref.agora.io/en/video-sdk/unreal-engine/4.x/API/class_iaudiodevicemanager.html#api_iaudiodevicemanager_startrecordingdevicetest)
    * [`stopRecordingDeviceTest`](https://api-ref.agora.io/en/video-sdk/unreal-engine/4.x/API/class_iaudiodevicemanager.html#api_iaudiodevicemanager_stoprecordingdevicetest)
    * [`startPlaybackDeviceTest`](https://api-ref.agora.io/en/video-sdk/unreal-engine/4.x/API/class_iaudiodevicemanager.html#api_iaudiodevicemanager_startplaybackdevicetest)
    * [`stopPlaybackDeviceTest`](https://api-ref.agora.io/en/video-sdk/unreal-engine/4.x/API/class_iaudiodevicemanager.html#api_iaudiodevicemanager_stopplaybackdevicetest)
    * [`startAudioDeviceLoopbackTest`](https://api-ref.agora.io/en/video-sdk/unreal-engine/4.x/API/class_iaudiodevicemanager.html#api_iaudiodevicemanager_startaudiodeviceloopbacktest)
    * [`stopAudioDeviceLoopbackTest`](https://api-ref.agora.io/en/video-sdk/unreal-engine/4.x/API/class_iaudiodevicemanager.html#api_iaudiodevicemanager_stopaudiodeviceloopbacktest)
    * [`startEchoTest`](https://api-ref.agora.io/en/video-sdk/unreal-engine/4.x/API/class_irtcengine.html#api_irtcengine_startechotest)
    * [`stopEchoTest`](https://api-ref.agora.io/en/video-sdk/unreal-engine/4.x/API/class_irtcengine.html#api_irtcengine_stopechotest)
    * [`startLastmileProbeTest`](https://api-ref.agora.io/en/video-sdk/unreal-engine/4.x/API/class_irtcengine.html#api_irtcengine_startlastmileprobetest)
    * [`stopLastmileProbeTest`](https://api-ref.agora.io/en/video-sdk/unreal-engine/4.x/API/class_irtcengine.html#api_irtcengine_stoplastmileprobetest)
    * [`onlastmileQuality`](https://api-ref.agora.io/en/video-sdk/unreal-engine/4.x/API/class_irtcengineeventhandler.html#callback_irtcengineeventhandler_onlastmilequality)
    * [`onlastmileProbeResult`](https://api-ref.agora.io/en/video-sdk/unreal-engine/4.x/API/class_irtcengineeventhandler.html#callback_irtcengineeventhandler_onlastmileproberesult)

    
  
      
  
      
  
      
  
