| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 return static_cast<VideoCaptureInput*>(obj)->CaptureProcess(); | 124 return static_cast<VideoCaptureInput*>(obj)->CaptureProcess(); |
| 125 } | 125 } |
| 126 | 126 |
| 127 bool VideoCaptureInput::CaptureProcess() { | 127 bool VideoCaptureInput::CaptureProcess() { |
| 128 static const int kThreadWaitTimeMs = 100; | 128 static const int kThreadWaitTimeMs = 100; |
| 129 int64_t capture_time = -1; | 129 int64_t capture_time = -1; |
| 130 if (capture_event_.Wait(kThreadWaitTimeMs) == kEventSignaled) { | 130 if (capture_event_.Wait(kThreadWaitTimeMs) == kEventSignaled) { |
| 131 if (rtc::AtomicOps::Load(&stop_)) | 131 if (rtc::AtomicOps::Load(&stop_)) |
| 132 return false; | 132 return false; |
| 133 | 133 |
| 134 overuse_detector_->FrameProcessingStarted(); | |
| 135 int64_t encode_start_time = -1; | 134 int64_t encode_start_time = -1; |
| 136 VideoFrame deliver_frame; | 135 VideoFrame deliver_frame; |
| 137 { | 136 { |
| 138 CriticalSectionScoped cs(capture_cs_.get()); | 137 CriticalSectionScoped cs(capture_cs_.get()); |
| 139 if (!captured_frame_.IsZeroSize()) { | 138 if (!captured_frame_.IsZeroSize()) { |
| 140 deliver_frame = captured_frame_; | 139 deliver_frame = captured_frame_; |
| 141 captured_frame_.Reset(); | 140 captured_frame_.Reset(); |
| 142 } | 141 } |
| 143 } | 142 } |
| 144 if (!deliver_frame.IsZeroSize()) { | 143 if (!deliver_frame.IsZeroSize()) { |
| 145 capture_time = deliver_frame.render_time_ms(); | 144 capture_time = deliver_frame.render_time_ms(); |
| 146 encode_start_time = Clock::GetRealTimeClock()->TimeInMilliseconds(); | 145 encode_start_time = Clock::GetRealTimeClock()->TimeInMilliseconds(); |
| 147 frame_callback_->DeliverFrame(deliver_frame); | 146 frame_callback_->DeliverFrame(deliver_frame); |
| 148 } | 147 } |
| 149 // Update the overuse detector with the duration. | 148 // Update the overuse detector with the duration. |
| 150 if (encode_start_time != -1) { | 149 if (encode_start_time != -1) { |
| 151 overuse_detector_->FrameEncoded( | 150 overuse_detector_->FrameEncoded( |
| 152 Clock::GetRealTimeClock()->TimeInMilliseconds() - encode_start_time); | 151 Clock::GetRealTimeClock()->TimeInMilliseconds() - encode_start_time); |
| 153 } | 152 } |
| 154 } | 153 } |
| 155 // We're done! | 154 // We're done! |
| 156 if (capture_time != -1) { | 155 if (capture_time != -1) { |
| 157 overuse_detector_->FrameSent(capture_time); | 156 overuse_detector_->FrameSent(capture_time); |
| 158 } | 157 } |
| 159 return true; | 158 return true; |
| 160 } | 159 } |
| 161 | 160 |
| 162 } // namespace internal | 161 } // namespace internal |
| 163 } // namespace webrtc | 162 } // namespace webrtc |
| OLD | NEW |