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

Side by Side Diff: webrtc/voice_engine/channel.cc

Issue 2518923003: Pass time constant to bwe smoothing filter. (Closed)
Patch Set: Add probing_interval_ms to NullBitrateObserver. 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) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1294 1294
1295 if (_rtpRtcpModule->SetAudioPacketSize(codec.pacsize) != 0) { 1295 if (_rtpRtcpModule->SetAudioPacketSize(codec.pacsize) != 0) {
1296 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId), 1296 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId),
1297 "SetSendCodec() failed to set audio packet size"); 1297 "SetSendCodec() failed to set audio packet size");
1298 return -1; 1298 return -1;
1299 } 1299 }
1300 1300
1301 return 0; 1301 return 0;
1302 } 1302 }
1303 1303
1304 void Channel::SetBitRate(int bitrate_bps) { 1304 void Channel::SetBitRate(int bitrate_bps, int64_t probing_interval_ms) {
1305 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), 1305 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
1306 "Channel::SetBitRate(bitrate_bps=%d)", bitrate_bps); 1306 "Channel::SetBitRate(bitrate_bps=%d)", bitrate_bps);
1307 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { 1307 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) {
1308 if (*encoder) 1308 if (*encoder)
1309 (*encoder)->OnReceivedTargetAudioBitrate(bitrate_bps); 1309 (*encoder)->OnReceivedTargetAudioBitrate(bitrate_bps);
1310 }); 1310 });
1311 retransmission_rate_limiter_->SetMaxRate(bitrate_bps); 1311 retransmission_rate_limiter_->SetMaxRate(bitrate_bps);
1312 1312
1313 // We give smoothed bitrate allocation to audio network adaptor as 1313 // We give smoothed bitrate allocation to audio network adaptor as
1314 // the uplink bandwidth. 1314 // the uplink bandwidth.
1315 // TODO(michaelt) : Remove kDefaultBitrateSmoothingTimeConstantMs as soon as 1315 // The probing spikes should not affect the bitrate smoother more than 25%.
1316 // we pass the probing interval to this function. 1316 // To simplify the calculations we use a step response as input signal.
1317 constexpr int64_t kDefaultBitrateSmoothingTimeConstantMs = 20000; 1317 // The step response of an exponential filter is
1318 bitrate_smoother_.SetTimeConstantMs(kDefaultBitrateSmoothingTimeConstantMs); 1318 // u(t) = 1 - e^(-t / time_constant).
1319 // In order to limit the affect of a BWE spike within 25% of its value before
1320 // the next probing, we would choose a time constant that fulfills
1321 // 1 - e^(-probing_interval_ms / time_constant) < 0.25
1322 // Then 4 * probing_interval_ms is a good choice.
1323 bitrate_smoother_.SetTimeConstantMs(probing_interval_ms * 4);
1319 bitrate_smoother_.AddSample(bitrate_bps); 1324 bitrate_smoother_.AddSample(bitrate_bps);
1320 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { 1325 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) {
1321 if (*encoder) { 1326 if (*encoder) {
1322 (*encoder)->OnReceivedUplinkBandwidth( 1327 (*encoder)->OnReceivedUplinkBandwidth(
1323 static_cast<int>(*bitrate_smoother_.GetAverage())); 1328 static_cast<int>(*bitrate_smoother_.GetAverage()));
1324 } 1329 }
1325 }); 1330 });
1326 } 1331 }
1327 1332
1328 void Channel::OnIncomingFractionLoss(int fraction_lost) { 1333 void Channel::OnIncomingFractionLoss(int fraction_lost) {
(...skipping 1915 matching lines...) Expand 10 before | Expand all | Expand 10 after
3244 int64_t min_rtt = 0; 3249 int64_t min_rtt = 0;
3245 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != 3250 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) !=
3246 0) { 3251 0) {
3247 return 0; 3252 return 0;
3248 } 3253 }
3249 return rtt; 3254 return rtt;
3250 } 3255 }
3251 3256
3252 } // namespace voe 3257 } // namespace voe
3253 } // namespace webrtc 3258 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698