Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: webrtc/modules/video_coding/video_sender.cc

Issue 2531383002: Wire up BitrateAllocation to be sent as RTCP TargetBitrate (Closed)
Patch Set: Addressed comments Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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_updated_callback) {
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_updated_callback)
216 bitrate_updated_callback->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_updated_callback) {
222 rtc::CritScope cs(&params_crit_); 225 rtc::CritScope cs(&params_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_updated_callback);
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_updated_callback) {
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 =
237 target_bitrate_bps); 241 UpdateEncoderParameters(encoder_params, bitrate_allocator,
242 target_bitrate_bps, bitrate_updated_callback);
238 243
239 bool encoder_has_internal_source; 244 bool encoder_has_internal_source;
240 { 245 {
241 rtc::CritScope cs(&params_crit_); 246 rtc::CritScope cs(&params_crit_);
242 encoder_params_ = encoder_params; 247 encoder_params_ = encoder_params;
243 encoder_has_internal_source = encoder_has_internal_source_; 248 encoder_has_internal_source = encoder_has_internal_source_;
244 } 249 }
245 250
246 // For encoders with internal sources, we need to tell the encoder directly, 251 // For encoders with internal sources, we need to tell the encoder directly,
247 // instead of waiting for an AddVideoFrame that will never come (internal 252 // instead of waiting for an AddVideoFrame that will never come (internal
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 } 393 }
389 394
390 int32_t VideoSender::EnableFrameDropper(bool enable) { 395 int32_t VideoSender::EnableFrameDropper(bool enable) {
391 rtc::CritScope lock(&encoder_crit_); 396 rtc::CritScope lock(&encoder_crit_);
392 frame_dropper_enabled_ = enable; 397 frame_dropper_enabled_ = enable;
393 _mediaOpt.EnableFrameDropper(enable); 398 _mediaOpt.EnableFrameDropper(enable);
394 return VCM_OK; 399 return VCM_OK;
395 } 400 }
396 } // namespace vcm 401 } // namespace vcm
397 } // namespace webrtc 402 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698