OLD | NEW |
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 11 matching lines...) Expand all Loading... |
22 #include "webrtc/system_wrappers/interface/logging.h" | 22 #include "webrtc/system_wrappers/interface/logging.h" |
23 #include "webrtc/system_wrappers/interface/tick_util.h" | 23 #include "webrtc/system_wrappers/interface/tick_util.h" |
24 #include "webrtc/system_wrappers/interface/trace_event.h" | 24 #include "webrtc/system_wrappers/interface/trace_event.h" |
25 #include "webrtc/video/send_statistics_proxy.h" | 25 #include "webrtc/video/send_statistics_proxy.h" |
26 #include "webrtc/video_engine/overuse_frame_detector.h" | 26 #include "webrtc/video_engine/overuse_frame_detector.h" |
27 #include "webrtc/video_engine/vie_encoder.h" | 27 #include "webrtc/video_engine/vie_encoder.h" |
28 | 28 |
29 namespace webrtc { | 29 namespace webrtc { |
30 | 30 |
31 namespace internal { | 31 namespace internal { |
32 VideoCaptureInput::VideoCaptureInput(ProcessThread* module_process_thread, | 32 VideoCaptureInput::VideoCaptureInput( |
33 VideoCaptureCallback* frame_callback, | 33 ProcessThread* module_process_thread, |
34 VideoRenderer* local_renderer, | 34 VideoCaptureCallback* frame_callback, |
35 SendStatisticsProxy* stats_proxy, | 35 VideoRenderer* local_renderer, |
36 CpuOveruseObserver* overuse_observer) | 36 SendStatisticsProxy* stats_proxy, |
| 37 CpuOveruseObserver* overuse_observer, |
| 38 EncodingTimeObserver* encoding_time_observer) |
37 : capture_cs_(CriticalSectionWrapper::CreateCriticalSection()), | 39 : capture_cs_(CriticalSectionWrapper::CreateCriticalSection()), |
38 module_process_thread_(module_process_thread), | 40 module_process_thread_(module_process_thread), |
39 frame_callback_(frame_callback), | 41 frame_callback_(frame_callback), |
40 local_renderer_(local_renderer), | 42 local_renderer_(local_renderer), |
41 stats_proxy_(stats_proxy), | 43 stats_proxy_(stats_proxy), |
42 incoming_frame_cs_(CriticalSectionWrapper::CreateCriticalSection()), | 44 incoming_frame_cs_(CriticalSectionWrapper::CreateCriticalSection()), |
43 encoder_thread_(ThreadWrapper::CreateThread(EncoderThreadFunction, | 45 encoder_thread_(ThreadWrapper::CreateThread(EncoderThreadFunction, |
44 this, | 46 this, |
45 "EncoderThread")), | 47 "EncoderThread")), |
46 capture_event_(EventWrapper::Create()), | 48 capture_event_(EventWrapper::Create()), |
47 stop_(0), | 49 stop_(0), |
48 last_captured_timestamp_(0), | 50 last_captured_timestamp_(0), |
49 delta_ntp_internal_ms_( | 51 delta_ntp_internal_ms_( |
50 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds() - | 52 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds() - |
51 TickTime::MillisecondTimestamp()), | 53 TickTime::MillisecondTimestamp()), |
52 overuse_detector_(new OveruseFrameDetector(Clock::GetRealTimeClock(), | 54 overuse_detector_(new OveruseFrameDetector(Clock::GetRealTimeClock(), |
53 CpuOveruseOptions(), | 55 CpuOveruseOptions(), |
54 overuse_observer, | 56 overuse_observer, |
55 stats_proxy)) { | 57 stats_proxy)), |
| 58 encoding_time_observer_(encoding_time_observer) { |
56 encoder_thread_->Start(); | 59 encoder_thread_->Start(); |
57 encoder_thread_->SetPriority(kHighPriority); | 60 encoder_thread_->SetPriority(kHighPriority); |
58 module_process_thread_->RegisterModule(overuse_detector_.get()); | 61 module_process_thread_->RegisterModule(overuse_detector_.get()); |
59 } | 62 } |
60 | 63 |
61 VideoCaptureInput::~VideoCaptureInput() { | 64 VideoCaptureInput::~VideoCaptureInput() { |
62 module_process_thread_->DeRegisterModule(overuse_detector_.get()); | 65 module_process_thread_->DeRegisterModule(overuse_detector_.get()); |
63 | 66 |
64 // Stop the thread. | 67 // Stop the thread. |
65 rtc::AtomicOps::ReleaseStore(&stop_, 1); | 68 rtc::AtomicOps::ReleaseStore(&stop_, 1); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 capture_time = deliver_frame.render_time_ms(); | 145 capture_time = deliver_frame.render_time_ms(); |
143 encode_start_time = Clock::GetRealTimeClock()->TimeInMilliseconds(); | 146 encode_start_time = Clock::GetRealTimeClock()->TimeInMilliseconds(); |
144 frame_callback_->DeliverFrame(deliver_frame); | 147 frame_callback_->DeliverFrame(deliver_frame); |
145 } | 148 } |
146 // Update the overuse detector with the duration. | 149 // Update the overuse detector with the duration. |
147 if (encode_start_time != -1) { | 150 if (encode_start_time != -1) { |
148 int encode_time_ms = static_cast<int>( | 151 int encode_time_ms = static_cast<int>( |
149 Clock::GetRealTimeClock()->TimeInMilliseconds() - encode_start_time); | 152 Clock::GetRealTimeClock()->TimeInMilliseconds() - encode_start_time); |
150 overuse_detector_->FrameEncoded(encode_time_ms); | 153 overuse_detector_->FrameEncoded(encode_time_ms); |
151 stats_proxy_->OnEncodedFrame(encode_time_ms); | 154 stats_proxy_->OnEncodedFrame(encode_time_ms); |
| 155 if (encoding_time_observer_) { |
| 156 encoding_time_observer_->OnReportEncodedTime( |
| 157 deliver_frame.ntp_time_ms(), encode_time_ms); |
| 158 } |
152 } | 159 } |
153 } | 160 } |
154 // We're done! | 161 // We're done! |
155 if (capture_time != -1) { | 162 if (capture_time != -1) { |
156 overuse_detector_->FrameSent(capture_time); | 163 overuse_detector_->FrameSent(capture_time); |
157 } | 164 } |
158 return true; | 165 return true; |
159 } | 166 } |
160 | 167 |
161 } // namespace internal | 168 } // namespace internal |
162 } // namespace webrtc | 169 } // namespace webrtc |
OLD | NEW |