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_({BitrateAllocation(), 0, 0, 0}), | 31 encoder_params_({0, 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 { | 83 { |
84 rtc::CritScope lock(¶ms_lock_); | 84 rtc::CritScope lock(¶ms_lock_); |
85 channel_parameters_have_changed = | 85 channel_parameters_have_changed = |
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 int res = encoder_->SetChannelParameters(params.loss_rate, params.rtt); | 94 encoder_->SetChannelParameters(params.loss_rate, params.rtt); |
95 if (res != 0) { | |
96 LOG(LS_WARNING) << "Error set encoder parameters (loss = " | |
97 << params.loss_rate << ", rtt = " << params.rtt | |
98 << "): " << res; | |
99 } | |
100 } | |
101 if (rates_have_changed) { | 95 if (rates_have_changed) { |
102 int res = encoder_->SetRateAllocation(params.target_bitrate, | 96 uint32_t target_bitrate_kbps = (params.target_bitrate + 500) / 1000; |
103 params.input_frame_rate); | 97 encoder_->SetRates(target_bitrate_kbps, params.input_frame_rate); |
104 if (res != 0) { | |
105 LOG(LS_WARNING) << "Error set encoder rate (total bitrate bps = " | |
106 << params.target_bitrate.get_sum_bps() | |
107 << ", framerate = " << params.input_frame_rate | |
108 << "): " << res; | |
109 } | |
110 } | 98 } |
111 } | 99 } |
112 | 100 |
113 EncoderParameters VCMGenericEncoder::GetEncoderParameters() const { | 101 EncoderParameters VCMGenericEncoder::GetEncoderParameters() const { |
114 rtc::CritScope lock(¶ms_lock_); | 102 rtc::CritScope lock(¶ms_lock_); |
115 return encoder_params_; | 103 return encoder_params_; |
116 } | 104 } |
117 | 105 |
118 int32_t VCMGenericEncoder::SetPeriodicKeyFrames(bool enable) { | 106 int32_t VCMGenericEncoder::SetPeriodicKeyFrames(bool enable) { |
119 RTC_DCHECK_RUNS_SERIALIZED(&race_checker_); | 107 RTC_DCHECK_RUNS_SERIALIZED(&race_checker_); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 media_opt_->UpdateWithEncodedData(encoded_image); | 153 media_opt_->UpdateWithEncodedData(encoded_image); |
166 if (internal_source_) { | 154 if (internal_source_) { |
167 // Signal to encoder to drop next frame. | 155 // Signal to encoder to drop next frame. |
168 result.drop_next_frame = media_opt_->DropFrame(); | 156 result.drop_next_frame = media_opt_->DropFrame(); |
169 } | 157 } |
170 } | 158 } |
171 return result; | 159 return result; |
172 } | 160 } |
173 | 161 |
174 } // namespace webrtc | 162 } // namespace webrtc |
OLD | NEW |