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

Side by Side Diff: webrtc/video/vie_encoder.cc

Issue 1958113003: Remove SendPacer from ViEEncoder and make sure SendPacer starts at a valid bitrate (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Removed initial bitrate from PacedSender. Updated unittests. Created 4 years, 7 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/video/vie_encoder.h ('k') | no next file » | 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) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 30 matching lines...) Expand all
41 const uint32_t width, 41 const uint32_t width,
42 const uint32_t height); 42 const uint32_t height);
43 43
44 private: 44 private:
45 VideoProcessing* vp_; 45 VideoProcessing* vp_;
46 }; 46 };
47 47
48 ViEEncoder::ViEEncoder(uint32_t number_of_cores, 48 ViEEncoder::ViEEncoder(uint32_t number_of_cores,
49 ProcessThread* module_process_thread, 49 ProcessThread* module_process_thread,
50 SendStatisticsProxy* stats_proxy, 50 SendStatisticsProxy* stats_proxy,
51 rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback, 51 OveruseFrameDetector* overuse_detector)
52 OveruseFrameDetector* overuse_detector,
53 PacedSender* pacer)
54 : number_of_cores_(number_of_cores), 52 : number_of_cores_(number_of_cores),
55 vp_(VideoProcessing::Create()), 53 vp_(VideoProcessing::Create()),
56 qm_callback_(new QMVideoSettingsCallback(vp_.get())), 54 qm_callback_(new QMVideoSettingsCallback(vp_.get())),
57 video_sender_(Clock::GetRealTimeClock(), 55 video_sender_(Clock::GetRealTimeClock(),
58 this, 56 this,
59 this, 57 this,
60 qm_callback_.get(), 58 qm_callback_.get(),
61 this), 59 this),
62 stats_proxy_(stats_proxy), 60 stats_proxy_(stats_proxy),
63 pre_encode_callback_(pre_encode_callback),
64 overuse_detector_(overuse_detector), 61 overuse_detector_(overuse_detector),
65 pacer_(pacer),
66 time_of_last_frame_activity_ms_(0), 62 time_of_last_frame_activity_ms_(0),
67 encoder_config_(), 63 encoder_config_(),
68 min_transmit_bitrate_bps_(0), 64 min_transmit_bitrate_bps_(0),
69 last_observed_bitrate_bps_(0), 65 last_observed_bitrate_bps_(0),
70 network_is_transmitting_(true), 66 network_is_transmitting_(true),
71 encoder_paused_(true), 67 encoder_paused_(true),
72 encoder_paused_and_dropped_frame_(false), 68 encoder_paused_and_dropped_frame_(false),
73 module_process_thread_(module_process_thread), 69 module_process_thread_(module_process_thread),
74 has_received_sli_(false), 70 has_received_sli_(false),
75 picture_id_sli_(0), 71 picture_id_sli_(0),
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 218
223 return pad_up_to_bitrate_bps; 219 return pad_up_to_bitrate_bps;
224 } 220 }
225 221
226 bool ViEEncoder::EncoderPaused() const { 222 bool ViEEncoder::EncoderPaused() const {
227 // Pause video if paused by caller or as long as the network is down or the 223 // Pause video if paused by caller or as long as the network is down or the
228 // pacer queue has grown too large in buffered mode. 224 // pacer queue has grown too large in buffered mode.
229 if (encoder_paused_) { 225 if (encoder_paused_) {
230 return true; 226 return true;
231 } 227 }
232 if (pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs) { 228 if (video_suspended_ || last_observed_bitrate_bps_ == 0) {
233 // Too much data in pacer queue, drop frame.
234 return true; 229 return true;
235 } 230 }
236 return !network_is_transmitting_; 231 return !network_is_transmitting_;
237 } 232 }
238 233
239 void ViEEncoder::TraceFrameDropStart() { 234 void ViEEncoder::TraceFrameDropStart() {
240 // Start trace event only on the first frame after encoder is paused. 235 // Start trace event only on the first frame after encoder is paused.
241 if (!encoder_paused_and_dropped_frame_) { 236 if (!encoder_paused_and_dropped_frame_) {
242 TRACE_EVENT_ASYNC_BEGIN0("webrtc", "EncoderPaused", this); 237 TRACE_EVENT_ASYNC_BEGIN0("webrtc", "EncoderPaused", this);
243 } 238 }
(...skipping 28 matching lines...) Expand all
272 // TODO(wuchengli): support texture frames. 267 // TODO(wuchengli): support texture frames.
273 if (!video_frame.video_frame_buffer()->native_handle()) { 268 if (!video_frame.video_frame_buffer()->native_handle()) {
274 // Pass frame via preprocessor. 269 // Pass frame via preprocessor.
275 frame_to_send = vp_->PreprocessFrame(video_frame); 270 frame_to_send = vp_->PreprocessFrame(video_frame);
276 if (!frame_to_send) { 271 if (!frame_to_send) {
277 // Drop this frame, or there was an error processing it. 272 // Drop this frame, or there was an error processing it.
278 return; 273 return;
279 } 274 }
280 } 275 }
281 276
282 if (pre_encode_callback_) {
283 pre_encode_callback_->OnFrame(*frame_to_send);
284 }
285
286 if (codec_type == webrtc::kVideoCodecVP8) { 277 if (codec_type == webrtc::kVideoCodecVP8) {
287 webrtc::CodecSpecificInfo codec_specific_info; 278 webrtc::CodecSpecificInfo codec_specific_info;
288 codec_specific_info.codecType = webrtc::kVideoCodecVP8; 279 codec_specific_info.codecType = webrtc::kVideoCodecVP8;
289 { 280 {
290 rtc::CritScope lock(&data_cs_); 281 rtc::CritScope lock(&data_cs_);
291 codec_specific_info.codecSpecific.VP8.hasReceivedRPSI = 282 codec_specific_info.codecSpecific.VP8.hasReceivedRPSI =
292 has_received_rpsi_; 283 has_received_rpsi_;
293 codec_specific_info.codecSpecific.VP8.hasReceivedSLI = 284 codec_specific_info.codecSpecific.VP8.hasReceivedSLI =
294 has_received_sli_; 285 has_received_sli_;
295 codec_specific_info.codecSpecific.VP8.pictureIdRPSI = 286 codec_specific_info.codecSpecific.VP8.pictureIdRPSI =
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 361
371 void ViEEncoder::OnReceivedIntraFrameRequest(size_t stream_index) { 362 void ViEEncoder::OnReceivedIntraFrameRequest(size_t stream_index) {
372 // Key frame request from remote side, signal to VCM. 363 // Key frame request from remote side, signal to VCM.
373 TRACE_EVENT0("webrtc", "OnKeyFrameRequest"); 364 TRACE_EVENT0("webrtc", "OnKeyFrameRequest");
374 video_sender_.IntraFrameRequest(stream_index); 365 video_sender_.IntraFrameRequest(stream_index);
375 } 366 }
376 367
377 void ViEEncoder::OnBitrateUpdated(uint32_t bitrate_bps, 368 void ViEEncoder::OnBitrateUpdated(uint32_t bitrate_bps,
378 uint8_t fraction_lost, 369 uint8_t fraction_lost,
379 int64_t round_trip_time_ms) { 370 int64_t round_trip_time_ms) {
380 LOG(LS_VERBOSE) << "OnBitrateUpdated, bitrate" << bitrate_bps 371 LOG(LS_VERBOSE) << "OnBitrateUpdated, bitrate " << bitrate_bps
381 << " packet loss " << static_cast<int>(fraction_lost) 372 << " packet loss " << static_cast<int>(fraction_lost)
382 << " rtt " << round_trip_time_ms; 373 << " rtt " << round_trip_time_ms;
383 video_sender_.SetChannelParameters(bitrate_bps, fraction_lost, 374 video_sender_.SetChannelParameters(bitrate_bps, fraction_lost,
384 round_trip_time_ms); 375 round_trip_time_ms);
385 bool video_is_suspended = video_sender_.VideoSuspended(); 376 bool video_is_suspended = video_sender_.VideoSuspended();
386 bool video_suspension_changed; 377 bool video_suspension_changed;
387 { 378 {
388 rtc::CritScope lock(&data_cs_); 379 rtc::CritScope lock(&data_cs_);
389 last_observed_bitrate_bps_ = bitrate_bps; 380 last_observed_bitrate_bps_ = bitrate_bps;
390 video_suspension_changed = video_suspended_ != video_is_suspended; 381 video_suspension_changed = video_suspended_ != video_is_suspended;
(...skipping 17 matching lines...) Expand all
408 } 399 }
409 400
410 int32_t QMVideoSettingsCallback::SetVideoQMSettings( 401 int32_t QMVideoSettingsCallback::SetVideoQMSettings(
411 const uint32_t frame_rate, 402 const uint32_t frame_rate,
412 const uint32_t width, 403 const uint32_t width,
413 const uint32_t height) { 404 const uint32_t height) {
414 return vp_->SetTargetResolution(width, height, frame_rate); 405 return vp_->SetTargetResolution(width, height, frame_rate);
415 } 406 }
416 407
417 } // namespace webrtc 408 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/vie_encoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698