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

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

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