overuse_detector.h (1883B)
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/transport/bandwidth_usage.h" 16 17 namespace webrtc { 18 19 class OveruseDetector { 20 public: 21 OveruseDetector(); 22 23 OveruseDetector(const OveruseDetector&) = delete; 24 OveruseDetector& operator=(const OveruseDetector&) = delete; 25 26 ~OveruseDetector() = default; 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 45 double threshold_ = 12.5; 46 int64_t last_update_ms_ = -1; 47 double prev_offset_ = 0.0; 48 double time_over_using_ = -1; 49 int overuse_counter_ = 0; 50 BandwidthUsage hypothesis_ = BandwidthUsage::kBwNormal; 51 }; 52 } // namespace webrtc 53 54 #endif // MODULES_REMOTE_BITRATE_ESTIMATOR_OVERUSE_DETECTOR_H_