Unverified 提交 abfd942f authored 作者: Gustavo Garcia's avatar Gustavo Garcia 提交者: GitHub

Upgrade trendline estimator to improve low bandwidth conditions (#1055)

* Uprade trendline estimator to improve low bandwidth conditions

* Missing constant change
上级 937bb6c8
...@@ -61,7 +61,7 @@ DelayBasedBwe::DelayBasedBwe(const WebRtcKeyValueConfig* key_value_config, ...@@ -61,7 +61,7 @@ DelayBasedBwe::DelayBasedBwe(const WebRtcKeyValueConfig* key_value_config,
network_state_predictor_(network_state_predictor), network_state_predictor_(network_state_predictor),
inter_arrival_(), inter_arrival_(),
delay_detector_( delay_detector_(
new TrendlineEstimator(key_value_config_, network_state_predictor_)), new TrendlineEstimator(network_state_predictor_)),
last_seen_packet_(Timestamp::MinusInfinity()), last_seen_packet_(Timestamp::MinusInfinity()),
uma_recorded_(false), uma_recorded_(false),
rate_control_(key_value_config, /*send_side=*/true), rate_control_(key_value_config, /*send_side=*/true),
...@@ -127,7 +127,7 @@ void DelayBasedBwe::IncomingPacketFeedback(const PacketResult& packet_feedback, ...@@ -127,7 +127,7 @@ void DelayBasedBwe::IncomingPacketFeedback(const PacketResult& packet_feedback,
new InterArrival((kTimestampGroupLengthMs << kInterArrivalShift) / 1000, new InterArrival((kTimestampGroupLengthMs << kInterArrivalShift) / 1000,
kTimestampToMs, true)); kTimestampToMs, true));
delay_detector_.reset( delay_detector_.reset(
new TrendlineEstimator(key_value_config_, network_state_predictor_)); new TrendlineEstimator(network_state_predictor_));
} }
last_seen_packet_ = at_time; last_seen_packet_ = at_time;
......
...@@ -10,37 +10,48 @@ ...@@ -10,37 +10,48 @@
#ifndef MODULES_CONGESTION_CONTROLLER_GOOG_CC_TRENDLINE_ESTIMATOR_H_ #ifndef MODULES_CONGESTION_CONTROLLER_GOOG_CC_TRENDLINE_ESTIMATOR_H_
#define MODULES_CONGESTION_CONTROLLER_GOOG_CC_TRENDLINE_ESTIMATOR_H_ #define MODULES_CONGESTION_CONTROLLER_GOOG_CC_TRENDLINE_ESTIMATOR_H_
#include <stddef.h>
#include <stdint.h>
#include <deque>
#include <memory>
#include <utility>
#include "api/network_state_predictor.h" #include "api/network_state_predictor.h"
#include "api/transport/webrtc_key_value_config.h" #include "api/transport/webrtc_key_value_config.h"
#include "modules/congestion_controller/goog_cc/delay_increase_detector_interface.h" #include "modules/congestion_controller/goog_cc/delay_increase_detector_interface.h"
#include "modules/remote_bitrate_estimator/include/bwe_defines.h" #include "modules/remote_bitrate_estimator/include/bwe_defines.h"
#include "rtc_base/constructor_magic.h" #include "rtc_base/constructor_magic.h"
#include <stddef.h>
#include <stdint.h>
#include <deque>
#include <utility>
namespace webrtc { namespace webrtc {
struct TrendlineEstimatorSettings {
static constexpr unsigned kDefaultTrendlineWindowSize = 20;
// Sort the packets in the window. Should be redundant,
// but then almost no cost.
bool enable_sort = false;
// Cap the trendline slope based on the minimum delay seen
// in the beginning_packets and end_packets respectively.
bool enable_cap = false;
unsigned beginning_packets = 7;
unsigned end_packets = 7;
double cap_uncertainty = 0.0;
// Size (in packets) of the window.
unsigned window_size = kDefaultTrendlineWindowSize;
};
class TrendlineEstimator : public DelayIncreaseDetectorInterface { class TrendlineEstimator : public DelayIncreaseDetectorInterface {
public: public:
TrendlineEstimator(const WebRtcKeyValueConfig* key_value_config, TrendlineEstimator(NetworkStatePredictor* network_state_predictor);
NetworkStatePredictor* network_state_predictor);
// |window_size| is the number of points required to compute a trend line.
// |smoothing_coef| controls how much we smooth out the delay before fitting
// the trend line. |threshold_gain| is used to scale the trendline slope for
// comparison to the old threshold. Once the old estimator has been removed
// (or the thresholds been merged into the estimators), we can just set the
// threshold instead of setting a gain.|network_state_predictor| is used to
// bettter predict network state.
TrendlineEstimator(size_t window_size,
double smoothing_coef,
double threshold_gain,
NetworkStatePredictor* network_state_predictor);
~TrendlineEstimator() override; ~TrendlineEstimator() override;
TrendlineEstimator(const TrendlineEstimator&) = delete;
TrendlineEstimator& operator=(const TrendlineEstimator&) = delete;
// Update the estimator with a new sample. The deltas should represent deltas // Update the estimator with a new sample. The deltas should represent deltas
// between timestamp groups as defined by the InterArrival class. // between timestamp groups as defined by the InterArrival class.
void Update(double recv_delta_ms, void Update(double recv_delta_ms,
...@@ -49,21 +60,33 @@ class TrendlineEstimator : public DelayIncreaseDetectorInterface { ...@@ -49,21 +60,33 @@ class TrendlineEstimator : public DelayIncreaseDetectorInterface {
int64_t arrival_time_ms, int64_t arrival_time_ms,
bool calculated_deltas) override; bool calculated_deltas) override;
void UpdateTrendline(double recv_delta_ms,
double send_delta_ms,
int64_t send_time_ms,
int64_t arrival_time_ms);
BandwidthUsage State() const override; BandwidthUsage State() const override;
protected: struct PacketTiming {
// Used in unit tests. PacketTiming(double arrival_time_ms,
double modified_trend() const { return prev_trend_ * threshold_gain_; } double smoothed_delay_ms,
double raw_delay_ms)
: arrival_time_ms(arrival_time_ms),
smoothed_delay_ms(smoothed_delay_ms),
raw_delay_ms(raw_delay_ms) {}
double arrival_time_ms;
double smoothed_delay_ms;
double raw_delay_ms;
};
private: private:
friend class GoogCcStatePrinter; friend class GoogCcStatePrinter;
void Detect(double trend, double ts_delta, int64_t now_ms); void Detect(double trend, double ts_delta, int64_t now_ms);
void UpdateThreshold(double modified_offset, int64_t now_ms); void UpdateThreshold(double modified_offset, int64_t now_ms);
// Parameters. // Parameters.
const size_t window_size_; TrendlineEstimatorSettings settings_;
const double smoothing_coef_; const double smoothing_coef_;
const double threshold_gain_; const double threshold_gain_;
// Used by the existing threshold. // Used by the existing threshold.
...@@ -74,7 +97,7 @@ class TrendlineEstimator : public DelayIncreaseDetectorInterface { ...@@ -74,7 +97,7 @@ class TrendlineEstimator : public DelayIncreaseDetectorInterface {
double accumulated_delay_; double accumulated_delay_;
double smoothed_delay_; double smoothed_delay_;
// Linear least squares regression. // Linear least squares regression.
std::deque<std::pair<double, double>> delay_hist_; std::deque<PacketTiming> delay_hist_;
const double k_up_; const double k_up_;
const double k_down_; const double k_down_;
...@@ -88,8 +111,6 @@ class TrendlineEstimator : public DelayIncreaseDetectorInterface { ...@@ -88,8 +111,6 @@ class TrendlineEstimator : public DelayIncreaseDetectorInterface {
BandwidthUsage hypothesis_; BandwidthUsage hypothesis_;
BandwidthUsage hypothesis_predicted_; BandwidthUsage hypothesis_predicted_;
NetworkStatePredictor* network_state_predictor_; NetworkStatePredictor* network_state_predictor_;
RTC_DISALLOW_COPY_AND_ASSIGN(TrendlineEstimator);
}; };
} // namespace webrtc } // namespace webrtc
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论