| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_controller.h" | 5 #include "content/browser/renderer_host/media/video_capture_controller.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 public: | 46 public: |
| 47 PoolBuffer(const scoped_refptr<VideoCaptureBufferPool>& pool, | 47 PoolBuffer(const scoped_refptr<VideoCaptureBufferPool>& pool, |
| 48 int buffer_id, | 48 int buffer_id, |
| 49 void* data, | 49 void* data, |
| 50 size_t size) | 50 size_t size) |
| 51 : Buffer(buffer_id, data, size), pool_(pool) { | 51 : Buffer(buffer_id, data, size), pool_(pool) { |
| 52 DCHECK(pool_.get()); | 52 DCHECK(pool_.get()); |
| 53 } | 53 } |
| 54 | 54 |
| 55 private: | 55 private: |
| 56 virtual ~PoolBuffer() { pool_->RelinquishProducerReservation(id()); } | 56 ~PoolBuffer() override { pool_->RelinquishProducerReservation(id()); } |
| 57 | 57 |
| 58 const scoped_refptr<VideoCaptureBufferPool> pool_; | 58 const scoped_refptr<VideoCaptureBufferPool> pool_; |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 class SyncPointClientImpl : public media::VideoFrame::SyncPointClient { | 61 class SyncPointClientImpl : public media::VideoFrame::SyncPointClient { |
| 62 public: | 62 public: |
| 63 explicit SyncPointClientImpl(GLHelper* gl_helper) : gl_helper_(gl_helper) {} | 63 explicit SyncPointClientImpl(GLHelper* gl_helper) : gl_helper_(gl_helper) {} |
| 64 virtual ~SyncPointClientImpl() {} | 64 ~SyncPointClientImpl() override {} |
| 65 virtual uint32 InsertSyncPoint() override { | 65 uint32 InsertSyncPoint() override { return gl_helper_->InsertSyncPoint(); } |
| 66 return gl_helper_->InsertSyncPoint(); | 66 void WaitSyncPoint(uint32 sync_point) override { |
| 67 } | |
| 68 virtual void WaitSyncPoint(uint32 sync_point) override { | |
| 69 gl_helper_->WaitSyncPoint(sync_point); | 67 gl_helper_->WaitSyncPoint(sync_point); |
| 70 } | 68 } |
| 71 | 69 |
| 72 private: | 70 private: |
| 73 GLHelper* gl_helper_; | 71 GLHelper* gl_helper_; |
| 74 }; | 72 }; |
| 75 | 73 |
| 76 void ReturnVideoFrame(const scoped_refptr<media::VideoFrame>& video_frame, | 74 void ReturnVideoFrame(const scoped_refptr<media::VideoFrame>& video_frame, |
| 77 uint32 sync_point) { | 75 uint32 sync_point) { |
| 78 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 76 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 // Methods of this class may be called from any thread, and in practice will | 147 // Methods of this class may be called from any thread, and in practice will |
| 150 // often be called on some auxiliary thread depending on the platform and the | 148 // often be called on some auxiliary thread depending on the platform and the |
| 151 // device type; including, for example, the DirectShow thread on Windows, the | 149 // device type; including, for example, the DirectShow thread on Windows, the |
| 152 // v4l2_thread on Linux, and the UI thread for tab capture. | 150 // v4l2_thread on Linux, and the UI thread for tab capture. |
| 153 class VideoCaptureController::VideoCaptureDeviceClient | 151 class VideoCaptureController::VideoCaptureDeviceClient |
| 154 : public media::VideoCaptureDevice::Client { | 152 : public media::VideoCaptureDevice::Client { |
| 155 public: | 153 public: |
| 156 explicit VideoCaptureDeviceClient( | 154 explicit VideoCaptureDeviceClient( |
| 157 const base::WeakPtr<VideoCaptureController>& controller, | 155 const base::WeakPtr<VideoCaptureController>& controller, |
| 158 const scoped_refptr<VideoCaptureBufferPool>& buffer_pool); | 156 const scoped_refptr<VideoCaptureBufferPool>& buffer_pool); |
| 159 virtual ~VideoCaptureDeviceClient(); | 157 ~VideoCaptureDeviceClient() override; |
| 160 | 158 |
| 161 // VideoCaptureDevice::Client implementation. | 159 // VideoCaptureDevice::Client implementation. |
| 162 virtual scoped_refptr<Buffer> ReserveOutputBuffer( | 160 scoped_refptr<Buffer> ReserveOutputBuffer(media::VideoFrame::Format format, |
| 163 media::VideoFrame::Format format, | 161 const gfx::Size& size) override; |
| 164 const gfx::Size& size) override; | 162 void OnIncomingCapturedData(const uint8* data, |
| 165 virtual void OnIncomingCapturedData(const uint8* data, | 163 int length, |
| 166 int length, | 164 const VideoCaptureFormat& frame_format, |
| 167 const VideoCaptureFormat& frame_format, | 165 int rotation, |
| 168 int rotation, | 166 base::TimeTicks timestamp) override; |
| 169 base::TimeTicks timestamp) override; | 167 void OnIncomingCapturedVideoFrame( |
| 170 virtual void OnIncomingCapturedVideoFrame( | |
| 171 const scoped_refptr<Buffer>& buffer, | 168 const scoped_refptr<Buffer>& buffer, |
| 172 const VideoCaptureFormat& buffer_format, | 169 const VideoCaptureFormat& buffer_format, |
| 173 const scoped_refptr<media::VideoFrame>& frame, | 170 const scoped_refptr<media::VideoFrame>& frame, |
| 174 base::TimeTicks timestamp) override; | 171 base::TimeTicks timestamp) override; |
| 175 virtual void OnError(const std::string& reason) override; | 172 void OnError(const std::string& reason) override; |
| 176 virtual void OnLog(const std::string& message) override; | 173 void OnLog(const std::string& message) override; |
| 177 | 174 |
| 178 private: | 175 private: |
| 179 scoped_refptr<Buffer> DoReserveOutputBuffer(media::VideoFrame::Format format, | 176 scoped_refptr<Buffer> DoReserveOutputBuffer(media::VideoFrame::Format format, |
| 180 const gfx::Size& dimensions); | 177 const gfx::Size& dimensions); |
| 181 | 178 |
| 182 // The controller to which we post events. | 179 // The controller to which we post events. |
| 183 const base::WeakPtr<VideoCaptureController> controller_; | 180 const base::WeakPtr<VideoCaptureController> controller_; |
| 184 | 181 |
| 185 // The pool of shared-memory buffers used for capturing. | 182 // The pool of shared-memory buffers used for capturing. |
| 186 const scoped_refptr<VideoCaptureBufferPool> buffer_pool_; | 183 const scoped_refptr<VideoCaptureBufferPool> buffer_pool_; |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 707 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 711 int active_client_count = 0; | 708 int active_client_count = 0; |
| 712 for (ControllerClient* client : controller_clients_) { | 709 for (ControllerClient* client : controller_clients_) { |
| 713 if (!client->paused) | 710 if (!client->paused) |
| 714 ++active_client_count; | 711 ++active_client_count; |
| 715 } | 712 } |
| 716 return active_client_count; | 713 return active_client_count; |
| 717 } | 714 } |
| 718 | 715 |
| 719 } // namespace content | 716 } // namespace content |
| OLD | NEW |