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

Unified Diff: webrtc/voice_engine/channel.cc

Issue 2503713003: Smooth BWE and pass it to Audio Network Adaptor. (Closed)
Patch Set: Rebased 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/voice_engine/channel.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/voice_engine/channel.cc
diff --git a/webrtc/voice_engine/channel.cc b/webrtc/voice_engine/channel.cc
index b2fade87439870af781ce7f310836bdfcf781342..a7df1f2176ce5ade86669c8295c461758f9a9b2b 100644
--- a/webrtc/voice_engine/channel.cc
+++ b/webrtc/voice_engine/channel.cc
@@ -894,7 +894,10 @@ Channel::Channel(int32_t channelId,
rtp_packet_sender_proxy_(new RtpPacketSenderProxy()),
retransmission_rate_limiter_(new RateLimiter(Clock::GetRealTimeClock(),
kMaxRetransmissionWindowMs)),
- decoder_factory_(config.acm_config.decoder_factory) {
+ decoder_factory_(config.acm_config.decoder_factory),
+ // Bitrate smoother can be initialized with arbitrary time constant
+ // (0 used here). The actual time constant will be set in SetBitRate.
+ bitrate_smoother_(0, Clock::GetRealTimeClock()) {
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId),
"Channel::Channel() - ctor");
AudioCodingModule::Config acm_config(config.acm_config);
@@ -1306,6 +1309,20 @@ void Channel::SetBitRate(int bitrate_bps) {
(*encoder)->OnReceivedTargetAudioBitrate(bitrate_bps);
});
retransmission_rate_limiter_->SetMaxRate(bitrate_bps);
+
+ // We give smoothed bitrate allocation to audio network adaptor as
+ // the uplink bandwidth.
+ // TODO(michaelt) : Remove kDefaultBitrateSmoothingTimeConstantMs as soon as
+ // we pass the probing interval to this function.
+ constexpr int64_t kDefaultBitrateSmoothingTimeConstantMs = 20000;
+ bitrate_smoother_.SetTimeConstantMs(kDefaultBitrateSmoothingTimeConstantMs);
+ bitrate_smoother_.AddSample(bitrate_bps);
+ audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) {
+ if (*encoder) {
+ (*encoder)->OnReceivedUplinkBandwidth(
+ static_cast<int>(*bitrate_smoother_.GetAverage()));
+ }
+ });
}
void Channel::OnIncomingFractionLoss(int fraction_lost) {
« 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