OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 } | 96 } |
97 | 97 |
98 // SetSendCodec succeeded, _encoder should be set. | 98 // SetSendCodec succeeded, _encoder should be set. |
99 RTC_DCHECK(_encoder); | 99 RTC_DCHECK(_encoder); |
100 | 100 |
101 int numLayers; | 101 int numLayers; |
102 if (sendCodec->codecType == kVideoCodecVP8) { | 102 if (sendCodec->codecType == kVideoCodecVP8) { |
103 numLayers = sendCodec->VP8().numberOfTemporalLayers; | 103 numLayers = sendCodec->VP8().numberOfTemporalLayers; |
104 } else if (sendCodec->codecType == kVideoCodecVP9) { | 104 } else if (sendCodec->codecType == kVideoCodecVP9) { |
105 numLayers = sendCodec->VP9().numberOfTemporalLayers; | 105 numLayers = sendCodec->VP9().numberOfTemporalLayers; |
| 106 } else if (sendCodec->codecType == kVideoCodecGeneric && |
| 107 sendCodec->numberOfSimulcastStreams > 0) { |
| 108 // This is mainly for unit testing, disabling frame dropping. |
| 109 // TODO(sprang): Add a better way to disable frame dropping. |
| 110 numLayers = sendCodec->simulcastStream[0].numberOfTemporalLayers; |
106 } else { | 111 } else { |
107 numLayers = 1; | 112 numLayers = 1; |
108 } | 113 } |
109 | 114 |
110 // If we have screensharing and we have layers, we disable frame dropper. | 115 // If we have screensharing and we have layers, we disable frame dropper. |
111 bool disable_frame_dropper = | 116 bool disable_frame_dropper = |
112 numLayers > 1 && sendCodec->mode == kScreensharing; | 117 numLayers > 1 && sendCodec->mode == kScreensharing; |
113 if (disable_frame_dropper) { | 118 if (disable_frame_dropper) { |
114 _mediaOpt.EnableFrameDropper(false); | 119 _mediaOpt.EnableFrameDropper(false); |
115 } else if (frame_dropper_enabled_) { | 120 } else if (frame_dropper_enabled_) { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 EncoderParameters VideoSender::UpdateEncoderParameters( | 195 EncoderParameters VideoSender::UpdateEncoderParameters( |
191 const EncoderParameters& params, | 196 const EncoderParameters& params, |
192 VideoBitrateAllocator* bitrate_allocator, | 197 VideoBitrateAllocator* bitrate_allocator, |
193 uint32_t target_bitrate_bps) { | 198 uint32_t target_bitrate_bps) { |
194 uint32_t video_target_rate_bps = _mediaOpt.SetTargetRates(target_bitrate_bps); | 199 uint32_t video_target_rate_bps = _mediaOpt.SetTargetRates(target_bitrate_bps); |
195 uint32_t input_frame_rate = _mediaOpt.InputFrameRate(); | 200 uint32_t input_frame_rate = _mediaOpt.InputFrameRate(); |
196 if (input_frame_rate == 0) | 201 if (input_frame_rate == 0) |
197 input_frame_rate = current_codec_.maxFramerate; | 202 input_frame_rate = current_codec_.maxFramerate; |
198 | 203 |
199 BitrateAllocation bitrate_allocation; | 204 BitrateAllocation bitrate_allocation; |
200 if (bitrate_allocator) { | 205 // Only call allocators if bitrate > 0 (ie, not suspended), otherwise they |
201 bitrate_allocation = bitrate_allocator->GetAllocation(video_target_rate_bps, | 206 // might cap the bitrate to the min bitrate configured. |
202 input_frame_rate); | 207 if (target_bitrate_bps > 0) { |
203 } else { | 208 if (bitrate_allocator) { |
204 DefaultVideoBitrateAllocator default_allocator(current_codec_); | 209 bitrate_allocation = bitrate_allocator->GetAllocation( |
205 bitrate_allocation = default_allocator.GetAllocation(video_target_rate_bps, | 210 video_target_rate_bps, input_frame_rate); |
206 input_frame_rate); | 211 } else { |
| 212 DefaultVideoBitrateAllocator default_allocator(current_codec_); |
| 213 bitrate_allocation = default_allocator.GetAllocation( |
| 214 video_target_rate_bps, input_frame_rate); |
| 215 } |
207 } | 216 } |
208 EncoderParameters new_encoder_params = {bitrate_allocation, params.loss_rate, | 217 EncoderParameters new_encoder_params = {bitrate_allocation, params.loss_rate, |
209 params.rtt, input_frame_rate}; | 218 params.rtt, input_frame_rate}; |
210 return new_encoder_params; | 219 return new_encoder_params; |
211 } | 220 } |
212 | 221 |
213 void VideoSender::UpdateChannelParemeters( | 222 void VideoSender::UpdateChannelParemeters( |
214 VideoBitrateAllocator* bitrate_allocator, | 223 VideoBitrateAllocator* bitrate_allocator, |
215 VideoBitrateAllocationObserver* bitrate_updated_callback) { | 224 VideoBitrateAllocationObserver* bitrate_updated_callback) { |
216 BitrateAllocation target_rate; | 225 BitrateAllocation target_rate; |
217 { | 226 { |
218 rtc::CritScope cs(¶ms_crit_); | 227 rtc::CritScope cs(¶ms_crit_); |
219 encoder_params_ = | 228 encoder_params_ = |
220 UpdateEncoderParameters(encoder_params_, bitrate_allocator, | 229 UpdateEncoderParameters(encoder_params_, bitrate_allocator, |
221 encoder_params_.target_bitrate.get_sum_bps()); | 230 encoder_params_.target_bitrate.get_sum_bps()); |
222 target_rate = encoder_params_.target_bitrate; | 231 target_rate = encoder_params_.target_bitrate; |
223 } | 232 } |
224 if (bitrate_updated_callback) | 233 if (bitrate_updated_callback && target_rate.get_sum_bps() > 0) |
225 bitrate_updated_callback->OnBitrateAllocationUpdated(target_rate); | 234 bitrate_updated_callback->OnBitrateAllocationUpdated(target_rate); |
226 } | 235 } |
227 | 236 |
228 int32_t VideoSender::SetChannelParameters( | 237 int32_t VideoSender::SetChannelParameters( |
229 uint32_t target_bitrate_bps, | 238 uint32_t target_bitrate_bps, |
230 uint8_t loss_rate, | 239 uint8_t loss_rate, |
231 int64_t rtt, | 240 int64_t rtt, |
232 VideoBitrateAllocator* bitrate_allocator, | 241 VideoBitrateAllocator* bitrate_allocator, |
233 VideoBitrateAllocationObserver* bitrate_updated_callback) { | 242 VideoBitrateAllocationObserver* bitrate_updated_callback) { |
234 EncoderParameters encoder_params; | 243 EncoderParameters encoder_params; |
235 encoder_params.loss_rate = loss_rate; | 244 encoder_params.loss_rate = loss_rate; |
236 encoder_params.rtt = rtt; | 245 encoder_params.rtt = rtt; |
237 encoder_params = UpdateEncoderParameters(encoder_params, bitrate_allocator, | 246 encoder_params = UpdateEncoderParameters(encoder_params, bitrate_allocator, |
238 target_bitrate_bps); | 247 target_bitrate_bps); |
239 if (bitrate_updated_callback) { | 248 if (bitrate_updated_callback && target_bitrate_bps > 0) { |
240 bitrate_updated_callback->OnBitrateAllocationUpdated( | 249 bitrate_updated_callback->OnBitrateAllocationUpdated( |
241 encoder_params.target_bitrate); | 250 encoder_params.target_bitrate); |
242 } | 251 } |
243 | 252 |
244 bool encoder_has_internal_source; | 253 bool encoder_has_internal_source; |
245 { | 254 { |
246 rtc::CritScope cs(¶ms_crit_); | 255 rtc::CritScope cs(¶ms_crit_); |
247 encoder_params_ = encoder_params; | 256 encoder_params_ = encoder_params; |
248 encoder_has_internal_source = encoder_has_internal_source_; | 257 encoder_has_internal_source = encoder_has_internal_source_; |
249 } | 258 } |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 } | 407 } |
399 | 408 |
400 int32_t VideoSender::EnableFrameDropper(bool enable) { | 409 int32_t VideoSender::EnableFrameDropper(bool enable) { |
401 rtc::CritScope lock(&encoder_crit_); | 410 rtc::CritScope lock(&encoder_crit_); |
402 frame_dropper_enabled_ = enable; | 411 frame_dropper_enabled_ = enable; |
403 _mediaOpt.EnableFrameDropper(enable); | 412 _mediaOpt.EnableFrameDropper(enable); |
404 return VCM_OK; | 413 return VCM_OK; |
405 } | 414 } |
406 } // namespace vcm | 415 } // namespace vcm |
407 } // namespace webrtc | 416 } // namespace webrtc |
OLD | NEW |