Skip to main content
Android
iOS
macOS
Web
Windows
Electron
Flutter
React Native
Python
React JS
Unity
Unreal Engine
Unreal (Blueprint)

Pre-call tests

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

Pre-call testing typically covers two aspects:

  • Equipment quality test

    Device quality testing involves testing whether the local microphone, speaker, and camera are working properly.

  • 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. It enables you to examine if current network conditions are good enough to meet the requirements of the currently selected audio bitrate or the target video bitrate.

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

You test the recording and playback devices separately.

Recording equipment testing

Refer to the following steps to test the local microphone and camera:

  1. Call AgoraRTC.getDevices to get the available devices and their IDs.

  2. When calling AgoraRTC.createCameraVideoTrack and AgoraRTC.createMicrophoneAudioTrack to create local audio and video track objects, pass in cameraId and microphoneId to specify the devices you want to test.

  3. After creating the local audio or video track object, call CameraVideoTrack.play to play the local video track:

    1. If you are testing the microphone, call MicrophoneAudioTrack.getVolumeLevel to get the volume level. If the volume is greater than 0, it means that the microphone is working normally.

    2. When testing the camera, if you see the picture after playing the video track, it means that the camera is working normally.

To implement recording equipment tests in your app, refer to the following code:

// Get all audio and video devices
AgoraRTC.getDevices()
.then(devices => {
const audioDevices = devices.filter(function(device){
return device.kind === "audioinput";
});
const videoDevices = devices.filter(function(device){
return device.kind === "videoinput";
});

var selectedMicrophoneId = audioDevices[0].deviceId;
var selectedCameraId = videoDevices[0].deviceId;
return Promise.all([
AgoraRTC.createCameraVideoTrack({ cameraId: selectedCameraId }),
AgoraRTC.createMicrophoneAudioTrack({ microphoneId: selectedMicrophoneId }),
]);
})
.then([videoTrack, audioTrack] => {
videoTrack.play("<ELEMENT_ID_IN_DOM>");
setInterval(() => {
const level = audioTrack.getVolumeLevel();
console.log("local stream audio level", level);
}, 1000);
});
Copy
Information
  • Best practice is to draw the volume change and camera screen on the UI so that users can judge if the device is working properly.
  • Device IDs are randomly generated, and in some cases the ID of the same device may change. Best practice is to call AgoraRTC.getDevices to get the device ID every time you test the device.

Playback device testing

The Agora SDK for Web does not provide an API for testing audio playback devices. Use the following methods to test the audio playback devices:

  • Create an audio player on the page using the HTML5 <audio> element. Prompt the user to play the audio file and confirm that the sound is audible.

  • After capturing the microphone audio, call MicrophoneAudioTrack.play to play the microphone sound and prompt the user to subjectively verify that the playback is audible.

Network quality analysis

Refer to the following steps to perform a network quality test before a call or live broadcast:

  1. Call createClient twice, to create two clients:

    • uplinkClient: To test the connection status of the uplink network.
    • downlinkClient: To test the connection status of the downlink network.
  2. Both clients call join to enter a channel for testing.

  3. Call createMicrophoneAndCameraTracks to create audio and video tracks.

  4. Call publish on uplinkClient to publish audio and video tracks and subscribe on downlinkClient to subscribe to audio and video tracks.

  5. Listen to the uplinkClient.on("network-quality") event to get the uplink network status between the local device and Agora server.

  6. Listen to downlinkClient.on("network-quality") event to get the downlink network status between the local device and the Agora server. The SDK triggers the client.on("network-quality") callback every two seconds.

  7. To get specific statistics about the sent or received media tracks, such as send/receive bitrate, end-to-end latency, call getLocalAudioStats and getLocalVideoStats on uplinkClient to get the uplink statistics, and getRemoteAudioStats and getRemoteVideoStats on downlinkClient to get the downlink statistics.

The following figure summarizes the calling sequence of network quality tests:

Pre-call last mile test

Network quality analysis

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

// Get uplink network quality
uplinkClient.on("network-quality", (quality) => {
console.log("uplink network quality", quality.uplinkNetworkQuality);
});

// Get downlink network quality
downlinkClient.on("network-quality", (quality) => {
console.log("downlink network quality", quality.downlinkNetworkQuality);
});

// Get uplink statistics
uplinkVideoStats = uplinkClient.getLocalVideoStats();
// Get downlink statistics
downlinkVideoStats = downlinkClient.getRemoteVideoStats()[<UPLINKCLIENT_UID>];

console.log("uplink video stats", uplinkVideoStats);
console.log("downlink video stats", downlinkVideoStats);
Copy

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 the following open-source projects for your reference:

Download or view the code for more detailed examples.

API reference

Voice Calling