| 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 // Notes about usage of this object by VideoCaptureImplManager. | 5 // Notes about usage of this object by VideoCaptureImplManager. |
| 6 // | 6 // |
| 7 // VideoCaptureImplManager access this object by using a Unretained() | 7 // VideoCaptureImplManager access this object by using a Unretained() |
| 8 // binding and tasks on the IO thread. It is then important that | 8 // binding and tasks on the IO thread. It is then important that |
| 9 // VideoCaptureImpl never post task to itself. All operations must be | 9 // VideoCaptureImpl never post task to itself. All operations must be |
| 10 // synchronous. | 10 // synchronous. |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 | 303 |
| 304 void VideoCaptureImpl::OnBufferReceived( | 304 void VideoCaptureImpl::OnBufferReceived( |
| 305 int buffer_id, | 305 int buffer_id, |
| 306 base::TimeDelta timestamp, | 306 base::TimeDelta timestamp, |
| 307 const base::DictionaryValue& metadata, | 307 const base::DictionaryValue& metadata, |
| 308 media::VideoPixelFormat pixel_format, | 308 media::VideoPixelFormat pixel_format, |
| 309 media::VideoFrame::StorageType storage_type, | 309 media::VideoFrame::StorageType storage_type, |
| 310 const gfx::Size& coded_size, | 310 const gfx::Size& coded_size, |
| 311 const gfx::Rect& visible_rect) { | 311 const gfx::Rect& visible_rect) { |
| 312 DCHECK(io_task_runner_->BelongsToCurrentThread()); | 312 DCHECK(io_task_runner_->BelongsToCurrentThread()); |
| 313 // TODO(astojilj) Check STORAGE_GPU_MEMORY_BUFFERS support for Y8/Y16. |
| 313 if (state_ != VIDEO_CAPTURE_STATE_STARTED || suspended_ || | 314 if (state_ != VIDEO_CAPTURE_STATE_STARTED || suspended_ || |
| 314 pixel_format != media::PIXEL_FORMAT_I420 || | 315 (pixel_format != media::PIXEL_FORMAT_I420 && |
| 316 ((pixel_format != media::PIXEL_FORMAT_Y8 && |
| 317 pixel_format != media::PIXEL_FORMAT_Y16) || |
| 318 storage_type != media::VideoFrame::STORAGE_SHMEM)) || |
| 315 (storage_type != media::VideoFrame::STORAGE_SHMEM && | 319 (storage_type != media::VideoFrame::STORAGE_SHMEM && |
| 316 storage_type != media::VideoFrame::STORAGE_GPU_MEMORY_BUFFERS)) { | 320 storage_type != media::VideoFrame::STORAGE_GPU_MEMORY_BUFFERS)) { |
| 317 // Crash in debug builds since the host should not have provided a buffer | 321 // Crash in debug builds since the host should not have provided a buffer |
| 318 // with an unsupported pixel format or storage type. | 322 // with an unsupported pixel format or storage type. |
| 319 DCHECK_EQ(media::PIXEL_FORMAT_I420, pixel_format); | 323 DCHECK(media::PIXEL_FORMAT_I420 == pixel_format || |
| 324 ((media::PIXEL_FORMAT_Y8 == pixel_format || |
| 325 media::PIXEL_FORMAT_Y16 == pixel_format) && |
| 326 storage_type == media::VideoFrame::STORAGE_SHMEM)); |
| 320 DCHECK(storage_type == media::VideoFrame::STORAGE_SHMEM || | 327 DCHECK(storage_type == media::VideoFrame::STORAGE_SHMEM || |
| 321 storage_type == media::VideoFrame::STORAGE_GPU_MEMORY_BUFFERS); | 328 storage_type == media::VideoFrame::STORAGE_GPU_MEMORY_BUFFERS); |
| 322 Send(new VideoCaptureHostMsg_BufferReady(device_id_, buffer_id, | 329 Send(new VideoCaptureHostMsg_BufferReady(device_id_, buffer_id, |
| 323 gpu::SyncToken(), -1.0)); | 330 gpu::SyncToken(), -1.0)); |
| 324 return; | 331 return; |
| 325 } | 332 } |
| 326 | 333 |
| 327 base::TimeTicks reference_time; | 334 base::TimeTicks reference_time; |
| 328 media::VideoFrameMetadata frame_metadata; | 335 media::VideoFrameMetadata frame_metadata; |
| 329 frame_metadata.MergeInternalValuesFrom(metadata); | 336 frame_metadata.MergeInternalValuesFrom(metadata); |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 double consumer_resource_utilization = -1.0; | 577 double consumer_resource_utilization = -1.0; |
| 571 if (!metadata->GetDouble(media::VideoFrameMetadata::RESOURCE_UTILIZATION, | 578 if (!metadata->GetDouble(media::VideoFrameMetadata::RESOURCE_UTILIZATION, |
| 572 &consumer_resource_utilization)) { | 579 &consumer_resource_utilization)) { |
| 573 consumer_resource_utilization = -1.0; | 580 consumer_resource_utilization = -1.0; |
| 574 } | 581 } |
| 575 | 582 |
| 576 callback_to_io_thread.Run(*release_sync_token, consumer_resource_utilization); | 583 callback_to_io_thread.Run(*release_sync_token, consumer_resource_utilization); |
| 577 } | 584 } |
| 578 | 585 |
| 579 } // namespace content | 586 } // namespace content |
| OLD | NEW |