Network and device detection before the call
Function description
In scenarios with high quality requirements, pre-call detection can help identify and troubleshoot problems in advance to ensure real-time communication experience. Before the callTesting can usually be carried out from the following two perspectives:
- Network quality detection: By detecting the current uplink and downlink last mile network quality, judge or predict whether the user’s current network status isgood
- Equipment quality inspection: to detect whether the local audio capture equipment and playback equipment can work normally.
CloudHub SDK provides a complete network detection and device detection interface to help you achieve the above functions and ensure the user experience.This article describes how to use related APIs to implement the above functions.
Network quality detection
CloudHub SDK provides the startLastmileProbeTest
method, which supports users to perform network quality detection before joining the channel.Then, through callbacks, the current network quality related data, including round-trip delay, uplink and downlink packet loss rate, uplink and downlink network bandwidth, etc. are returned toapp.
Implementation
Before starting, please make sure that you have implemented basic audio and video communication or live broadcast functions in your project.
- Before the user joins the channel or goes to the microphone, call
startLastmileProbeTest
to perform network quality detection. When calling this method,You need to specify the desired maximum uplink and downlink bit rate. - After enabling this method, the SDK will return the following two callbacks in turn:
onLastmileQuality
: Return in about 2 seconds. This callback provides feedback on the uplink and downlink network quality through scoring, which is closer to subjective feelings.onLastmileProbeResult
:Return in about 30 seconds. This callback provides feedback on the uplink and downlink network quality through objective data
- After obtaining the network quality data, call
stopLastmileProbeTest
to stop the network quality detection before the call.
API reference
android
ios
Equipment quality inspection
The CloudHub SDK supports a startEchoTest
method to enable users to start a call test before joining a channel. The purpose of the testIt is to test whether the audio equipment (headset, speaker, etc.) and network connection of the system are normal.
Implementation
Before you start, make sure you have understood how to implement audio and video calls or implement interactive live broadcasts
Before joining the channel, call the
startEchoTest
method. When calling this method, you need to set aTheintervalInSeconds
parameter indicates the interval time for obtaining the test results. The unit of this parameter is seconds, and the value range is[2,10], the default value is 10After successfully calling the
startEchoTest
method, guide the user to say a paragraph first, if the sound is played back after the set time intervalCome, and the user can hear what he just said, it means that the system audio equipment and network connection are normalAfter obtaining the audio device test results, call the
stopEchoTest
method to stop the voice call detection, and then you can calljoinChannel
join a channel
API reference
android
iOS
Development considerations
- When calling
startLastmileProbeTest
to detect the network quality before a call, a certain amount of network traffic will be consumed. So callAfter the method, CloudHub recommends not to call other methods before receiving theonLastmileProbeResult
callback to avoidAPI operations are too frequent and other methods cannot be executed. - The result of the
onLastmileQuality
callback for the first report has a certain probability of beingUNKNOWN
, which can be obtained through several callbacks afterwardsresult. - After starting the network test, pure voice products use a fixed detection bit rate of 48 Kbps; video products will be based on the currently selected video attributesAdjust the detection bit rate.
- In the live broadcast scenario, only the user whose role is the host can call
startEchoTest
. - Call
startEchoTest
must call afterstopEchoTest
to end the test will not be performed next echo test,Can’t join the channel either.