Chromium Code Reviews| 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 22 matching lines...) Expand all Loading... | |
| 33 | 33 |
| 34 namespace { | 34 namespace { |
| 35 | 35 |
| 36 static const int kInfiniteRatio = 99999; | 36 static const int kInfiniteRatio = 99999; |
| 37 | 37 |
| 38 #define UMA_HISTOGRAM_ASPECT_RATIO(name, width, height) \ | 38 #define UMA_HISTOGRAM_ASPECT_RATIO(name, width, height) \ |
| 39 UMA_HISTOGRAM_SPARSE_SLOWLY( \ | 39 UMA_HISTOGRAM_SPARSE_SLOWLY( \ |
| 40 name, \ | 40 name, \ |
| 41 (height) ? ((width) * 100) / (height) : kInfiniteRatio); | 41 (height) ? ((width) * 100) / (height) : kInfiniteRatio); |
| 42 | 42 |
| 43 class PoolBuffer : public media::VideoCaptureDevice::Client::Buffer { | 43 // Class coalescing a Client::Buffer interface implementation and a pool buffer |
|
perkj_chrome
2015/02/20 08:42:13
Can you simplify the language in this comment a bi
mcasas
2015/02/20 15:59:06
Done.
| |
| 44 // implementation to guarantee proper cleanup on destruction on our side. | |
| 45 class AutoReleaseBuffer : public media::VideoCaptureDevice::Client::Buffer { | |
| 44 public: | 46 public: |
| 45 PoolBuffer(const scoped_refptr<VideoCaptureBufferPool>& pool, | 47 AutoReleaseBuffer(const scoped_refptr<VideoCaptureBufferPool>& pool, |
| 46 int buffer_id, | 48 int buffer_id, |
| 47 void* data, | 49 void* data, |
| 48 size_t size) | 50 size_t size) |
| 49 : Buffer(buffer_id, data, size), pool_(pool) { | 51 : pool_(pool), |
| 52 id_(buffer_id), | |
| 53 data_(data), | |
| 54 size_(size) { | |
| 50 DCHECK(pool_.get()); | 55 DCHECK(pool_.get()); |
| 51 } | 56 } |
| 57 int id() const override { return id_; } | |
| 58 void* data() const override { return data_; } | |
| 59 size_t size() const override { return size_; } | |
| 52 | 60 |
| 53 private: | 61 private: |
| 54 ~PoolBuffer() override { pool_->RelinquishProducerReservation(id()); } | 62 ~AutoReleaseBuffer() override { pool_->RelinquishProducerReservation(id_); } |
| 55 | 63 |
| 56 const scoped_refptr<VideoCaptureBufferPool> pool_; | 64 const scoped_refptr<VideoCaptureBufferPool> pool_; |
| 65 const int id_; | |
| 66 void* const data_; | |
| 67 const size_t size_; | |
| 57 }; | 68 }; |
| 58 | 69 |
| 59 class SyncPointClientImpl : public media::VideoFrame::SyncPointClient { | 70 class SyncPointClientImpl : public media::VideoFrame::SyncPointClient { |
| 60 public: | 71 public: |
| 61 explicit SyncPointClientImpl(GLHelper* gl_helper) : gl_helper_(gl_helper) {} | 72 explicit SyncPointClientImpl(GLHelper* gl_helper) : gl_helper_(gl_helper) {} |
| 62 ~SyncPointClientImpl() override {} | 73 ~SyncPointClientImpl() override {} |
| 63 uint32 InsertSyncPoint() override { return gl_helper_->InsertSyncPoint(); } | 74 uint32 InsertSyncPoint() override { return gl_helper_->InsertSyncPoint(); } |
| 64 void WaitSyncPoint(uint32 sync_point) override { | 75 void WaitSyncPoint(uint32 sync_point) override { |
| 65 gl_helper_->WaitSyncPoint(sync_point); | 76 gl_helper_->WaitSyncPoint(sync_point); |
| 66 } | 77 } |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 353 int buffer_id_to_drop = VideoCaptureBufferPool::kInvalidId; | 364 int buffer_id_to_drop = VideoCaptureBufferPool::kInvalidId; |
| 354 int buffer_id = | 365 int buffer_id = |
| 355 buffer_pool_->ReserveForProducer(frame_bytes, &buffer_id_to_drop); | 366 buffer_pool_->ReserveForProducer(frame_bytes, &buffer_id_to_drop); |
| 356 if (buffer_id == VideoCaptureBufferPool::kInvalidId) | 367 if (buffer_id == VideoCaptureBufferPool::kInvalidId) |
| 357 return NULL; | 368 return NULL; |
| 358 void* data; | 369 void* data; |
| 359 size_t size; | 370 size_t size; |
| 360 buffer_pool_->GetBufferInfo(buffer_id, &data, &size); | 371 buffer_pool_->GetBufferInfo(buffer_id, &data, &size); |
| 361 | 372 |
| 362 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> output_buffer( | 373 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> output_buffer( |
| 363 new PoolBuffer(buffer_pool_, buffer_id, data, size)); | 374 new AutoReleaseBuffer(buffer_pool_, buffer_id, data, size)); |
| 364 | 375 |
| 365 if (buffer_id_to_drop != VideoCaptureBufferPool::kInvalidId) { | 376 if (buffer_id_to_drop != VideoCaptureBufferPool::kInvalidId) { |
| 366 BrowserThread::PostTask(BrowserThread::IO, | 377 BrowserThread::PostTask(BrowserThread::IO, |
| 367 FROM_HERE, | 378 FROM_HERE, |
| 368 base::Bind(&VideoCaptureController::DoBufferDestroyedOnIOThread, | 379 base::Bind(&VideoCaptureController::DoBufferDestroyedOnIOThread, |
| 369 controller_, buffer_id_to_drop)); | 380 controller_, buffer_id_to_drop)); |
| 370 } | 381 } |
| 371 | 382 |
| 372 return output_buffer; | 383 return output_buffer; |
| 373 } | 384 } |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 717 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 728 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 718 int active_client_count = 0; | 729 int active_client_count = 0; |
| 719 for (ControllerClient* client : controller_clients_) { | 730 for (ControllerClient* client : controller_clients_) { |
| 720 if (!client->paused) | 731 if (!client->paused) |
| 721 ++active_client_count; | 732 ++active_client_count; |
| 722 } | 733 } |
| 723 return active_client_count; | 734 return active_client_count; |
| 724 } | 735 } |
| 725 | 736 |
| 726 } // namespace content | 737 } // namespace content |
| OLD | NEW |