7.Sensing Network Quality
This document primarily discusses how to perceive the quality of the current network.
When engaging in a video call using WeChat, if we encounter inferior network conditions (such as after entering an elevator), WeChat will prompt on the video call interface that "Your current network quality is poor". This document primarily explores how to accomplish the same interaction using TRTC.
Call Guidelines
TRTC offers a callback event known as onNetworkQuality, which reports the current network quality to you every two seconds. Its parameters include two parts: localQuality and remoteQuality
localQuality: Represents your current network quality, divided into 6 levels, which are Excellent, Good, Poor, Bad, VeryBad, and Down.
remoteQuality: Represents the network quality of remote users. This is an array, each Element (XML) in the array represents the network quality of a remote user.
Quality | Name | Description |
1 | Unknown | Unperceived |
1 | Excellent | The present network is exceedingly good |
2 | Good | The current network is fairly good |
3 | Poor | Current network is average |
4 | Bad | Present network quality is poor, it might cause noticeable stutters and communication delays |
5 | VeryBad | The current network conditions are abysmal, TRTC can barely maintain a connection, yet it can't guarantee the quality of communication |
6 | Down | The current network does not meet the minimum requirements of TRTC, obstructing the normal audio and video conversation |
All you need is to monitor TRTC's onNetworkQuality and make corresponding prompts on the interface:
// Monitor the onNetworkQuality callback and perceive the alterations in the current network statusif (type == TRTCCloudListener.onNetworkQuality) {if (type == TRTCCloudDef.TRTC_QUALITY_UNKNOWN) {// TODO} else if (type == TRTCCloudDef.TRTC_QUALITY_Excellent) {// TODO} else if (type == TRTCCloudDef.TRTC_QUALITY_Good) {// TODO} else if (type == TRTCCloudDef.TRTC_QUALITY_Poor) {// TODO} else if (type == TRTCCloudDef.TRTC_QUALITY_Bad) {// TODO} else if (type == TRTCCloudDef.TRTC_QUALITY_Vbad) {// TODO} else if (type == TRTCCloudDef.TRTC_QUALITY_Down) {// TODO}// Get the network quality of remote usersfor (var info in param['remoteQuality']) {// TODO}}