| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/media/video_track_recorder.h" | 5 #include "content/renderer/media/video_track_recorder.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 const vpx_codec_iface_t* interface = | 285 const vpx_codec_iface_t* interface = |
| 286 use_vp9_ ? vpx_codec_vp9_cx() : vpx_codec_vp8_cx(); | 286 use_vp9_ ? vpx_codec_vp9_cx() : vpx_codec_vp8_cx(); |
| 287 vpx_codec_err_t result = | 287 vpx_codec_err_t result = |
| 288 vpx_codec_enc_config_default(interface, &codec_config_, 0 /* reserved */); | 288 vpx_codec_enc_config_default(interface, &codec_config_, 0 /* reserved */); |
| 289 DCHECK_EQ(VPX_CODEC_OK, result); | 289 DCHECK_EQ(VPX_CODEC_OK, result); |
| 290 | 290 |
| 291 DCHECK_EQ(320u, codec_config_.g_w); | 291 DCHECK_EQ(320u, codec_config_.g_w); |
| 292 DCHECK_EQ(240u, codec_config_.g_h); | 292 DCHECK_EQ(240u, codec_config_.g_h); |
| 293 DCHECK_EQ(256u, codec_config_.rc_target_bitrate); | 293 DCHECK_EQ(256u, codec_config_.rc_target_bitrate); |
| 294 // Use the selected bitrate or adjust default bit rate to account for the | 294 // Use the selected bitrate or adjust default bit rate to account for the |
| 295 // actual size. | 295 // actual size. Note: |rc_target_bitrate| units are kbit per second. |
| 296 if (bits_per_second_ > 0) { | 296 if (bits_per_second_ > 0) { |
| 297 codec_config_.rc_target_bitrate = bits_per_second_; | 297 codec_config_.rc_target_bitrate = bits_per_second_ / 1000; |
| 298 } else { | 298 } else { |
| 299 codec_config_.rc_target_bitrate = size.GetArea() * | 299 codec_config_.rc_target_bitrate = size.GetArea() * |
| 300 codec_config_.rc_target_bitrate / | 300 codec_config_.rc_target_bitrate / |
| 301 codec_config_.g_w / codec_config_.g_h; | 301 codec_config_.g_w / codec_config_.g_h; |
| 302 } | 302 } |
| 303 // Both VP8/VP9 configuration should be Variable BitRate by default. | 303 // Both VP8/VP9 configuration should be Variable BitRate by default. |
| 304 DCHECK_EQ(VPX_VBR, codec_config_.rc_end_usage); | 304 DCHECK_EQ(VPX_VBR, codec_config_.rc_end_usage); |
| 305 if (use_vp9_) { | 305 if (use_vp9_) { |
| 306 // Number of frames to consume before producing output. | 306 // Number of frames to consume before producing output. |
| 307 codec_config_.g_lag_in_frames = 0; | 307 codec_config_.g_lag_in_frames = 0; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 encoder_->set_paused(false); | 432 encoder_->set_paused(false); |
| 433 } | 433 } |
| 434 | 434 |
| 435 void VideoTrackRecorder::OnVideoFrameForTesting( | 435 void VideoTrackRecorder::OnVideoFrameForTesting( |
| 436 const scoped_refptr<media::VideoFrame>& frame, | 436 const scoped_refptr<media::VideoFrame>& frame, |
| 437 base::TimeTicks timestamp) { | 437 base::TimeTicks timestamp) { |
| 438 encoder_->StartFrameEncode(frame, timestamp); | 438 encoder_->StartFrameEncode(frame, timestamp); |
| 439 } | 439 } |
| 440 | 440 |
| 441 } // namespace content | 441 } // namespace content |
| OLD | NEW |