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

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: feedback 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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 RTC_DCHECK(send_payload_router_ != NULL); 458 RTC_DCHECK(send_payload_router_ != NULL);
456 459
457 { 460 {
458 rtc::CritScope lock(&data_cs_); 461 rtc::CritScope lock(&data_cs_);
459 time_of_last_frame_activity_ms_ = TickTime::MillisecondTimestamp(); 462 time_of_last_frame_activity_ms_ = TickTime::MillisecondTimestamp();
460 } 463 }
461 464
462 if (stats_proxy_ != NULL) 465 if (stats_proxy_ != NULL)
463 stats_proxy_->OnSendEncodedImage(encoded_image, rtp_video_hdr); 466 stats_proxy_->OnSendEncodedImage(encoded_image, rtp_video_hdr);
464 467
465 return send_payload_router_->RoutePayload( 468 bool success =
466 encoded_image._frameType, payload_type, encoded_image._timeStamp, 469 send_payload_router_->RoutePayload(encoded_image._frameType,
467 encoded_image.capture_time_ms_, encoded_image._buffer, 470 payload_type,
468 encoded_image._length, &fragmentation_header, rtp_video_hdr) 471 encoded_image._timeStamp,
469 ? 0 472 encoded_image.capture_time_ms_,
470 : -1; 473 encoded_image._buffer,
474 encoded_image._length,
475 &fragmentation_header,
476 rtp_video_hdr);
477 overuse_detector_->FrameSent(encoded_image._timeStamp);
478 return success ? 0 : -1;
471 } 479 }
472 480
473 void ViEEncoder::OnEncoderImplementationName( 481 void ViEEncoder::OnEncoderImplementationName(
474 const char* implementation_name) { 482 const char* implementation_name) {
475 if (stats_proxy_) 483 if (stats_proxy_)
476 stats_proxy_->OnEncoderImplementationName(implementation_name); 484 stats_proxy_->OnEncoderImplementationName(implementation_name);
477 } 485 }
478 486
479 int32_t ViEEncoder::SendStatistics(const uint32_t bit_rate, 487 int32_t ViEEncoder::SendStatistics(const uint32_t bit_rate,
480 const uint32_t frame_rate) { 488 const uint32_t frame_rate) {
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 const uint32_t width, 631 const uint32_t width,
624 const uint32_t height) { 632 const uint32_t height) {
625 return vp_->SetTargetResolution(width, height, frame_rate); 633 return vp_->SetTargetResolution(width, height, frame_rate);
626 } 634 }
627 635
628 void QMVideoSettingsCallback::SetTargetFramerate(int frame_rate) { 636 void QMVideoSettingsCallback::SetTargetFramerate(int frame_rate) {
629 vp_->SetTargetFramerate(frame_rate); 637 vp_->SetTargetFramerate(frame_rate);
630 } 638 }
631 639
632 } // namespace webrtc 640 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698