Removes RPLR based FEC controller.
This is not used and adds a lot of maintenance overhead to
the code since it requires that the transport feedback adapter
communicates directly with audio send stream.
This also means that the packet loss tracker used as input for
this can be removed and a lot of wiring up code overall.
Bug: webrtc:9883
Change-Id: I25689fb622ed89cbb378c27212a159485f5f53be
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/156502
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Reviewed-by: Minyue Li <minyue@webrtc.org>
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29667}
diff --git a/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl.cc b/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl.cc
index 11f93e6..64163f9 100644
--- a/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl.cc
+++ b/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl.cc
@@ -72,18 +72,6 @@
UpdateNetworkMetrics(network_metrics);
}
-void AudioNetworkAdaptorImpl::SetUplinkRecoverablePacketLossFraction(
- float uplink_recoverable_packet_loss_fraction) {
- last_metrics_.uplink_recoverable_packet_loss_fraction =
- uplink_recoverable_packet_loss_fraction;
- DumpNetworkMetrics();
-
- Controller::NetworkMetrics network_metrics;
- network_metrics.uplink_recoverable_packet_loss_fraction =
- uplink_recoverable_packet_loss_fraction;
- UpdateNetworkMetrics(network_metrics);
-}
-
void AudioNetworkAdaptorImpl::SetRtt(int rtt_ms) {
last_metrics_.rtt_ms = rtt_ms;
DumpNetworkMetrics();
diff --git a/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl.h b/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl.h
index e7cd056..1c91fa1 100644
--- a/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl.h
+++ b/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl.h
@@ -48,9 +48,6 @@
void SetUplinkPacketLossFraction(float uplink_packet_loss_fraction) override;
- void SetUplinkRecoverablePacketLossFraction(
- float uplink_recoverable_packet_loss_fraction) override;
-
void SetRtt(int rtt_ms) override;
void SetTargetAudioBitrate(int target_audio_bitrate_bps) override;
diff --git a/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl_unittest.cc b/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl_unittest.cc
index 8ca26bb..606237d 100644
--- a/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl_unittest.cc
+++ b/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl_unittest.cc
@@ -41,10 +41,7 @@
arg.target_audio_bitrate_bps == metric.target_audio_bitrate_bps &&
arg.rtt_ms == metric.rtt_ms &&
arg.overhead_bytes_per_packet == metric.overhead_bytes_per_packet &&
- arg.uplink_packet_loss_fraction ==
- metric.uplink_packet_loss_fraction &&
- arg.uplink_recoverable_packet_loss_fraction ==
- metric.uplink_recoverable_packet_loss_fraction;
+ arg.uplink_packet_loss_fraction == metric.uplink_packet_loss_fraction;
}
MATCHER_P(IsRtcEventAnaConfigEqualTo, config, "") {
@@ -139,17 +136,6 @@
states.audio_network_adaptor->SetUplinkPacketLossFraction(kPacketLoss);
}
-TEST(AudioNetworkAdaptorImplTest,
- UpdateNetworkMetricsIsCalledOnSetUplinkRecoverablePacketLossFraction) {
- auto states = CreateAudioNetworkAdaptor();
- constexpr float kRecoverablePacketLoss = 0.1f;
- Controller::NetworkMetrics check;
- check.uplink_recoverable_packet_loss_fraction = kRecoverablePacketLoss;
- SetExpectCallToUpdateNetworkMetrics(states.mock_controllers, check);
- states.audio_network_adaptor->SetUplinkRecoverablePacketLossFraction(
- kRecoverablePacketLoss);
-}
-
TEST(AudioNetworkAdaptorImplTest, UpdateNetworkMetricsIsCalledOnSetRtt) {
auto states = CreateAudioNetworkAdaptor();
constexpr int kRtt = 100;
@@ -216,7 +202,6 @@
constexpr int kBandwidth = 16000;
constexpr float kPacketLoss = 0.7f;
- const auto kRecoverablePacketLoss = 0.2f;
constexpr int kRtt = 100;
constexpr int kTargetAudioBitrate = 15000;
constexpr size_t kOverhead = 64;
@@ -238,11 +223,6 @@
fake_clock.AdvanceTime(TimeDelta::ms(50));
timestamp_check += 50;
- check.uplink_recoverable_packet_loss_fraction = kRecoverablePacketLoss;
- EXPECT_CALL(*states.mock_debug_dump_writer,
- DumpNetworkMetrics(NetworkMetricsIs(check), timestamp_check));
- states.audio_network_adaptor->SetUplinkRecoverablePacketLossFraction(
- kRecoverablePacketLoss);
fake_clock.AdvanceTime(TimeDelta::ms(200));
timestamp_check += 200;
diff --git a/modules/audio_coding/audio_network_adaptor/controller.h b/modules/audio_coding/audio_network_adaptor/controller.h
index 19d8599..b70ada0 100644
--- a/modules/audio_coding/audio_network_adaptor/controller.h
+++ b/modules/audio_coding/audio_network_adaptor/controller.h
@@ -23,7 +23,6 @@
~NetworkMetrics();
absl::optional<int> uplink_bandwidth_bps;
absl::optional<float> uplink_packet_loss_fraction;
- absl::optional<float> uplink_recoverable_packet_loss_fraction;
absl::optional<int> target_audio_bitrate_bps;
absl::optional<int> rtt_ms;
absl::optional<size_t> overhead_bytes_per_packet;
diff --git a/modules/audio_coding/audio_network_adaptor/controller_manager.cc b/modules/audio_coding/audio_network_adaptor/controller_manager.cc
index f22df54..c7aad1d 100644
--- a/modules/audio_coding/audio_network_adaptor/controller_manager.cc
+++ b/modules/audio_coding/audio_network_adaptor/controller_manager.cc
@@ -19,10 +19,10 @@
#include "modules/audio_coding/audio_network_adaptor/debug_dump_writer.h"
#include "modules/audio_coding/audio_network_adaptor/dtx_controller.h"
#include "modules/audio_coding/audio_network_adaptor/fec_controller_plr_based.h"
-#include "modules/audio_coding/audio_network_adaptor/fec_controller_rplr_based.h"
#include "modules/audio_coding/audio_network_adaptor/frame_length_controller.h"
#include "modules/audio_coding/audio_network_adaptor/util/threshold_curve.h"
#include "rtc_base/ignore_wundef.h"
+#include "rtc_base/logging.h"
#include "rtc_base/time_utils.h"
#if WEBRTC_ENABLE_PROTOBUF
@@ -74,43 +74,6 @@
config.time_constant_ms())));
}
-std::unique_ptr<FecControllerRplrBased> CreateFecControllerRplrBased(
- const audio_network_adaptor::config::FecControllerRplrBased& config,
- bool initial_fec_enabled) {
- RTC_CHECK(config.has_fec_enabling_threshold());
- RTC_CHECK(config.has_fec_disabling_threshold());
-
- auto& fec_enabling_threshold = config.fec_enabling_threshold();
- RTC_CHECK(fec_enabling_threshold.has_low_bandwidth_bps());
- RTC_CHECK(fec_enabling_threshold.has_low_bandwidth_recoverable_packet_loss());
- RTC_CHECK(fec_enabling_threshold.has_high_bandwidth_bps());
- RTC_CHECK(
- fec_enabling_threshold.has_high_bandwidth_recoverable_packet_loss());
-
- auto& fec_disabling_threshold = config.fec_disabling_threshold();
- RTC_CHECK(fec_disabling_threshold.has_low_bandwidth_bps());
- RTC_CHECK(
- fec_disabling_threshold.has_low_bandwidth_recoverable_packet_loss());
- RTC_CHECK(fec_disabling_threshold.has_high_bandwidth_bps());
- RTC_CHECK(
- fec_disabling_threshold.has_high_bandwidth_recoverable_packet_loss());
-
- return std::unique_ptr<FecControllerRplrBased>(
- new FecControllerRplrBased(FecControllerRplrBased::Config(
- initial_fec_enabled,
- ThresholdCurve(
- fec_enabling_threshold.low_bandwidth_bps(),
- fec_enabling_threshold.low_bandwidth_recoverable_packet_loss(),
- fec_enabling_threshold.high_bandwidth_bps(),
- fec_enabling_threshold.high_bandwidth_recoverable_packet_loss()),
- ThresholdCurve(
- fec_disabling_threshold.low_bandwidth_bps(),
- fec_disabling_threshold.low_bandwidth_recoverable_packet_loss(),
- fec_disabling_threshold.high_bandwidth_bps(),
- fec_disabling_threshold
- .high_bandwidth_recoverable_packet_loss()))));
-}
-
std::unique_ptr<FrameLengthController> CreateFrameLengthController(
const audio_network_adaptor::config::FrameLengthController& config,
rtc::ArrayView<const int> encoder_frame_lengths_ms,
@@ -291,9 +254,9 @@
controller_config.fec_controller(), initial_fec_enabled);
break;
case audio_network_adaptor::config::Controller::kFecControllerRplrBased:
- controller = CreateFecControllerRplrBased(
- controller_config.fec_controller_rplr_based(), initial_fec_enabled);
- break;
+ // FecControllerRplrBased has been removed and can't be used anymore.
+ RTC_NOTREACHED();
+ continue;
case audio_network_adaptor::config::Controller::kFrameLengthController:
controller = CreateFrameLengthController(
controller_config.frame_length_controller(),
diff --git a/modules/audio_coding/audio_network_adaptor/debug_dump_writer.cc b/modules/audio_coding/audio_network_adaptor/debug_dump_writer.cc
index 6daefa5..669cf5e 100644
--- a/modules/audio_coding/audio_network_adaptor/debug_dump_writer.cc
+++ b/modules/audio_coding/audio_network_adaptor/debug_dump_writer.cc
@@ -105,11 +105,6 @@
if (metrics.rtt_ms)
dump_metrics->set_rtt_ms(*metrics.rtt_ms);
- if (metrics.uplink_recoverable_packet_loss_fraction) {
- dump_metrics->set_uplink_recoverable_packet_loss_fraction(
- *metrics.uplink_recoverable_packet_loss_fraction);
- }
-
DumpEventToFile(event, &dump_file_);
#endif // WEBRTC_ENABLE_PROTOBUF
}
diff --git a/modules/audio_coding/audio_network_adaptor/fec_controller_rplr_based.cc b/modules/audio_coding/audio_network_adaptor/fec_controller_rplr_based.cc
deleted file mode 100644
index 6c30b8f..0000000
--- a/modules/audio_coding/audio_network_adaptor/fec_controller_rplr_based.cc
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
-
-#include "modules/audio_coding/audio_network_adaptor/fec_controller_rplr_based.h"
-
-#include "rtc_base/checks.h"
-
-namespace webrtc {
-
-FecControllerRplrBased::Config::Config(
- bool initial_fec_enabled,
- const ThresholdCurve& fec_enabling_threshold,
- const ThresholdCurve& fec_disabling_threshold)
- : initial_fec_enabled(initial_fec_enabled),
- fec_enabling_threshold(fec_enabling_threshold),
- fec_disabling_threshold(fec_disabling_threshold) {}
-
-FecControllerRplrBased::FecControllerRplrBased(const Config& config)
- : config_(config), fec_enabled_(config.initial_fec_enabled) {
- RTC_DCHECK(config_.fec_disabling_threshold <= config_.fec_enabling_threshold);
-}
-
-FecControllerRplrBased::~FecControllerRplrBased() = default;
-
-void FecControllerRplrBased::UpdateNetworkMetrics(
- const NetworkMetrics& network_metrics) {
- if (network_metrics.uplink_bandwidth_bps)
- uplink_bandwidth_bps_ = network_metrics.uplink_bandwidth_bps;
- if (network_metrics.uplink_recoverable_packet_loss_fraction) {
- uplink_recoverable_packet_loss_ =
- network_metrics.uplink_recoverable_packet_loss_fraction;
- }
-}
-
-void FecControllerRplrBased::MakeDecision(AudioEncoderRuntimeConfig* config) {
- RTC_DCHECK(!config->enable_fec);
- RTC_DCHECK(!config->uplink_packet_loss_fraction);
-
- fec_enabled_ = fec_enabled_ ? !FecDisablingDecision() : FecEnablingDecision();
-
- config->enable_fec = fec_enabled_;
- config->uplink_packet_loss_fraction =
- uplink_recoverable_packet_loss_ ? *uplink_recoverable_packet_loss_ : 0.0;
-}
-
-bool FecControllerRplrBased::FecEnablingDecision() const {
- if (!uplink_bandwidth_bps_ || !uplink_recoverable_packet_loss_) {
- return false;
- } else {
- // Enable when above the curve or exactly on it.
- return !config_.fec_enabling_threshold.IsBelowCurve(
- {static_cast<float>(*uplink_bandwidth_bps_),
- *uplink_recoverable_packet_loss_});
- }
-}
-
-bool FecControllerRplrBased::FecDisablingDecision() const {
- if (!uplink_bandwidth_bps_ || !uplink_recoverable_packet_loss_) {
- return false;
- } else {
- // Disable when below the curve.
- return config_.fec_disabling_threshold.IsBelowCurve(
- {static_cast<float>(*uplink_bandwidth_bps_),
- *uplink_recoverable_packet_loss_});
- }
-}
-
-} // namespace webrtc
diff --git a/modules/audio_coding/audio_network_adaptor/fec_controller_rplr_based.h b/modules/audio_coding/audio_network_adaptor/fec_controller_rplr_based.h
deleted file mode 100644
index c547bff..0000000
--- a/modules/audio_coding/audio_network_adaptor/fec_controller_rplr_based.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
-
-#ifndef MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_FEC_CONTROLLER_RPLR_BASED_H_
-#define MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_FEC_CONTROLLER_RPLR_BASED_H_
-
-#include "absl/types/optional.h"
-#include "modules/audio_coding/audio_network_adaptor/controller.h"
-#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h"
-#include "modules/audio_coding/audio_network_adaptor/util/threshold_curve.h"
-#include "rtc_base/constructor_magic.h"
-
-namespace webrtc {
-
-class FecControllerRplrBased final : public Controller {
- public:
- struct Config {
- // |fec_enabling_threshold| defines a curve, above which FEC should be
- // enabled. |fec_disabling_threshold| defines a curve, under which FEC
- // should be disabled. See below
- //
- // recoverable
- // packet-loss ^ | |
- // | | | FEC
- // | \ \ ON
- // | FEC \ \_______ fec_enabling_threshold
- // | OFF \_________ fec_disabling_threshold
- // |-----------------> bandwidth
- Config(bool initial_fec_enabled,
- const ThresholdCurve& fec_enabling_threshold,
- const ThresholdCurve& fec_disabling_threshold);
- bool initial_fec_enabled;
- ThresholdCurve fec_enabling_threshold;
- ThresholdCurve fec_disabling_threshold;
- };
-
- explicit FecControllerRplrBased(const Config& config);
-
- ~FecControllerRplrBased() override;
-
- void UpdateNetworkMetrics(const NetworkMetrics& network_metrics) override;
-
- void MakeDecision(AudioEncoderRuntimeConfig* config) override;
-
- private:
- bool FecEnablingDecision() const;
- bool FecDisablingDecision() const;
-
- const Config config_;
- bool fec_enabled_;
- absl::optional<int> uplink_bandwidth_bps_;
- absl::optional<float> uplink_recoverable_packet_loss_;
-
- RTC_DISALLOW_COPY_AND_ASSIGN(FecControllerRplrBased);
-};
-
-} // namespace webrtc
-
-#endif // MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_FEC_CONTROLLER_RPLR_BASED_H_
diff --git a/modules/audio_coding/audio_network_adaptor/fec_controller_rplr_based_unittest.cc b/modules/audio_coding/audio_network_adaptor/fec_controller_rplr_based_unittest.cc
deleted file mode 100644
index c51d561..0000000
--- a/modules/audio_coding/audio_network_adaptor/fec_controller_rplr_based_unittest.cc
+++ /dev/null
@@ -1,522 +0,0 @@
-/*
- * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
-
-#include "modules/audio_coding/audio_network_adaptor/fec_controller_rplr_based.h"
-
-#include <random>
-#include <utility>
-
-#include "test/gtest.h"
-
-namespace webrtc {
-
-namespace {
-
-// The test uses the following settings:
-//
-// recoverable ^
-// packet-loss | | |
-// | A| C| FEC
-// | \ \ ON
-// | FEC \ D\_______
-// | OFF B\_________
-// |-----------------> bandwidth
-//
-// A : (kDisablingBandwidthLow, kDisablingRecoverablePacketLossAtLowBw)
-// B : (kDisablingBandwidthHigh, kDisablingRecoverablePacketLossAtHighBw)
-// C : (kEnablingBandwidthLow, kEnablingRecoverablePacketLossAtLowBw)
-// D : (kEnablingBandwidthHigh, kEnablingRecoverablePacketLossAtHighBw)
-
-constexpr int kDisablingBandwidthLow = 15000;
-constexpr float kDisablingRecoverablePacketLossAtLowBw = 0.08f;
-constexpr int kDisablingBandwidthHigh = 64000;
-constexpr float kDisablingRecoverablePacketLossAtHighBw = 0.01f;
-constexpr int kEnablingBandwidthLow = 17000;
-constexpr float kEnablingRecoverablePacketLossAtLowBw = 0.1f;
-constexpr int kEnablingBandwidthHigh = 64000;
-constexpr float kEnablingRecoverablePacketLossAtHighBw = 0.05f;
-
-constexpr float kEpsilon = 1e-5f;
-
-absl::optional<float> GetRandomProbabilityOrUnknown() {
- std::random_device rd;
- std::mt19937 generator(rd());
- std::uniform_real_distribution<> distribution(0, 1);
-
- return (distribution(generator) < 0.2)
- ? absl::nullopt
- : absl::optional<float>(distribution(generator));
-}
-
-std::unique_ptr<FecControllerRplrBased> CreateFecControllerRplrBased(
- bool initial_fec_enabled) {
- return std::unique_ptr<FecControllerRplrBased>(
- new FecControllerRplrBased(FecControllerRplrBased::Config(
- initial_fec_enabled,
- ThresholdCurve(
- kEnablingBandwidthLow, kEnablingRecoverablePacketLossAtLowBw,
- kEnablingBandwidthHigh, kEnablingRecoverablePacketLossAtHighBw),
- ThresholdCurve(kDisablingBandwidthLow,
- kDisablingRecoverablePacketLossAtLowBw,
- kDisablingBandwidthHigh,
- kDisablingRecoverablePacketLossAtHighBw))));
-}
-
-void UpdateNetworkMetrics(
- FecControllerRplrBased* controller,
- const absl::optional<int>& uplink_bandwidth_bps,
- const absl::optional<float>& uplink_packet_loss,
- const absl::optional<float>& uplink_recoveralbe_packet_loss) {
- // UpdateNetworkMetrics can accept multiple network metric updates at once.
- // However, currently, the most used case is to update one metric at a time.
- // To reflect this fact, we separate the calls.
- if (uplink_bandwidth_bps) {
- Controller::NetworkMetrics network_metrics;
- network_metrics.uplink_bandwidth_bps = uplink_bandwidth_bps;
- controller->UpdateNetworkMetrics(network_metrics);
- }
- if (uplink_packet_loss) {
- Controller::NetworkMetrics network_metrics;
- network_metrics.uplink_packet_loss_fraction = uplink_packet_loss;
- controller->UpdateNetworkMetrics(network_metrics);
- }
- if (uplink_recoveralbe_packet_loss) {
- Controller::NetworkMetrics network_metrics;
- network_metrics.uplink_recoverable_packet_loss_fraction =
- uplink_recoveralbe_packet_loss;
- controller->UpdateNetworkMetrics(network_metrics);
- }
-}
-
-void UpdateNetworkMetrics(
- FecControllerRplrBased* controller,
- const absl::optional<int>& uplink_bandwidth_bps,
- const absl::optional<float>& uplink_recoveralbe_packet_loss) {
- // FecControllerRplrBased doesn't currently use the PLR (general packet-loss
- // rate) at all. (This might be changed in the future.) The unit-tests will
- // use a random value (including unknown), to show this does not interfere.
- UpdateNetworkMetrics(controller, uplink_bandwidth_bps,
- GetRandomProbabilityOrUnknown(),
- uplink_recoveralbe_packet_loss);
-}
-
-// Checks that the FEC decision and |uplink_packet_loss_fraction| given by
-// |states->controller->MakeDecision| matches |expected_enable_fec| and
-// |expected_uplink_packet_loss_fraction|, respectively.
-void CheckDecision(FecControllerRplrBased* controller,
- bool expected_enable_fec,
- float expected_uplink_packet_loss_fraction) {
- AudioEncoderRuntimeConfig config;
- controller->MakeDecision(&config);
-
- // Less compact than comparing optionals, but yields more readable errors.
- EXPECT_TRUE(config.enable_fec);
- if (config.enable_fec) {
- EXPECT_EQ(expected_enable_fec, *config.enable_fec);
- }
- EXPECT_TRUE(config.uplink_packet_loss_fraction);
- if (config.uplink_packet_loss_fraction) {
- EXPECT_EQ(expected_uplink_packet_loss_fraction,
- *config.uplink_packet_loss_fraction);
- }
-}
-
-} // namespace
-
-TEST(FecControllerRplrBasedTest, OutputInitValueBeforeAnyInputsAreReceived) {
- for (bool initial_fec_enabled : {false, true}) {
- auto controller = CreateFecControllerRplrBased(initial_fec_enabled);
- CheckDecision(controller.get(), initial_fec_enabled, 0);
- }
-}
-
-TEST(FecControllerRplrBasedTest, OutputInitValueWhenUplinkBandwidthUnknown) {
- // Regardless of the initial FEC state and the recoverable-packet-loss
- // rate, the initial FEC state is maintained as long as the BWE is unknown.
- for (bool initial_fec_enabled : {false, true}) {
- for (float recoverable_packet_loss :
- {kDisablingRecoverablePacketLossAtHighBw - kEpsilon,
- kDisablingRecoverablePacketLossAtHighBw,
- kDisablingRecoverablePacketLossAtHighBw + kEpsilon,
- kEnablingRecoverablePacketLossAtHighBw - kEpsilon,
- kEnablingRecoverablePacketLossAtHighBw,
- kEnablingRecoverablePacketLossAtHighBw + kEpsilon}) {
- auto controller = CreateFecControllerRplrBased(initial_fec_enabled);
- UpdateNetworkMetrics(controller.get(), absl::nullopt,
- recoverable_packet_loss);
- CheckDecision(controller.get(), initial_fec_enabled,
- recoverable_packet_loss);
- }
- }
-}
-
-TEST(FecControllerRplrBasedTest,
- OutputInitValueWhenUplinkRecoverablePacketLossFractionUnknown) {
- // Regardless of the initial FEC state and the BWE, the initial FEC state
- // is maintained as long as the recoverable-packet-loss rate is unknown.
- for (bool initial_fec_enabled : {false, true}) {
- for (int bandwidth : {kDisablingBandwidthLow - 1, kDisablingBandwidthLow,
- kDisablingBandwidthLow + 1, kEnablingBandwidthLow - 1,
- kEnablingBandwidthLow, kEnablingBandwidthLow + 1}) {
- auto controller = CreateFecControllerRplrBased(initial_fec_enabled);
- UpdateNetworkMetrics(controller.get(), bandwidth, absl::nullopt);
- CheckDecision(controller.get(), initial_fec_enabled, 0.0);
- }
- }
-}
-
-TEST(FecControllerRplrBasedTest, EnableFecForHighBandwidth) {
- auto controller = CreateFecControllerRplrBased(false);
- UpdateNetworkMetrics(controller.get(), kEnablingBandwidthHigh,
- kEnablingRecoverablePacketLossAtHighBw);
- CheckDecision(controller.get(), true, kEnablingRecoverablePacketLossAtHighBw);
-}
-
-TEST(FecControllerRplrBasedTest, UpdateMultipleNetworkMetricsAtOnce) {
- // This test is similar to EnableFecForHighBandwidth. But instead of
- // using ::UpdateNetworkMetrics(...), which calls
- // FecControllerRplrBasedTest::UpdateNetworkMetrics(...) multiple times, we
- // we call it only once. This is to verify that
- // FecControllerRplrBasedTest::UpdateNetworkMetrics(...) can handle multiple
- // network updates at once. This is, however, not a common use case in current
- // audio_network_adaptor_impl.cc.
- auto controller = CreateFecControllerRplrBased(false);
- Controller::NetworkMetrics network_metrics;
- network_metrics.uplink_bandwidth_bps = kEnablingBandwidthHigh;
- network_metrics.uplink_packet_loss_fraction = GetRandomProbabilityOrUnknown();
- network_metrics.uplink_recoverable_packet_loss_fraction =
- kEnablingRecoverablePacketLossAtHighBw;
- controller->UpdateNetworkMetrics(network_metrics);
- CheckDecision(controller.get(), true, kEnablingRecoverablePacketLossAtHighBw);
-}
-
-TEST(FecControllerRplrBasedTest, MaintainFecOffForHighBandwidth) {
- auto controller = CreateFecControllerRplrBased(false);
- constexpr float kRecoverablePacketLoss =
- kEnablingRecoverablePacketLossAtHighBw * 0.99f;
- UpdateNetworkMetrics(controller.get(), kEnablingBandwidthHigh,
- kRecoverablePacketLoss);
- CheckDecision(controller.get(), false, kRecoverablePacketLoss);
-}
-
-TEST(FecControllerRplrBasedTest, EnableFecForMediumBandwidth) {
- auto controller = CreateFecControllerRplrBased(false);
- constexpr float kRecoverablePacketLoss =
- (kEnablingRecoverablePacketLossAtLowBw +
- kEnablingRecoverablePacketLossAtHighBw) /
- 2.0;
- UpdateNetworkMetrics(controller.get(),
- (kEnablingBandwidthHigh + kEnablingBandwidthLow) / 2,
- kRecoverablePacketLoss);
- CheckDecision(controller.get(), true, kRecoverablePacketLoss);
-}
-
-TEST(FecControllerRplrBasedTest, MaintainFecOffForMediumBandwidth) {
- auto controller = CreateFecControllerRplrBased(false);
- constexpr float kRecoverablePacketLoss =
- kEnablingRecoverablePacketLossAtLowBw * 0.49f +
- kEnablingRecoverablePacketLossAtHighBw * 0.51f;
- UpdateNetworkMetrics(controller.get(),
- (kEnablingBandwidthHigh + kEnablingBandwidthLow) / 2,
- kRecoverablePacketLoss);
- CheckDecision(controller.get(), false, kRecoverablePacketLoss);
-}
-
-TEST(FecControllerRplrBasedTest, EnableFecForLowBandwidth) {
- auto controller = CreateFecControllerRplrBased(false);
- UpdateNetworkMetrics(controller.get(), kEnablingBandwidthLow,
- kEnablingRecoverablePacketLossAtLowBw);
- CheckDecision(controller.get(), true, kEnablingRecoverablePacketLossAtLowBw);
-}
-
-TEST(FecControllerRplrBasedTest, MaintainFecOffForLowBandwidth) {
- auto controller = CreateFecControllerRplrBased(false);
- constexpr float kRecoverablePacketLoss =
- kEnablingRecoverablePacketLossAtLowBw * 0.99f;
- UpdateNetworkMetrics(controller.get(), kEnablingBandwidthLow,
- kRecoverablePacketLoss);
- CheckDecision(controller.get(), false, kRecoverablePacketLoss);
-}
-
-TEST(FecControllerRplrBasedTest, MaintainFecOffForVeryLowBandwidth) {
- auto controller = CreateFecControllerRplrBased(false);
- // Below |kEnablingBandwidthLow|, no recoverable packet loss fraction can
- // cause FEC to turn on.
- UpdateNetworkMetrics(controller.get(), kEnablingBandwidthLow - 1, 1.0);
- CheckDecision(controller.get(), false, 1.0);
-}
-
-TEST(FecControllerRplrBasedTest, DisableFecForHighBandwidth) {
- auto controller = CreateFecControllerRplrBased(true);
- constexpr float kRecoverablePacketLoss =
- kDisablingRecoverablePacketLossAtHighBw - kEpsilon;
- UpdateNetworkMetrics(controller.get(), kDisablingBandwidthHigh,
- kRecoverablePacketLoss);
- CheckDecision(controller.get(), false, kRecoverablePacketLoss);
-}
-
-TEST(FecControllerRplrBasedTest, MaintainFecOnForHighBandwidth) {
- // Note: Disabling happens when the value is strictly below the threshold.
- auto controller = CreateFecControllerRplrBased(true);
- UpdateNetworkMetrics(controller.get(), kDisablingBandwidthHigh,
- kDisablingRecoverablePacketLossAtHighBw);
- CheckDecision(controller.get(), true,
- kDisablingRecoverablePacketLossAtHighBw);
-}
-
-TEST(FecControllerRplrBasedTest, DisableFecOnMediumBandwidth) {
- auto controller = CreateFecControllerRplrBased(true);
- constexpr float kRecoverablePacketLoss =
- ((kDisablingRecoverablePacketLossAtLowBw +
- kDisablingRecoverablePacketLossAtHighBw) /
- 2.0f) -
- kEpsilon;
- UpdateNetworkMetrics(controller.get(),
- (kDisablingBandwidthHigh + kDisablingBandwidthLow) / 2,
- kRecoverablePacketLoss);
- CheckDecision(controller.get(), false, kRecoverablePacketLoss);
-}
-
-TEST(FecControllerRplrBasedTest, MaintainFecOnForMediumBandwidth) {
- auto controller = CreateFecControllerRplrBased(true);
- constexpr float kRecoverablePacketLoss =
- kDisablingRecoverablePacketLossAtLowBw * 0.51f +
- kDisablingRecoverablePacketLossAtHighBw * 0.49f - kEpsilon;
- UpdateNetworkMetrics(controller.get(),
- (kEnablingBandwidthHigh + kDisablingBandwidthLow) / 2,
- kRecoverablePacketLoss);
- CheckDecision(controller.get(), true, kRecoverablePacketLoss);
-}
-
-TEST(FecControllerRplrBasedTest, DisableFecForLowBandwidth) {
- auto controller = CreateFecControllerRplrBased(true);
- constexpr float kRecoverablePacketLoss =
- kDisablingRecoverablePacketLossAtLowBw - kEpsilon;
- UpdateNetworkMetrics(controller.get(), kDisablingBandwidthLow,
- kRecoverablePacketLoss);
- CheckDecision(controller.get(), false, kRecoverablePacketLoss);
-}
-
-TEST(FecControllerRplrBasedTest, DisableFecForVeryLowBandwidth) {
- auto controller = CreateFecControllerRplrBased(true);
- // Below |kEnablingBandwidthLow|, any recoverable packet loss fraction can
- // cause FEC to turn off.
- UpdateNetworkMetrics(controller.get(), kDisablingBandwidthLow - 1, 1.0);
- CheckDecision(controller.get(), false, 1.0);
-}
-
-TEST(FecControllerRplrBasedTest, CheckBehaviorOnChangingNetworkMetrics) {
- // In this test, we let the network metrics to traverse from 1 to 5.
- //
- // recoverable ^
- // packet-loss | 1 | |
- // | | 2|
- // | \ \ 3
- // | \4 \_______
- // | \_________
- // |---------5-------> bandwidth
-
- auto controller = CreateFecControllerRplrBased(true);
- UpdateNetworkMetrics(controller.get(), kDisablingBandwidthLow - 1, 1.0);
- CheckDecision(controller.get(), false, 1.0);
-
- UpdateNetworkMetrics(controller.get(), kEnablingBandwidthLow,
- kEnablingRecoverablePacketLossAtLowBw * 0.99f);
- CheckDecision(controller.get(), false,
- kEnablingRecoverablePacketLossAtLowBw * 0.99f);
-
- UpdateNetworkMetrics(controller.get(), kEnablingBandwidthHigh,
- kEnablingRecoverablePacketLossAtHighBw);
- CheckDecision(controller.get(), true, kEnablingRecoverablePacketLossAtHighBw);
-
- UpdateNetworkMetrics(controller.get(), kDisablingBandwidthHigh,
- kDisablingRecoverablePacketLossAtHighBw);
- CheckDecision(controller.get(), true,
- kDisablingRecoverablePacketLossAtHighBw);
-
- UpdateNetworkMetrics(controller.get(), kDisablingBandwidthHigh + 1, 0.0);
- CheckDecision(controller.get(), false, 0.0);
-}
-
-TEST(FecControllerRplrBasedTest, CheckBehaviorOnSpecialCurves) {
- // We test a special configuration, where the points to define the FEC
- // enabling/disabling curves are placed like the following, otherwise the test
- // is the same as CheckBehaviorOnChangingNetworkMetrics.
- //
- // recoverable ^
- // packet-loss | | |
- // | | C|
- // | | |
- // | | D|_______
- // | A|___B______
- // |-----------------> bandwidth
-
- constexpr int kEnablingBandwidthHigh = kEnablingBandwidthLow;
- constexpr float kDisablingRecoverablePacketLossAtLowBw =
- kDisablingRecoverablePacketLossAtHighBw;
- FecControllerRplrBased controller(FecControllerRplrBased::Config(
- true,
- ThresholdCurve(
- kEnablingBandwidthLow, kEnablingRecoverablePacketLossAtLowBw,
- kEnablingBandwidthHigh, kEnablingRecoverablePacketLossAtHighBw),
- ThresholdCurve(
- kDisablingBandwidthLow, kDisablingRecoverablePacketLossAtLowBw,
- kDisablingBandwidthHigh, kDisablingRecoverablePacketLossAtHighBw)));
-
- UpdateNetworkMetrics(&controller, kDisablingBandwidthLow - 1, 1.0);
- CheckDecision(&controller, false, 1.0);
-
- UpdateNetworkMetrics(&controller, kEnablingBandwidthLow,
- kEnablingRecoverablePacketLossAtHighBw * 0.99f);
- CheckDecision(&controller, false,
- kEnablingRecoverablePacketLossAtHighBw * 0.99f);
-
- UpdateNetworkMetrics(&controller, kEnablingBandwidthHigh,
- kEnablingRecoverablePacketLossAtHighBw);
- CheckDecision(&controller, true, kEnablingRecoverablePacketLossAtHighBw);
-
- UpdateNetworkMetrics(&controller, kDisablingBandwidthHigh,
- kDisablingRecoverablePacketLossAtHighBw);
- CheckDecision(&controller, true, kDisablingRecoverablePacketLossAtHighBw);
-
- UpdateNetworkMetrics(&controller, kDisablingBandwidthHigh + 1, 0.0);
- CheckDecision(&controller, false, 0.0);
-}
-
-TEST(FecControllerRplrBasedTest, SingleThresholdCurveForEnablingAndDisabling) {
- // Note: To avoid numerical errors, keep kRecoverablePacketLossAtLowBw and
- // kRecoverablePacketLossAthighBw as (negative) integer powers of 2.
- // This is mostly relevant for the O3 case.
- constexpr int kBandwidthLow = 10000;
- constexpr float kRecoverablePacketLossAtLowBw = 0.25f;
- constexpr int kBandwidthHigh = 20000;
- constexpr float kRecoverablePacketLossAtHighBw = 0.125f;
- auto curve = ThresholdCurve(kBandwidthLow, kRecoverablePacketLossAtLowBw,
- kBandwidthHigh, kRecoverablePacketLossAtHighBw);
-
- // B* stands for "below-curve", O* for "on-curve", and A* for "above-curve".
- //
- // //
- // recoverable ^ //
- // packet-loss | | //
- // | B1 O1 //
- // | | //
- // | O2 //
- // | \ A1 //
- // | \ //
- // | O3 A2 //
- // | B2 \ //
- // | \ //
- // | O4--O5---- //
- // | //
- // | B3 //
- // |-----------------> bandwidth //
-
- struct NetworkState {
- int bandwidth;
- float recoverable_packet_loss;
- };
-
- std::vector<NetworkState> below{
- {kBandwidthLow - 1, kRecoverablePacketLossAtLowBw + 0.1f}, // B1
- {(kBandwidthLow + kBandwidthHigh) / 2,
- (kRecoverablePacketLossAtLowBw + kRecoverablePacketLossAtHighBw) / 2 -
- kEpsilon}, // B2
- {kBandwidthHigh + 1, kRecoverablePacketLossAtHighBw - kEpsilon} // B3
- };
-
- std::vector<NetworkState> on{
- {kBandwidthLow, kRecoverablePacketLossAtLowBw + 0.1f}, // O1
- {kBandwidthLow, kRecoverablePacketLossAtLowBw}, // O2
- {(kBandwidthLow + kBandwidthHigh) / 2,
- (kRecoverablePacketLossAtLowBw + kRecoverablePacketLossAtHighBw) /
- 2}, // O3
- {kBandwidthHigh, kRecoverablePacketLossAtHighBw}, // O4
- {kBandwidthHigh + 1, kRecoverablePacketLossAtHighBw}, // O5
- };
-
- std::vector<NetworkState> above{
- {(kBandwidthLow + kBandwidthHigh) / 2,
- (kRecoverablePacketLossAtLowBw + kRecoverablePacketLossAtHighBw) / 2 +
- kEpsilon}, // A1
- {kBandwidthHigh + 1, kRecoverablePacketLossAtHighBw + kEpsilon}, // A2
- };
-
- // Test that FEC is turned off whenever we're below the curve, independent
- // of the starting FEC state.
- for (NetworkState net_state : below) {
- for (bool initial_fec_enabled : {false, true}) {
- FecControllerRplrBased controller(
- FecControllerRplrBased::Config(initial_fec_enabled, curve, curve));
- UpdateNetworkMetrics(&controller, net_state.bandwidth,
- net_state.recoverable_packet_loss);
- CheckDecision(&controller, false, net_state.recoverable_packet_loss);
- }
- }
-
- // Test that FEC is turned on whenever we're on the curve or above it,
- // independent of the starting FEC state.
- for (const std::vector<NetworkState>& states_list : {on, above}) {
- for (NetworkState net_state : states_list) {
- for (bool initial_fec_enabled : {false, true}) {
- FecControllerRplrBased controller(
- FecControllerRplrBased::Config(initial_fec_enabled, curve, curve));
- UpdateNetworkMetrics(&controller, net_state.bandwidth,
- net_state.recoverable_packet_loss);
- CheckDecision(&controller, true, net_state.recoverable_packet_loss);
- }
- }
- }
-}
-
-TEST(FecControllerRplrBasedTest, FecAlwaysOff) {
- ThresholdCurve always_off_curve(0, 1.0f + kEpsilon, 0, 1.0f + kEpsilon);
- for (bool initial_fec_enabled : {false, true}) {
- for (int bandwidth : {0, 10000}) {
- for (float recoverable_packet_loss : {0.0f, 0.5f, 1.0f}) {
- FecControllerRplrBased controller(FecControllerRplrBased::Config(
- initial_fec_enabled, always_off_curve, always_off_curve));
- UpdateNetworkMetrics(&controller, bandwidth, recoverable_packet_loss);
- CheckDecision(&controller, false, recoverable_packet_loss);
- }
- }
- }
-}
-
-TEST(FecControllerRplrBasedTest, FecAlwaysOn) {
- ThresholdCurve always_on_curve(0, 0.0f, 0, 0.0f);
- for (bool initial_fec_enabled : {false, true}) {
- for (int bandwidth : {0, 10000}) {
- for (float recoverable_packet_loss : {0.0f, 0.5f, 1.0f}) {
- FecControllerRplrBased controller(FecControllerRplrBased::Config(
- initial_fec_enabled, always_on_curve, always_on_curve));
- UpdateNetworkMetrics(&controller, bandwidth, recoverable_packet_loss);
- CheckDecision(&controller, true, recoverable_packet_loss);
- }
- }
- }
-}
-
-#if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
-TEST(FecControllerRplrBasedDeathTest, InvalidConfig) {
- EXPECT_DEATH(
- FecControllerRplrBased controller(FecControllerRplrBased::Config(
- true,
- ThresholdCurve(
- kDisablingBandwidthLow - 1, kEnablingRecoverablePacketLossAtLowBw,
- kEnablingBandwidthHigh, kEnablingRecoverablePacketLossAtHighBw),
- ThresholdCurve(kDisablingBandwidthLow,
- kDisablingRecoverablePacketLossAtLowBw,
- kDisablingBandwidthHigh,
- kDisablingRecoverablePacketLossAtHighBw))),
- "Check failed");
-}
-#endif
-} // namespace webrtc
diff --git a/modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h b/modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h
index c11279e..346ed5d 100644
--- a/modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h
+++ b/modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h
@@ -29,9 +29,6 @@
virtual void SetUplinkPacketLossFraction(
float uplink_packet_loss_fraction) = 0;
- virtual void SetUplinkRecoverablePacketLossFraction(
- float uplink_recoverable_packet_loss_fraction) = 0;
-
virtual void SetRtt(int rtt_ms) = 0;
virtual void SetTargetAudioBitrate(int target_audio_bitrate_bps) = 0;
diff --git a/modules/audio_coding/audio_network_adaptor/mock/mock_audio_network_adaptor.h b/modules/audio_coding/audio_network_adaptor/mock/mock_audio_network_adaptor.h
index 15dc741..8c04849 100644
--- a/modules/audio_coding/audio_network_adaptor/mock/mock_audio_network_adaptor.h
+++ b/modules/audio_coding/audio_network_adaptor/mock/mock_audio_network_adaptor.h
@@ -26,9 +26,6 @@
MOCK_METHOD1(SetUplinkPacketLossFraction,
void(float uplink_packet_loss_fraction));
- MOCK_METHOD1(SetUplinkRecoverablePacketLossFraction,
- void(float uplink_recoverable_packet_loss_fraction));
-
MOCK_METHOD1(SetRtt, void(int rtt_ms));
MOCK_METHOD1(SetTargetAudioBitrate, void(int target_audio_bitrate_bps));