Unverified 提交 47147afe authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo 提交者: GitHub

TransportCongestionControlClient: make usage of TrendCalculator for desired bitrate optional (#956)

上级 237fd62f
#define MS_CLASS "RTC::TransportCongestionControlClient" #define MS_CLASS "RTC::TransportCongestionControlClient"
// #define MS_LOG_DEV_LEVEL 3 // #define MS_LOG_DEV_LEVEL 3
#define USE_TREND_CALCULATOR
#include "RTC/TransportCongestionControlClient.hpp" #include "RTC/TransportCongestionControlClient.hpp"
#include "DepLibUV.hpp" #include "DepLibUV.hpp"
...@@ -111,12 +112,17 @@ namespace RTC ...@@ -111,12 +112,17 @@ namespace RTC
{ {
MS_TRACE(); MS_TRACE();
#ifdef USE_TREND_CALCULATOR
auto nowMs = DepLibUV::GetTimeMsInt64(); auto nowMs = DepLibUV::GetTimeMsInt64();
#endif
this->bitrates.desiredBitrate = 0u; this->bitrates.desiredBitrate = 0u;
this->bitrates.effectiveDesiredBitrate = 0u; this->bitrates.effectiveDesiredBitrate = 0u;
#ifdef USE_TREND_CALCULATOR
this->desiredBitrateTrend.ForceUpdate(0u, nowMs); this->desiredBitrateTrend.ForceUpdate(0u, nowMs);
#endif
this->rtpTransportControllerSend->OnNetworkAvailability(false); this->rtpTransportControllerSend->OnNetworkAvailability(false);
} }
...@@ -279,16 +285,26 @@ namespace RTC ...@@ -279,16 +285,26 @@ namespace RTC
{ {
MS_TRACE(); MS_TRACE();
#ifdef USE_TREND_CALCULATOR
auto nowMs = DepLibUV::GetTimeMsInt64(); auto nowMs = DepLibUV::GetTimeMsInt64();
#endif
// Manage it via trending and increase it a bit to avoid immediate oscillations. // Manage it via trending and increase it a bit to avoid immediate oscillations.
#ifdef USE_TREND_CALCULATOR
if (!force) if (!force)
this->desiredBitrateTrend.Update(desiredBitrate, nowMs); this->desiredBitrateTrend.Update(desiredBitrate, nowMs);
else else
this->desiredBitrateTrend.ForceUpdate(desiredBitrate, nowMs); this->desiredBitrateTrend.ForceUpdate(desiredBitrate, nowMs);
#endif
this->bitrates.desiredBitrate = desiredBitrate; this->bitrates.desiredBitrate = desiredBitrate;
#ifdef USE_TREND_CALCULATOR
this->bitrates.effectiveDesiredBitrate = this->desiredBitrateTrend.GetValue(); this->bitrates.effectiveDesiredBitrate = this->desiredBitrateTrend.GetValue();
#else
this->bitrates.effectiveDesiredBitrate = desiredBitrate;
#endif
this->bitrates.minBitrate = RTC::TransportCongestionControlMinOutgoingBitrate; this->bitrates.minBitrate = RTC::TransportCongestionControlMinOutgoingBitrate;
// NOTE: Setting 'startBitrate' to 'availableBitrate' has proven to generate // NOTE: Setting 'startBitrate' to 'availableBitrate' has proven to generate
// more stable values. // more stable values.
...@@ -303,11 +319,19 @@ namespace RTC ...@@ -303,11 +319,19 @@ namespace RTC
auto currentMaxBitrate = this->bitrates.maxBitrate; auto currentMaxBitrate = this->bitrates.maxBitrate;
uint32_t newMaxBitrate = 0; uint32_t newMaxBitrate = 0;
#ifdef USE_TREND_CALCULATOR
if (this->desiredBitrateTrend.GetValue() > 0u) if (this->desiredBitrateTrend.GetValue() > 0u)
#else
if (this->bitrates.desiredBitrate > 0u)
#endif
{ {
newMaxBitrate = std::max<uint32_t>( newMaxBitrate = std::max<uint32_t>(
this->initialAvailableBitrate, this->initialAvailableBitrate,
#ifdef USE_TREND_CALCULATOR
this->desiredBitrateTrend.GetValue() * MaxBitrateIncrementFactor); this->desiredBitrateTrend.GetValue() * MaxBitrateIncrementFactor);
#else
this->bitrates.desiredBitrate * MaxBitrateIncrementFactor);
#endif
// If max bitrate requested didn't change by more than a small % keep the previous settings // If max bitrate requested didn't change by more than a small % keep the previous settings
// to avoid constant small fluctuations requiring extra probing and making the estimation // to avoid constant small fluctuations requiring extra probing and making the estimation
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论