| OLD | NEW |
| 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 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 namespace webrtc { | 22 namespace webrtc { |
| 23 | 23 |
| 24 VCMGenericEncoder::VCMGenericEncoder( | 24 VCMGenericEncoder::VCMGenericEncoder( |
| 25 VideoEncoder* encoder, | 25 VideoEncoder* encoder, |
| 26 VCMEncodedFrameCallback* encoded_frame_callback, | 26 VCMEncodedFrameCallback* encoded_frame_callback, |
| 27 bool internal_source) | 27 bool internal_source) |
| 28 : encoder_(encoder), | 28 : encoder_(encoder), |
| 29 vcm_encoded_frame_callback_(encoded_frame_callback), | 29 vcm_encoded_frame_callback_(encoded_frame_callback), |
| 30 internal_source_(internal_source), | 30 internal_source_(internal_source), |
| 31 encoder_params_({0, 0, 0, 0}), | 31 encoder_params_({BitrateAllocation(), 0, 0, 0}), |
| 32 is_screenshare_(false) {} | 32 is_screenshare_(false) {} |
| 33 | 33 |
| 34 VCMGenericEncoder::~VCMGenericEncoder() {} | 34 VCMGenericEncoder::~VCMGenericEncoder() {} |
| 35 | 35 |
| 36 int32_t VCMGenericEncoder::Release() { | 36 int32_t VCMGenericEncoder::Release() { |
| 37 RTC_DCHECK_RUNS_SERIALIZED(&race_checker_); | 37 RTC_DCHECK_RUNS_SERIALIZED(&race_checker_); |
| 38 TRACE_EVENT0("webrtc", "VCMGenericEncoder::Release"); | 38 TRACE_EVENT0("webrtc", "VCMGenericEncoder::Release"); |
| 39 return encoder_->Release(); | 39 return encoder_->Release(); |
| 40 } | 40 } |
| 41 | 41 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 params.loss_rate != encoder_params_.loss_rate || | 86 params.loss_rate != encoder_params_.loss_rate || |
| 87 params.rtt != encoder_params_.rtt; | 87 params.rtt != encoder_params_.rtt; |
| 88 rates_have_changed = | 88 rates_have_changed = |
| 89 params.target_bitrate != encoder_params_.target_bitrate || | 89 params.target_bitrate != encoder_params_.target_bitrate || |
| 90 params.input_frame_rate != encoder_params_.input_frame_rate; | 90 params.input_frame_rate != encoder_params_.input_frame_rate; |
| 91 encoder_params_ = params; | 91 encoder_params_ = params; |
| 92 } | 92 } |
| 93 if (channel_parameters_have_changed) | 93 if (channel_parameters_have_changed) |
| 94 encoder_->SetChannelParameters(params.loss_rate, params.rtt); | 94 encoder_->SetChannelParameters(params.loss_rate, params.rtt); |
| 95 if (rates_have_changed) { | 95 if (rates_have_changed) { |
| 96 uint32_t target_bitrate_kbps = (params.target_bitrate + 500) / 1000; | 96 encoder_->SetRateAllocation(params.target_bitrate, params.input_frame_rate); |
| 97 encoder_->SetRates(target_bitrate_kbps, params.input_frame_rate); | |
| 98 } | 97 } |
| 99 } | 98 } |
| 100 | 99 |
| 101 EncoderParameters VCMGenericEncoder::GetEncoderParameters() const { | 100 EncoderParameters VCMGenericEncoder::GetEncoderParameters() const { |
| 102 rtc::CritScope lock(¶ms_lock_); | 101 rtc::CritScope lock(¶ms_lock_); |
| 103 return encoder_params_; | 102 return encoder_params_; |
| 104 } | 103 } |
| 105 | 104 |
| 106 int32_t VCMGenericEncoder::SetPeriodicKeyFrames(bool enable) { | 105 int32_t VCMGenericEncoder::SetPeriodicKeyFrames(bool enable) { |
| 107 RTC_DCHECK_RUNS_SERIALIZED(&race_checker_); | 106 RTC_DCHECK_RUNS_SERIALIZED(&race_checker_); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 media_opt_->UpdateWithEncodedData(encoded_image); | 152 media_opt_->UpdateWithEncodedData(encoded_image); |
| 154 if (internal_source_) { | 153 if (internal_source_) { |
| 155 // Signal to encoder to drop next frame. | 154 // Signal to encoder to drop next frame. |
| 156 result.drop_next_frame = media_opt_->DropFrame(); | 155 result.drop_next_frame = media_opt_->DropFrame(); |
| 157 } | 156 } |
| 158 } | 157 } |
| 159 return result; | 158 return result; |
| 160 } | 159 } |
| 161 | 160 |
| 162 } // namespace webrtc | 161 } // namespace webrtc |
| OLD | NEW |