OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 #include "webrtc/modules/congestion_controller/probing_interval_estimator.h" | 11 #include "webrtc/modules/congestion_controller/probing_interval_estimator.h" |
12 | 12 |
13 #include <algorithm> | 13 #include <algorithm> |
14 #include <utility> | 14 #include <utility> |
15 | 15 |
16 namespace webrtc { | 16 namespace webrtc { |
17 | 17 |
18 namespace { | 18 namespace { |
19 constexpr int kMinIntervalMs = 2000; | 19 constexpr int kMinIntervalMs = 2000; |
| 20 constexpr int kDefaultIntervalMs = 3000; |
20 constexpr int kMaxIntervalMs = 50000; | 21 constexpr int kMaxIntervalMs = 50000; |
21 } | 22 } |
22 | 23 |
23 ProbingIntervalEstimator::ProbingIntervalEstimator( | 24 ProbingIntervalEstimator::ProbingIntervalEstimator( |
24 const AimdRateControl* aimd_rate_control) | 25 const AimdRateControl* aimd_rate_control) |
25 : ProbingIntervalEstimator(kMinIntervalMs, | 26 : ProbingIntervalEstimator(kMinIntervalMs, |
26 kMaxIntervalMs, | 27 kMaxIntervalMs, |
| 28 kDefaultIntervalMs, |
27 aimd_rate_control) {} | 29 aimd_rate_control) {} |
28 | 30 |
29 ProbingIntervalEstimator::ProbingIntervalEstimator( | 31 ProbingIntervalEstimator::ProbingIntervalEstimator( |
30 int min_interval_ms, | 32 int64_t min_interval_ms, |
31 int max_interval_ms, | 33 int64_t max_interval_ms, |
| 34 int64_t default_interval_ms, |
32 const AimdRateControl* aimd_rate_control) | 35 const AimdRateControl* aimd_rate_control) |
33 : min_interval_ms_(min_interval_ms), | 36 : min_interval_ms_(min_interval_ms), |
34 max_interval_ms_(max_interval_ms), | 37 max_interval_ms_(max_interval_ms), |
| 38 default_interval_ms_(default_interval_ms), |
35 aimd_rate_control_(aimd_rate_control) {} | 39 aimd_rate_control_(aimd_rate_control) {} |
36 | 40 |
37 rtc::Optional<int> ProbingIntervalEstimator::GetIntervalMs() const { | 41 int64_t ProbingIntervalEstimator::GetIntervalMs() const { |
38 rtc::Optional<int> bitrate_drop = | 42 rtc::Optional<int> bitrate_drop = |
39 aimd_rate_control_->GetLastBitrateDecreaseBps(); | 43 aimd_rate_control_->GetLastBitrateDecreaseBps(); |
40 int increase_rate = aimd_rate_control_->GetNearMaxIncreaseRateBps(); | 44 int increase_rate = aimd_rate_control_->GetNearMaxIncreaseRateBps(); |
41 | 45 |
42 if (!bitrate_drop || increase_rate <= 0) | 46 if (!bitrate_drop || increase_rate <= 0) |
43 return rtc::Optional<int>(); | 47 return default_interval_ms_; |
44 | 48 |
45 return rtc::Optional<int>(std::min( | 49 return std::min( |
46 max_interval_ms_, | 50 max_interval_ms_, |
47 std::max(1000 * (*bitrate_drop) / increase_rate, min_interval_ms_))); | 51 std::max(static_cast<int64_t>(1000 * (*bitrate_drop) / increase_rate), |
| 52 min_interval_ms_)); |
48 } | 53 } |
49 | 54 |
50 } // namespace webrtc | 55 } // namespace webrtc |
OLD | NEW |