| 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 30 matching lines...) Expand all Loading... |
| 41 name, \ | 41 name, \ |
| 42 (height) ? ((width) * 100) / (height) : kInfiniteRatio); | 42 (height) ? ((width) * 100) / (height) : kInfiniteRatio); |
| 43 | 43 |
| 44 class PoolBuffer : public media::VideoCaptureDevice::Client::Buffer { | 44 class PoolBuffer : public media::VideoCaptureDevice::Client::Buffer { |
| 45 public: | 45 public: |
| 46 PoolBuffer(const scoped_refptr<VideoCaptureBufferPool>& pool, | 46 PoolBuffer(const scoped_refptr<VideoCaptureBufferPool>& pool, |
| 47 int buffer_id, | 47 int buffer_id, |
| 48 void* data, | 48 void* data, |
| 49 size_t size) | 49 size_t size) |
| 50 : Buffer(buffer_id, data, size), pool_(pool) { | 50 : Buffer(buffer_id, data, size), pool_(pool) { |
| 51 DCHECK(pool_); | 51 DCHECK(pool_.get()); |
| 52 } | 52 } |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 virtual ~PoolBuffer() { pool_->RelinquishProducerReservation(id()); } | 55 virtual ~PoolBuffer() { pool_->RelinquishProducerReservation(id()); } |
| 56 | 56 |
| 57 const scoped_refptr<VideoCaptureBufferPool> pool_; | 57 const scoped_refptr<VideoCaptureBufferPool> pool_; |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 class SyncPointClientImpl : public media::VideoFrame::SyncPointClient { | 60 class SyncPointClientImpl : public media::VideoFrame::SyncPointClient { |
| 61 public: | 61 public: |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 if (!media::VideoFrame::IsValidConfig(media::VideoFrame::I420, | 358 if (!media::VideoFrame::IsValidConfig(media::VideoFrame::I420, |
| 359 dimensions, | 359 dimensions, |
| 360 gfx::Rect(dimensions), | 360 gfx::Rect(dimensions), |
| 361 dimensions)) { | 361 dimensions)) { |
| 362 return; | 362 return; |
| 363 } | 363 } |
| 364 | 364 |
| 365 scoped_refptr<Buffer> buffer = | 365 scoped_refptr<Buffer> buffer = |
| 366 DoReserveOutputBuffer(media::VideoFrame::I420, dimensions); | 366 DoReserveOutputBuffer(media::VideoFrame::I420, dimensions); |
| 367 | 367 |
| 368 if (!buffer) | 368 if (!buffer.get()) |
| 369 return; | 369 return; |
| 370 uint8* yplane = NULL; | 370 uint8* yplane = NULL; |
| 371 bool flip = false; | 371 bool flip = false; |
| 372 yplane = reinterpret_cast<uint8*>(buffer->data()); | 372 yplane = reinterpret_cast<uint8*>(buffer->data()); |
| 373 uint8* uplane = | 373 uint8* uplane = |
| 374 yplane + | 374 yplane + |
| 375 media::VideoFrame::PlaneAllocationSize( | 375 media::VideoFrame::PlaneAllocationSize( |
| 376 media::VideoFrame::I420, media::VideoFrame::kYPlane, dimensions); | 376 media::VideoFrame::I420, media::VideoFrame::kYPlane, dimensions); |
| 377 uint8* vplane = | 377 uint8* vplane = |
| 378 uplane + | 378 uplane + |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 media::VideoFrame::I420, | 457 media::VideoFrame::I420, |
| 458 dimensions, | 458 dimensions, |
| 459 gfx::Rect(dimensions), | 459 gfx::Rect(dimensions), |
| 460 dimensions, | 460 dimensions, |
| 461 yplane, | 461 yplane, |
| 462 media::VideoFrame::AllocationSize(media::VideoFrame::I420, | 462 media::VideoFrame::AllocationSize(media::VideoFrame::I420, |
| 463 dimensions), | 463 dimensions), |
| 464 base::SharedMemory::NULLHandle(), | 464 base::SharedMemory::NULLHandle(), |
| 465 base::TimeDelta(), | 465 base::TimeDelta(), |
| 466 base::Closure()); | 466 base::Closure()); |
| 467 DCHECK(frame); | 467 DCHECK(frame.get()); |
| 468 | 468 |
| 469 VideoCaptureFormat format( | 469 VideoCaptureFormat format( |
| 470 dimensions, frame_format.frame_rate, media::PIXEL_FORMAT_I420); | 470 dimensions, frame_format.frame_rate, media::PIXEL_FORMAT_I420); |
| 471 BrowserThread::PostTask( | 471 BrowserThread::PostTask( |
| 472 BrowserThread::IO, | 472 BrowserThread::IO, |
| 473 FROM_HERE, | 473 FROM_HERE, |
| 474 base::Bind( | 474 base::Bind( |
| 475 &VideoCaptureController::DoIncomingCapturedVideoFrameOnIOThread, | 475 &VideoCaptureController::DoIncomingCapturedVideoFrameOnIOThread, |
| 476 controller_, | 476 controller_, |
| 477 buffer, | 477 buffer, |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 } | 676 } |
| 677 return NULL; | 677 return NULL; |
| 678 } | 678 } |
| 679 | 679 |
| 680 int VideoCaptureController::GetClientCount() { | 680 int VideoCaptureController::GetClientCount() { |
| 681 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 681 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 682 return controller_clients_.size(); | 682 return controller_clients_.size(); |
| 683 } | 683 } |
| 684 | 684 |
| 685 } // namespace content | 685 } // namespace content |
| OLD | NEW |