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

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

Issue 2503713003: Smooth BWE and pass it to Audio Network Adaptor. (Closed)
Patch Set: Rebased 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
« no previous file with comments | « webrtc/voice_engine/channel.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 876 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 _outputSpeechType(AudioFrame::kNormalSpeech), 887 _outputSpeechType(AudioFrame::kNormalSpeech),
888 restored_packet_in_use_(false), 888 restored_packet_in_use_(false),
889 rtcp_observer_(new VoERtcpObserver(this)), 889 rtcp_observer_(new VoERtcpObserver(this)),
890 associate_send_channel_(ChannelOwner(nullptr)), 890 associate_send_channel_(ChannelOwner(nullptr)),
891 pacing_enabled_(config.enable_voice_pacing), 891 pacing_enabled_(config.enable_voice_pacing),
892 feedback_observer_proxy_(new TransportFeedbackProxy()), 892 feedback_observer_proxy_(new TransportFeedbackProxy()),
893 seq_num_allocator_proxy_(new TransportSequenceNumberProxy()), 893 seq_num_allocator_proxy_(new TransportSequenceNumberProxy()),
894 rtp_packet_sender_proxy_(new RtpPacketSenderProxy()), 894 rtp_packet_sender_proxy_(new RtpPacketSenderProxy()),
895 retransmission_rate_limiter_(new RateLimiter(Clock::GetRealTimeClock(), 895 retransmission_rate_limiter_(new RateLimiter(Clock::GetRealTimeClock(),
896 kMaxRetransmissionWindowMs)), 896 kMaxRetransmissionWindowMs)),
897 decoder_factory_(config.acm_config.decoder_factory) { 897 decoder_factory_(config.acm_config.decoder_factory),
898 // Bitrate smoother can be initialized with arbitrary time constant
899 // (0 used here). The actual time constant will be set in SetBitRate.
900 bitrate_smoother_(0, Clock::GetRealTimeClock()) {
898 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId), 901 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId),
899 "Channel::Channel() - ctor"); 902 "Channel::Channel() - ctor");
900 AudioCodingModule::Config acm_config(config.acm_config); 903 AudioCodingModule::Config acm_config(config.acm_config);
901 acm_config.id = VoEModuleId(instanceId, channelId); 904 acm_config.id = VoEModuleId(instanceId, channelId);
902 acm_config.neteq_config.enable_muted_state = true; 905 acm_config.neteq_config.enable_muted_state = true;
903 audio_coding_.reset(AudioCodingModule::Create(acm_config)); 906 audio_coding_.reset(AudioCodingModule::Create(acm_config));
904 907
905 _outputAudioLevel.Clear(); 908 _outputAudioLevel.Clear();
906 909
907 RtpRtcp::Configuration configuration; 910 RtpRtcp::Configuration configuration;
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
1299 } 1302 }
1300 1303
1301 void Channel::SetBitRate(int bitrate_bps) { 1304 void Channel::SetBitRate(int bitrate_bps) {
1302 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), 1305 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
1303 "Channel::SetBitRate(bitrate_bps=%d)", bitrate_bps); 1306 "Channel::SetBitRate(bitrate_bps=%d)", bitrate_bps);
1304 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { 1307 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) {
1305 if (*encoder) 1308 if (*encoder)
1306 (*encoder)->OnReceivedTargetAudioBitrate(bitrate_bps); 1309 (*encoder)->OnReceivedTargetAudioBitrate(bitrate_bps);
1307 }); 1310 });
1308 retransmission_rate_limiter_->SetMaxRate(bitrate_bps); 1311 retransmission_rate_limiter_->SetMaxRate(bitrate_bps);
1312
1313 // We give smoothed bitrate allocation to audio network adaptor as
1314 // the uplink bandwidth.
1315 // TODO(michaelt) : Remove kDefaultBitrateSmoothingTimeConstantMs as soon as
1316 // we pass the probing interval to this function.
1317 constexpr int64_t kDefaultBitrateSmoothingTimeConstantMs = 20000;
1318 bitrate_smoother_.SetTimeConstantMs(kDefaultBitrateSmoothingTimeConstantMs);
1319 bitrate_smoother_.AddSample(bitrate_bps);
1320 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) {
1321 if (*encoder) {
1322 (*encoder)->OnReceivedUplinkBandwidth(
1323 static_cast<int>(*bitrate_smoother_.GetAverage()));
1324 }
1325 });
1309 } 1326 }
1310 1327
1311 void Channel::OnIncomingFractionLoss(int fraction_lost) { 1328 void Channel::OnIncomingFractionLoss(int fraction_lost) {
1312 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { 1329 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) {
1313 if (*encoder) 1330 if (*encoder)
1314 (*encoder)->OnReceivedUplinkPacketLossFraction(fraction_lost / 255.0f); 1331 (*encoder)->OnReceivedUplinkPacketLossFraction(fraction_lost / 255.0f);
1315 }); 1332 });
1316 } 1333 }
1317 1334
1318 int32_t Channel::SetVADStatus(bool enableVAD, 1335 int32_t Channel::SetVADStatus(bool enableVAD,
(...skipping 1908 matching lines...) Expand 10 before | Expand all | Expand 10 after
3227 int64_t min_rtt = 0; 3244 int64_t min_rtt = 0;
3228 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != 3245 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) !=
3229 0) { 3246 0) {
3230 return 0; 3247 return 0;
3231 } 3248 }
3232 return rtt; 3249 return rtt;
3233 } 3250 }
3234 3251
3235 } // namespace voe 3252 } // namespace voe
3236 } // namespace webrtc 3253 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/voice_engine/channel.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698