Chromium Code Reviews| Index: content/browser/renderer_host/media/video_capture_buffer_pool.cc |
| diff --git a/content/browser/renderer_host/media/video_capture_buffer_pool.cc b/content/browser/renderer_host/media/video_capture_buffer_pool.cc |
| index 41f3f504f047b0b261b7a2ae3110e1b9d9541da9..8479022c42878f310e8d5668aaad7d4f79ccaffa 100644 |
| --- a/content/browser/renderer_host/media/video_capture_buffer_pool.cc |
| +++ b/content/browser/renderer_host/media/video_capture_buffer_pool.cc |
| @@ -25,8 +25,7 @@ VideoFrame::Format VideoPixelFormatToVideoFrameFormat( |
| VideoFrame::Format frame_format; |
| } const kVideoPixelFormatToVideoFrameFormat[] = { |
| {media::PIXEL_FORMAT_I420, VideoFrame::I420}, |
| - {media::PIXEL_FORMAT_TEXTURE, VideoFrame::ARGB}, |
| - {media::PIXEL_FORMAT_GPUMEMORYBUFFER, VideoFrame::ARGB}, |
| + {media::PIXEL_FORMAT_ARGB, VideoFrame::ARGB}, |
| }; |
| for (const auto& format_pair : kVideoPixelFormatToVideoFrameFormat) { |
| @@ -38,23 +37,27 @@ VideoFrame::Format VideoPixelFormatToVideoFrameFormat( |
| return VideoFrame::UNKNOWN; |
| } |
| -VideoFrame::StorageType VideoPixelFormatToVideoFrameStorageType( |
| - media::VideoPixelFormat pixel_format) { |
| +VideoFrame::StorageType VideoPixelStorageToVideoFrameStorageType( |
| + media::VideoPixelStorage pixel_storage) { |
| static struct { |
| - media::VideoPixelFormat pixel_format; |
| + media::VideoPixelStorage pixel_storage; |
| VideoFrame::StorageType storage_type; |
| - } const kVideoPixelFormatToVideoFrameStorageType[] = { |
| - {media::PIXEL_FORMAT_I420, VideoFrame::STORAGE_SHMEM}, |
| - {media::PIXEL_FORMAT_TEXTURE, VideoFrame::STORAGE_OPAQUE}, |
| - {media::PIXEL_FORMAT_GPUMEMORYBUFFER, VideoFrame::STORAGE_OPAQUE}, |
| + } const kVideoPixelStorageToVideoFrameStorageType[] = { |
| + {media::PIXEL_STORAGE_CPU, VideoFrame::STORAGE_SHMEM}, |
| + {media::PIXEL_STORAGE_TEXTURE, VideoFrame::STORAGE_OPAQUE}, |
| + {media::PIXEL_STORAGE_GPUMEMORYBUFFER, |
|
miu
2015/06/13 00:41:37
nit: Up to you, but this feels more readable:
#if
mcasas
2015/06/16 23:14:01
Yes. And this is actually for USE_OZONE build,
not
|
| +#if defined(OS_LINUX) |
| + VideoFrame::STORAGE_DMABUFS}, |
| +#else |
| + VideoFrame::STORAGE_SHMEM}, |
| +#endif |
| }; |
| - for (const auto& format_pair : kVideoPixelFormatToVideoFrameStorageType) { |
| - if (format_pair.pixel_format == pixel_format) |
| + for (const auto& format_pair : kVideoPixelStorageToVideoFrameStorageType) { |
| + if (format_pair.pixel_storage == pixel_storage) |
| return format_pair.storage_type; |
| } |
| - LOG(ERROR) << "Unsupported VideoPixelFormat " |
| - << media::VideoCaptureFormat::PixelFormatToString(pixel_format); |
| + LOG(ERROR) << "Unsupported VideoPixelStorage " << pixel_storage; |
| return VideoFrame::STORAGE_UNKNOWN; |
| } |
| @@ -283,10 +286,12 @@ VideoCaptureBufferPool::GetBufferHandle(int buffer_id) { |
| } |
| int VideoCaptureBufferPool::ReserveForProducer(media::VideoPixelFormat format, |
| + media::VideoPixelStorage storage, |
| const gfx::Size& dimensions, |
| int* buffer_id_to_drop) { |
| base::AutoLock lock(lock_); |
| - return ReserveForProducerInternal(format, dimensions, buffer_id_to_drop); |
| + return ReserveForProducerInternal(format, storage, dimensions, |
| + buffer_id_to_drop); |
| } |
| void VideoCaptureBufferPool::RelinquishProducerReservation(int buffer_id) { |
| @@ -334,11 +339,9 @@ void VideoCaptureBufferPool::RelinquishConsumerHold(int buffer_id, |
| int VideoCaptureBufferPool::ReserveForProducerInternal( |
| media::VideoPixelFormat format, |
| + media::VideoPixelStorage storage, |
| const gfx::Size& dimensions, |
| int* buffer_id_to_drop) { |
| - DCHECK(format == media::PIXEL_FORMAT_I420 || |
| - format == media::PIXEL_FORMAT_TEXTURE || |
| - format == media::PIXEL_FORMAT_GPUMEMORYBUFFER ); |
| lock_.AssertAcquired(); |
| *buffer_id_to_drop = kInvalidId; |
| @@ -346,7 +349,7 @@ int VideoCaptureBufferPool::ReserveForProducerInternal( |
| const media::VideoFrame::Format pixel_format = |
| VideoPixelFormatToVideoFrameFormat(format); |
| const media::VideoFrame::StorageType storage_type = |
| - VideoPixelFormatToVideoFrameStorageType(format); |
| + VideoPixelStorageToVideoFrameStorageType(storage); |
| // Look for a tracker that's allocated, big enough, and not in use. Track the |
| // largest one that's not big enough, in case we have to reallocate a tracker. |
| *buffer_id_to_drop = kInvalidId; |
| @@ -385,8 +388,9 @@ int VideoCaptureBufferPool::ReserveForProducerInternal( |
| // Create the new tracker. |
| const int buffer_id = next_buffer_id_++; |
| - scoped_ptr<Tracker> tracker = |
| - Tracker::CreateTracker(format == media::PIXEL_FORMAT_GPUMEMORYBUFFER); |
| + const bool use_simple_tracker = |
| + storage == media::PIXEL_STORAGE_GPUMEMORYBUFFER; |
| + scoped_ptr<Tracker> tracker = Tracker::CreateTracker(use_simple_tracker); |
| if (!tracker->Init(pixel_format, storage_type, dimensions)) { |
| DLOG(ERROR) << "Error initializing Tracker"; |
| return kInvalidId; |