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

Side by Side Diff: webrtc/modules/audio_coding/audio_network_adaptor/fec_controller_rplr_based_unittest.cc

Issue 2688613003: Introduce ThresholdCurve (avoids code duplication between PLR/RPLR-based FecController) (Closed)
Patch Set: . Created 3 years, 8 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
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 if (distribution(generator) < 0.2) { 51 if (distribution(generator) < 0.2) {
52 return rtc::Optional<float>(); 52 return rtc::Optional<float>();
53 } else { 53 } else {
54 return rtc::Optional<float>(distribution(generator)); 54 return rtc::Optional<float>(distribution(generator));
55 } 55 }
56 } 56 }
57 57
58 std::unique_ptr<FecControllerRplrBased> CreateFecControllerRplrBased( 58 std::unique_ptr<FecControllerRplrBased> CreateFecControllerRplrBased(
59 bool initial_fec_enabled) { 59 bool initial_fec_enabled) {
60 using Threshold = FecControllerRplrBased::Config::Threshold;
61 return std::unique_ptr<FecControllerRplrBased>( 60 return std::unique_ptr<FecControllerRplrBased>(
62 new FecControllerRplrBased(FecControllerRplrBased::Config( 61 new FecControllerRplrBased(FecControllerRplrBased::Config(
63 initial_fec_enabled, 62 initial_fec_enabled,
64 Threshold( 63 ThresholdCurve(
65 kEnablingBandwidthLow, kEnablingRecoverablePacketLossAtLowBw, 64 kEnablingBandwidthLow, kEnablingRecoverablePacketLossAtLowBw,
66 kEnablingBandwidthHigh, kEnablingRecoverablePacketLossAtHighBw), 65 kEnablingBandwidthHigh, kEnablingRecoverablePacketLossAtHighBw),
67 Threshold(kDisablingBandwidthLow, 66 ThresholdCurve(kDisablingBandwidthLow,
68 kDisablingRecoverablePacketLossAtLowBw, 67 kDisablingRecoverablePacketLossAtLowBw,
69 kDisablingBandwidthHigh, 68 kDisablingBandwidthHigh,
70 kDisablingRecoverablePacketLossAtHighBw)))); 69 kDisablingRecoverablePacketLossAtHighBw))));
71 } 70 }
72 71
73 void UpdateNetworkMetrics( 72 void UpdateNetworkMetrics(
74 FecControllerRplrBased* controller, 73 FecControllerRplrBased* controller,
75 const rtc::Optional<int>& uplink_bandwidth_bps, 74 const rtc::Optional<int>& uplink_bandwidth_bps,
76 const rtc::Optional<float>& uplink_packet_loss, 75 const rtc::Optional<float>& uplink_packet_loss,
77 const rtc::Optional<float>& uplink_recoveralbe_packet_loss) { 76 const rtc::Optional<float>& uplink_recoveralbe_packet_loss) {
78 // UpdateNetworkMetrics can accept multiple network metric updates at once. 77 // UpdateNetworkMetrics can accept multiple network metric updates at once.
79 // However, currently, the most used case is to update one metric at a time. 78 // However, currently, the most used case is to update one metric at a time.
80 // To reflect this fact, we separate the calls. 79 // To reflect this fact, we separate the calls.
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 // packet-loss | | | 353 // packet-loss | | |
355 // | | C| 354 // | | C|
356 // | | | 355 // | | |
357 // | | D|_______ 356 // | | D|_______
358 // | A|___B______ 357 // | A|___B______
359 // |-----------------> bandwidth 358 // |-----------------> bandwidth
360 359
361 constexpr int kEnablingBandwidthHigh = kEnablingBandwidthLow; 360 constexpr int kEnablingBandwidthHigh = kEnablingBandwidthLow;
362 constexpr float kDisablingRecoverablePacketLossAtLowBw = 361 constexpr float kDisablingRecoverablePacketLossAtLowBw =
363 kDisablingRecoverablePacketLossAtHighBw; 362 kDisablingRecoverablePacketLossAtHighBw;
364 using Threshold = FecControllerRplrBased::Config::Threshold;
365 FecControllerRplrBased controller(FecControllerRplrBased::Config( 363 FecControllerRplrBased controller(FecControllerRplrBased::Config(
366 true, 364 true,
367 Threshold(kEnablingBandwidthLow, kEnablingRecoverablePacketLossAtLowBw, 365 ThresholdCurve(
368 kEnablingBandwidthHigh, kEnablingRecoverablePacketLossAtHighBw), 366 kEnablingBandwidthLow, kEnablingRecoverablePacketLossAtLowBw,
369 Threshold(kDisablingBandwidthLow, kDisablingRecoverablePacketLossAtLowBw, 367 kEnablingBandwidthHigh, kEnablingRecoverablePacketLossAtHighBw),
370 kDisablingBandwidthHigh, 368 ThresholdCurve(
371 kDisablingRecoverablePacketLossAtHighBw))); 369 kDisablingBandwidthLow, kDisablingRecoverablePacketLossAtLowBw,
370 kDisablingBandwidthHigh, kDisablingRecoverablePacketLossAtHighBw)));
372 371
373 UpdateNetworkMetrics(&controller, 372 UpdateNetworkMetrics(&controller,
374 rtc::Optional<int>(kDisablingBandwidthLow - 1), 373 rtc::Optional<int>(kDisablingBandwidthLow - 1),
375 rtc::Optional<float>(1.0)); 374 rtc::Optional<float>(1.0));
376 CheckDecision(&controller, false, 1.0); 375 CheckDecision(&controller, false, 1.0);
377 376
378 UpdateNetworkMetrics( 377 UpdateNetworkMetrics(
379 &controller, rtc::Optional<int>(kEnablingBandwidthLow), 378 &controller, rtc::Optional<int>(kEnablingBandwidthLow),
380 rtc::Optional<float>(kEnablingRecoverablePacketLossAtHighBw * 0.99f)); 379 rtc::Optional<float>(kEnablingRecoverablePacketLossAtHighBw * 0.99f));
381 CheckDecision(&controller, false, 380 CheckDecision(&controller, false,
(...skipping 11 matching lines...) Expand all
393 kDisablingRecoverablePacketLossAtHighBw * 1.01f); 392 kDisablingRecoverablePacketLossAtHighBw * 1.01f);
394 393
395 UpdateNetworkMetrics(&controller, 394 UpdateNetworkMetrics(&controller,
396 rtc::Optional<int>(kDisablingBandwidthHigh + 1), 395 rtc::Optional<int>(kDisablingBandwidthHigh + 1),
397 rtc::Optional<float>(0.0)); 396 rtc::Optional<float>(0.0));
398 CheckDecision(&controller, false, 0.0); 397 CheckDecision(&controller, false, 0.0);
399 } 398 }
400 399
401 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) 400 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
402 TEST(FecControllerRplrBasedDeathTest, InvalidConfig) { 401 TEST(FecControllerRplrBasedDeathTest, InvalidConfig) {
403 using Threshold = FecControllerRplrBased::Config::Threshold;
404 EXPECT_DEATH( 402 EXPECT_DEATH(
405 FecControllerRplrBased controller(FecControllerRplrBased::Config( 403 FecControllerRplrBased controller(FecControllerRplrBased::Config(
406 true, 404 true,
407 Threshold( 405 ThresholdCurve(
408 kDisablingBandwidthLow - 1, kEnablingRecoverablePacketLossAtLowBw, 406 kDisablingBandwidthLow - 1, kEnablingRecoverablePacketLossAtLowBw,
409 kEnablingBandwidthHigh, kEnablingRecoverablePacketLossAtHighBw), 407 kEnablingBandwidthHigh, kEnablingRecoverablePacketLossAtHighBw),
410 Threshold(kDisablingBandwidthLow, 408 ThresholdCurve(kDisablingBandwidthLow,
411 kDisablingRecoverablePacketLossAtLowBw, 409 kDisablingRecoverablePacketLossAtLowBw,
412 kDisablingBandwidthHigh, 410 kDisablingBandwidthHigh,
413 kDisablingRecoverablePacketLossAtHighBw))), 411 kDisablingRecoverablePacketLossAtHighBw))),
414 "Check failed"); 412 "Check failed");
415 } 413 }
416 #endif 414 #endif
417 415
418 } // namespace webrtc 416 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698