2012-06-05 12:25:35 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2012 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.
|
|
|
|
|
*/
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MODULES_REMOTE_BITRATE_ESTIMATOR_OVERUSE_DETECTOR_H_
|
|
|
|
|
#define MODULES_REMOTE_BITRATE_ESTIMATOR_OVERUSE_DETECTOR_H_
|
2012-06-05 12:25:35 +00:00
|
|
|
|
2018-10-23 12:03:01 +02:00
|
|
|
#include <stdint.h>
|
2012-06-05 12:25:35 +00:00
|
|
|
|
2022-03-29 11:04:48 +02:00
|
|
|
#include "api/field_trials_view.h"
|
2020-11-24 17:50:31 +01:00
|
|
|
#include "api/network_state_predictor.h"
|
2012-06-05 12:25:35 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2019-04-16 14:50:08 +02:00
|
|
|
bool AdaptiveThresholdExperimentIsDisabled(
|
2022-03-29 11:04:48 +02:00
|
|
|
const FieldTrialsView& key_value_config);
|
2015-07-07 04:20:34 -07:00
|
|
|
|
2012-09-21 13:20:21 +00:00
|
|
|
class OveruseDetector {
|
2012-06-05 12:25:35 +00:00
|
|
|
public:
|
2022-03-29 11:04:48 +02:00
|
|
|
explicit OveruseDetector(const FieldTrialsView* key_value_config);
|
2015-07-07 04:20:34 -07:00
|
|
|
virtual ~OveruseDetector();
|
2012-06-05 12:25:35 +00:00
|
|
|
|
2022-01-21 09:49:39 +09:00
|
|
|
OveruseDetector(const OveruseDetector&) = delete;
|
|
|
|
|
OveruseDetector& operator=(const OveruseDetector&) = delete;
|
|
|
|
|
|
2014-12-04 15:34:06 +00:00
|
|
|
// Update the detection state based on the estimated inter-arrival time delta
|
2021-07-28 20:29:52 +02:00
|
|
|
// offset. `timestamp_delta` is the delta between the last timestamp which the
|
2014-12-04 15:34:06 +00:00
|
|
|
// estimated offset is based on and the last timestamp on which the last
|
|
|
|
|
// offset was based on, representing the time between detector updates.
|
2021-07-28 20:29:52 +02:00
|
|
|
// `num_of_deltas` is the number of deltas the offset estimate is based on.
|
2014-12-04 15:34:06 +00:00
|
|
|
// Returns the state after the detection update.
|
2015-04-10 10:35:30 +02:00
|
|
|
BandwidthUsage Detect(double offset,
|
|
|
|
|
double timestamp_delta,
|
|
|
|
|
int num_of_deltas,
|
|
|
|
|
int64_t now_ms);
|
2012-10-29 16:06:08 +00:00
|
|
|
|
2014-12-04 15:34:06 +00:00
|
|
|
// Returns the current detector state.
|
|
|
|
|
BandwidthUsage State() const;
|
2012-09-21 13:20:21 +00:00
|
|
|
|
2014-12-04 15:34:06 +00:00
|
|
|
private:
|
2015-07-07 04:20:34 -07:00
|
|
|
void UpdateThreshold(double modified_offset, int64_t now_ms);
|
2022-03-29 11:04:48 +02:00
|
|
|
void InitializeExperiment(const FieldTrialsView& key_value_config);
|
2015-07-07 04:20:34 -07:00
|
|
|
|
2016-02-16 18:22:21 +01:00
|
|
|
bool in_experiment_;
|
2015-07-07 04:20:34 -07:00
|
|
|
double k_up_;
|
|
|
|
|
double k_down_;
|
|
|
|
|
double overusing_time_threshold_;
|
2012-06-05 12:25:35 +00:00
|
|
|
double threshold_;
|
2015-07-07 04:20:34 -07:00
|
|
|
int64_t last_update_ms_;
|
2012-06-26 10:47:04 +00:00
|
|
|
double prev_offset_;
|
|
|
|
|
double time_over_using_;
|
2014-12-04 15:34:06 +00:00
|
|
|
int overuse_counter_;
|
2012-06-05 12:25:35 +00:00
|
|
|
BandwidthUsage hypothesis_;
|
|
|
|
|
};
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MODULES_REMOTE_BITRATE_ESTIMATOR_OVERUSE_DETECTOR_H_
|