blob: d1c6aa8d307f0f73fb9053bda1f6c39ac2d07f4f [file] [log] [blame]
bjornv@webrtc.orgcb89c6f2012-06-05 12:25:351/*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
Mirko Bonadei92ea95e2017-09-15 04:47:3110#ifndef MODULES_REMOTE_BITRATE_ESTIMATOR_OVERUSE_DETECTOR_H_
11#define MODULES_REMOTE_BITRATE_ESTIMATOR_OVERUSE_DETECTOR_H_
bjornv@webrtc.orgcb89c6f2012-06-05 12:25:3512
Yves Gerey988cc082018-10-23 10:03:0113#include <stdint.h>
bjornv@webrtc.orgcb89c6f2012-06-05 12:25:3514
Niels Möller0d863f72020-11-24 16:50:3115#include "api/network_state_predictor.h"
Per Kjellander494947b2019-04-16 12:50:0816#include "api/transport/webrtc_key_value_config.h"
Steve Anton10542f22019-01-11 17:11:0017#include "rtc_base/constructor_magic.h"
bjornv@webrtc.orgcb89c6f2012-06-05 12:25:3518
bjornv@webrtc.orgcb89c6f2012-06-05 12:25:3519namespace webrtc {
bjornv@webrtc.orgcb89c6f2012-06-05 12:25:3520
Per Kjellander494947b2019-04-16 12:50:0821bool AdaptiveThresholdExperimentIsDisabled(
22 const WebRtcKeyValueConfig& key_value_config);
stefanc62642c2015-07-07 11:20:3423
stefan@webrtc.org976a7e62012-09-21 13:20:2124class OveruseDetector {
bjornv@webrtc.orgcb89c6f2012-06-05 12:25:3525 public:
Per Kjellander494947b2019-04-16 12:50:0826 explicit OveruseDetector(const WebRtcKeyValueConfig* key_value_config);
stefanc62642c2015-07-07 11:20:3427 virtual ~OveruseDetector();
pbos@webrtc.org9f79fe62014-12-04 15:34:0628
29 // Update the detection state based on the estimated inter-arrival time delta
Artem Titov1fd7af52021-07-28 18:29:5230 // offset. `timestamp_delta` is the delta between the last timestamp which the
pbos@webrtc.org9f79fe62014-12-04 15:34:0631 // estimated offset is based on and the last timestamp on which the last
32 // offset was based on, representing the time between detector updates.
Artem Titov1fd7af52021-07-28 18:29:5233 // `num_of_deltas` is the number of deltas the offset estimate is based on.
pbos@webrtc.org9f79fe62014-12-04 15:34:0634 // Returns the state after the detection update.
Stefan Holmerdcbd3ac2015-04-10 08:35:3035 BandwidthUsage Detect(double offset,
36 double timestamp_delta,
37 int num_of_deltas,
38 int64_t now_ms);
pbos@webrtc.org9f79fe62014-12-04 15:34:0639
40 // Returns the current detector state.
bjornv@webrtc.orgcb89c6f2012-06-05 12:25:3541 BandwidthUsage State() const;
pbos@webrtc.org9f79fe62014-12-04 15:34:0642
bjornv@webrtc.orgcb89c6f2012-06-05 12:25:3543 private:
stefanc62642c2015-07-07 11:20:3444 void UpdateThreshold(double modified_offset, int64_t now_ms);
Per Kjellander494947b2019-04-16 12:50:0845 void InitializeExperiment(const WebRtcKeyValueConfig& key_value_config);
stefanc62642c2015-07-07 11:20:3446
Stefan Holmer44c65e92016-02-16 17:22:2147 bool in_experiment_;
stefanc62642c2015-07-07 11:20:3448 double k_up_;
49 double k_down_;
50 double overusing_time_threshold_;
bjornv@webrtc.orgcb89c6f2012-06-05 12:25:3551 double threshold_;
stefanc62642c2015-07-07 11:20:3452 int64_t last_update_ms_;
astor@webrtc.orgbd7aeba2012-06-26 10:47:0453 double prev_offset_;
54 double time_over_using_;
pbos@webrtc.org9f79fe62014-12-04 15:34:0655 int overuse_counter_;
bjornv@webrtc.orgcb89c6f2012-06-05 12:25:3556 BandwidthUsage hypothesis_;
pbos@webrtc.org9f79fe62014-12-04 15:34:0657
henrikg3c089d72015-09-16 12:37:4458 RTC_DISALLOW_COPY_AND_ASSIGN(OveruseDetector);
bjornv@webrtc.orgcb89c6f2012-06-05 12:25:3559};
60} // namespace webrtc
61
Mirko Bonadei92ea95e2017-09-15 04:47:3162#endif // MODULES_REMOTE_BITRATE_ESTIMATOR_OVERUSE_DETECTOR_H_