| OLD | NEW |
| 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 | 17 |
| 18 #include "webrtc/rtc_base/optional.h" | 18 #include "webrtc/rtc_base/optional.h" |
| 19 | 19 |
| 20 namespace webrtc { | 20 namespace webrtc { |
| 21 namespace testing { | 21 namespace testing { |
| 22 namespace bwe { | 22 namespace bwe { |
| 23 |
| 24 // Expiration time for min_rtt sample, which is set to 10 seconds according to |
| 25 // BBR design doc. |
| 26 const int64_t kMinRttFilterSizeMs = 10000; |
| 27 |
| 23 class MinRttFilter { | 28 class MinRttFilter { |
| 24 public: | 29 public: |
| 25 MinRttFilter() {} | 30 MinRttFilter() {} |
| 26 ~MinRttFilter() {} | 31 ~MinRttFilter() {} |
| 27 | 32 |
| 28 rtc::Optional<int64_t> min_rtt_ms() { return min_rtt_ms_; } | 33 rtc::Optional<int64_t> min_rtt_ms() { return min_rtt_ms_; } |
| 29 void add_rtt_sample(int64_t rtt_ms, int64_t now_ms) { | 34 void AddRttSample(int64_t rtt_ms, int64_t now_ms) { |
| 30 if (!min_rtt_ms_ || rtt_ms <= *min_rtt_ms_) { | 35 if (!min_rtt_ms_ || rtt_ms <= *min_rtt_ms_ || MinRttExpired(now_ms)) { |
| 31 min_rtt_ms_.emplace(rtt_ms); | 36 min_rtt_ms_.emplace(rtt_ms); |
| 32 discovery_time_ms_ = now_ms; | 37 discovery_time_ms_ = now_ms; |
| 33 } | 38 } |
| 34 } | 39 } |
| 35 int64_t discovery_time() { return discovery_time_ms_; } | 40 int64_t discovery_time() { return discovery_time_ms_; } |
| 36 | 41 |
| 37 // Checks whether or not last discovered min_rtt value is older than x | 42 // Checks whether or not last discovered min_rtt value is older than x |
| 38 // milliseconds. | 43 // milliseconds. |
| 39 bool min_rtt_expired(int64_t now_ms, int64_t min_rtt_filter_window_size_ms) { | 44 bool MinRttExpired(int64_t now_ms) { |
| 40 return now_ms - discovery_time_ms_ >= min_rtt_filter_window_size_ms; | 45 return now_ms - discovery_time_ms_ >= kMinRttFilterSizeMs; |
| 41 } | 46 } |
| 42 | 47 |
| 43 private: | 48 private: |
| 44 rtc::Optional<int64_t> min_rtt_ms_; | 49 rtc::Optional<int64_t> min_rtt_ms_; |
| 45 int64_t discovery_time_ms_ = 0; | 50 int64_t discovery_time_ms_ = 0; |
| 46 }; | 51 }; |
| 47 } // namespace bwe | 52 } // namespace bwe |
| 48 } // namespace testing | 53 } // namespace testing |
| 49 } // namespace webrtc | 54 } // namespace webrtc |
| 50 | 55 |
| 51 #endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_ESTIMATORS_MIN_RTT_FILTE
R_H_ | 56 #endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_ESTIMATORS_MIN_RTT_FILTE
R_H_ |
| OLD | NEW |