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 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 std::unique_ptr<FecControllerPlrBased> controller; | 49 std::unique_ptr<FecControllerPlrBased> controller; |
50 MockSmoothingFilter* packet_loss_smoother; | 50 MockSmoothingFilter* packet_loss_smoother; |
51 }; | 51 }; |
52 | 52 |
53 FecControllerPlrBasedTestStates CreateFecControllerPlrBased( | 53 FecControllerPlrBasedTestStates CreateFecControllerPlrBased( |
54 bool initial_fec_enabled) { | 54 bool initial_fec_enabled) { |
55 FecControllerPlrBasedTestStates states; | 55 FecControllerPlrBasedTestStates states; |
56 std::unique_ptr<MockSmoothingFilter> mock_smoothing_filter( | 56 std::unique_ptr<MockSmoothingFilter> mock_smoothing_filter( |
57 new NiceMock<MockSmoothingFilter>()); | 57 new NiceMock<MockSmoothingFilter>()); |
58 states.packet_loss_smoother = mock_smoothing_filter.get(); | 58 states.packet_loss_smoother = mock_smoothing_filter.get(); |
59 using Threshold = FecControllerPlrBased::Config::Threshold; | |
60 states.controller.reset(new FecControllerPlrBased( | 59 states.controller.reset(new FecControllerPlrBased( |
61 FecControllerPlrBased::Config( | 60 FecControllerPlrBased::Config( |
62 initial_fec_enabled, | 61 initial_fec_enabled, |
63 Threshold(kEnablingBandwidthLow, kEnablingPacketLossAtLowBw, | 62 ThresholdCurve(kEnablingBandwidthLow, kEnablingPacketLossAtLowBw, |
64 kEnablingBandwidthHigh, kEnablingPacketLossAtHighBw), | 63 kEnablingBandwidthHigh, kEnablingPacketLossAtHighBw), |
65 Threshold(kDisablingBandwidthLow, kDisablingPacketLossAtLowBw, | 64 ThresholdCurve(kDisablingBandwidthLow, kDisablingPacketLossAtLowBw, |
66 kDisablingBandwidthHigh, kDisablingPacketLossAtHighBw), | 65 kDisablingBandwidthHigh, kDisablingPacketLossAtHighBw), |
67 0, nullptr), | 66 0, nullptr), |
68 std::move(mock_smoothing_filter))); | 67 std::move(mock_smoothing_filter))); |
69 return states; | 68 return states; |
70 } | 69 } |
71 | 70 |
72 void UpdateNetworkMetrics(FecControllerPlrBasedTestStates* states, | 71 void UpdateNetworkMetrics(FecControllerPlrBasedTestStates* states, |
73 const rtc::Optional<int>& uplink_bandwidth_bps, | 72 const rtc::Optional<int>& uplink_bandwidth_bps, |
74 const rtc::Optional<float>& uplink_packet_loss) { | 73 const rtc::Optional<float>& uplink_packet_loss) { |
75 // UpdateNetworkMetrics can accept multiple network metric updates at once. | 74 // UpdateNetworkMetrics can accept multiple network metric updates at once. |
76 // However, currently, the most used case is to update one metric at a time. | 75 // However, currently, the most used case is to update one metric at a time. |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 // | | D|_______ | 305 // | | D|_______ |
307 // | A|___B______ | 306 // | A|___B______ |
308 // |-----------------> bandwidth | 307 // |-----------------> bandwidth |
309 | 308 |
310 constexpr int kEnablingBandwidthHigh = kEnablingBandwidthLow; | 309 constexpr int kEnablingBandwidthHigh = kEnablingBandwidthLow; |
311 constexpr float kDisablingPacketLossAtLowBw = kDisablingPacketLossAtHighBw; | 310 constexpr float kDisablingPacketLossAtLowBw = kDisablingPacketLossAtHighBw; |
312 FecControllerPlrBasedTestStates states; | 311 FecControllerPlrBasedTestStates states; |
313 std::unique_ptr<MockSmoothingFilter> mock_smoothing_filter( | 312 std::unique_ptr<MockSmoothingFilter> mock_smoothing_filter( |
314 new NiceMock<MockSmoothingFilter>()); | 313 new NiceMock<MockSmoothingFilter>()); |
315 states.packet_loss_smoother = mock_smoothing_filter.get(); | 314 states.packet_loss_smoother = mock_smoothing_filter.get(); |
316 using Threshold = FecControllerPlrBased::Config::Threshold; | |
317 states.controller.reset(new FecControllerPlrBased( | 315 states.controller.reset(new FecControllerPlrBased( |
318 FecControllerPlrBased::Config( | 316 FecControllerPlrBased::Config( |
319 true, | 317 true, |
320 Threshold(kEnablingBandwidthLow, kEnablingPacketLossAtLowBw, | 318 ThresholdCurve(kEnablingBandwidthLow, kEnablingPacketLossAtLowBw, |
321 kEnablingBandwidthHigh, kEnablingPacketLossAtHighBw), | 319 kEnablingBandwidthHigh, kEnablingPacketLossAtHighBw), |
322 Threshold(kDisablingBandwidthLow, kDisablingPacketLossAtLowBw, | 320 ThresholdCurve(kDisablingBandwidthLow, kDisablingPacketLossAtLowBw, |
323 kDisablingBandwidthHigh, kDisablingPacketLossAtHighBw), | 321 kDisablingBandwidthHigh, kDisablingPacketLossAtHighBw), |
324 0, nullptr), | 322 0, nullptr), |
325 std::move(mock_smoothing_filter))); | 323 std::move(mock_smoothing_filter))); |
326 | 324 |
327 UpdateNetworkMetrics(&states, rtc::Optional<int>(kDisablingBandwidthLow - 1), | 325 UpdateNetworkMetrics(&states, rtc::Optional<int>(kDisablingBandwidthLow - 1), |
328 rtc::Optional<float>(1.0)); | 326 rtc::Optional<float>(1.0)); |
329 CheckDecision(&states, false, 1.0); | 327 CheckDecision(&states, false, 1.0); |
330 | 328 |
331 UpdateNetworkMetrics( | 329 UpdateNetworkMetrics( |
332 &states, rtc::Optional<int>(kEnablingBandwidthLow), | 330 &states, rtc::Optional<int>(kEnablingBandwidthLow), |
333 rtc::Optional<float>(kEnablingPacketLossAtHighBw * 0.99f)); | 331 rtc::Optional<float>(kEnablingPacketLossAtHighBw * 0.99f)); |
(...skipping 12 matching lines...) Expand all Loading... |
346 rtc::Optional<float>(0.0)); | 344 rtc::Optional<float>(0.0)); |
347 CheckDecision(&states, false, 0.0); | 345 CheckDecision(&states, false, 0.0); |
348 } | 346 } |
349 | 347 |
350 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) | 348 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) |
351 TEST(FecControllerPlrBasedDeathTest, InvalidConfig) { | 349 TEST(FecControllerPlrBasedDeathTest, InvalidConfig) { |
352 FecControllerPlrBasedTestStates states; | 350 FecControllerPlrBasedTestStates states; |
353 std::unique_ptr<MockSmoothingFilter> mock_smoothing_filter( | 351 std::unique_ptr<MockSmoothingFilter> mock_smoothing_filter( |
354 new NiceMock<MockSmoothingFilter>()); | 352 new NiceMock<MockSmoothingFilter>()); |
355 states.packet_loss_smoother = mock_smoothing_filter.get(); | 353 states.packet_loss_smoother = mock_smoothing_filter.get(); |
356 using Threshold = FecControllerPlrBased::Config::Threshold; | |
357 EXPECT_DEATH( | 354 EXPECT_DEATH( |
358 states.controller.reset(new FecControllerPlrBased( | 355 states.controller.reset(new FecControllerPlrBased( |
359 FecControllerPlrBased::Config( | 356 FecControllerPlrBased::Config( |
360 true, | 357 true, |
361 Threshold(kDisablingBandwidthLow - 1, kEnablingPacketLossAtLowBw, | 358 ThresholdCurve(kDisablingBandwidthLow - 1, |
362 kEnablingBandwidthHigh, kEnablingPacketLossAtHighBw), | 359 kEnablingPacketLossAtLowBw, kEnablingBandwidthHigh, |
363 Threshold(kDisablingBandwidthLow, kDisablingPacketLossAtLowBw, | 360 kEnablingPacketLossAtHighBw), |
364 kDisablingBandwidthHigh, kDisablingPacketLossAtHighBw), | 361 ThresholdCurve( |
| 362 kDisablingBandwidthLow, kDisablingPacketLossAtLowBw, |
| 363 kDisablingBandwidthHigh, kDisablingPacketLossAtHighBw), |
365 0, nullptr), | 364 0, nullptr), |
366 std::move(mock_smoothing_filter))), | 365 std::move(mock_smoothing_filter))), |
367 "Check failed"); | 366 "Check failed"); |
368 } | 367 } |
369 #endif | 368 #endif |
370 | 369 |
371 } // namespace webrtc | 370 } // namespace webrtc |
OLD | NEW |