| Index: webrtc/modules/audio_coding/audio_network_adaptor/fec_controller_plr_based.cc
|
| diff --git a/webrtc/modules/audio_coding/audio_network_adaptor/fec_controller.cc b/webrtc/modules/audio_coding/audio_network_adaptor/fec_controller_plr_based.cc
|
| similarity index 74%
|
| rename from webrtc/modules/audio_coding/audio_network_adaptor/fec_controller.cc
|
| rename to webrtc/modules/audio_coding/audio_network_adaptor/fec_controller_plr_based.cc
|
| index df9275a6eda1004287e8d9c37c32d20e0a82ed8b..c3c27c6bed41c16093a2f4ee70cd2229c432d1e0 100644
|
| --- a/webrtc/modules/audio_coding/audio_network_adaptor/fec_controller.cc
|
| +++ b/webrtc/modules/audio_coding/audio_network_adaptor/fec_controller_plr_based.cc
|
| @@ -8,7 +8,7 @@
|
| * be found in the AUTHORS file in the root of the source tree.
|
| */
|
|
|
| -#include "webrtc/modules/audio_coding/audio_network_adaptor/fec_controller.h"
|
| +#include "webrtc/modules/audio_coding/audio_network_adaptor/fec_controller_plr_based.h"
|
|
|
| #include <limits>
|
| #include <utility>
|
| @@ -17,28 +17,30 @@
|
|
|
| namespace webrtc {
|
|
|
| -FecController::Config::Threshold::Threshold(int low_bandwidth_bps,
|
| - float low_bandwidth_packet_loss,
|
| - int high_bandwidth_bps,
|
| - float high_bandwidth_packet_loss)
|
| +FecControllerPlrBased::Config::Threshold::Threshold(
|
| + int low_bandwidth_bps,
|
| + float low_bandwidth_packet_loss,
|
| + int high_bandwidth_bps,
|
| + float high_bandwidth_packet_loss)
|
| : low_bandwidth_bps(low_bandwidth_bps),
|
| low_bandwidth_packet_loss(low_bandwidth_packet_loss),
|
| high_bandwidth_bps(high_bandwidth_bps),
|
| high_bandwidth_packet_loss(high_bandwidth_packet_loss) {}
|
|
|
| -FecController::Config::Config(bool initial_fec_enabled,
|
| - const Threshold& fec_enabling_threshold,
|
| - const Threshold& fec_disabling_threshold,
|
| - int time_constant_ms,
|
| - const Clock* clock)
|
| +FecControllerPlrBased::Config::Config(bool initial_fec_enabled,
|
| + const Threshold& fec_enabling_threshold,
|
| + const Threshold& fec_disabling_threshold,
|
| + int time_constant_ms,
|
| + const Clock* clock)
|
| : initial_fec_enabled(initial_fec_enabled),
|
| fec_enabling_threshold(fec_enabling_threshold),
|
| fec_disabling_threshold(fec_disabling_threshold),
|
| time_constant_ms(time_constant_ms),
|
| clock(clock) {}
|
|
|
| -FecController::FecController(const Config& config,
|
| - std::unique_ptr<SmoothingFilter> smoothing_filter)
|
| +FecControllerPlrBased::FecControllerPlrBased(
|
| + const Config& config,
|
| + std::unique_ptr<SmoothingFilter> smoothing_filter)
|
| : config_(config),
|
| fec_enabled_(config.initial_fec_enabled),
|
| packet_loss_smoother_(std::move(smoothing_filter)),
|
| @@ -58,16 +60,16 @@ FecController::FecController(const Config& config,
|
| config_.fec_enabling_threshold.high_bandwidth_packet_loss);
|
| }
|
|
|
| -FecController::FecController(const Config& config)
|
| - : FecController(
|
| +FecControllerPlrBased::FecControllerPlrBased(const Config& config)
|
| + : FecControllerPlrBased(
|
| config,
|
| std::unique_ptr<SmoothingFilter>(
|
| new SmoothingFilterImpl(config.time_constant_ms, config.clock))) {
|
| }
|
|
|
| -FecController::~FecController() = default;
|
| +FecControllerPlrBased::~FecControllerPlrBased() = default;
|
|
|
| -void FecController::UpdateNetworkMetrics(
|
| +void FecControllerPlrBased::UpdateNetworkMetrics(
|
| const NetworkMetrics& network_metrics) {
|
| if (network_metrics.uplink_bandwidth_bps)
|
| uplink_bandwidth_bps_ = network_metrics.uplink_bandwidth_bps;
|
| @@ -77,7 +79,7 @@ void FecController::UpdateNetworkMetrics(
|
| }
|
| }
|
|
|
| -void FecController::MakeDecision(
|
| +void FecControllerPlrBased::MakeDecision(
|
| AudioNetworkAdaptor::EncoderRuntimeConfig* config) {
|
| RTC_DCHECK(!config->enable_fec);
|
| RTC_DCHECK(!config->uplink_packet_loss_fraction);
|
| @@ -93,7 +95,7 @@ void FecController::MakeDecision(
|
| rtc::Optional<float>(packet_loss ? *packet_loss : 0.0);
|
| }
|
|
|
| -FecController::ThresholdInfo::ThresholdInfo(
|
| +FecControllerPlrBased::ThresholdInfo::ThresholdInfo(
|
| const Config::Threshold& threshold) {
|
| int bandwidth_diff_bps =
|
| threshold.high_bandwidth_bps - threshold.low_bandwidth_bps;
|
| @@ -104,18 +106,23 @@ FecController::ThresholdInfo::ThresholdInfo(
|
| threshold.low_bandwidth_packet_loss - slope * threshold.low_bandwidth_bps;
|
| }
|
|
|
| -float FecController::GetPacketLossThreshold(
|
| +float FecControllerPlrBased::GetPacketLossThreshold(
|
| int bandwidth_bps,
|
| const Config::Threshold& threshold,
|
| const ThresholdInfo& threshold_info) const {
|
| - if (bandwidth_bps < threshold.low_bandwidth_bps)
|
| + if (bandwidth_bps < threshold.low_bandwidth_bps) {
|
| return std::numeric_limits<float>::max();
|
| - if (bandwidth_bps >= threshold.high_bandwidth_bps)
|
| + } else if (bandwidth_bps >= threshold.high_bandwidth_bps) {
|
| return threshold.high_bandwidth_packet_loss;
|
| - return threshold_info.offset + threshold_info.slope * bandwidth_bps;
|
| + } else {
|
| + float rc = threshold_info.offset + threshold_info.slope * bandwidth_bps;
|
| + RTC_DCHECK_LE(rc, threshold.low_bandwidth_packet_loss);
|
| + RTC_DCHECK_GE(rc, threshold.high_bandwidth_packet_loss);
|
| + return rc;
|
| + }
|
| }
|
|
|
| -bool FecController::FecEnablingDecision(
|
| +bool FecControllerPlrBased::FecEnablingDecision(
|
| const rtc::Optional<float>& packet_loss) const {
|
| if (!uplink_bandwidth_bps_)
|
| return false;
|
| @@ -126,7 +133,7 @@ bool FecController::FecEnablingDecision(
|
| fec_enabling_threshold_info_);
|
| }
|
|
|
| -bool FecController::FecDisablingDecision(
|
| +bool FecControllerPlrBased::FecDisablingDecision(
|
| const rtc::Optional<float>& packet_loss) const {
|
| if (!uplink_bandwidth_bps_)
|
| return false;
|
|
|