Index: webrtc/voice_engine/channel.cc |
diff --git a/webrtc/voice_engine/channel.cc b/webrtc/voice_engine/channel.cc |
index 3d195eb141aaf47af41f7d9bcdfbf5fcfb7a67b9..5161881b08e140f5d9af03db80c743e2d465f542 100644 |
--- a/webrtc/voice_engine/channel.cc |
+++ b/webrtc/voice_engine/channel.cc |
@@ -895,7 +895,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), |
+ // 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.
|
+ // call of SetBitRate. |
+ bitrate_smoother_(0, Clock::GetRealTimeClock()) { |
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId), |
"Channel::Channel() - ctor"); |
AudioCodingModule::Config acm_config(config.acm_config); |
@@ -1309,6 +1312,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) { |