ant-media/Ant-Media-Server

Excessive Bandwidth Algorithm

mekya opened this issue · 1 comments

mekya commented

WebRTC stack increased the measured bandwidth with small steps and encoder is updated according to do that. However in Ant Media Server, we've predefined bitrates and cannot be changed on the runtime according to the viewers bandwidth otherwise it's impossible to scale.

This algorithm tries to switch to higher bitrate if there is already excessive bandwidth and try to stay there is bandwidth seems to be enough to stream.

mekya commented

/**
* *******************************************************
* What is Excessive Bandwidth Algorithm?
* Excessive Bandwidth Algorithm tries to switch to higher bitrate even if bandwidth seems not enough
*
* Why is it implemented?
* WebRTC stack sometimes does not calculate the bandwidth correctly. For instance,
* when network quality drop for a few seconds, it does not calculates the bitrate correctly
*
* How it works?
* If measured bandwidth - the current video bitrate is more than {@link #excessiveBandwidthValue}
* for consecutive {@link #excessiveBandwidthCallThreshold} times it switches to higher bitrate
*
* If bandwidth measured is still than the required bandwidth it tries {@link #excessiveBandwithTryCountBeforeSwitchback}
* times to stay in the high bitrate. It also switches back to lower quality
* if packetLoss different is bigger than {@link #packetLossDiffThresholdForSwitchback} or
* rtt time difference is bigger than {@link #rttMeasurementDiffThresholdForSwitchback} before
* {@link #tryCountBeforeSwitchback} reaches to zero
*
*
* Side effect
* If network fluctuates too much or not consistent, quality of the video changes also fluctuates too much for the viewers
* *********************************************************
*/