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

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

Issue 2546493002: Update smoothed bitrate. (Closed)
Patch Set: Fix thread safety problem and changed smoothing filter. 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 1300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1311 }); 1311 });
1312 retransmission_rate_limiter_->SetMaxRate(bitrate_bps); 1312 retransmission_rate_limiter_->SetMaxRate(bitrate_bps);
1313 1313
1314 // We give smoothed bitrate allocation to audio network adaptor as 1314 // We give smoothed bitrate allocation to audio network adaptor as
1315 // the uplink bandwidth. 1315 // the uplink bandwidth.
1316 // TODO(michaelt) : Remove kDefaultBitrateSmoothingTimeConstantMs as soon as 1316 // TODO(michaelt) : Remove kDefaultBitrateSmoothingTimeConstantMs as soon as
1317 // we pass the probing interval to this function. 1317 // we pass the probing interval to this function.
1318 constexpr int64_t kDefaultBitrateSmoothingTimeConstantMs = 20000; 1318 constexpr int64_t kDefaultBitrateSmoothingTimeConstantMs = 20000;
1319 bitrate_smoother_.SetTimeConstantMs(kDefaultBitrateSmoothingTimeConstantMs); 1319 bitrate_smoother_.SetTimeConstantMs(kDefaultBitrateSmoothingTimeConstantMs);
1320 bitrate_smoother_.AddSample(bitrate_bps); 1320 bitrate_smoother_.AddSample(bitrate_bps);
1321 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) {
1322 if (*encoder) {
1323 (*encoder)->OnReceivedUplinkBandwidth(
1324 static_cast<int>(*bitrate_smoother_.GetAverage()));
1325 }
1326 });
1327 } 1321 }
1328 1322
1329 void Channel::OnIncomingFractionLoss(int fraction_lost) { 1323 void Channel::OnIncomingFractionLoss(int fraction_lost) {
1330 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { 1324 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) {
1331 if (*encoder) 1325 if (*encoder)
1332 (*encoder)->OnReceivedUplinkPacketLossFraction(fraction_lost / 255.0f); 1326 (*encoder)->OnReceivedUplinkPacketLossFraction(fraction_lost / 255.0f);
1333 }); 1327 });
1334 } 1328 }
1335 1329
1336 int32_t Channel::SetVADStatus(bool enableVAD, 1330 int32_t Channel::SetVADStatus(bool enableVAD,
(...skipping 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after
2713 // If pacing is enabled we always store packets. 2707 // If pacing is enabled we always store packets.
2714 if (!pacing_enabled_) 2708 if (!pacing_enabled_)
2715 _rtpRtcpModule->SetStorePacketsStatus(enable, maxNumberOfPackets); 2709 _rtpRtcpModule->SetStorePacketsStatus(enable, maxNumberOfPackets);
2716 rtp_receive_statistics_->SetMaxReorderingThreshold(maxNumberOfPackets); 2710 rtp_receive_statistics_->SetMaxReorderingThreshold(maxNumberOfPackets);
2717 if (enable) 2711 if (enable)
2718 audio_coding_->EnableNack(maxNumberOfPackets); 2712 audio_coding_->EnableNack(maxNumberOfPackets);
2719 else 2713 else
2720 audio_coding_->DisableNack(); 2714 audio_coding_->DisableNack();
2721 } 2715 }
2722 2716
2717 void Channel::AdaptCodec() {
2718 rtc::Optional<float> smoothed_bitrate = bitrate_smoother_.GetAverage();
2719 if (smoothed_bitrate) {
2720 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) {
2721 if (*encoder) {
2722 (*encoder)->OnReceivedUplinkBandwidth(
2723 static_cast<int>(*smoothed_bitrate));
2724 }
2725 });
2726 }
2727 }
2728
2723 // Called when we are missing one or more packets. 2729 // Called when we are missing one or more packets.
2724 int Channel::ResendPackets(const uint16_t* sequence_numbers, int length) { 2730 int Channel::ResendPackets(const uint16_t* sequence_numbers, int length) {
2725 return _rtpRtcpModule->SendNACK(sequence_numbers, length); 2731 return _rtpRtcpModule->SendNACK(sequence_numbers, length);
2726 } 2732 }
2727 2733
2728 uint32_t Channel::Demultiplex(const AudioFrame& audioFrame) { 2734 uint32_t Channel::Demultiplex(const AudioFrame& audioFrame) {
2729 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), 2735 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId),
2730 "Channel::Demultiplex()"); 2736 "Channel::Demultiplex()");
2731 _audioFrame.CopyFrom(audioFrame); 2737 _audioFrame.CopyFrom(audioFrame);
2732 _audioFrame.id_ = _channelId; 2738 _audioFrame.id_ = _channelId;
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
3246 int64_t min_rtt = 0; 3252 int64_t min_rtt = 0;
3247 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != 3253 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) !=
3248 0) { 3254 0) {
3249 return 0; 3255 return 0;
3250 } 3256 }
3251 return rtt; 3257 return rtt;
3252 } 3258 }
3253 3259
3254 } // namespace voe 3260 } // namespace voe
3255 } // namespace webrtc 3261 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698