OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 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 |
(...skipping 30 matching lines...) Expand all Loading... |
41 | 41 |
42 uint32_t GetTargetBitrateBpsPct(float pct) { | 42 uint32_t GetTargetBitrateBpsPct(float pct) { |
43 return pct * adjuster_.GetTargetBitrateBps(); | 43 return pct * adjuster_.GetTargetBitrateBps(); |
44 } | 44 } |
45 | 45 |
46 void VerifyAdjustment() { | 46 void VerifyAdjustment() { |
47 // The adjusted bitrate should be between the estimated bitrate and the | 47 // The adjusted bitrate should be between the estimated bitrate and the |
48 // target bitrate within clamp. | 48 // target bitrate within clamp. |
49 uint32_t target_bitrate_bps = adjuster_.GetTargetBitrateBps(); | 49 uint32_t target_bitrate_bps = adjuster_.GetTargetBitrateBps(); |
50 uint32_t adjusted_bitrate_bps = adjuster_.GetAdjustedBitrateBps(); | 50 uint32_t adjusted_bitrate_bps = adjuster_.GetAdjustedBitrateBps(); |
51 uint32_t estimated_bitrate_bps = adjuster_.GetEstimatedBitrateBps(); | 51 uint32_t estimated_bitrate_bps = |
| 52 adjuster_.GetEstimatedBitrateBps().value_or(target_bitrate_bps); |
52 uint32_t adjusted_lower_bound_bps = | 53 uint32_t adjusted_lower_bound_bps = |
53 GetTargetBitrateBpsPct(kMinAdjustedBitratePct); | 54 GetTargetBitrateBpsPct(kMinAdjustedBitratePct); |
54 uint32_t adjusted_upper_bound_bps = | 55 uint32_t adjusted_upper_bound_bps = |
55 GetTargetBitrateBpsPct(kMaxAdjustedBitratePct); | 56 GetTargetBitrateBpsPct(kMaxAdjustedBitratePct); |
56 EXPECT_LE(adjusted_bitrate_bps, adjusted_upper_bound_bps); | 57 EXPECT_LE(adjusted_bitrate_bps, adjusted_upper_bound_bps); |
57 EXPECT_GE(adjusted_bitrate_bps, adjusted_lower_bound_bps); | 58 EXPECT_GE(adjusted_bitrate_bps, adjusted_lower_bound_bps); |
58 if (estimated_bitrate_bps > target_bitrate_bps) { | 59 if (estimated_bitrate_bps > target_bitrate_bps) { |
59 EXPECT_LT(adjusted_bitrate_bps, target_bitrate_bps); | 60 EXPECT_LT(adjusted_bitrate_bps, target_bitrate_bps); |
60 } | 61 } |
61 } | 62 } |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 EXPECT_EQ(initial_target_bitrate_bps, adjuster_.GetAdjustedBitrateBps()); | 160 EXPECT_EQ(initial_target_bitrate_bps, adjuster_.GetAdjustedBitrateBps()); |
160 | 161 |
161 // 1.05 * 1.05 is 1.1 which is greater than tolerance for the initial target | 162 // 1.05 * 1.05 is 1.1 which is greater than tolerance for the initial target |
162 // bitrate. Since we didn't advance the clock the adjuster never updated. | 163 // bitrate. Since we didn't advance the clock the adjuster never updated. |
163 target_bitrate_bps = (1 + delta_pct) * target_bitrate_bps; | 164 target_bitrate_bps = (1 + delta_pct) * target_bitrate_bps; |
164 adjuster_.SetTargetBitrateBps(target_bitrate_bps); | 165 adjuster_.SetTargetBitrateBps(target_bitrate_bps); |
165 EXPECT_EQ(target_bitrate_bps, adjuster_.GetAdjustedBitrateBps()); | 166 EXPECT_EQ(target_bitrate_bps, adjuster_.GetAdjustedBitrateBps()); |
166 } | 167 } |
167 | 168 |
168 } // namespace webrtc | 169 } // namespace webrtc |
OLD | NEW |