Reducing calling to SmoothingFilter in Fec Controller.

BUG=webrtc:6303

Review-Url: https://codereview.webrtc.org/2585293002
Cr-Commit-Position: refs/heads/master@{#15806}
This commit is contained in:
minyue
2016-12-27 06:42:49 -08:00
committed by Commit bot
parent 6d3c57300b
commit e1c2d9b0a8
2 changed files with 14 additions and 12 deletions

View File

@ -75,8 +75,10 @@ void FecController::MakeDecision(
if (metrics.uplink_packet_loss_fraction)
packet_loss_smoothed_->AddSample(*metrics.uplink_packet_loss_fraction);
fec_enabled_ = fec_enabled_ ? !FecDisablingDecision(metrics)
: FecEnablingDecision(metrics);
const auto& packet_loss = packet_loss_smoothed_->GetAverage();
fec_enabled_ = fec_enabled_ ? !FecDisablingDecision(metrics, packet_loss)
: FecEnablingDecision(metrics, packet_loss);
config->enable_fec = rtc::Optional<bool>(fec_enabled_);
@ -107,27 +109,25 @@ float FecController::GetPacketLossThreshold(
return threshold_info.offset + threshold_info.slope * bandwidth_bps;
}
bool FecController::FecEnablingDecision(const NetworkMetrics& metrics) const {
bool FecController::FecEnablingDecision(
const NetworkMetrics& metrics,
const rtc::Optional<float>& packet_loss) const {
if (!metrics.uplink_bandwidth_bps)
return false;
auto packet_loss = packet_loss_smoothed_->GetAverage();
if (!packet_loss)
return false;
return *packet_loss >= GetPacketLossThreshold(*metrics.uplink_bandwidth_bps,
config_.fec_enabling_threshold,
fec_enabling_threshold_info_);
}
bool FecController::FecDisablingDecision(const NetworkMetrics& metrics) const {
bool FecController::FecDisablingDecision(
const NetworkMetrics& metrics,
const rtc::Optional<float>& packet_loss) const {
if (!metrics.uplink_bandwidth_bps)
return false;
auto packet_loss = packet_loss_smoothed_->GetAverage();
if (!packet_loss)
return false;
return *packet_loss <= GetPacketLossThreshold(*metrics.uplink_bandwidth_bps,
config_.fec_disabling_threshold,
fec_disabling_threshold_info_);

View File

@ -87,8 +87,10 @@ class FecController final : public Controller {
const Config::Threshold& threshold,
const ThresholdInfo& threshold_info) const;
bool FecEnablingDecision(const NetworkMetrics& metrics) const;
bool FecDisablingDecision(const NetworkMetrics& metrics) const;
bool FecEnablingDecision(const NetworkMetrics& metrics,
const rtc::Optional<float>& packet_loss) const;
bool FecDisablingDecision(const NetworkMetrics& metrics,
const rtc::Optional<float>& packet_loss) const;
const Config config_;
bool fec_enabled_;