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_THEIL_SEN_ESTIMATOR_H_ | |
11 #define WEBRTC_MODULES_CONGESTION_CONTROLLER_THEIL_SEN_ESTIMATOR_H_ | |
12 | |
13 #include <list> | |
14 #include <utility> | |
15 | |
16 #include "webrtc/base/analytics/percentile_filter.h" | |
17 #include "webrtc/base/constructormagic.h" | |
18 #include "webrtc/common_types.h" | |
19 | |
20 namespace webrtc { | |
21 | |
22 class TheilSenEstimator { | |
23 public: | |
24 // |window_size| is the number of points required to compute a trend line. | |
25 // |threshold_gain| is used to scale the trendline slope for comparison to | |
26 // the old threshold. Once the old estimator has been removed (or the | |
27 // thresholds been merged into the estimators), we can just set the | |
28 // threshold instead of setting a gain. | |
brandtr
2016/11/28 16:27:19
I.e., the gain would be unity when the old estimat
terelius
2016/12/02 16:45:52
Yes, but we might want a parameter to set the init
brandtr
2016/12/05 12:34:44
Right.
| |
29 TheilSenEstimator(size_t window_size, double threshold_gain); | |
30 ~TheilSenEstimator(); | |
31 | |
32 // Update the estimator with a new sample. The deltas should represent deltas | |
33 // between timestamp groups as defined by the InterArrival class. | |
34 void Update(double recv_delta_ms, double send_delta_ms, double now_ms); | |
35 | |
36 // Returns the estimated trend k multiplied by some gain. | |
37 // 0 < k < 1 -> the delay increases, queues are filling up | |
38 // k == 0 -> the delay does not change | |
39 // k < 0 -> the delay decreases, queues are being emptied | |
brandtr
2016/11/28 16:27:20
Why is |k| not lower bounded by -1, when it is upp
terelius
2016/12/02 16:45:52
It depends on whose clock we are using for the x-a
| |
40 double trendline_slope() const { return trendline_ * threshold_gain_; } | |
41 | |
42 // Returns the number of deltas which the current estimator state is based on. | |
43 unsigned int num_of_deltas() const { return num_of_deltas_; } | |
brandtr
2016/11/28 16:27:19
size_t?
terelius
2016/12/02 16:45:52
I agree that size_t would be better, but the resul
brandtr
2016/12/05 12:34:44
Acknowledged.
| |
44 | |
45 private: | |
46 // Parameters. | |
47 const size_t window_size_; | |
48 const double threshold_gain_; | |
49 // Used by the existing threshold. | |
50 unsigned int num_of_deltas_; | |
51 // Theil-Sen robust line fitting | |
52 double accumulated_delay_; | |
53 std::list<std::pair<double, double>> delay_hist_; | |
54 PercentileFilter<double> median_filter_; | |
55 double trendline_; | |
56 | |
57 RTC_DISALLOW_COPY_AND_ASSIGN(TheilSenEstimator); | |
58 }; | |
59 } // namespace webrtc | |
60 | |
61 #endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_THEIL_SEN_ESTIMATOR_H_ | |
OLD | NEW |