logo
On this page

Traffic Control

2024-11-13

Feature Overview

Traffic control refers to the SDK dynamically adjusting the video publishing bitrate based on the local and remote current network status, automatically adapting to the current network environment and network fluctuations, thereby ensuring smooth audio/video pushing.

Usage Steps

1 Enable Traffic Control

When publishing a stream, call the startPublishingStream interface and enable traffic control through the enableTrafficControl parameter to dynamically adjust the video publishing bitrate and automatically adapt to the current network environment and network fluctuations. If traffic control is disabled, stuttering may occur when network bandwidth is insufficient.

Warning

Usage Limitation: Only supports RTC streaming.

// Enable traffic control
zg.startPublishingStream(streamID, stream, {
    enableTrafficControl: true
};

2 (Optional) Set Trigger Factors for Traffic Control

When enabling traffic control, you can set the factors of concern through the trafficControlFocusOnMode parameter.

  • TrafficControlFocusOnLocalOnly: Only focus on local network, i.e., do not consider remote network status, only perform traffic control based on local network.
  • TrafficControlFocusOnRemote: Focus on local network and also take into account remote network, currently only effective in 1v1 scenarios. That is, when there is only one RTC publishing stream, and only one RTC playing stream or only one L3 playing stream, SDK will automatically enable downstream traffic control. The playing end notifies the publishing end of its network situation, the publishing end estimates its own upstream bandwidth and the playing end's downstream bandwidth, and takes the minimum value from the upstream and downstream bandwidth estimates to adjust its own upstream bitrate, ensuring smooth connection.
// Enable traffic control, set trigger factors for traffic control
zg.startPublishingStream(streamID, stream, {
    enableTrafficControl: true,
    trafficControlFocusOnMode: 0
};

3 Set Traffic Control Video Bitrate Minimum Value (Can be Skipped in Audio-only Scenarios)

When enabling traffic control, you can set the video bitrate minimum value (default value is "0") and sending mode through the trafficControlMinVideoBitrate parameter, allowing the SDK to send at a very low frame rate when the network does not reach the minimum bitrate for sending video.

// Enable traffic control, traffic control video bitrate
zg.startPublishingStream(streamID, stream, {
    enableTrafficControl: true,
    trafficControlMinVideoBitrate: 200
};

Previous

Supplemental Enhancement Information (SEI)

Next

Cloud Proxy

On this page

Back to top