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

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: Undo crit removal 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 if (_sendStatsTimer.TimeUntilProcess() == 0) { 56 if (_sendStatsTimer.TimeUntilProcess() == 0) {
57 // |_sendStatsTimer.Processed()| must be called. Otherwise 57 // |_sendStatsTimer.Processed()| must be called. Otherwise
58 // VideoSender::Process() will be called in an infinite loop. 58 // VideoSender::Process() will be called in an infinite loop.
59 _sendStatsTimer.Processed(); 59 _sendStatsTimer.Processed();
60 if (send_stats_callback_) { 60 if (send_stats_callback_) {
61 uint32_t bitRate = _mediaOpt.SentBitRate(); 61 uint32_t bitRate = _mediaOpt.SentBitRate();
62 uint32_t frameRate = _mediaOpt.SentFrameRate(); 62 uint32_t frameRate = _mediaOpt.SentFrameRate();
63 send_stats_callback_->SendStatistics(bitRate, frameRate); 63 send_stats_callback_->SendStatistics(bitRate, frameRate);
64 } 64 }
65 } 65 }
66
67 { 66 {
68 rtc::CritScope cs(&params_crit_); 67 rtc::CritScope cs(&params_crit_);
69 // Force an encoder parameters update, so that incoming frame rate is 68 // Force an encoder parameters update, so that incoming frame rate is
70 // updated even if bandwidth hasn't changed. 69 // updated even if bandwidth hasn't changed.
71 encoder_params_.input_frame_rate = _mediaOpt.InputFrameRate(); 70 encoder_params_.input_frame_rate = _mediaOpt.InputFrameRate();
72 } 71 }
73 } 72 }
74 73
75 int64_t VideoSender::TimeUntilNextProcess() { 74 int64_t VideoSender::TimeUntilNextProcess() {
76 return _sendStatsTimer.TimeUntilProcess(); 75 return _sendStatsTimer.TimeUntilProcess();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 } 114 }
116 115
117 // If we have screensharing and we have layers, we disable frame dropper. 116 // If we have screensharing and we have layers, we disable frame dropper.
118 bool disable_frame_dropper = 117 bool disable_frame_dropper =
119 numLayers > 1 && sendCodec->mode == kScreensharing; 118 numLayers > 1 && sendCodec->mode == kScreensharing;
120 if (disable_frame_dropper) { 119 if (disable_frame_dropper) {
121 _mediaOpt.EnableFrameDropper(false); 120 _mediaOpt.EnableFrameDropper(false);
122 } else if (frame_dropper_enabled_) { 121 } else if (frame_dropper_enabled_) {
123 _mediaOpt.EnableFrameDropper(true); 122 _mediaOpt.EnableFrameDropper(true);
124 } 123 }
124
125 { 125 {
126 rtc::CritScope cs(&params_crit_); 126 rtc::CritScope cs(&params_crit_);
127 next_frame_types_.clear(); 127 next_frame_types_.clear();
128 next_frame_types_.resize(VCM_MAX(sendCodec->numberOfSimulcastStreams, 1), 128 next_frame_types_.resize(VCM_MAX(sendCodec->numberOfSimulcastStreams, 1),
129 kVideoFrameKey); 129 kVideoFrameKey);
130 // Cache InternalSource() to have this available from IntraFrameRequest() 130 // Cache InternalSource() to have this available from IntraFrameRequest()
131 // without having to acquire encoder_crit_ (avoid blocking on encoder use). 131 // without having to acquire encoder_crit_ (avoid blocking on encoder use).
132 encoder_has_internal_source_ = _encoder->InternalSource(); 132 encoder_has_internal_source_ = _encoder->InternalSource();
133 } 133 }
134 134
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 205
206 BitrateAllocation bitrate_allocation; 206 BitrateAllocation bitrate_allocation;
207 if (bitrate_allocator) { 207 if (bitrate_allocator) {
208 bitrate_allocation = bitrate_allocator->GetAllocation(video_target_rate_bps, 208 bitrate_allocation = bitrate_allocator->GetAllocation(video_target_rate_bps,
209 input_frame_rate); 209 input_frame_rate);
210 } else { 210 } else {
211 DefaultVideoBitrateAllocator default_allocator(current_codec_); 211 DefaultVideoBitrateAllocator default_allocator(current_codec_);
212 bitrate_allocation = default_allocator.GetAllocation(video_target_rate_bps, 212 bitrate_allocation = default_allocator.GetAllocation(video_target_rate_bps,
213 input_frame_rate); 213 input_frame_rate);
214 } 214 }
215
216 EncoderParameters new_encoder_params = {bitrate_allocation, params.loss_rate, 215 EncoderParameters new_encoder_params = {bitrate_allocation, params.loss_rate,
217 params.rtt, input_frame_rate}; 216 params.rtt, input_frame_rate};
218 return new_encoder_params; 217 return new_encoder_params;
219 } 218 }
220 219
221 void VideoSender::UpdateChannelParemeters( 220 void VideoSender::UpdateChannelParemeters(
222 VideoBitrateAllocator* bitrate_allocator) { 221 VideoBitrateAllocator* bitrate_allocator,
223 rtc::CritScope cs(&params_crit_); 222 VideoBitrateAllocationObserver* bitrate_updated_callback) {
224 encoder_params_ = 223 BitrateAllocation target_rate;
225 UpdateEncoderParameters(encoder_params_, bitrate_allocator, 224 {
226 encoder_params_.target_bitrate.get_sum_bps()); 225 rtc::CritScope cs(&params_crit_);
226 encoder_params_ =
227 UpdateEncoderParameters(encoder_params_, bitrate_allocator,
228 encoder_params_.target_bitrate.get_sum_bps());
229 target_rate = encoder_params_.target_bitrate;
230 }
231 if (bitrate_updated_callback)
232 bitrate_updated_callback->OnBitrateAllocationUpdated(target_rate);
227 } 233 }
228 234
229 int32_t VideoSender::SetChannelParameters( 235 int32_t VideoSender::SetChannelParameters(
230 uint32_t target_bitrate_bps, 236 uint32_t target_bitrate_bps,
231 uint8_t lossRate, 237 uint8_t loss_rate,
232 int64_t rtt, 238 int64_t rtt,
233 VideoBitrateAllocator* bitrate_allocator) { 239 VideoBitrateAllocator* bitrate_allocator,
240 VideoBitrateAllocationObserver* bitrate_updated_callback) {
234 EncoderParameters encoder_params; 241 EncoderParameters encoder_params;
235 encoder_params.loss_rate = lossRate; 242 encoder_params.loss_rate = loss_rate;
236 encoder_params.rtt = rtt; 243 encoder_params.rtt = rtt;
237 encoder_params = UpdateEncoderParameters(encoder_params, bitrate_allocator, 244 encoder_params = UpdateEncoderParameters(encoder_params, bitrate_allocator,
238 target_bitrate_bps); 245 target_bitrate_bps);
246 if (bitrate_updated_callback) {
247 bitrate_updated_callback->OnBitrateAllocationUpdated(
248 encoder_params.target_bitrate);
249 }
239 250
240 bool encoder_has_internal_source; 251 bool encoder_has_internal_source;
241 { 252 {
242 rtc::CritScope cs(&params_crit_); 253 rtc::CritScope cs(&params_crit_);
243 encoder_params_ = encoder_params; 254 encoder_params_ = encoder_params;
244 encoder_has_internal_source = encoder_has_internal_source_; 255 encoder_has_internal_source = encoder_has_internal_source_;
245 } 256 }
246 257
247 // For encoders with internal sources, we need to tell the encoder directly, 258 // For encoders with internal sources, we need to tell the encoder directly,
248 // instead of waiting for an AddVideoFrame that will never come (internal 259 // instead of waiting for an AddVideoFrame that will never come (internal
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 } 400 }
390 401
391 int32_t VideoSender::EnableFrameDropper(bool enable) { 402 int32_t VideoSender::EnableFrameDropper(bool enable) {
392 rtc::CritScope lock(&encoder_crit_); 403 rtc::CritScope lock(&encoder_crit_);
393 frame_dropper_enabled_ = enable; 404 frame_dropper_enabled_ = enable;
394 _mediaOpt.EnableFrameDropper(enable); 405 _mediaOpt.EnableFrameDropper(enable);
395 return VCM_OK; 406 return VCM_OK;
396 } 407 }
397 } // namespace vcm 408 } // namespace vcm
398 } // namespace webrtc 409 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/video_coding_impl.cc ('k') | webrtc/modules/video_coding/video_sender_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698