| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_client.h" | 5 #include "content/browser/renderer_host/media/video_capture_device_client.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 10 #include "content/browser/compositor/image_transport_factory.h" | 10 #include "content/browser/compositor/image_transport_factory.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 pool_(pool), | 113 pool_(pool), |
| 114 buffer_handle_(pool_->GetBufferHandle(buffer_id).Pass()) { | 114 buffer_handle_(pool_->GetBufferHandle(buffer_id).Pass()) { |
| 115 DCHECK(pool_.get()); | 115 DCHECK(pool_.get()); |
| 116 } | 116 } |
| 117 int id() const override { return id_; } | 117 int id() const override { return id_; } |
| 118 size_t size() const override { return buffer_handle_->size(); } | 118 size_t size() const override { return buffer_handle_->size(); } |
| 119 void* data() override { return buffer_handle_->data(); } | 119 void* data() override { return buffer_handle_->data(); } |
| 120 gfx::GpuMemoryBufferType GetType() override { | 120 gfx::GpuMemoryBufferType GetType() override { |
| 121 return buffer_handle_->GetType(); | 121 return buffer_handle_->GetType(); |
| 122 } | 122 } |
| 123 base::PlatformFile AsPlatformFile() const override { |
| 124 return base::PlatformFile(); |
| 125 } |
| 123 ClientBuffer AsClientBuffer() override { | 126 ClientBuffer AsClientBuffer() override { |
| 124 return buffer_handle_->AsClientBuffer(); | 127 return buffer_handle_->AsClientBuffer(); |
| 125 } | 128 } |
| 126 | 129 |
| 127 private: | 130 private: |
| 128 ~AutoReleaseBuffer() override { pool_->RelinquishProducerReservation(id_); } | 131 ~AutoReleaseBuffer() override { pool_->RelinquishProducerReservation(id_); } |
| 129 | 132 |
| 130 const int id_; | 133 const int id_; |
| 131 const scoped_refptr<VideoCaptureBufferPool> pool_; | 134 const scoped_refptr<VideoCaptureBufferPool> pool_; |
| 132 const scoped_ptr<VideoCaptureBufferPool::BufferHandle> buffer_handle_; | 135 const scoped_ptr<VideoCaptureBufferPool::BufferHandle> buffer_handle_; |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 } | 414 } |
| 412 | 415 |
| 413 OnIncomingCapturedBuffer(buffer.Pass(), frame_format, timestamp); | 416 OnIncomingCapturedBuffer(buffer.Pass(), frame_format, timestamp); |
| 414 }; | 417 }; |
| 415 | 418 |
| 416 scoped_ptr<media::VideoCaptureDevice::Client::Buffer> | 419 scoped_ptr<media::VideoCaptureDevice::Client::Buffer> |
| 417 VideoCaptureDeviceClient::ReserveOutputBuffer(media::VideoPixelFormat format, | 420 VideoCaptureDeviceClient::ReserveOutputBuffer(media::VideoPixelFormat format, |
| 418 const gfx::Size& dimensions) { | 421 const gfx::Size& dimensions) { |
| 419 DCHECK(format == media::PIXEL_FORMAT_I420 || | 422 DCHECK(format == media::PIXEL_FORMAT_I420 || |
| 420 format == media::PIXEL_FORMAT_TEXTURE || | 423 format == media::PIXEL_FORMAT_TEXTURE || |
| 421 format == media::PIXEL_FORMAT_GPUMEMORYBUFFER); | 424 format == media::PIXEL_FORMAT_GPUMEMORYBUFFER) |
| 425 << "format " << media::VideoCaptureFormat::PixelFormatToString(format); |
| 422 DCHECK_GT(dimensions.width(), 0); | 426 DCHECK_GT(dimensions.width(), 0); |
| 423 DCHECK_GT(dimensions.height(), 0); | 427 DCHECK_GT(dimensions.height(), 0); |
| 424 | 428 |
| 425 if (format == media::PIXEL_FORMAT_GPUMEMORYBUFFER && !texture_wrap_helper_) { | 429 if (format == media::PIXEL_FORMAT_GPUMEMORYBUFFER && !texture_wrap_helper_) { |
| 426 texture_wrap_helper_ = | 430 texture_wrap_helper_ = |
| 427 new TextureWrapHelper(controller_, capture_task_runner_); | 431 new TextureWrapHelper(controller_, capture_task_runner_); |
| 428 } | 432 } |
| 429 | 433 |
| 430 int buffer_id_to_drop = VideoCaptureBufferPool::kInvalidId; | 434 int buffer_id_to_drop = VideoCaptureBufferPool::kInvalidId; |
| 431 const int buffer_id = | 435 const int buffer_id = |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 void VideoCaptureDeviceClient::TextureWrapHelper::OnError( | 666 void VideoCaptureDeviceClient::TextureWrapHelper::OnError( |
| 663 const std::string& message) { | 667 const std::string& message) { |
| 664 DCHECK(capture_task_runner_->BelongsToCurrentThread()); | 668 DCHECK(capture_task_runner_->BelongsToCurrentThread()); |
| 665 DLOG(ERROR) << message; | 669 DLOG(ERROR) << message; |
| 666 BrowserThread::PostTask( | 670 BrowserThread::PostTask( |
| 667 BrowserThread::IO, FROM_HERE, | 671 BrowserThread::IO, FROM_HERE, |
| 668 base::Bind(&VideoCaptureController::DoErrorOnIOThread, controller_)); | 672 base::Bind(&VideoCaptureController::DoErrorOnIOThread, controller_)); |
| 669 } | 673 } |
| 670 | 674 |
| 671 } // namespace content | 675 } // namespace content |
| OLD | NEW |