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

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

Issue 1972083002: Move logic for calculating needed bitrate overhead used by NACK and FEC to VideoSender. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed Åsas comments. Created 4 years, 6 months 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
« no previous file with comments | « webrtc/modules/video_coding/video_coding_impl.cc ('k') | webrtc/video/send_statistics_proxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 19 matching lines...) Expand all
30 VCMSendStatisticsCallback* send_stats_callback) 30 VCMSendStatisticsCallback* send_stats_callback)
31 : clock_(clock), 31 : clock_(clock),
32 _encoder(nullptr), 32 _encoder(nullptr),
33 _mediaOpt(clock_), 33 _mediaOpt(clock_),
34 _encodedFrameCallback(post_encode_callback, &_mediaOpt), 34 _encodedFrameCallback(post_encode_callback, &_mediaOpt),
35 send_stats_callback_(send_stats_callback), 35 send_stats_callback_(send_stats_callback),
36 _codecDataBase(encoder_rate_observer, &_encodedFrameCallback), 36 _codecDataBase(encoder_rate_observer, &_encodedFrameCallback),
37 frame_dropper_enabled_(true), 37 frame_dropper_enabled_(true),
38 _sendStatsTimer(1000, clock_), 38 _sendStatsTimer(1000, clock_),
39 current_codec_(), 39 current_codec_(),
40 protection_callback_(nullptr),
41 encoder_params_({0, 0, 0, 0}), 40 encoder_params_({0, 0, 0, 0}),
42 encoder_has_internal_source_(false), 41 encoder_has_internal_source_(false),
43 next_frame_types_(1, kVideoFrameDelta) { 42 next_frame_types_(1, kVideoFrameDelta) {
44 _mediaOpt.Reset(); 43 _mediaOpt.Reset();
45 // Allow VideoSender to be created on one thread but used on another, post 44 // Allow VideoSender to be created on one thread but used on another, post
46 // construction. This is currently how this class is being used by at least 45 // construction. This is currently how this class is being used by at least
47 // one external project (diffractor). 46 // one external project (diffractor).
48 main_thread_.DetachFromThread(); 47 main_thread_.DetachFromThread();
49 } 48 }
50 49
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 kVideoFrameKey); 132 kVideoFrameKey);
134 // Cache InternalSource() to have this available from IntraFrameRequest() 133 // Cache InternalSource() to have this available from IntraFrameRequest()
135 // without having to acquire encoder_crit_ (avoid blocking on encoder use). 134 // without having to acquire encoder_crit_ (avoid blocking on encoder use).
136 encoder_has_internal_source_ = _encoder->InternalSource(); 135 encoder_has_internal_source_ = _encoder->InternalSource();
137 } 136 }
138 137
139 LOG(LS_VERBOSE) << " max bitrate " << sendCodec->maxBitrate 138 LOG(LS_VERBOSE) << " max bitrate " << sendCodec->maxBitrate
140 << " start bitrate " << sendCodec->startBitrate 139 << " start bitrate " << sendCodec->startBitrate
141 << " max frame rate " << sendCodec->maxFramerate 140 << " max frame rate " << sendCodec->maxFramerate
142 << " max payload size " << maxPayloadSize; 141 << " max payload size " << maxPayloadSize;
143 _mediaOpt.SetEncodingData(sendCodec->codecType, sendCodec->maxBitrate * 1000, 142 _mediaOpt.SetEncodingData(sendCodec->maxBitrate * 1000,
144 sendCodec->startBitrate * 1000, sendCodec->width, 143 sendCodec->startBitrate * 1000, sendCodec->width,
145 sendCodec->height, sendCodec->maxFramerate, 144 sendCodec->height, sendCodec->maxFramerate,
146 numLayers, maxPayloadSize); 145 numLayers, maxPayloadSize);
147 return VCM_OK; 146 return VCM_OK;
148 } 147 }
149 148
150 // Register an external decoder object. 149 // Register an external decoder object.
151 // This can not be used together with external decoder callbacks. 150 // This can not be used together with external decoder callbacks.
152 void VideoSender::RegisterExternalEncoder(VideoEncoder* externalEncoder, 151 void VideoSender::RegisterExternalEncoder(VideoEncoder* externalEncoder,
153 uint8_t payloadType, 152 uint8_t payloadType,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 if (!_encoder) 192 if (!_encoder)
194 return VCM_UNINITIALIZED; 193 return VCM_UNINITIALIZED;
195 194
196 *framerate = _encoder->GetEncoderParameters().input_frame_rate; 195 *framerate = _encoder->GetEncoderParameters().input_frame_rate;
197 return 0; 196 return 0;
198 } 197 }
199 198
200 int32_t VideoSender::SetChannelParameters(uint32_t target_bitrate, 199 int32_t VideoSender::SetChannelParameters(uint32_t target_bitrate,
201 uint8_t lossRate, 200 uint8_t lossRate,
202 int64_t rtt) { 201 int64_t rtt) {
203 uint32_t target_rate = _mediaOpt.SetTargetRates(target_bitrate, lossRate, rtt, 202 uint32_t target_rate =
204 protection_callback_); 203 _mediaOpt.SetTargetRates(target_bitrate, lossRate, rtt);
205 204
206 uint32_t input_frame_rate = _mediaOpt.InputFrameRate(); 205 uint32_t input_frame_rate = _mediaOpt.InputFrameRate();
207 206
208 EncoderParameters encoder_params = {target_rate, lossRate, rtt, 207 EncoderParameters encoder_params = {target_rate, lossRate, rtt,
209 input_frame_rate}; 208 input_frame_rate};
210 bool encoder_has_internal_source; 209 bool encoder_has_internal_source;
211 { 210 {
212 rtc::CritScope cs(&params_crit_); 211 rtc::CritScope cs(&params_crit_);
213 encoder_params_ = encoder_params; 212 encoder_params_ = encoder_params;
214 encoder_has_internal_source = encoder_has_internal_source_; 213 encoder_has_internal_source = encoder_has_internal_source_;
(...skipping 21 matching lines...) Expand all
236 return; 235 return;
237 236
238 if (params.input_frame_rate == 0) { 237 if (params.input_frame_rate == 0) {
239 // No frame rate estimate available, use default. 238 // No frame rate estimate available, use default.
240 params.input_frame_rate = current_codec_.maxFramerate; 239 params.input_frame_rate = current_codec_.maxFramerate;
241 } 240 }
242 if (_encoder != nullptr) 241 if (_encoder != nullptr)
243 _encoder->SetEncoderParameters(params); 242 _encoder->SetEncoderParameters(params);
244 } 243 }
245 244
246 // Register a video protection callback which will be called to deliver the 245 // Deprecated:
247 // requested FEC rate and NACK status (on/off). 246 // TODO(perkj): Remove once no projects call this method. It currently do
248 // Note: this callback is assumed to only be registered once and before it is 247 // nothing.
249 // used in this class.
250 int32_t VideoSender::RegisterProtectionCallback( 248 int32_t VideoSender::RegisterProtectionCallback(
251 VCMProtectionCallback* protection_callback) { 249 VCMProtectionCallback* protection_callback) {
252 RTC_DCHECK(protection_callback == nullptr || protection_callback_ == nullptr); 250 // Deprecated:
253 protection_callback_ = protection_callback; 251 // TODO(perkj): Remove once no projects call this method. It currently do
252 // nothing.
254 return VCM_OK; 253 return VCM_OK;
255 } 254 }
256 255
257 // Enable or disable a video protection method.
258 void VideoSender::SetVideoProtection(VCMVideoProtection videoProtection) {
259 rtc::CritScope lock(&encoder_crit_);
260 switch (videoProtection) {
261 case kProtectionNone:
262 _mediaOpt.SetProtectionMethod(media_optimization::kNone);
263 break;
264 case kProtectionNack:
265 _mediaOpt.SetProtectionMethod(media_optimization::kNack);
266 break;
267 case kProtectionNackFEC:
268 _mediaOpt.SetProtectionMethod(media_optimization::kNackFec);
269 break;
270 case kProtectionFEC:
271 _mediaOpt.SetProtectionMethod(media_optimization::kFec);
272 break;
273 }
274 }
275 // Add one raw video frame to the encoder, blocking. 256 // Add one raw video frame to the encoder, blocking.
276 int32_t VideoSender::AddVideoFrame(const VideoFrame& videoFrame, 257 int32_t VideoSender::AddVideoFrame(const VideoFrame& videoFrame,
277 const CodecSpecificInfo* codecSpecificInfo) { 258 const CodecSpecificInfo* codecSpecificInfo) {
278 EncoderParameters encoder_params; 259 EncoderParameters encoder_params;
279 std::vector<FrameType> next_frame_types; 260 std::vector<FrameType> next_frame_types;
280 { 261 {
281 rtc::CritScope lock(&params_crit_); 262 rtc::CritScope lock(&params_crit_);
282 encoder_params = encoder_params_; 263 encoder_params = encoder_params_;
283 next_frame_types = next_frame_types_; 264 next_frame_types = next_frame_types_;
284 } 265 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 // 10 kbps. 363 // 10 kbps.
383 int window_bps = std::max(threshold_bps / 10, 10000); 364 int window_bps = std::max(threshold_bps / 10, 10000);
384 _mediaOpt.SuspendBelowMinBitrate(threshold_bps, window_bps); 365 _mediaOpt.SuspendBelowMinBitrate(threshold_bps, window_bps);
385 } 366 }
386 367
387 bool VideoSender::VideoSuspended() const { 368 bool VideoSender::VideoSuspended() const {
388 return _mediaOpt.IsVideoSuspended(); 369 return _mediaOpt.IsVideoSuspended();
389 } 370 }
390 } // namespace vcm 371 } // namespace vcm
391 } // namespace webrtc 372 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/video_coding_impl.cc ('k') | webrtc/video/send_statistics_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698