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.
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.getDevices
to get the available devices and their IDs. -
When calling
AgoraRTC.createCameraVideoTrack
andAgoraRTC.createMicrophoneAudioTrack
to create local audio and video track objects, pass incameraId
andmicrophoneId
to specify the devices you want to test. -
After creating the local audio or video track object, call
CameraVideoTrack.play
to play the local video track:-
If you are testing the microphone, call
MicrophoneAudioTrack.getVolumeLevel
to 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:
- 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:
-
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.
-
Both clients call
join
to enter a channel for testing. -
Call
createMicrophoneAndCameraTracks
to create audio and video tracks. -
Call
publish
onuplinkClient
to publish audio and video tracks andsubscribe
ondownlinkClient
to 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
getLocalAudioStats
andgetLocalVideoStats
onuplinkClient
to get the uplink statistics, andgetRemoteAudioStats
andgetRemoteVideoStats
ondownlinkClient
to get the downlink statistics.
The following figure summarizes the calling sequence of network quality tests:
Pre-call last mile test
To implement network quality testing in your app, refer to the following code:
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. |
|
Cannot see the screen when testing video devices. |
|
Poor uplink network quality detected (packet loss > 5%; network jitter > 100ms) |
|
Poor downlink network quality detected (packet loss > 5%; network jitter > 100ms) |
|
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: