Chromium Code Reviews| 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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 if (!_encoder) | 188 if (!_encoder) |
| 189 return VCM_UNINITIALIZED; | 189 return VCM_UNINITIALIZED; |
| 190 | 190 |
| 191 *framerate = _encoder->GetEncoderParameters().input_frame_rate; | 191 *framerate = _encoder->GetEncoderParameters().input_frame_rate; |
| 192 return 0; | 192 return 0; |
| 193 } | 193 } |
| 194 | 194 |
| 195 EncoderParameters VideoSender::UpdateEncoderParameters( | 195 EncoderParameters VideoSender::UpdateEncoderParameters( |
| 196 const EncoderParameters& params, | 196 const EncoderParameters& params, |
| 197 VideoBitrateAllocator* bitrate_allocator, | 197 VideoBitrateAllocator* bitrate_allocator, |
| 198 uint32_t target_bitrate_bps) { | 198 uint32_t target_bitrate_bps, |
| 199 VideoBitrateAllocationObserver* bitrate_observer) { | |
|
danilchap
2016/11/29 10:39:31
bitrate_observer used as callback (called during t
sprang_webrtc
2016/11/29 12:24:01
Done.
| |
| 199 uint32_t video_target_rate_bps = _mediaOpt.SetTargetRates( | 200 uint32_t video_target_rate_bps = _mediaOpt.SetTargetRates( |
| 200 target_bitrate_bps, params.loss_rate, params.rtt); | 201 target_bitrate_bps, params.loss_rate, params.rtt); |
| 201 uint32_t input_frame_rate = _mediaOpt.InputFrameRate(); | 202 uint32_t input_frame_rate = _mediaOpt.InputFrameRate(); |
| 202 if (input_frame_rate == 0) | 203 if (input_frame_rate == 0) |
| 203 input_frame_rate = current_codec_.maxFramerate; | 204 input_frame_rate = current_codec_.maxFramerate; |
| 204 | 205 |
| 205 BitrateAllocation bitrate_allocation; | 206 BitrateAllocation bitrate_allocation; |
| 206 if (bitrate_allocator) { | 207 if (bitrate_allocator) { |
| 207 bitrate_allocation = bitrate_allocator->GetAllocation(video_target_rate_bps, | 208 bitrate_allocation = bitrate_allocator->GetAllocation(video_target_rate_bps, |
| 208 input_frame_rate); | 209 input_frame_rate); |
| 209 } else { | 210 } else { |
| 210 DefaultVideoBitrateAllocator default_allocator(current_codec_); | 211 DefaultVideoBitrateAllocator default_allocator(current_codec_); |
| 211 bitrate_allocation = default_allocator.GetAllocation(video_target_rate_bps, | 212 bitrate_allocation = default_allocator.GetAllocation(video_target_rate_bps, |
| 212 input_frame_rate); | 213 input_frame_rate); |
| 213 } | 214 } |
| 214 | 215 if (bitrate_observer) |
| 216 bitrate_observer->OnBitrateAllocationUpdated(bitrate_allocation); | |
| 215 EncoderParameters new_encoder_params = {bitrate_allocation, params.loss_rate, | 217 EncoderParameters new_encoder_params = {bitrate_allocation, params.loss_rate, |
| 216 params.rtt, input_frame_rate}; | 218 params.rtt, input_frame_rate}; |
| 217 return new_encoder_params; | 219 return new_encoder_params; |
| 218 } | 220 } |
| 219 | 221 |
| 220 void VideoSender::UpdateChannelParemeters( | 222 void VideoSender::UpdateChannelParemeters( |
| 221 VideoBitrateAllocator* bitrate_allocator) { | 223 VideoBitrateAllocator* bitrate_allocator, |
| 224 VideoBitrateAllocationObserver* bitrate_observer) { | |
| 222 rtc::CritScope cs(¶ms_crit_); | 225 rtc::CritScope cs(¶ms_crit_); |
| 223 encoder_params_ = | 226 encoder_params_ = UpdateEncoderParameters( |
| 224 UpdateEncoderParameters(encoder_params_, bitrate_allocator, | 227 encoder_params_, bitrate_allocator, |
| 225 encoder_params_.target_bitrate.get_sum_bps()); | 228 encoder_params_.target_bitrate.get_sum_bps(), bitrate_observer); |
| 226 } | 229 } |
| 227 | 230 |
| 228 int32_t VideoSender::SetChannelParameters( | 231 int32_t VideoSender::SetChannelParameters( |
| 229 uint32_t target_bitrate_bps, | 232 uint32_t target_bitrate_bps, |
| 230 uint8_t lossRate, | 233 uint8_t lossRate, |
| 231 int64_t rtt, | 234 int64_t rtt, |
| 232 VideoBitrateAllocator* bitrate_allocator) { | 235 VideoBitrateAllocator* bitrate_allocator, |
| 236 VideoBitrateAllocationObserver* bitrate_observer) { | |
| 233 EncoderParameters encoder_params; | 237 EncoderParameters encoder_params; |
| 234 encoder_params.loss_rate = lossRate; | 238 encoder_params.loss_rate = lossRate; |
| 235 encoder_params.rtt = rtt; | 239 encoder_params.rtt = rtt; |
| 236 encoder_params = UpdateEncoderParameters(encoder_params, bitrate_allocator, | 240 encoder_params = UpdateEncoderParameters( |
| 237 target_bitrate_bps); | 241 encoder_params, bitrate_allocator, target_bitrate_bps, bitrate_observer); |
| 238 | 242 |
| 239 bool encoder_has_internal_source; | 243 bool encoder_has_internal_source; |
| 240 { | 244 { |
| 241 rtc::CritScope cs(¶ms_crit_); | 245 rtc::CritScope cs(¶ms_crit_); |
| 242 encoder_params_ = encoder_params; | 246 encoder_params_ = encoder_params; |
| 243 encoder_has_internal_source = encoder_has_internal_source_; | 247 encoder_has_internal_source = encoder_has_internal_source_; |
| 244 } | 248 } |
| 245 | 249 |
| 246 // For encoders with internal sources, we need to tell the encoder directly, | 250 // For encoders with internal sources, we need to tell the encoder directly, |
| 247 // instead of waiting for an AddVideoFrame that will never come (internal | 251 // instead of waiting for an AddVideoFrame that will never come (internal |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 388 } | 392 } |
| 389 | 393 |
| 390 int32_t VideoSender::EnableFrameDropper(bool enable) { | 394 int32_t VideoSender::EnableFrameDropper(bool enable) { |
| 391 rtc::CritScope lock(&encoder_crit_); | 395 rtc::CritScope lock(&encoder_crit_); |
| 392 frame_dropper_enabled_ = enable; | 396 frame_dropper_enabled_ = enable; |
| 393 _mediaOpt.EnableFrameDropper(enable); | 397 _mediaOpt.EnableFrameDropper(enable); |
| 394 return VCM_OK; | 398 return VCM_OK; |
| 395 } | 399 } |
| 396 } // namespace vcm | 400 } // namespace vcm |
| 397 } // namespace webrtc | 401 } // namespace webrtc |
| OLD | NEW |