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

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

Issue 1569853002: Measure encoding time on encode callbacks. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 4 years, 10 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
11 #include "webrtc/video/vie_encoder.h" 11 #include "webrtc/video/vie_encoder.h"
12 12
13 #include <assert.h> 13 #include <assert.h>
14 14
15 #include <algorithm> 15 #include <algorithm>
16 16
17 #include "webrtc/base/checks.h" 17 #include "webrtc/base/checks.h"
18 #include "webrtc/base/logging.h" 18 #include "webrtc/base/logging.h"
19 #include "webrtc/base/trace_event.h" 19 #include "webrtc/base/trace_event.h"
20 #include "webrtc/call/bitrate_allocator.h" 20 #include "webrtc/call/bitrate_allocator.h"
21 #include "webrtc/common_video/include/video_image.h" 21 #include "webrtc/common_video/include/video_image.h"
22 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" 22 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
23 #include "webrtc/frame_callback.h" 23 #include "webrtc/frame_callback.h"
24 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" 24 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
25 #include "webrtc/modules/pacing/paced_sender.h" 25 #include "webrtc/modules/pacing/paced_sender.h"
26 #include "webrtc/modules/utility/include/process_thread.h" 26 #include "webrtc/modules/utility/include/process_thread.h"
27 #include "webrtc/modules/video_coding/include/video_codec_interface.h" 27 #include "webrtc/modules/video_coding/include/video_codec_interface.h"
28 #include "webrtc/modules/video_coding/include/video_coding.h" 28 #include "webrtc/modules/video_coding/include/video_coding.h"
29 #include "webrtc/modules/video_coding/include/video_coding_defines.h" 29 #include "webrtc/modules/video_coding/include/video_coding_defines.h"
30 #include "webrtc/modules/video_coding/encoded_frame.h"
31 #include "webrtc/system_wrappers/include/clock.h" 30 #include "webrtc/system_wrappers/include/clock.h"
32 #include "webrtc/system_wrappers/include/metrics.h" 31 #include "webrtc/system_wrappers/include/metrics.h"
33 #include "webrtc/system_wrappers/include/tick_util.h" 32 #include "webrtc/system_wrappers/include/tick_util.h"
33 #include "webrtc/video/overuse_frame_detector.h"
34 #include "webrtc/video/payload_router.h" 34 #include "webrtc/video/payload_router.h"
35 #include "webrtc/video/send_statistics_proxy.h" 35 #include "webrtc/video/send_statistics_proxy.h"
36 #include "webrtc/video_frame.h"
36 37
37 namespace webrtc { 38 namespace webrtc {
38 39
39 // Margin on when we pause the encoder when the pacing buffer overflows relative 40 // Margin on when we pause the encoder when the pacing buffer overflows relative
40 // to the configured buffer delay. 41 // to the configured buffer delay.
41 static const float kEncoderPausePacerMargin = 2.0f; 42 static const float kEncoderPausePacerMargin = 2.0f;
42 43
43 // Don't stop the encoder unless the delay is above this configured value. 44 // Don't stop the encoder unless the delay is above this configured value.
44 static const int kMinPacingDelayMs = 200; 45 static const int kMinPacingDelayMs = 200;
45 46
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 owner_->OnNetworkChanged(bitrate_bps, fraction_lost, rtt); 101 owner_->OnNetworkChanged(bitrate_bps, fraction_lost, rtt);
101 } 102 }
102 private: 103 private:
103 ViEEncoder* owner_; 104 ViEEncoder* owner_;
104 }; 105 };
105 106
106 ViEEncoder::ViEEncoder(uint32_t number_of_cores, 107 ViEEncoder::ViEEncoder(uint32_t number_of_cores,
107 ProcessThread* module_process_thread, 108 ProcessThread* module_process_thread,
108 SendStatisticsProxy* stats_proxy, 109 SendStatisticsProxy* stats_proxy,
109 I420FrameCallback* pre_encode_callback, 110 I420FrameCallback* pre_encode_callback,
111 OveruseFrameDetector* overuse_detector,
110 PacedSender* pacer, 112 PacedSender* pacer,
111 BitrateAllocator* bitrate_allocator) 113 BitrateAllocator* bitrate_allocator)
112 : number_of_cores_(number_of_cores), 114 : number_of_cores_(number_of_cores),
113 vp_(VideoProcessing::Create()), 115 vp_(VideoProcessing::Create()),
114 qm_callback_(new QMVideoSettingsCallback(vp_.get())), 116 qm_callback_(new QMVideoSettingsCallback(vp_.get())),
115 vcm_(VideoCodingModule::Create(Clock::GetRealTimeClock(), 117 vcm_(VideoCodingModule::Create(Clock::GetRealTimeClock(),
116 this, 118 this,
117 qm_callback_.get())), 119 qm_callback_.get())),
118 send_payload_router_(NULL), 120 send_payload_router_(NULL),
119 stats_proxy_(stats_proxy), 121 stats_proxy_(stats_proxy),
120 pre_encode_callback_(pre_encode_callback), 122 pre_encode_callback_(pre_encode_callback),
123 overuse_detector_(overuse_detector),
121 pacer_(pacer), 124 pacer_(pacer),
122 bitrate_allocator_(bitrate_allocator), 125 bitrate_allocator_(bitrate_allocator),
123 time_of_last_frame_activity_ms_(0), 126 time_of_last_frame_activity_ms_(0),
124 encoder_config_(), 127 encoder_config_(),
125 min_transmit_bitrate_kbps_(0), 128 min_transmit_bitrate_kbps_(0),
126 last_observed_bitrate_bps_(0), 129 last_observed_bitrate_bps_(0),
127 target_delay_ms_(0), 130 target_delay_ms_(0),
128 network_is_transmitting_(true), 131 network_is_transmitting_(true),
129 encoder_paused_(false), 132 encoder_paused_(false),
130 encoder_paused_and_dropped_frame_(false), 133 encoder_paused_and_dropped_frame_(false),
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 RTC_DCHECK(send_payload_router_ != NULL); 457 RTC_DCHECK(send_payload_router_ != NULL);
455 458
456 { 459 {
457 rtc::CritScope lock(&data_cs_); 460 rtc::CritScope lock(&data_cs_);
458 time_of_last_frame_activity_ms_ = TickTime::MillisecondTimestamp(); 461 time_of_last_frame_activity_ms_ = TickTime::MillisecondTimestamp();
459 } 462 }
460 463
461 if (stats_proxy_ != NULL) 464 if (stats_proxy_ != NULL)
462 stats_proxy_->OnSendEncodedImage(encoded_image, rtp_video_hdr); 465 stats_proxy_->OnSendEncodedImage(encoded_image, rtp_video_hdr);
463 466
464 return send_payload_router_->RoutePayload( 467 bool success = send_payload_router_->RoutePayload(
465 encoded_image._frameType, payload_type, encoded_image._timeStamp, 468 encoded_image._frameType, payload_type, encoded_image._timeStamp,
466 encoded_image.capture_time_ms_, encoded_image._buffer, 469 encoded_image.capture_time_ms_, encoded_image._buffer,
467 encoded_image._length, fragmentation_header, rtp_video_hdr) 470 encoded_image._length, fragmentation_header, rtp_video_hdr);
468 ? 0 471 overuse_detector_->FrameSent(encoded_image._timeStamp);
469 : -1; 472 return success ? 0 : -1;
470 } 473 }
471 474
472 void ViEEncoder::OnEncoderImplementationName( 475 void ViEEncoder::OnEncoderImplementationName(
473 const char* implementation_name) { 476 const char* implementation_name) {
474 if (stats_proxy_) 477 if (stats_proxy_)
475 stats_proxy_->OnEncoderImplementationName(implementation_name); 478 stats_proxy_->OnEncoderImplementationName(implementation_name);
476 } 479 }
477 480
478 int32_t ViEEncoder::SendStatistics(const uint32_t bit_rate, 481 int32_t ViEEncoder::SendStatistics(const uint32_t bit_rate,
479 const uint32_t frame_rate) { 482 const uint32_t frame_rate) {
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 const uint32_t width, 625 const uint32_t width,
623 const uint32_t height) { 626 const uint32_t height) {
624 return vp_->SetTargetResolution(width, height, frame_rate); 627 return vp_->SetTargetResolution(width, height, frame_rate);
625 } 628 }
626 629
627 void QMVideoSettingsCallback::SetTargetFramerate(int frame_rate) { 630 void QMVideoSettingsCallback::SetTargetFramerate(int frame_rate) {
628 vp_->SetTargetFramerate(frame_rate); 631 vp_->SetTargetFramerate(frame_rate);
629 } 632 }
630 633
631 } // namespace webrtc 634 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698