This document describes how to assess the current network conditions.
When you have a video call on WeChat under poor network conditions (for example, when you are in an elevator), WeChat displays a message indicating the current network quality is poor. This document describes how to use TRTC to implement a similar interaction in your own application.
TRTC provides the onNetworkQuality callback to report the current network quality once every two seconds. It contains two parameters: localQuality
and remoteQuality
.
Excellent
, Good
, Poor
, Bad
, VeryBad
, and Down
.Quality | Name | Description |
---|---|---|
0 | Unknown | Unknown |
1 | Excellent | The current network is excellent. |
2 | Good | The current network is good. |
3 | Poor | The current network is fine. |
4 | Bad | The current network is poor, and there may be obvious stuttering and delay. |
5 | VeryBad | The current network is very poor, and TRTC can merely sustain the connection but cannot guarantee the communication quality. |
6 | Down | The current network cannot meet the minimum requirements of TRTC, and it is impossible to have a normal audio/video call. |
You only need to listen for onNetworkQuality
of TRTC and display the corresponding prompt on the UI.
// Listen for the `onNetworkQuality` callback to get the change of the current network conditions
@Override
public void onNetworkQuality(TRTCCloudDef.TRTCQuality localQuality,
ArrayList<trtcclouddef.trtcquality> remoteQuality)
{
// Get your local network quality
switch(localQuality) {
case TRTCQuality_Unknown:
Log.d(TAG, "SDK has not yet sensed the current network quality.");
break;
case TRTCQuality_Excellent:
Log.d(TAG, "The current network is very good.");
break;
case TRTCQuality_Good:
Log.d(TAG, "The current network is good.");
break;
case TRTCQuality_Poor:
Log.d(TAG, "The current network quality barely meets the demand.");
break;
case TRTCQuality_Bad:
Log.d(TAG, "The current network is poor, and there may be significant freezes and call delays.");
break;
case TRTCQuality_VeryBad:
Log.d(TAG, "The current network is very poor, the communication quality cannot be guaranteed");
break;
case TRTCQuality_Down:
Log.d(TAG, "The current network does not meet the minimum requirements.");
break;
default:
break;
}
// Get the network quality of remote users
for (TRTCCloudDef.TRTCQuality info : arrayList) {
Log.d(TAG, "remote user : = " + info.userId + ", quality = " + info.quality);
}
}
Was this page helpful?