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