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

Side by Side Diff: webrtc/audio/audio_send_stream.cc

Issue 2546493002: Update smoothed bitrate. (Closed)
Patch Set: 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) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 } 220 }
221 221
222 bool AudioSendStream::DeliverRtcp(const uint8_t* packet, size_t length) { 222 bool AudioSendStream::DeliverRtcp(const uint8_t* packet, size_t length) {
223 // TODO(solenberg): Tests call this function on a network thread, libjingle 223 // TODO(solenberg): Tests call this function on a network thread, libjingle
224 // calls on the worker thread. We should move towards always using a network 224 // calls on the worker thread. We should move towards always using a network
225 // thread. Then this check can be enabled. 225 // thread. Then this check can be enabled.
226 // RTC_DCHECK(!thread_checker_.CalledOnValidThread()); 226 // RTC_DCHECK(!thread_checker_.CalledOnValidThread());
227 return channel_proxy_->ReceivedRTCPPacket(packet, length); 227 return channel_proxy_->ReceivedRTCPPacket(packet, length);
228 } 228 }
229 229
230 uint32_t AudioSendStream::OnBitrateUpdated(uint32_t bitrate_bps, 230 uint32_t AudioSendStream::OnBitrateUpdated(uint32_t bitrate_bps,
the sun 2016/12/01 09:16:55 If we can't RTC_DCHECK(thread_checker_.CalledOnVa
michaelt 2016/12/05 15:08:49 OnBitrateUpdated is called on the worker queue. h
231 uint8_t fraction_loss, 231 uint8_t fraction_loss,
232 int64_t rtt) { 232 int64_t rtt) {
233 RTC_DCHECK_GE(bitrate_bps, 233 RTC_DCHECK_GE(bitrate_bps,
234 static_cast<uint32_t>(config_.min_bitrate_bps)); 234 static_cast<uint32_t>(config_.min_bitrate_bps));
235 // The bitrate allocator might allocate an higher than max configured bitrate 235 // The bitrate allocator might allocate an higher than max configured bitrate
236 // if there is room, to allow for, as example, extra FEC. Ignore that for now. 236 // if there is room, to allow for, as example, extra FEC. Ignore that for now.
237 const uint32_t max_bitrate_bps = config_.max_bitrate_bps; 237 const uint32_t max_bitrate_bps = config_.max_bitrate_bps;
238 if (bitrate_bps > max_bitrate_bps) 238 if (bitrate_bps > max_bitrate_bps)
239 bitrate_bps = max_bitrate_bps; 239 bitrate_bps = max_bitrate_bps;
240 240
241 channel_proxy_->SetBitrate(bitrate_bps); 241 channel_proxy_->SetBitrate(bitrate_bps);
242 242
243 if (first_update_bitrate_())
the sun 2016/12/01 09:16:55 nit: always {} in this file, even for one-liners
michaelt 2016/12/05 15:08:49 Done.
244 UpdateSmoothedBitrate();
243 // The amount of audio protection is not exposed by the encoder, hence 245 // The amount of audio protection is not exposed by the encoder, hence
244 // always returning 0. 246 // always returning 0.
245 return 0; 247 return 0;
246 } 248 }
247 249
248 const webrtc::AudioSendStream::Config& AudioSendStream::config() const { 250 const webrtc::AudioSendStream::Config& AudioSendStream::config() const {
249 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 251 RTC_DCHECK(thread_checker_.CalledOnValidThread());
250 return config_; 252 return config_;
251 } 253 }
252 254
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 // interaction between VAD and Opus FEC. 377 // interaction between VAD and Opus FEC.
376 if (codec->SetVADStatus(channel, true) != 0) { 378 if (codec->SetVADStatus(channel, true) != 0) {
377 LOG(LS_WARNING) << "SetVADStatus() failed: " << base->LastError(); 379 LOG(LS_WARNING) << "SetVADStatus() failed: " << base->LastError();
378 return false; 380 return false;
379 } 381 }
380 } 382 }
381 } 383 }
382 return true; 384 return true;
383 } 385 }
384 386
387 void AudioSendStream::UpdateSmoothedBitrate() {
388 channel_proxy_->UpdateSmoothedBitrate();
389 constexpr uint32_t kUpdateSmoothedBitrateIntervalMs = 200;
390 worker_queue_->PostDelayedTask([this]() { UpdateSmoothedBitrate(); },
391 kUpdateSmoothedBitrateIntervalMs);
392 }
393
385 } // namespace internal 394 } // namespace internal
386 } // namespace webrtc 395 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698