Index: webrtc/modules/audio_coding/audio_network_adaptor/fec_controller.cc |
diff --git a/webrtc/modules/audio_coding/audio_network_adaptor/fec_controller.cc b/webrtc/modules/audio_coding/audio_network_adaptor/fec_controller.cc |
index 15c12b1a1ba8bc2f22e3666b5c4e9a53166ce6e2..5ae484b3017136be0e8350bccd13432366905027 100644 |
--- a/webrtc/modules/audio_coding/audio_network_adaptor/fec_controller.cc |
+++ b/webrtc/modules/audio_coding/audio_network_adaptor/fec_controller.cc |
@@ -40,7 +40,7 @@ FecController::Config::Config(bool initial_fec_enabled, |
FecController::FecController(const Config& config) |
: config_(config), |
fec_enabled_(config.initial_fec_enabled), |
- packet_loss_smoothed_( |
+ packet_loss_smoother_( |
new SmoothingFilterImpl(config_.time_constant_ms, config_.clock)), |
fec_enabling_threshold_info_(config_.fec_enabling_threshold), |
fec_disabling_threshold_info_(config_.fec_disabling_threshold) { |
@@ -61,30 +61,35 @@ FecController::FecController(const Config& config) |
FecController::FecController(const Config& config, |
std::unique_ptr<SmoothingFilter> smoothing_filter) |
: FecController(config) { |
- packet_loss_smoothed_ = std::move(smoothing_filter); |
michaelt
2017/01/23 15:15:52
I would prefer to make packet_loss_smoothed_ const
|
+ packet_loss_smoother_ = std::move(smoothing_filter); |
} |
FecController::~FecController() = default; |
+void FecController::UpdateNetworkMetrics( |
+ const NetworkMetrics& network_metrics) { |
+ if (network_metrics.uplink_bandwidth_bps) |
+ uplink_bandwidth_bps_ = network_metrics.uplink_bandwidth_bps; |
+ if (network_metrics.uplink_packet_loss_fraction) { |
+ packet_loss_smoother_->AddSample( |
+ *network_metrics.uplink_packet_loss_fraction); |
+ } |
+} |
+ |
void FecController::MakeDecision( |
- const NetworkMetrics& metrics, |
AudioNetworkAdaptor::EncoderRuntimeConfig* config) { |
RTC_DCHECK(!config->enable_fec); |
RTC_DCHECK(!config->uplink_packet_loss_fraction); |
- if (metrics.uplink_packet_loss_fraction) |
- packet_loss_smoothed_->AddSample(*metrics.uplink_packet_loss_fraction); |
- |
- const auto& packet_loss = packet_loss_smoothed_->GetAverage(); |
+ const auto& packet_loss = packet_loss_smoother_->GetAverage(); |
- fec_enabled_ = fec_enabled_ ? !FecDisablingDecision(metrics, packet_loss) |
- : FecEnablingDecision(metrics, packet_loss); |
+ fec_enabled_ = fec_enabled_ ? !FecDisablingDecision(packet_loss) |
+ : FecEnablingDecision(packet_loss); |
config->enable_fec = rtc::Optional<bool>(fec_enabled_); |
- auto packet_loss_fraction = packet_loss_smoothed_->GetAverage(); |
- config->uplink_packet_loss_fraction = rtc::Optional<float>( |
- packet_loss_fraction ? *packet_loss_fraction : 0.0); |
+ config->uplink_packet_loss_fraction = |
+ rtc::Optional<float>(packet_loss ? *packet_loss : 0.0); |
} |
FecController::ThresholdInfo::ThresholdInfo( |
@@ -110,25 +115,23 @@ float FecController::GetPacketLossThreshold( |
} |
bool FecController::FecEnablingDecision( |
- const NetworkMetrics& metrics, |
const rtc::Optional<float>& packet_loss) const { |
- if (!metrics.uplink_bandwidth_bps) |
+ if (!uplink_bandwidth_bps_) |
return false; |
if (!packet_loss) |
return false; |
- return *packet_loss >= GetPacketLossThreshold(*metrics.uplink_bandwidth_bps, |
+ return *packet_loss >= GetPacketLossThreshold(*uplink_bandwidth_bps_, |
config_.fec_enabling_threshold, |
fec_enabling_threshold_info_); |
} |
bool FecController::FecDisablingDecision( |
- const NetworkMetrics& metrics, |
const rtc::Optional<float>& packet_loss) const { |
- if (!metrics.uplink_bandwidth_bps) |
+ if (!uplink_bandwidth_bps_) |
return false; |
if (!packet_loss) |
return false; |
- return *packet_loss <= GetPacketLossThreshold(*metrics.uplink_bandwidth_bps, |
+ return *packet_loss <= GetPacketLossThreshold(*uplink_bandwidth_bps_, |
config_.fec_disabling_threshold, |
fec_disabling_threshold_info_); |
} |