• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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  */
10 #ifndef MODULES_REMOTE_BITRATE_ESTIMATOR_OVERUSE_DETECTOR_H_
11 #define MODULES_REMOTE_BITRATE_ESTIMATOR_OVERUSE_DETECTOR_H_
12 
13 #include <stdint.h>
14 
15 #include "api/field_trials_view.h"
16 #include "api/network_state_predictor.h"
17 
18 namespace webrtc {
19 
20 class OveruseDetector {
21  public:
22   explicit OveruseDetector(const FieldTrialsView* key_value_config);
23   virtual ~OveruseDetector();
24 
25   OveruseDetector(const OveruseDetector&) = delete;
26   OveruseDetector& operator=(const OveruseDetector&) = delete;
27 
28   // Update the detection state based on the estimated inter-arrival time delta
29   // offset. `timestamp_delta` is the delta between the last timestamp which the
30   // estimated offset is based on and the last timestamp on which the last
31   // offset was based on, representing the time between detector updates.
32   // `num_of_deltas` is the number of deltas the offset estimate is based on.
33   // Returns the state after the detection update.
34   BandwidthUsage Detect(double offset,
35                         double timestamp_delta,
36                         int num_of_deltas,
37                         int64_t now_ms);
38 
39   // Returns the current detector state.
40   BandwidthUsage State() const;
41 
42  private:
43   void UpdateThreshold(double modified_offset, int64_t now_ms);
44   void InitializeExperiment(const FieldTrialsView& key_value_config);
45 
46   const double k_up_;
47   const double k_down_;
48   const double overusing_time_threshold_;
49   double threshold_;
50   int64_t last_update_ms_;
51   double prev_offset_;
52   double time_over_using_;
53   int overuse_counter_;
54   BandwidthUsage hypothesis_;
55 };
56 }  // namespace webrtc
57 
58 #endif  // MODULES_REMOTE_BITRATE_ESTIMATOR_OVERUSE_DETECTOR_H_
59