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

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

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

Powered by Google App Engine
This is Rietveld 408576698