| 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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 .insert(std::make_pair(buffer_id, | 251 .insert(std::make_pair(buffer_id, |
| 252 new ClientBuffer(std::move(shm), memory_size))) | 252 new ClientBuffer(std::move(shm), memory_size))) |
| 253 .second; | 253 .second; |
| 254 DCHECK(inserted); | 254 DCHECK(inserted); |
| 255 } | 255 } |
| 256 | 256 |
| 257 void VideoCaptureImpl::OnBufferReady(int32_t buffer_id, | 257 void VideoCaptureImpl::OnBufferReady(int32_t buffer_id, |
| 258 mojom::VideoFrameInfoPtr info) { | 258 mojom::VideoFrameInfoPtr info) { |
| 259 DVLOG(1) << __func__ << " buffer_id: " << buffer_id; | 259 DVLOG(1) << __func__ << " buffer_id: " << buffer_id; |
| 260 DCHECK(io_thread_checker_.CalledOnValidThread()); | 260 DCHECK(io_thread_checker_.CalledOnValidThread()); |
| 261 DCHECK_EQ(media::PIXEL_FORMAT_I420, info->pixel_format); | |
| 262 DCHECK_EQ(media::PIXEL_STORAGE_CPU, info->storage_type); | |
| 263 | 261 |
| 264 if (state_ != VIDEO_CAPTURE_STATE_STARTED || | 262 bool consume_buffer = state_ == VIDEO_CAPTURE_STATE_STARTED; |
| 265 info->pixel_format != media::PIXEL_FORMAT_I420 || | 263 if ((info->pixel_format != media::PIXEL_FORMAT_I420 && |
| 264 info->pixel_format != media::PIXEL_FORMAT_Y16) || |
| 266 info->storage_type != media::PIXEL_STORAGE_CPU) { | 265 info->storage_type != media::PIXEL_STORAGE_CPU) { |
| 266 consume_buffer = false; |
| 267 LOG(DFATAL) << "Wrong pixel format or storage, got pixel format:" |
| 268 << VideoPixelFormatToString(info->pixel_format) |
| 269 << ", storage:" << info->storage_type; |
| 270 } |
| 271 if (!consume_buffer) { |
| 267 GetVideoCaptureHost()->ReleaseBuffer(device_id_, buffer_id, | 272 GetVideoCaptureHost()->ReleaseBuffer(device_id_, buffer_id, |
| 268 gpu::SyncToken(), -1.0); | 273 gpu::SyncToken(), -1.0); |
| 269 return; | 274 return; |
| 270 } | 275 } |
| 271 | 276 |
| 272 base::TimeTicks reference_time; | 277 base::TimeTicks reference_time; |
| 273 media::VideoFrameMetadata frame_metadata; | 278 media::VideoFrameMetadata frame_metadata; |
| 274 frame_metadata.MergeInternalValuesFrom(info->metadata); | 279 frame_metadata.MergeInternalValuesFrom(info->metadata); |
| 275 const bool success = frame_metadata.GetTimeTicks( | 280 const bool success = frame_metadata.GetTimeTicks( |
| 276 media::VideoFrameMetadata::REFERENCE_TIME, &reference_time); | 281 media::VideoFrameMetadata::REFERENCE_TIME, &reference_time); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 double consumer_resource_utilization = -1.0; | 435 double consumer_resource_utilization = -1.0; |
| 431 if (!metadata->GetDouble(media::VideoFrameMetadata::RESOURCE_UTILIZATION, | 436 if (!metadata->GetDouble(media::VideoFrameMetadata::RESOURCE_UTILIZATION, |
| 432 &consumer_resource_utilization)) { | 437 &consumer_resource_utilization)) { |
| 433 consumer_resource_utilization = -1.0; | 438 consumer_resource_utilization = -1.0; |
| 434 } | 439 } |
| 435 | 440 |
| 436 callback_to_io_thread.Run(*release_sync_token, consumer_resource_utilization); | 441 callback_to_io_thread.Run(*release_sync_token, consumer_resource_utilization); |
| 437 } | 442 } |
| 438 | 443 |
| 439 } // namespace content | 444 } // namespace content |
| OLD | NEW |