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

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

Issue 2585293002: Reducing calling to SmoothingFilter in Fec Controller. (Closed)
Patch Set: Created 4 years 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) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 68
69 void FecController::MakeDecision( 69 void FecController::MakeDecision(
70 const NetworkMetrics& metrics, 70 const NetworkMetrics& metrics,
71 AudioNetworkAdaptor::EncoderRuntimeConfig* config) { 71 AudioNetworkAdaptor::EncoderRuntimeConfig* config) {
72 RTC_DCHECK(!config->enable_fec); 72 RTC_DCHECK(!config->enable_fec);
73 RTC_DCHECK(!config->uplink_packet_loss_fraction); 73 RTC_DCHECK(!config->uplink_packet_loss_fraction);
74 74
75 if (metrics.uplink_packet_loss_fraction) 75 if (metrics.uplink_packet_loss_fraction)
76 packet_loss_smoothed_->AddSample(*metrics.uplink_packet_loss_fraction); 76 packet_loss_smoothed_->AddSample(*metrics.uplink_packet_loss_fraction);
77 77
78 fec_enabled_ = fec_enabled_ ? !FecDisablingDecision(metrics) 78 const auto& packet_loss = packet_loss_smoothed_->GetAverage();
79 : FecEnablingDecision(metrics); 79
80 fec_enabled_ = fec_enabled_ ? !FecDisablingDecision(metrics, packet_loss)
81 : FecEnablingDecision(metrics, packet_loss);
80 82
81 config->enable_fec = rtc::Optional<bool>(fec_enabled_); 83 config->enable_fec = rtc::Optional<bool>(fec_enabled_);
82 84
83 auto packet_loss_fraction = packet_loss_smoothed_->GetAverage(); 85 auto packet_loss_fraction = packet_loss_smoothed_->GetAverage();
84 config->uplink_packet_loss_fraction = rtc::Optional<float>( 86 config->uplink_packet_loss_fraction = rtc::Optional<float>(
85 packet_loss_fraction ? *packet_loss_fraction : 0.0); 87 packet_loss_fraction ? *packet_loss_fraction : 0.0);
86 } 88 }
87 89
88 FecController::ThresholdInfo::ThresholdInfo( 90 FecController::ThresholdInfo::ThresholdInfo(
89 const Config::Threshold& threshold) { 91 const Config::Threshold& threshold) {
(...skipping 10 matching lines...) Expand all
100 int bandwidth_bps, 102 int bandwidth_bps,
101 const Config::Threshold& threshold, 103 const Config::Threshold& threshold,
102 const ThresholdInfo& threshold_info) const { 104 const ThresholdInfo& threshold_info) const {
103 if (bandwidth_bps < threshold.low_bandwidth_bps) 105 if (bandwidth_bps < threshold.low_bandwidth_bps)
104 return std::numeric_limits<float>::max(); 106 return std::numeric_limits<float>::max();
105 if (bandwidth_bps >= threshold.high_bandwidth_bps) 107 if (bandwidth_bps >= threshold.high_bandwidth_bps)
106 return threshold.high_bandwidth_packet_loss; 108 return threshold.high_bandwidth_packet_loss;
107 return threshold_info.offset + threshold_info.slope * bandwidth_bps; 109 return threshold_info.offset + threshold_info.slope * bandwidth_bps;
108 } 110 }
109 111
110 bool FecController::FecEnablingDecision(const NetworkMetrics& metrics) const { 112 bool FecController::FecEnablingDecision(
113 const NetworkMetrics& metrics,
114 const rtc::Optional<float>& packet_loss) const {
111 if (!metrics.uplink_bandwidth_bps) 115 if (!metrics.uplink_bandwidth_bps)
112 return false; 116 return false;
113
114 auto packet_loss = packet_loss_smoothed_->GetAverage();
115 if (!packet_loss) 117 if (!packet_loss)
116 return false; 118 return false;
117
118 return *packet_loss >= GetPacketLossThreshold(*metrics.uplink_bandwidth_bps, 119 return *packet_loss >= GetPacketLossThreshold(*metrics.uplink_bandwidth_bps,
119 config_.fec_enabling_threshold, 120 config_.fec_enabling_threshold,
120 fec_enabling_threshold_info_); 121 fec_enabling_threshold_info_);
121 } 122 }
122 123
123 bool FecController::FecDisablingDecision(const NetworkMetrics& metrics) const { 124 bool FecController::FecDisablingDecision(
125 const NetworkMetrics& metrics,
126 const rtc::Optional<float>& packet_loss) const {
124 if (!metrics.uplink_bandwidth_bps) 127 if (!metrics.uplink_bandwidth_bps)
125 return false; 128 return false;
126
127 auto packet_loss = packet_loss_smoothed_->GetAverage();
128 if (!packet_loss) 129 if (!packet_loss)
129 return false; 130 return false;
130
131 return *packet_loss <= GetPacketLossThreshold(*metrics.uplink_bandwidth_bps, 131 return *packet_loss <= GetPacketLossThreshold(*metrics.uplink_bandwidth_bps,
132 config_.fec_disabling_threshold, 132 config_.fec_disabling_threshold,
133 fec_disabling_threshold_info_); 133 fec_disabling_threshold_info_);
134 } 134 }
135 135
136 } // namespace webrtc 136 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698