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

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

Issue 1917793002: Remove SendPacer from ViEEncoder (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed code review comments. 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
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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 const uint32_t height); 72 const uint32_t height);
73 73
74 private: 74 private:
75 VideoProcessing* vp_; 75 VideoProcessing* vp_;
76 }; 76 };
77 77
78 ViEEncoder::ViEEncoder(uint32_t number_of_cores, 78 ViEEncoder::ViEEncoder(uint32_t number_of_cores,
79 const std::vector<uint32_t>& ssrcs, 79 const std::vector<uint32_t>& ssrcs,
80 ProcessThread* module_process_thread, 80 ProcessThread* module_process_thread,
81 SendStatisticsProxy* stats_proxy, 81 SendStatisticsProxy* stats_proxy,
82 rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback,
83 OveruseFrameDetector* overuse_detector, 82 OveruseFrameDetector* overuse_detector,
84 PacedSender* pacer,
85 PayloadRouter* payload_router, 83 PayloadRouter* payload_router,
86 EncodedImageCallback* post_encode_callback) 84 EncodedImageCallback* post_encode_callback)
87 : number_of_cores_(number_of_cores), 85 : number_of_cores_(number_of_cores),
88 ssrcs_(ssrcs), 86 ssrcs_(ssrcs),
89 vp_(VideoProcessing::Create()), 87 vp_(VideoProcessing::Create()),
90 qm_callback_(new QMVideoSettingsCallback(vp_.get())), 88 qm_callback_(new QMVideoSettingsCallback(vp_.get())),
91 video_sender_(Clock::GetRealTimeClock(), this, this, qm_callback_.get()), 89 video_sender_(Clock::GetRealTimeClock(), this, this, qm_callback_.get()),
92 stats_proxy_(stats_proxy), 90 stats_proxy_(stats_proxy),
93 pre_encode_callback_(pre_encode_callback),
94 overuse_detector_(overuse_detector), 91 overuse_detector_(overuse_detector),
95 pacer_(pacer),
96 send_payload_router_(payload_router), 92 send_payload_router_(payload_router),
97 post_encode_callback_(post_encode_callback), 93 post_encode_callback_(post_encode_callback),
98 time_of_last_frame_activity_ms_(0), 94 time_of_last_frame_activity_ms_(0),
99 encoder_config_(), 95 encoder_config_(),
100 min_transmit_bitrate_bps_(0), 96 min_transmit_bitrate_bps_(0),
101 last_observed_bitrate_bps_(0), 97 last_observed_bitrate_bps_(0),
102 network_is_transmitting_(true), 98 network_is_transmitting_(true),
103 encoder_paused_(false), 99 encoder_paused_(false),
104 encoder_paused_and_dropped_frame_(false), 100 encoder_paused_and_dropped_frame_(false),
105 time_last_intra_request_ms_(ssrcs.size(), -1), 101 time_last_intra_request_ms_(ssrcs.size(), -1),
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 271
276 return pad_up_to_bitrate_bps; 272 return pad_up_to_bitrate_bps;
277 } 273 }
278 274
279 bool ViEEncoder::EncoderPaused() const { 275 bool ViEEncoder::EncoderPaused() const {
280 // Pause video if paused by caller or as long as the network is down or the 276 // Pause video if paused by caller or as long as the network is down or the
281 // pacer queue has grown too large in buffered mode. 277 // pacer queue has grown too large in buffered mode.
282 if (encoder_paused_) { 278 if (encoder_paused_) {
283 return true; 279 return true;
284 } 280 }
285 if (pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs) { 281 if (video_suspended_ || last_observed_bitrate_bps_ == 0) {
286 // Too much data in pacer queue, drop frame.
287 return true; 282 return true;
288 } 283 }
289 return !network_is_transmitting_; 284 return !network_is_transmitting_;
290 } 285 }
291 286
292 void ViEEncoder::TraceFrameDropStart() { 287 void ViEEncoder::TraceFrameDropStart() {
293 // Start trace event only on the first frame after encoder is paused. 288 // Start trace event only on the first frame after encoder is paused.
294 if (!encoder_paused_and_dropped_frame_) { 289 if (!encoder_paused_and_dropped_frame_) {
295 TRACE_EVENT_ASYNC_BEGIN0("webrtc", "EncoderPaused", this); 290 TRACE_EVENT_ASYNC_BEGIN0("webrtc", "EncoderPaused", this);
296 } 291 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 // TODO(wuchengli): support texture frames. 325 // TODO(wuchengli): support texture frames.
331 if (!video_frame.video_frame_buffer()->native_handle()) { 326 if (!video_frame.video_frame_buffer()->native_handle()) {
332 // Pass frame via preprocessor. 327 // Pass frame via preprocessor.
333 frame_to_send = vp_->PreprocessFrame(video_frame); 328 frame_to_send = vp_->PreprocessFrame(video_frame);
334 if (!frame_to_send) { 329 if (!frame_to_send) {
335 // Drop this frame, or there was an error processing it. 330 // Drop this frame, or there was an error processing it.
336 return; 331 return;
337 } 332 }
338 } 333 }
339 334
340 if (pre_encode_callback_) {
341 pre_encode_callback_->OnFrame(*frame_to_send);
342 }
343
344 if (codec_type == webrtc::kVideoCodecVP8) { 335 if (codec_type == webrtc::kVideoCodecVP8) {
345 webrtc::CodecSpecificInfo codec_specific_info; 336 webrtc::CodecSpecificInfo codec_specific_info;
346 codec_specific_info.codecType = webrtc::kVideoCodecVP8; 337 codec_specific_info.codecType = webrtc::kVideoCodecVP8;
347 { 338 {
348 rtc::CritScope lock(&data_cs_); 339 rtc::CritScope lock(&data_cs_);
349 codec_specific_info.codecSpecific.VP8.hasReceivedRPSI = 340 codec_specific_info.codecSpecific.VP8.hasReceivedRPSI =
350 has_received_rpsi_; 341 has_received_rpsi_;
351 codec_specific_info.codecSpecific.VP8.hasReceivedSLI = 342 codec_specific_info.codecSpecific.VP8.hasReceivedSLI =
352 has_received_sli_; 343 has_received_sli_;
353 codec_specific_info.codecSpecific.VP8.pictureIdRPSI = 344 codec_specific_info.codecSpecific.VP8.pictureIdRPSI =
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 } 470 }
480 video_sender_.IntraFrameRequest(static_cast<int>(i)); 471 video_sender_.IntraFrameRequest(static_cast<int>(i));
481 return; 472 return;
482 } 473 }
483 RTC_NOTREACHED() << "Should not receive keyframe requests on unknown SSRCs."; 474 RTC_NOTREACHED() << "Should not receive keyframe requests on unknown SSRCs.";
484 } 475 }
485 476
486 void ViEEncoder::OnBitrateUpdated(uint32_t bitrate_bps, 477 void ViEEncoder::OnBitrateUpdated(uint32_t bitrate_bps,
487 uint8_t fraction_lost, 478 uint8_t fraction_lost,
488 int64_t round_trip_time_ms) { 479 int64_t round_trip_time_ms) {
489 LOG(LS_VERBOSE) << "OnBitrateUpdated, bitrate" << bitrate_bps 480 LOG(LS_VERBOSE) << "OnBitrateUpdated, bitrate " << bitrate_bps
490 << " packet loss " << static_cast<int>(fraction_lost) 481 << " packet loss " << static_cast<int>(fraction_lost)
491 << " rtt " << round_trip_time_ms; 482 << " rtt " << round_trip_time_ms;
492 RTC_DCHECK(send_payload_router_); 483 RTC_DCHECK(send_payload_router_);
493 video_sender_.SetChannelParameters(bitrate_bps, fraction_lost, 484 video_sender_.SetChannelParameters(bitrate_bps, fraction_lost,
494 round_trip_time_ms); 485 round_trip_time_ms);
495 bool video_is_suspended = video_sender_.VideoSuspended(); 486 bool video_is_suspended = video_sender_.VideoSuspended();
496 bool video_suspension_changed; 487 bool video_suspension_changed;
497 VideoCodec send_codec; 488 VideoCodec send_codec;
498 { 489 {
499 rtc::CritScope lock(&data_cs_); 490 rtc::CritScope lock(&data_cs_);
(...skipping 26 matching lines...) Expand all
526 } 517 }
527 518
528 int32_t QMVideoSettingsCallback::SetVideoQMSettings( 519 int32_t QMVideoSettingsCallback::SetVideoQMSettings(
529 const uint32_t frame_rate, 520 const uint32_t frame_rate,
530 const uint32_t width, 521 const uint32_t width,
531 const uint32_t height) { 522 const uint32_t height) {
532 return vp_->SetTargetResolution(width, height, frame_rate); 523 return vp_->SetTargetResolution(width, height, frame_rate);
533 } 524 }
534 525
535 } // namespace webrtc 526 } // namespace webrtc
OLDNEW
« webrtc/modules/remote_bitrate_estimator/test/estimators/remb.h ('K') | « webrtc/video/vie_encoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698