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
|
|
|
|
2024-08-29 13:00:40 +00:00
|
|
|
#include <optional>
|
|
|
|
|
|
2022-03-29 11:04:48 +02:00
|
|
|
#include "api/field_trials_view.h"
|
2019-03-27 16:24:09 +01:00
|
|
|
#include "api/units/data_rate.h"
|
2023-09-06 13:22:20 +02:00
|
|
|
#include "api/units/data_size.h"
|
2019-06-20 12:26:31 +02:00
|
|
|
#include "api/units/timestamp.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:
|
2022-03-29 11:04:48 +02:00
|
|
|
explicit BitrateEstimator(const FieldTrialsView* key_value_config);
|
2018-02-27 17:07:02 +01:00
|
|
|
virtual ~BitrateEstimator();
|
2019-06-20 12:26:31 +02:00
|
|
|
virtual void Update(Timestamp at_time, DataSize amount, bool in_alr);
|
2018-02-27 17:07:02 +01:00
|
|
|
|
2024-08-29 13:00:40 +00:00
|
|
|
virtual std::optional<DataRate> bitrate() const;
|
|
|
|
|
std::optional<DataRate> PeekRate() const;
|
2018-02-27 17:07:02 +01:00
|
|
|
|
|
|
|
|
virtual void ExpectFastRateChange();
|
|
|
|
|
|
|
|
|
|
private:
|
2019-11-21 15:19:40 +01:00
|
|
|
float UpdateWindow(int64_t now_ms,
|
|
|
|
|
int bytes,
|
|
|
|
|
int rate_window_ms,
|
|
|
|
|
bool* is_small_sample);
|
2018-02-27 17:07:02 +01:00
|
|
|
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_;
|
2019-05-29 13:54:20 +02:00
|
|
|
FieldTrialParameter<double> uncertainty_scale_in_alr_;
|
2019-11-21 15:19:40 +01:00
|
|
|
FieldTrialParameter<double> small_sample_uncertainty_scale_;
|
|
|
|
|
FieldTrialParameter<DataSize> small_sample_threshold_;
|
2019-03-27 16:24:09 +01:00
|
|
|
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_
|