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

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

Issue 1947873002: Reland of Remove SendPacer from ViEEncoder (patchset #13 id:240001 of https://codereview.we… (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixed CongestionController backwards compatibility 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 const uint32_t height); 50 const uint32_t height);
51 51
52 private: 52 private:
53 VideoProcessing* vp_; 53 VideoProcessing* vp_;
54 }; 54 };
55 55
56 ViEEncoder::ViEEncoder(uint32_t number_of_cores, 56 ViEEncoder::ViEEncoder(uint32_t number_of_cores,
57 const std::vector<uint32_t>& ssrcs, 57 const std::vector<uint32_t>& ssrcs,
58 ProcessThread* module_process_thread, 58 ProcessThread* module_process_thread,
59 SendStatisticsProxy* stats_proxy, 59 SendStatisticsProxy* stats_proxy,
60 rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback, 60 OveruseFrameDetector* overuse_detector)
61 OveruseFrameDetector* overuse_detector,
62 PacedSender* pacer)
63 : number_of_cores_(number_of_cores), 61 : number_of_cores_(number_of_cores),
64 ssrcs_(ssrcs), 62 ssrcs_(ssrcs),
65 vp_(VideoProcessing::Create()), 63 vp_(VideoProcessing::Create()),
66 qm_callback_(new QMVideoSettingsCallback(vp_.get())), 64 qm_callback_(new QMVideoSettingsCallback(vp_.get())),
67 video_sender_(Clock::GetRealTimeClock(), 65 video_sender_(Clock::GetRealTimeClock(),
68 this, 66 this,
69 this, 67 this,
70 qm_callback_.get(), 68 qm_callback_.get(),
71 this), 69 this),
72 stats_proxy_(stats_proxy), 70 stats_proxy_(stats_proxy),
73 pre_encode_callback_(pre_encode_callback),
74 overuse_detector_(overuse_detector), 71 overuse_detector_(overuse_detector),
75 pacer_(pacer),
76 time_of_last_frame_activity_ms_(0), 72 time_of_last_frame_activity_ms_(0),
77 encoder_config_(), 73 encoder_config_(),
78 min_transmit_bitrate_bps_(0), 74 min_transmit_bitrate_bps_(0),
79 last_observed_bitrate_bps_(0), 75 last_observed_bitrate_bps_(0),
80 network_is_transmitting_(true), 76 network_is_transmitting_(true),
81 encoder_paused_(true), 77 encoder_paused_(true),
82 encoder_paused_and_dropped_frame_(false), 78 encoder_paused_and_dropped_frame_(false),
83 time_last_intra_request_ms_(ssrcs.size(), -1), 79 time_last_intra_request_ms_(ssrcs.size(), -1),
84 module_process_thread_(module_process_thread), 80 module_process_thread_(module_process_thread),
85 has_received_sli_(false), 81 has_received_sli_(false),
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 234
239 return pad_up_to_bitrate_bps; 235 return pad_up_to_bitrate_bps;
240 } 236 }
241 237
242 bool ViEEncoder::EncoderPaused() const { 238 bool ViEEncoder::EncoderPaused() const {
243 // Pause video if paused by caller or as long as the network is down or the 239 // Pause video if paused by caller or as long as the network is down or the
244 // pacer queue has grown too large in buffered mode. 240 // pacer queue has grown too large in buffered mode.
245 if (encoder_paused_) { 241 if (encoder_paused_) {
246 return true; 242 return true;
247 } 243 }
248 if (pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs) { 244 if (video_suspended_ || last_observed_bitrate_bps_ == 0) {
249 // Too much data in pacer queue, drop frame.
250 return true; 245 return true;
251 } 246 }
252 return !network_is_transmitting_; 247 return !network_is_transmitting_;
253 } 248 }
254 249
255 void ViEEncoder::TraceFrameDropStart() { 250 void ViEEncoder::TraceFrameDropStart() {
256 // Start trace event only on the first frame after encoder is paused. 251 // Start trace event only on the first frame after encoder is paused.
257 if (!encoder_paused_and_dropped_frame_) { 252 if (!encoder_paused_and_dropped_frame_) {
258 TRACE_EVENT_ASYNC_BEGIN0("webrtc", "EncoderPaused", this); 253 TRACE_EVENT_ASYNC_BEGIN0("webrtc", "EncoderPaused", this);
259 } 254 }
(...skipping 28 matching lines...) Expand all
288 // TODO(wuchengli): support texture frames. 283 // TODO(wuchengli): support texture frames.
289 if (!video_frame.video_frame_buffer()->native_handle()) { 284 if (!video_frame.video_frame_buffer()->native_handle()) {
290 // Pass frame via preprocessor. 285 // Pass frame via preprocessor.
291 frame_to_send = vp_->PreprocessFrame(video_frame); 286 frame_to_send = vp_->PreprocessFrame(video_frame);
292 if (!frame_to_send) { 287 if (!frame_to_send) {
293 // Drop this frame, or there was an error processing it. 288 // Drop this frame, or there was an error processing it.
294 return; 289 return;
295 } 290 }
296 } 291 }
297 292
298 if (pre_encode_callback_) {
299 pre_encode_callback_->OnFrame(*frame_to_send);
300 }
301
302 if (codec_type == webrtc::kVideoCodecVP8) { 293 if (codec_type == webrtc::kVideoCodecVP8) {
303 webrtc::CodecSpecificInfo codec_specific_info; 294 webrtc::CodecSpecificInfo codec_specific_info;
304 codec_specific_info.codecType = webrtc::kVideoCodecVP8; 295 codec_specific_info.codecType = webrtc::kVideoCodecVP8;
305 { 296 {
306 rtc::CritScope lock(&data_cs_); 297 rtc::CritScope lock(&data_cs_);
307 codec_specific_info.codecSpecific.VP8.hasReceivedRPSI = 298 codec_specific_info.codecSpecific.VP8.hasReceivedRPSI =
308 has_received_rpsi_; 299 has_received_rpsi_;
309 codec_specific_info.codecSpecific.VP8.hasReceivedSLI = 300 codec_specific_info.codecSpecific.VP8.hasReceivedSLI =
310 has_received_sli_; 301 has_received_sli_;
311 codec_specific_info.codecSpecific.VP8.pictureIdRPSI = 302 codec_specific_info.codecSpecific.VP8.pictureIdRPSI =
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 } 419 }
429 video_sender_.IntraFrameRequest(static_cast<int>(i)); 420 video_sender_.IntraFrameRequest(static_cast<int>(i));
430 return; 421 return;
431 } 422 }
432 RTC_NOTREACHED() << "Should not receive keyframe requests on unknown SSRCs."; 423 RTC_NOTREACHED() << "Should not receive keyframe requests on unknown SSRCs.";
433 } 424 }
434 425
435 void ViEEncoder::OnBitrateUpdated(uint32_t bitrate_bps, 426 void ViEEncoder::OnBitrateUpdated(uint32_t bitrate_bps,
436 uint8_t fraction_lost, 427 uint8_t fraction_lost,
437 int64_t round_trip_time_ms) { 428 int64_t round_trip_time_ms) {
438 LOG(LS_VERBOSE) << "OnBitrateUpdated, bitrate" << bitrate_bps 429 LOG(LS_VERBOSE) << "OnBitrateUpdated, bitrate " << bitrate_bps
439 << " packet loss " << static_cast<int>(fraction_lost) 430 << " packet loss " << static_cast<int>(fraction_lost)
440 << " rtt " << round_trip_time_ms; 431 << " rtt " << round_trip_time_ms;
441 video_sender_.SetChannelParameters(bitrate_bps, fraction_lost, 432 video_sender_.SetChannelParameters(bitrate_bps, fraction_lost,
442 round_trip_time_ms); 433 round_trip_time_ms);
443 bool video_is_suspended = video_sender_.VideoSuspended(); 434 bool video_is_suspended = video_sender_.VideoSuspended();
444 bool video_suspension_changed; 435 bool video_suspension_changed;
445 { 436 {
446 rtc::CritScope lock(&data_cs_); 437 rtc::CritScope lock(&data_cs_);
447 last_observed_bitrate_bps_ = bitrate_bps; 438 last_observed_bitrate_bps_ = bitrate_bps;
448 video_suspension_changed = video_suspended_ != video_is_suspended; 439 video_suspension_changed = video_suspended_ != video_is_suspended;
(...skipping 17 matching lines...) Expand all
466 } 457 }
467 458
468 int32_t QMVideoSettingsCallback::SetVideoQMSettings( 459 int32_t QMVideoSettingsCallback::SetVideoQMSettings(
469 const uint32_t frame_rate, 460 const uint32_t frame_rate,
470 const uint32_t width, 461 const uint32_t width,
471 const uint32_t height) { 462 const uint32_t height) {
472 return vp_->SetTargetResolution(width, height, frame_rate); 463 return vp_->SetTargetResolution(width, height, frame_rate);
473 } 464 }
474 465
475 } // namespace webrtc 466 } // 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