overuse_estimator.h (2162B)
1 /* 2 * Copyright (c) 2013 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_ESTIMATOR_H_ 11 #define MODULES_REMOTE_BITRATE_ESTIMATOR_OVERUSE_ESTIMATOR_H_ 12 13 #include <stdint.h> 14 15 #include <deque> 16 17 #include "api/transport/bandwidth_usage.h" 18 19 namespace webrtc { 20 21 class OveruseEstimator { 22 public: 23 OveruseEstimator(); 24 25 OveruseEstimator(const OveruseEstimator&) = delete; 26 OveruseEstimator& operator=(const OveruseEstimator&) = delete; 27 28 ~OveruseEstimator() = default; 29 30 // Update the estimator with a new sample. The deltas should represent deltas 31 // between timestamp groups as defined by the InterArrival class. 32 // `current_hypothesis` should be the hypothesis of the over-use detector at 33 // this time. 34 void Update(int64_t t_delta, 35 double ts_delta, 36 int size_delta, 37 BandwidthUsage current_hypothesis, 38 int64_t now_ms); 39 40 // Returns the estimated noise/jitter variance in ms^2. 41 double var_noise() const { return var_noise_; } 42 43 // Returns the estimated inter-arrival time delta offset in ms. 44 double offset() const { return offset_; } 45 46 // Returns the number of deltas which the current over-use estimator state is 47 // based on. 48 int num_of_deltas() const { return num_of_deltas_; } 49 50 private: 51 double UpdateMinFramePeriod(double ts_delta); 52 void UpdateNoiseEstimate(double residual, double ts_delta, bool stable_state); 53 54 int num_of_deltas_ = 0; 55 double slope_ = 8.0 / 512.0; 56 double offset_ = 0; 57 double prev_offset_ = 0; 58 double E_[2][2] = {{100.0, 0.0}, {0.0, 1e-1}}; 59 double process_noise_[2] = {1e-13, 1e-3}; 60 double avg_noise_ = 0.0; 61 double var_noise_ = 50.0; 62 std::deque<double> ts_delta_hist_; 63 }; 64 } // namespace webrtc 65 66 #endif // MODULES_REMOTE_BITRATE_ESTIMATOR_OVERUSE_ESTIMATOR_H_