Real-Time Communication (RTC) SDK supports network environment monitoring. You can obtain the network quality through callbacks when network conditions change. You can configure media track specifications based on the callback results to ensure the quality of RTC calls. This topic describes how to monitor the network environment and configure media track specifications.
Overview
The quality of RTC calls can be affected when the network condition is poor. To improve the quality of your calls, we recommend that you perform the following operations on the publishing or subscription end when you detect poor network conditions.
- Adjust video specifications: Lower the specifications of video tracks to reduce bandwidth usage.
- Switch to small tracks: Small tracks have the same aspect ratio as large tracks, but have lower resolutions and bitrates. This helps reduce bandwidth usage.
- Publish only audio tracks: In extreme cases, you can publish only audio tracks to maintain the connection of your calls.
You can use the onNetworkQualityChanged callback to obtain the network quality. Then, perform the preceding operations based on the callback results to improve the quality of your calls.
void onNetworkQualityChanged(String uid, AliRtcNetworkQuality upQuality, AliRtcNetworkQuality downQuality);| Parameter | Type | Description |
| downQuality | AliRtcNetworkQuality | The downstream network quality. |
| upQuality | AliRtcNetworkQuality | Upstream network quality. |
| uid | String | The ID of the user whose network quality has changed. If the user ID is empty, it means local, and others means remote. |
Methods
You can use the following methods to configure the specifications of media tracks. For more information, see AliRtcEngine interface.
setVideoProfile: Set parameters for the video stream.
Parameter descriptionpublic abstract void setVideoProfile(AliRtcVideoProfile profile, AliRtcVideoTrack track)Parameter Type Description profile AliRtcVideoProfile The video stream parameters. A camera stream with a default resolution of 480*640 and a frame rate of 15. track AliRtcVideoTrack The type of the video stream to be set. The default camera stream. configRemoteCameraTrack: specifies whether to subscribe to remote camera streams.
Parameter descriptionpublic abstract void configRemoteCameraTrack(String uid, boolean master, boolean enable)Parameter Type Description uid String The ID of the user. master boolean true indicates that a large stream is subscribed first. false indicates that a small stream is subscribed to. The default value is to subscribe to a large stream. enable boolean No subscription by default. true to subscribe to the remote camera stream. false to stop subscribing to the remote camera stream. Important When you need to perform operations on streams (such as manual subscription or disabling subscription), you must call subscribe to take effect.configLocalCameraPublish: specifies whether to allow the camera stream to be published.
Parameter descriptionpublic abstract void configLocalCameraPublish(boolean enable)Parameter Type Description enable boolean true indicates that the camera stream is allowed to be published. false indicates that the camera stream is not allowed. The default is to allow the camera stream to be published. Important If you manually publish a file, you must call Publish to take effect.