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.
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 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:
-
Before joining a channel, call
startEchoTest. Specify theintervalInSecondsparameter to set the delay time for the echo test. The value range is 2-10 seconds and the default value is 10. -
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.
-
To stop the test, call
stopEchoTest, and then calljoinChannelto join a channel.
To implement running an echo test in your app, refer to the following code:
this.engine.startEchoTest(10);
this.engine.stopEchoTest();Audio recording device test
To test whether a local audio recording device, such as a microphone, is working properly, refer to the following steps.
-
Call
startRecordingDeviceTestand set theindicationIntervalparameter to the time interval after which the callback is triggered. -
After starting the test, speak into the microphone. The SDK reports
uid = 0, and the volume information of the device in theonAudioVolumeIndicationcallback. -
When you are done testing, call
stopRecordingDeviceTestto stop the test.Information
Best practice is to set the
indicationIntervalparameter to more than200milliseconds and not less than10milliseconds, otherwise theonAudioVolumeIndicationcallback may not be received.
To implement running a recording device test in your app, refer to the following code:
this.engine.getAudioDeviceManager().setRecordingDevice(deviceId);
this.engine.registerEventHandler({
onAudioVolumeIndication(
connection: RtcConnection,
speakers: AudioVolumeInfo[],
speakerNumber: number,
totalVolume: number
){},
});
this.engine.getAudioDeviceManager().startRecordingDeviceTest(1000);
this.engine.getAudioDeviceManager().stopRecordingDeviceTest();Audio playback device test
To test that the local audio playback device is working properly, refer to the following steps:
-
Call
startPlaybackDeviceTestand set theaudioFileNameparameter to the absolute path of the audio file to be played. -
If the user hears the audio, the playback device is working properly. The SDK triggers the
onAudioVolumeIndicationcallback to reportuid = 1and the volume information of the playback device. -
When you are done testing, call
stopPlaybackDeviceTestto stop the test.
To implement running a playback device test in your app, refer to the following code:
this.engine.getAudioDeviceManager().setPlaybackDevice(deviceId);
this.engine.getAudioDeviceManager().startPlaybackDeviceTest(filePath);
this.engine.getAudioDeviceManager().stopPlaybackDeviceTest();Audio device loopback test
To test if the local audio device loop is working properly, refer to the following steps:
-
Call
startAudioDeviceLoopbackTestand set theindicationIntervalparameter to the time interval after which the callback is triggered. -
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
onAudioVolumeIndicationcallbacks to report the volume information of the audio capture device withuid= 0, and the audio playback device withuid= 1, respectively. -
When you are done testing, call
stopAudioDeviceLoopbackTestto stop the recording device test.Information
Best practice is to set the
indicationIntervalparameter to more than200milliseconds and not less than10milliseconds, otherwise theonAudioVolumeIndicationcallback may not be received.
To implement an audio loopback device test in your app, refer to the following code:
this.engine.registerEventHandler({
onAudioVolumeIndication(
connection: RtcConnection,
speakers: AudioVolumeInfo[],
speakerNumber: number,
totalVolume: number
){},
}); this.engine.getAudioDeviceManager().startAudioDeviceLoopbackTest(1000);
this.engine.getAudioDeviceManager().stopAudioDeviceLoopbackTest();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:
-
Before joining a channel or switching user roles, call
startLastmileProbeTestto start the network test. Set the probe configuration and the expected maximum bitrate inLastmileProbeConfig. -
After you start the test, the SDK triggers the following callbacks:
-
onLastmileQuality: This callback is triggered two seconds afterstartLastmileProbeTestis called. It provides feedback on the upstream and downstream network quality through a subjectivequalityscore. -
onLastmileProbeResult: This callback is triggered 30 seconds afterstartLastmileProbeTestis called. It returns objective real-time network statistics, includingpacketLossRate, networkjitter, andavailableBandwidth.
-
-
Call
stopLastmileProbeTestto stop last-mile network testing.
To implement network quality testing in your app, refer to the following code:
this.engine.registerEventHandler({
onLastmileQuality(quality: QualityType) {},
onLastmileProbeResult(result: LastmileProbeResult) {},
});
this.engine.startLastmileProbeTest({
probeUplink: true,
probeDownlink: true,
expectedUplinkBitrate: 100000,
expectedDownlinkBitrate: 100000,
});
this.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:
| 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.
