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

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: Rebased 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. 282 // Too low bitrate to send data.
stefan-webrtc 2016/04/29 10:48:39 I think we can remove the comment.
perkj_webrtc 2016/05/02 11:29:10 Done.
287 return true; 283 return true;
288 } 284 }
289 return !network_is_transmitting_; 285 return !network_is_transmitting_;
290 } 286 }
291 287
292 void ViEEncoder::TraceFrameDropStart() { 288 void ViEEncoder::TraceFrameDropStart() {
293 // Start trace event only on the first frame after encoder is paused. 289 // Start trace event only on the first frame after encoder is paused.
294 if (!encoder_paused_and_dropped_frame_) { 290 if (!encoder_paused_and_dropped_frame_) {
295 TRACE_EVENT_ASYNC_BEGIN0("webrtc", "EncoderPaused", this); 291 TRACE_EVENT_ASYNC_BEGIN0("webrtc", "EncoderPaused", this);
296 } 292 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 // TODO(wuchengli): support texture frames. 326 // TODO(wuchengli): support texture frames.
331 if (!video_frame.video_frame_buffer()->native_handle()) { 327 if (!video_frame.video_frame_buffer()->native_handle()) {
332 // Pass frame via preprocessor. 328 // Pass frame via preprocessor.
333 frame_to_send = vp_->PreprocessFrame(video_frame); 329 frame_to_send = vp_->PreprocessFrame(video_frame);
334 if (!frame_to_send) { 330 if (!frame_to_send) {
335 // Drop this frame, or there was an error processing it. 331 // Drop this frame, or there was an error processing it.
336 return; 332 return;
337 } 333 }
338 } 334 }
339 335
340 if (pre_encode_callback_) {
341 pre_encode_callback_->OnFrame(*frame_to_send);
342 }
343
344 if (codec_type == webrtc::kVideoCodecVP8) { 336 if (codec_type == webrtc::kVideoCodecVP8) {
345 webrtc::CodecSpecificInfo codec_specific_info; 337 webrtc::CodecSpecificInfo codec_specific_info;
346 codec_specific_info.codecType = webrtc::kVideoCodecVP8; 338 codec_specific_info.codecType = webrtc::kVideoCodecVP8;
347 { 339 {
348 rtc::CritScope lock(&data_cs_); 340 rtc::CritScope lock(&data_cs_);
349 codec_specific_info.codecSpecific.VP8.hasReceivedRPSI = 341 codec_specific_info.codecSpecific.VP8.hasReceivedRPSI =
350 has_received_rpsi_; 342 has_received_rpsi_;
351 codec_specific_info.codecSpecific.VP8.hasReceivedSLI = 343 codec_specific_info.codecSpecific.VP8.hasReceivedSLI =
352 has_received_sli_; 344 has_received_sli_;
353 codec_specific_info.codecSpecific.VP8.pictureIdRPSI = 345 codec_specific_info.codecSpecific.VP8.pictureIdRPSI =
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 } 471 }
480 video_sender_.IntraFrameRequest(static_cast<int>(i)); 472 video_sender_.IntraFrameRequest(static_cast<int>(i));
481 return; 473 return;
482 } 474 }
483 RTC_NOTREACHED() << "Should not receive keyframe requests on unknown SSRCs."; 475 RTC_NOTREACHED() << "Should not receive keyframe requests on unknown SSRCs.";
484 } 476 }
485 477
486 void ViEEncoder::OnBitrateUpdated(uint32_t bitrate_bps, 478 void ViEEncoder::OnBitrateUpdated(uint32_t bitrate_bps,
487 uint8_t fraction_lost, 479 uint8_t fraction_lost,
488 int64_t round_trip_time_ms) { 480 int64_t round_trip_time_ms) {
489 LOG(LS_VERBOSE) << "OnBitrateUpdated, bitrate" << bitrate_bps 481 LOG(LS_VERBOSE) << "OnBitrateUpdated, bitrate " << bitrate_bps
490 << " packet loss " << static_cast<int>(fraction_lost) 482 << " packet loss " << static_cast<int>(fraction_lost)
491 << " rtt " << round_trip_time_ms; 483 << " rtt " << round_trip_time_ms;
492 RTC_DCHECK(send_payload_router_); 484 RTC_DCHECK(send_payload_router_);
493 video_sender_.SetChannelParameters(bitrate_bps, fraction_lost, 485 video_sender_.SetChannelParameters(bitrate_bps, fraction_lost,
494 round_trip_time_ms); 486 round_trip_time_ms);
495 bool video_is_suspended = video_sender_.VideoSuspended(); 487 bool video_is_suspended = video_sender_.VideoSuspended();
496 bool video_suspension_changed; 488 bool video_suspension_changed;
497 VideoCodec send_codec; 489 VideoCodec send_codec;
498 { 490 {
499 rtc::CritScope lock(&data_cs_); 491 rtc::CritScope lock(&data_cs_);
(...skipping 26 matching lines...) Expand all
526 } 518 }
527 519
528 int32_t QMVideoSettingsCallback::SetVideoQMSettings( 520 int32_t QMVideoSettingsCallback::SetVideoQMSettings(
529 const uint32_t frame_rate, 521 const uint32_t frame_rate,
530 const uint32_t width, 522 const uint32_t width,
531 const uint32_t height) { 523 const uint32_t height) {
532 return vp_->SetTargetResolution(width, height, frame_rate); 524 return vp_->SetTargetResolution(width, height, frame_rate);
533 } 525 }
534 526
535 } // namespace webrtc 527 } // namespace webrtc
OLDNEW
« webrtc/modules/pacing/paced_sender_unittest.cc ('K') | « webrtc/video/vie_encoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698