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)

Pre-call tests

In video calling scenarios 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

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:

    Echo Test

  • 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 SD-RTN 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.

    Last Mile Test

information

Best practice is to run the device test first and then perform a network test.

Prerequisites

Ensure that you have implemented the SDK quickstart project and that your app has obtained permissions to use the relevant devices.

Implement pre-call testing

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

Equipment quality test

The SDK provides the startEchoTest [3/3] 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 [3/3] with EchoTestConfiguration. Specify the channel name, whether to test audio or video, and the time interval for the echo.

  2. After starting the test, face the camera and speak into the microphone. The user's audio or video 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 joinChannel to join a channel.

Note

Using startEchoTest [3/3] to test an audio device and a video device at the same time may result in a brief audio-video desynchronization of the test results.

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


_32
// Test audio device
_32
if (v.getId() == R.id.btn_audio) {
_32
// Create an EchoTestConfiguration instance
_32
EchoTestConfiguration config = new EchoTestConfiguration();
_32
// Disable video device testing
_32
config.enableVideo = false;
_32
// Enable audio device testing
_32
config.enableAudio = true;
_32
// Set the interval for returning test results
_32
config.intervalInSeconds = MAX_COUNT_DOWN;
_32
// Identify each test by channel name
_32
config.channelId = "AudioEchoTest" + (new Random().nextInt(1000) + 10000);
_32
// Start the test
_32
engine.startEchoTest(config);
_32
_32
// Test video device
_32
} else if (v.getId() == R.id.btn_video) {
_32
// Create an EchoTestConfiguration instance
_32
EchoTestConfiguration config = new EchoTestConfiguration();
_32
// Enable video device testing
_32
config.enableVideo = true;
_32
// Specify the view for rendering the local user's video
_32
config.view = requireView().findViewById(R.id.surfaceView);
_32
// Disable audio device testing
_32
config.enableAudio = false;
_32
// Set the expected delay for video rendering
_32
config.intervalInSeconds = MAX_COUNT_DOWN;
_32
// Identify each test by channel name
_32
config.channelId = "VideoEchoTest" + (new Random().nextInt(1000) + 10000);
_32
// Start the test
_32
engine.startEchoTest(config);
_32
}

Network quality analysis

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:


_25
// Configure a LastmileProbeConfig instance
_25
LastmileProbeConfig config = new LastmileProbeConfig(){};
_25
// Probe uplink network quality
_25
config.probeUplink = true;
_25
// Probe downlink network quality
_25
config.probeDownlink = true;
_25
// User's expected maximum sending bitrate (bps). Range: [100000,5000000]
_25
config.expectedUplinkBitrate = 100000;
_25
// User's expected maximum receiving bitrate (bps). Range: [100000,5000000]
_25
config.expectedDownlinkBitrate = 100000;
_25
// Start the network quality probe
_25
engine.startLastmileProbeTest(config);
_25
_25
// Register callbacks
_25
public void onLastmileQuality(int quality){
_25
statisticsInfo.setLastMileQuality(quality);
_25
updateLastMileResult();
_25
}
_25
public void onLastmileProbeResult(LastmileProbeResult) {
_25
statisticsInfo.setLastMileProbeResult(lastmileProbeResult);
_25
updateLastMileResult();
_25
}
_25
_25
// Stop the network quality probe
_25
engine.stopLastmileProbeTest();

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

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:

ProblemSolution
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.
  • Check that the network connection is normal.
Cannot see the screen when testing video devices.
  • Check that the video device is working properly and not occupied by other programs.
  • Check whether the network connection is normal.
Poor uplink network quality detected (packet loss > 5%; network jitter > 100ms)
  • Check that the local network is working properly.
  • Ensure that the bitrate of the published audio and video streams does not exceed the available uplink bandwidth by reducing the resolution or lowering the frame rate.
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.

Sample project

Agora provides an open-source PreCallTest sample project for your reference. Download and explore this project for a more detailed example.

API reference

Interactive Live Streaming