Network and device detection before the call
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.
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
startLastmileProbeTestto 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
stopLastmileProbeTestto stop the network quality detection before the call.
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.
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
startEchoTestmethod. When calling this method, you need to set aThe
intervalInSecondsparameter 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 10
After successfully calling the
startEchoTestmethod, 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 normal
After obtaining the audio device test results, call the
stopEchoTestmethod to stop the voice call detection, and then you can call
joinChanneljoin a channel
- When calling
startLastmileProbeTestto 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 the
onLastmileProbeResultcallback to avoidAPI operations are too frequent and other methods cannot be executed.
- The result of the
onLastmileQualitycallback for the first report has a certain probability of being
UNKNOWN, 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
startEchoTestmust call after
stopEchoTestto end the test will not be performed next echo test,Can’t join the channel either.