2018-02-27 17:07:02 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2018-02-28 16:48:00 +01:00
|
|
|
#ifndef MODULES_CONGESTION_CONTROLLER_GOOG_CC_BITRATE_ESTIMATOR_H_
|
|
|
|
|
#define MODULES_CONGESTION_CONTROLLER_GOOG_CC_BITRATE_ESTIMATOR_H_
|
2018-02-27 17:07:02 +01:00
|
|
|
|
2018-10-23 12:03:01 +02:00
|
|
|
#include <stdint.h>
|
2018-02-27 17:07:02 +01:00
|
|
|
|
2018-06-18 10:48:16 +02:00
|
|
|
#include "absl/types/optional.h"
|
2019-01-17 16:24:12 +01:00
|
|
|
#include "api/transport/webrtc_key_value_config.h"
|
2019-03-27 16:24:09 +01:00
|
|
|
#include "api/units/data_rate.h"
|
2019-01-31 16:41:07 +01:00
|
|
|
#include "rtc_base/experiments/field_trial_parser.h"
|
2018-02-27 17:07:02 +01:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
// Computes a bayesian estimate of the throughput given acks containing
|
|
|
|
|
// the arrival time and payload size. Samples which are far from the current
|
|
|
|
|
// estimate or are based on few packets are given a smaller weight, as they
|
|
|
|
|
// are considered to be more likely to have been caused by, e.g., delay spikes
|
|
|
|
|
// unrelated to congestion.
|
|
|
|
|
class BitrateEstimator {
|
|
|
|
|
public:
|
2019-01-17 16:24:12 +01:00
|
|
|
explicit BitrateEstimator(const WebRtcKeyValueConfig* key_value_config);
|
2018-02-27 17:07:02 +01:00
|
|
|
virtual ~BitrateEstimator();
|
|
|
|
|
virtual void Update(int64_t now_ms, int bytes);
|
|
|
|
|
|
2018-06-18 10:48:16 +02:00
|
|
|
virtual absl::optional<uint32_t> bitrate_bps() const;
|
2018-11-12 10:24:25 +01:00
|
|
|
absl::optional<uint32_t> PeekBps() const;
|
2018-02-27 17:07:02 +01:00
|
|
|
|
|
|
|
|
virtual void ExpectFastRateChange();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
float UpdateWindow(int64_t now_ms, int bytes, int rate_window_ms);
|
|
|
|
|
int sum_;
|
2019-01-31 16:41:07 +01:00
|
|
|
FieldTrialConstrained<int> initial_window_ms_;
|
|
|
|
|
FieldTrialConstrained<int> noninitial_window_ms_;
|
2019-03-27 16:24:09 +01:00
|
|
|
FieldTrialParameter<double> uncertainty_scale_;
|
|
|
|
|
FieldTrialParameter<DataRate> uncertainty_symmetry_cap_;
|
|
|
|
|
FieldTrialParameter<DataRate> estimate_floor_;
|
2018-07-04 17:03:55 +02:00
|
|
|
int64_t current_window_ms_;
|
2018-02-27 17:07:02 +01:00
|
|
|
int64_t prev_time_ms_;
|
2019-03-27 16:24:09 +01:00
|
|
|
float bitrate_estimate_kbps_;
|
2018-02-27 17:07:02 +01:00
|
|
|
float bitrate_estimate_var_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2018-02-28 16:48:00 +01:00
|
|
|
#endif // MODULES_CONGESTION_CONTROLLER_GOOG_CC_BITRATE_ESTIMATOR_H_
|