iOS

更新时间:
复制 MD 格式

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:(NSString *)uid 
        upNetworkQuality:(AliRtcNetworkQuality)upQuality      
        downNetworkQuality:(AliRtcNetworkQuality)downQuality;
ParameterTypeDescription
uidNSString *The ID of the user whose network quality has changed. If the user ID is empty, it means local, and others means remote.
upQualityAliRtcNetworkQualityUpstream network quality.
downQualityAliRtcNetworkQualityThe downstream network quality.

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.

    - (void)setVideoProfile:(AliRtcVideoProfile)profile forTrack:(AliRtcVideoTrack)track;
    Parameter description
    ParameterTypeDescription
    profileAliRtcVideoProfileThe video stream parameters. The default is a camera stream with a resolution of 480*640 and a frame rate of 15.
    trackAliRtcVideoTrackThe type of the video track to be set. The default camera stream.
  • configRemoteCameraTrack: specifies whether to subscribe to remote camera streams.

    - (void)configRemoteCameraTrack:(NSString *)uid preferMaster:(BOOL)master enable:(BOOL)enable;
    Parameter description
    ParameterTypeDescription
    uidNSString *The ID of the user.
    masterBOOLYES indicates a subscription to a major stream, and NO indicates a subscription to a minor stream. The default value is to subscribe to a large stream.
    enableBOOLYES is to subscribe to the remote camera stream, and NO is to stop subscribing to the remote camera stream. The default value is No Subscription.
    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.

    - (void)configLocalCameraPublish:(BOOL)enable;
    Parameter description
    ParameterTypeDescription
    enableBOOLYES is allowed to publish camera streams, and NO 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.