Chromium Code Reviews| 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 class AutoReleaseBuffer : public media::VideoCaptureDevice::Client::Buffer { | 114 class AutoReleaseBuffer : public media::VideoCaptureDevice::Client::Buffer { |
| 115 public: | 115 public: |
| 116 AutoReleaseBuffer(const scoped_refptr<VideoCaptureBufferPool>& pool, | 116 AutoReleaseBuffer(const scoped_refptr<VideoCaptureBufferPool>& pool, |
| 117 int buffer_id) | 117 int buffer_id) |
| 118 : id_(buffer_id), | 118 : id_(buffer_id), |
| 119 pool_(pool), | 119 pool_(pool), |
| 120 buffer_handle_(pool_->GetBufferHandle(buffer_id).Pass()) { | 120 buffer_handle_(pool_->GetBufferHandle(buffer_id).Pass()) { |
| 121 DCHECK(pool_.get()); | 121 DCHECK(pool_.get()); |
| 122 } | 122 } |
| 123 int id() const override { return id_; } | 123 int id() const override { return id_; } |
| 124 size_t size() const override { return buffer_handle_->size(); } | 124 gfx::Size dimensions() const override { return buffer_handle_->dimensions(); } |
| 125 size_t mapped_size() const override { return buffer_handle_->mapped_size(); } | |
| 125 void* data(int plane) override { return buffer_handle_->data(plane); } | 126 void* data(int plane) override { return buffer_handle_->data(plane); } |
| 126 ClientBuffer AsClientBuffer(int plane) override { | 127 ClientBuffer AsClientBuffer(int plane) override { |
| 127 return buffer_handle_->AsClientBuffer(plane); | 128 return buffer_handle_->AsClientBuffer(plane); |
| 128 } | 129 } |
| 129 #if defined(OS_POSIX) | 130 #if defined(OS_POSIX) |
| 130 base::FileDescriptor AsPlatformFile() override { | 131 base::FileDescriptor AsPlatformFile() override { |
| 131 return buffer_handle_->AsPlatformFile(); | 132 return buffer_handle_->AsPlatformFile(); |
| 132 } | 133 } |
| 133 #endif | 134 #endif |
| 134 | 135 |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 347 break; | 348 break; |
| 348 case media::VIDEO_CAPTURE_PIXEL_FORMAT_MJPEG: | 349 case media::VIDEO_CAPTURE_PIXEL_FORMAT_MJPEG: |
| 349 origin_colorspace = libyuv::FOURCC_MJPG; | 350 origin_colorspace = libyuv::FOURCC_MJPG; |
| 350 break; | 351 break; |
| 351 default: | 352 default: |
| 352 NOTREACHED(); | 353 NOTREACHED(); |
| 353 } | 354 } |
| 354 | 355 |
| 355 // The input |length| can be greater than the required buffer size because of | 356 // The input |length| can be greater than the required buffer size because of |
| 356 // paddings and/or alignments, but it cannot be smaller. | 357 // paddings and/or alignments, but it cannot be smaller. |
| 357 DCHECK_GE(static_cast<size_t>(length), frame_format.ImageAllocationSize()); | 358 // DCHECK_GE(static_cast<size_t>(length), frame_format.ImageAllocationSize()); |
|
reveman
2015/08/26 11:54:04
why comment this out?
emircan
2015/08/26 21:23:11
My bad, leftover from crbug.com/520740.
| |
| 358 | 359 |
| 359 if (external_jpeg_decoder_) { | 360 if (external_jpeg_decoder_) { |
| 360 const VideoCaptureGpuJpegDecoder::STATUS status = | 361 const VideoCaptureGpuJpegDecoder::STATUS status = |
| 361 external_jpeg_decoder_->GetStatus(); | 362 external_jpeg_decoder_->GetStatus(); |
| 362 if (status == VideoCaptureGpuJpegDecoder::FAILED) { | 363 if (status == VideoCaptureGpuJpegDecoder::FAILED) { |
| 363 external_jpeg_decoder_.reset(); | 364 external_jpeg_decoder_.reset(); |
| 364 } else if (status == VideoCaptureGpuJpegDecoder::INIT_PASSED && | 365 } else if (status == VideoCaptureGpuJpegDecoder::INIT_PASSED && |
| 365 frame_format.pixel_format == media::VIDEO_CAPTURE_PIXEL_FORMAT_MJPEG && | 366 frame_format.pixel_format == media::VIDEO_CAPTURE_PIXEL_FORMAT_MJPEG && |
| 366 rotation == 0 && !flip) { | 367 rotation == 0 && !flip) { |
| 367 external_jpeg_decoder_->DecodeCapturedData(data, length, frame_format, | 368 external_jpeg_decoder_->DecodeCapturedData(data, length, frame_format, |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 767 void VideoCaptureDeviceClient::TextureWrapHelper::OnError( | 768 void VideoCaptureDeviceClient::TextureWrapHelper::OnError( |
| 768 const std::string& message) { | 769 const std::string& message) { |
| 769 DCHECK(capture_task_runner_->BelongsToCurrentThread()); | 770 DCHECK(capture_task_runner_->BelongsToCurrentThread()); |
| 770 DLOG(ERROR) << message; | 771 DLOG(ERROR) << message; |
| 771 BrowserThread::PostTask( | 772 BrowserThread::PostTask( |
| 772 BrowserThread::IO, FROM_HERE, | 773 BrowserThread::IO, FROM_HERE, |
| 773 base::Bind(&VideoCaptureController::DoErrorOnIOThread, controller_)); | 774 base::Bind(&VideoCaptureController::DoErrorOnIOThread, controller_)); |
| 774 } | 775 } |
| 775 | 776 |
| 776 } // namespace content | 777 } // namespace content |
| OLD | NEW |