Pre-call tests
Updated
Run microphone, speaker, camera, and last-mile network checks before users join a Video Calling session.
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
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.
-
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 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. 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:
-
Call
AgoraRTC.getDevicesto get the available devices and their IDs. -
When calling
AgoraRTC.createCameraVideoTrackandAgoraRTC.createMicrophoneAudioTrackto create local audio and video track objects, pass incameraIdandmicrophoneIdto specify the devices you want to test. -
After creating the local audio or video track object, call
CameraVideoTrack.playto play the local video track:-
If you are testing the microphone, call
MicrophoneAudioTrack.getVolumeLevelto get the volume level. If the volume is greater than0, it means that the microphone is working normally. -
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);
});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.getDevicesto 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.playto 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:
-
Call
createClienttwice, to create two clients:uplinkClient: To test the connection status of the uplink network.downlinkClient: To test the connection status of the downlink network.
-
Both clients call
jointo enter a channel for testing. -
Call
createMicrophoneAndCameraTracksto create audio and video tracks. -
Call
publishonuplinkClientto publish audio and video tracks andsubscribeondownlinkClientto subscribe to audio and video tracks. -
Listen to the
uplinkClient.on("network-quality")event to get the uplink network status between the local device and Agora server. -
Listen to
downlinkClient.on("network-quality")event to get the downlink network status between the local device and the Agora server. The SDK triggers theclient.on("network-quality")callback every two seconds. -
To get specific statistics about the sent or received media tracks, such as send/receive bitrate, end-to-end latency, call
getLocalAudioStatsandgetLocalVideoStatsonuplinkClientto get the uplink statistics, andgetRemoteAudioStatsandgetRemoteVideoStatsondownlinkClientto get the downlink statistics.
The following figure summarizes the calling sequence of network quality tests:
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);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:
| 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) |
|
This feature guide is not available yet for JavaScript.
Sample project
Agora provides the following open-source projects for your reference:
Download or view the code for more detailed examples.
API reference
-
Equipment testing :
-
Network analysis:
