| OLD | NEW |
| 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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 encoded_image_buffer_.reset(); | 245 encoded_image_buffer_.reset(); |
| 246 return WEBRTC_VIDEO_CODEC_OK; | 246 return WEBRTC_VIDEO_CODEC_OK; |
| 247 } | 247 } |
| 248 | 248 |
| 249 int32_t H264EncoderImpl::RegisterEncodeCompleteCallback( | 249 int32_t H264EncoderImpl::RegisterEncodeCompleteCallback( |
| 250 EncodedImageCallback* callback) { | 250 EncodedImageCallback* callback) { |
| 251 encoded_image_callback_ = callback; | 251 encoded_image_callback_ = callback; |
| 252 return WEBRTC_VIDEO_CODEC_OK; | 252 return WEBRTC_VIDEO_CODEC_OK; |
| 253 } | 253 } |
| 254 | 254 |
| 255 int32_t H264EncoderImpl::SetRates(uint32_t bitrate, uint32_t framerate) { | 255 int32_t H264EncoderImpl::SetRateAllocation( |
| 256 if (bitrate <= 0 || framerate <= 0) { | 256 const BitrateAllocation& bitrate_allocation, |
| 257 uint32_t framerate) { |
| 258 if (bitrate_allocation.get_sum_kbps() <= 0 || framerate <= 0) { |
| 257 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; | 259 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; |
| 258 } | 260 } |
| 259 codec_settings_.targetBitrate = bitrate; | 261 codec_settings_.targetBitrate = bitrate_allocation.get_sum_kbps(); |
| 260 codec_settings_.maxFramerate = framerate; | 262 codec_settings_.maxFramerate = framerate; |
| 261 quality_scaler_.ReportFramerate(framerate); | 263 quality_scaler_.ReportFramerate(framerate); |
| 262 | 264 |
| 263 SBitrateInfo target_bitrate; | 265 SBitrateInfo target_bitrate; |
| 264 memset(&target_bitrate, 0, sizeof(SBitrateInfo)); | 266 memset(&target_bitrate, 0, sizeof(SBitrateInfo)); |
| 265 target_bitrate.iLayer = SPATIAL_LAYER_ALL, | 267 target_bitrate.iLayer = SPATIAL_LAYER_ALL, |
| 266 target_bitrate.iBitrate = codec_settings_.targetBitrate * 1000; | 268 target_bitrate.iBitrate = codec_settings_.targetBitrate * 1000; |
| 267 openh264_encoder_->SetOption(ENCODER_OPTION_BITRATE, | 269 openh264_encoder_->SetOption(ENCODER_OPTION_BITRATE, |
| 268 &target_bitrate); | 270 &target_bitrate); |
| 269 float max_framerate = static_cast<float>(codec_settings_.maxFramerate); | 271 float max_framerate = static_cast<float>(codec_settings_.maxFramerate); |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 | 484 |
| 483 int32_t H264EncoderImpl::SetPeriodicKeyFrames(bool enable) { | 485 int32_t H264EncoderImpl::SetPeriodicKeyFrames(bool enable) { |
| 484 return WEBRTC_VIDEO_CODEC_OK; | 486 return WEBRTC_VIDEO_CODEC_OK; |
| 485 } | 487 } |
| 486 | 488 |
| 487 void H264EncoderImpl::OnDroppedFrame() { | 489 void H264EncoderImpl::OnDroppedFrame() { |
| 488 quality_scaler_.ReportDroppedFrame(); | 490 quality_scaler_.ReportDroppedFrame(); |
| 489 } | 491 } |
| 490 | 492 |
| 491 } // namespace webrtc | 493 } // namespace webrtc |
| OLD | NEW |