| 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 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 namespace { | 35 namespace { |
| 36 | 36 |
| 37 static const int kInfiniteRatio = 99999; | 37 static const int kInfiniteRatio = 99999; |
| 38 | 38 |
| 39 #define UMA_HISTOGRAM_ASPECT_RATIO(name, width, height) \ | 39 #define UMA_HISTOGRAM_ASPECT_RATIO(name, width, height) \ |
| 40 UMA_HISTOGRAM_SPARSE_SLOWLY( \ | 40 UMA_HISTOGRAM_SPARSE_SLOWLY( \ |
| 41 name, \ | 41 name, \ |
| 42 (height) ? ((width) * 100) / (height) : kInfiniteRatio); | 42 (height) ? ((width) * 100) / (height) : kInfiniteRatio); |
| 43 | 43 |
| 44 // The number of buffers that VideoCaptureBufferPool should allocate. | |
| 45 const int kNoOfBuffers = 3; | |
| 46 | |
| 47 class PoolBuffer : public media::VideoCaptureDevice::Client::Buffer { | 44 class PoolBuffer : public media::VideoCaptureDevice::Client::Buffer { |
| 48 public: | 45 public: |
| 49 PoolBuffer(const scoped_refptr<VideoCaptureBufferPool>& pool, | 46 PoolBuffer(const scoped_refptr<VideoCaptureBufferPool>& pool, |
| 50 int buffer_id, | 47 int buffer_id, |
| 51 void* data, | 48 void* data, |
| 52 size_t size) | 49 size_t size) |
| 53 : Buffer(buffer_id, data, size), pool_(pool) { | 50 : Buffer(buffer_id, data, size), pool_(pool) { |
| 54 DCHECK(pool_); | 51 DCHECK(pool_); |
| 55 } | 52 } |
| 56 | 53 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 | 175 |
| 179 // The controller to which we post events. | 176 // The controller to which we post events. |
| 180 const base::WeakPtr<VideoCaptureController> controller_; | 177 const base::WeakPtr<VideoCaptureController> controller_; |
| 181 | 178 |
| 182 // The pool of shared-memory buffers used for capturing. | 179 // The pool of shared-memory buffers used for capturing. |
| 183 const scoped_refptr<VideoCaptureBufferPool> buffer_pool_; | 180 const scoped_refptr<VideoCaptureBufferPool> buffer_pool_; |
| 184 | 181 |
| 185 bool first_frame_; | 182 bool first_frame_; |
| 186 }; | 183 }; |
| 187 | 184 |
| 188 VideoCaptureController::VideoCaptureController() | 185 VideoCaptureController::VideoCaptureController(int max_buffers) |
| 189 : buffer_pool_(new VideoCaptureBufferPool(kNoOfBuffers)), | 186 : buffer_pool_(new VideoCaptureBufferPool(max_buffers)), |
| 190 state_(VIDEO_CAPTURE_STATE_STARTED), | 187 state_(VIDEO_CAPTURE_STATE_STARTED), |
| 191 weak_ptr_factory_(this) { | 188 weak_ptr_factory_(this) { |
| 192 } | 189 } |
| 193 | 190 |
| 194 VideoCaptureController::VideoCaptureDeviceClient::VideoCaptureDeviceClient( | 191 VideoCaptureController::VideoCaptureDeviceClient::VideoCaptureDeviceClient( |
| 195 const base::WeakPtr<VideoCaptureController>& controller, | 192 const base::WeakPtr<VideoCaptureController>& controller, |
| 196 const scoped_refptr<VideoCaptureBufferPool>& buffer_pool) | 193 const scoped_refptr<VideoCaptureBufferPool>& buffer_pool) |
| 197 : controller_(controller), buffer_pool_(buffer_pool), first_frame_(true) {} | 194 : controller_(controller), buffer_pool_(buffer_pool), first_frame_(true) {} |
| 198 | 195 |
| 199 VideoCaptureController::VideoCaptureDeviceClient::~VideoCaptureDeviceClient() {} | 196 VideoCaptureController::VideoCaptureDeviceClient::~VideoCaptureDeviceClient() {} |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 } | 676 } |
| 680 return NULL; | 677 return NULL; |
| 681 } | 678 } |
| 682 | 679 |
| 683 int VideoCaptureController::GetClientCount() { | 680 int VideoCaptureController::GetClientCount() { |
| 684 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 681 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 685 return controller_clients_.size(); | 682 return controller_clients_.size(); |
| 686 } | 683 } |
| 687 | 684 |
| 688 } // namespace content | 685 } // namespace content |
| OLD | NEW |