| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/renderer_host/media/video_capture_device_impl.h" | 5 #include "content/browser/renderer_host/media/video_capture_device_impl.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/callback_forward.h" | 9 #include "base/callback_forward.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 capture_size_ = gfx::Size( | 55 capture_size_ = gfx::Size( |
| 56 MakeEven(params.requested_format.frame_size.width()), | 56 MakeEven(params.requested_format.frame_size.width()), |
| 57 MakeEven(params.requested_format.frame_size.height())); | 57 MakeEven(params.requested_format.frame_size.height())); |
| 58 frame_rate_ = params.requested_format.frame_rate; | 58 frame_rate_ = params.requested_format.frame_rate; |
| 59 } | 59 } |
| 60 | 60 |
| 61 ThreadSafeCaptureOracle::~ThreadSafeCaptureOracle() {} | 61 ThreadSafeCaptureOracle::~ThreadSafeCaptureOracle() {} |
| 62 | 62 |
| 63 bool ThreadSafeCaptureOracle::ObserveEventAndDecideCapture( | 63 bool ThreadSafeCaptureOracle::ObserveEventAndDecideCapture( |
| 64 VideoCaptureOracle::Event event, | 64 VideoCaptureOracle::Event event, |
| 65 base::Time event_time, | 65 base::TimeTicks event_time, |
| 66 scoped_refptr<media::VideoFrame>* storage, | 66 scoped_refptr<media::VideoFrame>* storage, |
| 67 CaptureFrameCallback* callback) { | 67 CaptureFrameCallback* callback) { |
| 68 base::AutoLock guard(lock_); | 68 base::AutoLock guard(lock_); |
| 69 | 69 |
| 70 if (!client_) | 70 if (!client_) |
| 71 return false; // Capture is stopped. | 71 return false; // Capture is stopped. |
| 72 | 72 |
| 73 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> output_buffer = | 73 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> output_buffer = |
| 74 client_->ReserveOutputBuffer(media::VideoFrame::I420, capture_size_); | 74 client_->ReserveOutputBuffer(media::VideoFrame::I420, capture_size_); |
| 75 const bool should_capture = | 75 const bool should_capture = |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 159 |
| 160 void ThreadSafeCaptureOracle::ReportError() { | 160 void ThreadSafeCaptureOracle::ReportError() { |
| 161 base::AutoLock guard(lock_); | 161 base::AutoLock guard(lock_); |
| 162 if (client_) | 162 if (client_) |
| 163 client_->OnError(); | 163 client_->OnError(); |
| 164 } | 164 } |
| 165 | 165 |
| 166 void ThreadSafeCaptureOracle::DidCaptureFrame( | 166 void ThreadSafeCaptureOracle::DidCaptureFrame( |
| 167 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> buffer, | 167 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> buffer, |
| 168 int frame_number, | 168 int frame_number, |
| 169 base::Time timestamp, | 169 base::TimeTicks timestamp, |
| 170 bool success) { | 170 bool success) { |
| 171 base::AutoLock guard(lock_); | 171 base::AutoLock guard(lock_); |
| 172 TRACE_EVENT_ASYNC_END2("mirroring", "Capture", buffer.get(), | 172 TRACE_EVENT_ASYNC_END2("mirroring", "Capture", buffer.get(), |
| 173 "success", success, | 173 "success", success, |
| 174 "timestamp", timestamp.ToInternalValue()); | 174 "timestamp", timestamp.ToInternalValue()); |
| 175 | 175 |
| 176 if (!client_) | 176 if (!client_) |
| 177 return; // Capture is stopped. | 177 return; // Capture is stopped. |
| 178 | 178 |
| 179 if (success) { | 179 if (success) { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 return; | 295 return; |
| 296 | 296 |
| 297 if (oracle_proxy_) | 297 if (oracle_proxy_) |
| 298 oracle_proxy_->ReportError(); | 298 oracle_proxy_->ReportError(); |
| 299 | 299 |
| 300 StopAndDeAllocate(); | 300 StopAndDeAllocate(); |
| 301 TransitionStateTo(kError); | 301 TransitionStateTo(kError); |
| 302 } | 302 } |
| 303 | 303 |
| 304 } // namespace content | 304 } // namespace content |
| OLD | NEW |