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

Side by Side Diff: webrtc/video_engine/vie_encoder.cc

Issue 1231273004: Base padding bitrate for an encoder on the bitrate allocated for that encoder, rather than the tota… (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed comments Created 5 years, 5 months 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/video_engine/vie_encoder.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 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 if (enable) { 390 if (enable) {
391 // kInterpolation is currently not supported. 391 // kInterpolation is currently not supported.
392 LOG_F(LS_ERROR) << "Not supported."; 392 LOG_F(LS_ERROR) << "Not supported.";
393 return -1; 393 return -1;
394 } 394 }
395 vpm_->SetInputFrameResampleMode(resampling_mode); 395 vpm_->SetInputFrameResampleMode(resampling_mode);
396 396
397 return 0; 397 return 0;
398 } 398 }
399 399
400 int ViEEncoder::GetPaddingNeededBps(int bitrate_bps) const { 400 int ViEEncoder::GetPaddingNeededBps() const {
401 int64_t time_of_last_frame_activity_ms; 401 int64_t time_of_last_frame_activity_ms;
402 int min_transmit_bitrate_bps; 402 int min_transmit_bitrate_bps;
403 int bitrate_bps;
403 { 404 {
404 CriticalSectionScoped cs(data_cs_.get()); 405 CriticalSectionScoped cs(data_cs_.get());
405 bool send_padding = 406 bool send_padding =
406 send_padding_ || video_suspended_ || min_transmit_bitrate_kbps_ > 0; 407 send_padding_ || video_suspended_ || min_transmit_bitrate_kbps_ > 0;
407 if (!send_padding) 408 if (!send_padding)
408 return 0; 409 return 0;
409 time_of_last_frame_activity_ms = time_of_last_frame_activity_ms_; 410 time_of_last_frame_activity_ms = time_of_last_frame_activity_ms_;
410 min_transmit_bitrate_bps = 1000 * min_transmit_bitrate_kbps_; 411 min_transmit_bitrate_bps = 1000 * min_transmit_bitrate_kbps_;
412 bitrate_bps = last_observed_bitrate_bps_;
411 } 413 }
412 414
413 VideoCodec send_codec; 415 VideoCodec send_codec;
414 if (vcm_->SendCodec(&send_codec) != 0) 416 if (vcm_->SendCodec(&send_codec) != 0)
415 return 0; 417 return 0;
416 SimulcastStream* stream_configs = send_codec.simulcastStream;
417 // Allocate the bandwidth between the streams.
418 std::vector<uint32_t> stream_bitrates = AllocateStreamBitrates(
419 bitrate_bps, stream_configs, send_codec.numberOfSimulcastStreams);
420 418
421 bool video_is_suspended = vcm_->VideoSuspended(); 419 bool video_is_suspended = vcm_->VideoSuspended();
422 420
423 // Find the max amount of padding we can allow ourselves to send at this 421 // Find the max amount of padding we can allow ourselves to send at this
424 // point, based on which streams are currently active and what our current 422 // point, based on which streams are currently active and what our current
425 // available bandwidth is. 423 // available bandwidth is.
426 int pad_up_to_bitrate_bps = 0; 424 int pad_up_to_bitrate_bps = 0;
427 if (send_codec.numberOfSimulcastStreams == 0) { 425 if (send_codec.numberOfSimulcastStreams == 0) {
428 pad_up_to_bitrate_bps = send_codec.minBitrate * 1000; 426 pad_up_to_bitrate_bps = send_codec.minBitrate * 1000;
429 } else { 427 } else {
428 SimulcastStream* stream_configs = send_codec.simulcastStream;
430 pad_up_to_bitrate_bps = 429 pad_up_to_bitrate_bps =
431 stream_configs[send_codec.numberOfSimulcastStreams - 1].minBitrate * 430 stream_configs[send_codec.numberOfSimulcastStreams - 1].minBitrate *
432 1000; 431 1000;
433 for (int i = 0; i < send_codec.numberOfSimulcastStreams - 1; ++i) { 432 for (int i = 0; i < send_codec.numberOfSimulcastStreams - 1; ++i) {
434 pad_up_to_bitrate_bps += stream_configs[i].targetBitrate * 1000; 433 pad_up_to_bitrate_bps += stream_configs[i].targetBitrate * 1000;
435 } 434 }
436 } 435 }
437 436
438 // Disable padding if only sending one stream and video isn't suspended and 437 // Disable padding if only sending one stream and video isn't suspended and
439 // min-transmit bitrate isn't used (applied later). 438 // min-transmit bitrate isn't used (applied later).
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 const uint32_t width, 868 const uint32_t width,
870 const uint32_t height) { 869 const uint32_t height) {
871 return vpm_->SetTargetResolution(width, height, frame_rate); 870 return vpm_->SetTargetResolution(width, height, frame_rate);
872 } 871 }
873 872
874 void QMVideoSettingsCallback::SetTargetFramerate(int frame_rate) { 873 void QMVideoSettingsCallback::SetTargetFramerate(int frame_rate) {
875 vpm_->SetTargetFramerate(frame_rate); 874 vpm_->SetTargetFramerate(frame_rate);
876 } 875 }
877 876
878 } // namespace webrtc 877 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video_engine/vie_encoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698