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

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: add extended overuse time Created 4 years, 11 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/encoded_frame.h"
mflodman 2016/01/21 08:00:05 Shouldn't this be webrtc/video_frame.h?
pbos-webrtc 2016/01/21 14:18:33 Done.
27 #include "webrtc/modules/video_coding/include/video_codec_interface.h" 28 #include "webrtc/modules/video_coding/include/video_codec_interface.h"
28 #include "webrtc/modules/video_coding/include/video_coding.h" 29 #include "webrtc/modules/video_coding/include/video_coding.h"
29 #include "webrtc/modules/video_coding/include/video_coding_defines.h" 30 #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" 31 #include "webrtc/system_wrappers/include/clock.h"
32 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" 32 #include "webrtc/system_wrappers/include/critical_section_wrapper.h"
33 #include "webrtc/system_wrappers/include/metrics.h" 33 #include "webrtc/system_wrappers/include/metrics.h"
34 #include "webrtc/system_wrappers/include/tick_util.h" 34 #include "webrtc/system_wrappers/include/tick_util.h"
35 #include "webrtc/video/overuse_frame_detector.h"
35 #include "webrtc/video/payload_router.h" 36 #include "webrtc/video/payload_router.h"
36 #include "webrtc/video/send_statistics_proxy.h" 37 #include "webrtc/video/send_statistics_proxy.h"
37 38
38 namespace webrtc { 39 namespace webrtc {
39 40
40 // Margin on when we pause the encoder when the pacing buffer overflows relative 41 // Margin on when we pause the encoder when the pacing buffer overflows relative
41 // to the configured buffer delay. 42 // to the configured buffer delay.
42 static const float kEncoderPausePacerMargin = 2.0f; 43 static const float kEncoderPausePacerMargin = 2.0f;
43 44
44 // Don't stop the encoder unless the delay is above this configured value. 45 // Don't stop the encoder unless the delay is above this configured value.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 owner_->OnNetworkChanged(bitrate_bps, fraction_lost, rtt); 102 owner_->OnNetworkChanged(bitrate_bps, fraction_lost, rtt);
102 } 103 }
103 private: 104 private:
104 ViEEncoder* owner_; 105 ViEEncoder* owner_;
105 }; 106 };
106 107
107 ViEEncoder::ViEEncoder(uint32_t number_of_cores, 108 ViEEncoder::ViEEncoder(uint32_t number_of_cores,
108 ProcessThread* module_process_thread, 109 ProcessThread* module_process_thread,
109 SendStatisticsProxy* stats_proxy, 110 SendStatisticsProxy* stats_proxy,
110 I420FrameCallback* pre_encode_callback, 111 I420FrameCallback* pre_encode_callback,
112 OveruseFrameDetector* overuse_detector,
111 PacedSender* pacer, 113 PacedSender* pacer,
112 BitrateAllocator* bitrate_allocator) 114 BitrateAllocator* bitrate_allocator)
113 : number_of_cores_(number_of_cores), 115 : number_of_cores_(number_of_cores),
114 vp_(VideoProcessing::Create()), 116 vp_(VideoProcessing::Create()),
115 qm_callback_(new QMVideoSettingsCallback(vp_.get())), 117 qm_callback_(new QMVideoSettingsCallback(vp_.get())),
116 vcm_(VideoCodingModule::Create(Clock::GetRealTimeClock(), 118 vcm_(VideoCodingModule::Create(Clock::GetRealTimeClock(),
117 this, 119 this,
118 qm_callback_.get())), 120 qm_callback_.get())),
119 send_payload_router_(NULL), 121 send_payload_router_(NULL),
120 data_cs_(CriticalSectionWrapper::CreateCriticalSection()), 122 data_cs_(CriticalSectionWrapper::CreateCriticalSection()),
121 stats_proxy_(stats_proxy), 123 stats_proxy_(stats_proxy),
122 pre_encode_callback_(pre_encode_callback), 124 pre_encode_callback_(pre_encode_callback),
125 overuse_detector_(overuse_detector),
123 pacer_(pacer), 126 pacer_(pacer),
124 bitrate_allocator_(bitrate_allocator), 127 bitrate_allocator_(bitrate_allocator),
125 time_of_last_frame_activity_ms_(0), 128 time_of_last_frame_activity_ms_(0),
126 encoder_config_(), 129 encoder_config_(),
127 min_transmit_bitrate_kbps_(0), 130 min_transmit_bitrate_kbps_(0),
128 last_observed_bitrate_bps_(0), 131 last_observed_bitrate_bps_(0),
129 target_delay_ms_(0), 132 target_delay_ms_(0),
130 network_is_transmitting_(true), 133 network_is_transmitting_(true),
131 encoder_paused_(false), 134 encoder_paused_(false),
132 encoder_paused_and_dropped_frame_(false), 135 encoder_paused_and_dropped_frame_(false),
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 RTC_DCHECK(send_payload_router_ != NULL); 460 RTC_DCHECK(send_payload_router_ != NULL);
458 461
459 { 462 {
460 CriticalSectionScoped cs(data_cs_.get()); 463 CriticalSectionScoped cs(data_cs_.get());
461 time_of_last_frame_activity_ms_ = TickTime::MillisecondTimestamp(); 464 time_of_last_frame_activity_ms_ = TickTime::MillisecondTimestamp();
462 } 465 }
463 466
464 if (stats_proxy_ != NULL) 467 if (stats_proxy_ != NULL)
465 stats_proxy_->OnSendEncodedImage(encoded_image, rtp_video_hdr); 468 stats_proxy_->OnSendEncodedImage(encoded_image, rtp_video_hdr);
466 469
467 return send_payload_router_->RoutePayload( 470 bool success =
468 encoded_image._frameType, payload_type, encoded_image._timeStamp, 471 send_payload_router_->RoutePayload(encoded_image._frameType,
469 encoded_image.capture_time_ms_, encoded_image._buffer, 472 payload_type,
470 encoded_image._length, &fragmentation_header, rtp_video_hdr) 473 encoded_image._timeStamp,
471 ? 0 474 encoded_image.capture_time_ms_,
472 : -1; 475 encoded_image._buffer,
476 encoded_image._length,
477 &fragmentation_header,
478 rtp_video_hdr);
479 overuse_detector_->FrameSent(encoded_image);
480 return success ? 0 : -1;
473 } 481 }
474 482
475 void ViEEncoder::OnEncoderImplementationName( 483 void ViEEncoder::OnEncoderImplementationName(
476 const char* implementation_name) { 484 const char* implementation_name) {
477 if (stats_proxy_) 485 if (stats_proxy_)
478 stats_proxy_->OnEncoderImplementationName(implementation_name); 486 stats_proxy_->OnEncoderImplementationName(implementation_name);
479 } 487 }
480 488
481 int32_t ViEEncoder::SendStatistics(const uint32_t bit_rate, 489 int32_t ViEEncoder::SendStatistics(const uint32_t bit_rate,
482 const uint32_t frame_rate) { 490 const uint32_t frame_rate) {
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 const uint32_t width, 633 const uint32_t width,
626 const uint32_t height) { 634 const uint32_t height) {
627 return vp_->SetTargetResolution(width, height, frame_rate); 635 return vp_->SetTargetResolution(width, height, frame_rate);
628 } 636 }
629 637
630 void QMVideoSettingsCallback::SetTargetFramerate(int frame_rate) { 638 void QMVideoSettingsCallback::SetTargetFramerate(int frame_rate) {
631 vp_->SetTargetFramerate(frame_rate); 639 vp_->SetTargetFramerate(frame_rate);
632 } 640 }
633 641
634 } // namespace webrtc 642 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698