Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: webrtc/modules/remote_bitrate_estimator/test/estimators/min_rtt_filter.h

Issue 2999073002: Tweaked version of BBR for WebRTC. (Closed)
Patch Set: Updated according to comments. Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 * 9 *
10 */ 10 */
11 11
12 #ifndef WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_ESTIMATORS_MIN_RTT_FILTER_H _ 12 #ifndef WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_ESTIMATORS_MIN_RTT_FILTER_H _
13 #define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_ESTIMATORS_MIN_RTT_FILTER_H _ 13 #define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_ESTIMATORS_MIN_RTT_FILTER_H _
14 14
15 #include <cstdint> 15 #include <cstdint>
16 #include <limits> 16 #include <limits>
17 #include <list>
17 18
18 #include "webrtc/rtc_base/optional.h" 19 #include "webrtc/rtc_base/optional.h"
19 20
20 namespace webrtc { 21 namespace webrtc {
21 namespace testing { 22 namespace testing {
22 namespace bwe { 23 namespace bwe {
23 24
24 // Expiration time for min_rtt sample, which is set to 10 seconds according to 25 // Expiration time for min_rtt sample, which is set to 10 seconds according to
philipel 2017/08/18 11:22:15 Update comment
gnish1 2017/08/18 11:48:42 Done.
25 // BBR design doc. 26 // BBR design doc.
26 const int64_t kMinRttFilterSizeMs = 10000; 27 const float kRttIncreaseThresholdForExpiry = 2.3f;
28 const size_t kRttFilterSize = 25;
27 29
28 class MinRttFilter { 30 class MinRttFilter {
philipel 2017/08/18 11:22:15 Add a comment about what this class does, and why
gnish1 2017/08/18 11:48:43 Done.
29 public: 31 public:
30 MinRttFilter() {} 32 MinRttFilter() {}
31 ~MinRttFilter() {} 33 ~MinRttFilter() {}
32 34
33 rtc::Optional<int64_t> min_rtt_ms() { return min_rtt_ms_; } 35 rtc::Optional<int64_t> min_rtt_ms() { return min_rtt_ms_; }
34 void AddRttSample(int64_t rtt_ms, int64_t now_ms) { 36 void AddRttSample(int64_t rtt_ms, int64_t now_ms) {
35 if (!min_rtt_ms_ || rtt_ms <= *min_rtt_ms_ || MinRttExpired(now_ms)) { 37 if (!min_rtt_ms_ || rtt_ms <= *min_rtt_ms_ || MinRttExpired(now_ms)) {
36 min_rtt_ms_.emplace(rtt_ms); 38 min_rtt_ms_.emplace(rtt_ms);
37 discovery_time_ms_ = now_ms;
38 } 39 }
40 rtt_samples_.push_back(rtt_ms);
41 if (rtt_samples_.size() > kRttFilterSize)
42 rtt_samples_.pop_front();
39 } 43 }
40 int64_t discovery_time() { return discovery_time_ms_; }
41 44
42 // Checks whether or not last discovered min_rtt value is older than x 45 // Checks whether or not last discovered min_rtt value is older than x
philipel 2017/08/18 11:22:15 Edit comment.
gnish1 2017/08/18 11:48:42 Done.
43 // milliseconds. 46 // milliseconds.
44 bool MinRttExpired(int64_t now_ms) { 47 bool MinRttExpired(int64_t now_ms) {
45 return now_ms - discovery_time_ms_ >= kMinRttFilterSizeMs; 48 if (rtt_samples_.size() < kRttFilterSize || !min_rtt_ms_)
49 return false;
50 int64_t sum_of_rtts_ms = 0;
51 for (int64_t i : rtt_samples_)
52 sum_of_rtts_ms += i;
53 if (sum_of_rtts_ms >=
54 *min_rtt_ms_ * kRttIncreaseThresholdForExpiry * kRttFilterSize) {
55 rtt_samples_.clear();
56 return true;
57 }
58 return false;
46 } 59 }
47 60
48 private: 61 private:
49 rtc::Optional<int64_t> min_rtt_ms_; 62 rtc::Optional<int64_t> min_rtt_ms_;
50 int64_t discovery_time_ms_ = 0; 63 std::list<int64_t> rtt_samples_;
51 }; 64 };
52 } // namespace bwe 65 } // namespace bwe
53 } // namespace testing 66 } // namespace testing
54 } // namespace webrtc 67 } // namespace webrtc
55 68
56 #endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_ESTIMATORS_MIN_RTT_FILTE R_H_ 69 #endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_ESTIMATORS_MIN_RTT_FILTE R_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698