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

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

Issue 2546493002: Update smoothed bitrate. (Closed)
Patch Set: Response to comments 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 1327 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 // We give smoothed bitrate allocation to audio network adaptor as 1338 // We give smoothed bitrate allocation to audio network adaptor as
1339 // the uplink bandwidth. 1339 // the uplink bandwidth.
1340 // The probing spikes should not affect the bitrate smoother more than 25%. 1340 // The probing spikes should not affect the bitrate smoother more than 25%.
1341 // To simplify the calculations we use a step response as input signal. 1341 // To simplify the calculations we use a step response as input signal.
1342 // The step response of an exponential filter is 1342 // The step response of an exponential filter is
1343 // u(t) = 1 - e^(-t / time_constant). 1343 // u(t) = 1 - e^(-t / time_constant).
1344 // In order to limit the affect of a BWE spike within 25% of its value before 1344 // In order to limit the affect of a BWE spike within 25% of its value before
1345 // the next probing, we would choose a time constant that fulfills 1345 // the next probing, we would choose a time constant that fulfills
1346 // 1 - e^(-probing_interval_ms / time_constant) < 0.25 1346 // 1 - e^(-probing_interval_ms / time_constant) < 0.25
1347 // Then 4 * probing_interval_ms is a good choice. 1347 // Then 4 * probing_interval_ms is a good choice.
1348 rtc::CritScope lock(&bitrate_smoother_lock_);
1348 bitrate_smoother_.SetTimeConstantMs(probing_interval_ms * 4); 1349 bitrate_smoother_.SetTimeConstantMs(probing_interval_ms * 4);
ossu 2016/12/20 13:58:09 Not strictly part of this CL, but I'm interested:
michaelt 2016/12/20 15:13:03 The same filter is used in a different place where
1349 bitrate_smoother_.AddSample(bitrate_bps); 1350 bitrate_smoother_.AddSample(bitrate_bps);
1350 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) {
1351 if (*encoder) {
1352 (*encoder)->OnReceivedUplinkBandwidth(
1353 static_cast<int>(*bitrate_smoother_.GetAverage()));
1354 }
1355 });
1356 } 1351 }
1357 1352
1358 void Channel::OnIncomingFractionLoss(int fraction_lost) { 1353 void Channel::OnIncomingFractionLoss(int fraction_lost) {
1359 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { 1354 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) {
1360 if (*encoder) 1355 if (*encoder)
1361 (*encoder)->OnReceivedUplinkPacketLossFraction(fraction_lost / 255.0f); 1356 (*encoder)->OnReceivedUplinkPacketLossFraction(fraction_lost / 255.0f);
1362 }); 1357 });
1363 } 1358 }
1364 1359
1365 int32_t Channel::SetVADStatus(bool enableVAD, 1360 int32_t Channel::SetVADStatus(bool enableVAD,
(...skipping 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after
2742 // If pacing is enabled we always store packets. 2737 // If pacing is enabled we always store packets.
2743 if (!pacing_enabled_) 2738 if (!pacing_enabled_)
2744 _rtpRtcpModule->SetStorePacketsStatus(enable, maxNumberOfPackets); 2739 _rtpRtcpModule->SetStorePacketsStatus(enable, maxNumberOfPackets);
2745 rtp_receive_statistics_->SetMaxReorderingThreshold(maxNumberOfPackets); 2740 rtp_receive_statistics_->SetMaxReorderingThreshold(maxNumberOfPackets);
2746 if (enable) 2741 if (enable)
2747 audio_coding_->EnableNack(maxNumberOfPackets); 2742 audio_coding_->EnableNack(maxNumberOfPackets);
2748 else 2743 else
2749 audio_coding_->DisableNack(); 2744 audio_coding_->DisableNack();
2750 } 2745 }
2751 2746
2747 void Channel::AdaptCodec() {
2748 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) {
2749 rtc::CritScope lock(&bitrate_smoother_lock_);
2750 if (*encoder) {
2751 (*encoder)->OnReceivedUplinkBandwidth(
2752 static_cast<int>(*bitrate_smoother_.GetAverage()));
2753 }
2754 });
2755 }
2756
2752 // Called when we are missing one or more packets. 2757 // Called when we are missing one or more packets.
2753 int Channel::ResendPackets(const uint16_t* sequence_numbers, int length) { 2758 int Channel::ResendPackets(const uint16_t* sequence_numbers, int length) {
2754 return _rtpRtcpModule->SendNACK(sequence_numbers, length); 2759 return _rtpRtcpModule->SendNACK(sequence_numbers, length);
2755 } 2760 }
2756 2761
2757 uint32_t Channel::Demultiplex(const AudioFrame& audioFrame) { 2762 uint32_t Channel::Demultiplex(const AudioFrame& audioFrame) {
2758 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), 2763 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId),
2759 "Channel::Demultiplex()"); 2764 "Channel::Demultiplex()");
2760 _audioFrame.CopyFrom(audioFrame); 2765 _audioFrame.CopyFrom(audioFrame);
2761 _audioFrame.id_ = _channelId; 2766 _audioFrame.id_ = _channelId;
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
3279 int64_t min_rtt = 0; 3284 int64_t min_rtt = 0;
3280 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != 3285 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) !=
3281 0) { 3286 0) {
3282 return 0; 3287 return 0;
3283 } 3288 }
3284 return rtt; 3289 return rtt;
3285 } 3290 }
3286 3291
3287 } // namespace voe 3292 } // namespace voe
3288 } // namespace webrtc 3293 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698