OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (c) 2016 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 WEBRTC_MODULES_CONGESTION_CONTROLLER_TRENDLINE_ESTIMATOR_H_ | |
11 #define WEBRTC_MODULES_CONGESTION_CONTROLLER_TRENDLINE_ESTIMATOR_H_ | |
12 | |
13 #include <list> | |
14 #include <utility> | |
15 | |
16 #include "webrtc/base/constructormagic.h" | |
17 #include "webrtc/common_types.h" | |
18 #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h" | |
19 | |
20 namespace webrtc { | |
21 | |
22 class TrendlineEstimator { | |
23 public: | |
24 // |window_size| is the number of points required to compute a trend_line | |
25 // |smoothing_coef| controls how the much we smooth out the delay | |
stefan-webrtc
2016/11/13 13:09:53
how much
terelius
2016/11/14 13:21:39
Done.
| |
26 // before fitting the trendline. |threashold_gain| is used to scale the | |
stefan-webrtc
2016/11/13 13:09:53
threshold_gain
terelius
2016/11/14 13:21:39
Done.
| |
27 // trendline slope for comparison to the old threshold. | |
stefan-webrtc
2016/11/13 13:09:53
Maybe add a comment that the threshold gain perhap
terelius
2016/11/14 13:21:39
Done.
| |
28 TrendlineEstimator(size_t window_size, | |
29 double smoothing_coef, | |
30 double threshold_gain); | |
31 ~TrendlineEstimator(); | |
32 | |
33 // Update the estimator with a new sample. The deltas should represent deltas | |
34 // between timestamp groups as defined by the InterArrival class. | |
35 void Update(double recv_delta_ms, double send_delta_ms, int64_t now_ms); | |
36 | |
37 // Returns the estimated trend k multiplied by some gain. | |
38 // 0 < k < 1 -> the delay increases, queues are filling up | |
39 // k == 0 -> the delay does not change | |
40 // -1 < k < 0 -> the delay decreases, queues are being emptied | |
41 double trendline_slope() const { return trendline_ * threshold_gain_; } | |
42 | |
43 // Returns the number of deltas which the current estimator state is based on. | |
44 unsigned int num_of_deltas() const { return num_of_deltas_; } | |
45 | |
46 private: | |
47 // Parameters. | |
48 const size_t window_size_; | |
49 const double smoothing_coef_; | |
50 const double threshold_gain_; | |
51 // Used by the existing threshold. | |
52 unsigned int num_of_deltas_; | |
stefan-webrtc
2016/11/13 13:09:53
Can we use an int instead?
terelius
2016/11/14 13:21:39
Yes except that the Kalman filter uses an unsigned
stefan-webrtc
2016/11/14 13:30:58
Ah, feel free to keep for now.
| |
53 // Exponential backoff filtering. | |
54 double accumulated_delay_; | |
55 double smoothed_delay_; | |
56 double last_smoothed_delay_; | |
57 // Linear least squares regression. | |
58 std::list<std::pair<int64_t, double>> accumulated_delay_hist_; | |
59 double sum_x_; | |
60 double sum_y_; | |
61 double sum_xy_; | |
62 double sum_x2_; | |
63 double trendline_; | |
64 | |
65 RTC_DISALLOW_COPY_AND_ASSIGN(TrendlineEstimator); | |
66 }; | |
67 } // namespace webrtc | |
68 | |
69 #endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_TRENDLINE_ESTIMATOR_H_ | |
OLD | NEW |