| 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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 << VideoPixelFormatToString(info->pixel_format) | 277 << VideoPixelFormatToString(info->pixel_format) |
| 278 << ", storage:" << info->storage_type; | 278 << ", storage:" << info->storage_type; |
| 279 } | 279 } |
| 280 if (!consume_buffer) { | 280 if (!consume_buffer) { |
| 281 GetVideoCaptureHost()->ReleaseBuffer(device_id_, buffer_id, -1.0); | 281 GetVideoCaptureHost()->ReleaseBuffer(device_id_, buffer_id, -1.0); |
| 282 return; | 282 return; |
| 283 } | 283 } |
| 284 | 284 |
| 285 base::TimeTicks reference_time; | 285 base::TimeTicks reference_time; |
| 286 media::VideoFrameMetadata frame_metadata; | 286 media::VideoFrameMetadata frame_metadata; |
| 287 frame_metadata.MergeInternalValuesFrom(*info->metadata); | 287 frame_metadata.MergeInternalValuesFrom(info->metadata); |
| 288 const bool success = frame_metadata.GetTimeTicks( | 288 const bool success = frame_metadata.GetTimeTicks( |
| 289 media::VideoFrameMetadata::REFERENCE_TIME, &reference_time); | 289 media::VideoFrameMetadata::REFERENCE_TIME, &reference_time); |
| 290 DCHECK(success); | 290 DCHECK(success); |
| 291 | 291 |
| 292 if (first_frame_ref_time_.is_null()) | 292 if (first_frame_ref_time_.is_null()) |
| 293 first_frame_ref_time_ = reference_time; | 293 first_frame_ref_time_ = reference_time; |
| 294 | 294 |
| 295 // If the timestamp is not prepared, we use reference time to make a rough | 295 // If the timestamp is not prepared, we use reference time to make a rough |
| 296 // estimate. e.g. ThreadSafeCaptureOracle::DidCaptureFrame(). | 296 // estimate. e.g. ThreadSafeCaptureOracle::DidCaptureFrame(). |
| 297 // TODO(miu): Fix upstream capturers to always set timestamp and reference | 297 // TODO(miu): Fix upstream capturers to always set timestamp and reference |
| (...skipping 24 matching lines...) Expand all Loading... |
| 322 return; | 322 return; |
| 323 } | 323 } |
| 324 | 324 |
| 325 BufferFinishedCallback buffer_finished_callback = media::BindToCurrentLoop( | 325 BufferFinishedCallback buffer_finished_callback = media::BindToCurrentLoop( |
| 326 base::Bind(&VideoCaptureImpl::OnClientBufferFinished, | 326 base::Bind(&VideoCaptureImpl::OnClientBufferFinished, |
| 327 weak_factory_.GetWeakPtr(), buffer_id, buffer)); | 327 weak_factory_.GetWeakPtr(), buffer_id, buffer)); |
| 328 frame->AddDestructionObserver( | 328 frame->AddDestructionObserver( |
| 329 base::Bind(&VideoCaptureImpl::DidFinishConsumingFrame, frame->metadata(), | 329 base::Bind(&VideoCaptureImpl::DidFinishConsumingFrame, frame->metadata(), |
| 330 buffer_finished_callback)); | 330 buffer_finished_callback)); |
| 331 | 331 |
| 332 frame->metadata()->MergeInternalValuesFrom(*info->metadata); | 332 frame->metadata()->MergeInternalValuesFrom(info->metadata); |
| 333 | 333 |
| 334 // TODO(qiangchen): Dive into the full code path to let frame metadata hold | 334 // TODO(qiangchen): Dive into the full code path to let frame metadata hold |
| 335 // reference time rather than using an extra parameter. | 335 // reference time rather than using an extra parameter. |
| 336 for (const auto& client : clients_) | 336 for (const auto& client : clients_) |
| 337 client.second.deliver_frame_cb.Run(frame, reference_time); | 337 client.second.deliver_frame_cb.Run(frame, reference_time); |
| 338 } | 338 } |
| 339 | 339 |
| 340 void VideoCaptureImpl::OnBufferDestroyed(int32_t buffer_id) { | 340 void VideoCaptureImpl::OnBufferDestroyed(int32_t buffer_id) { |
| 341 DCHECK(io_thread_checker_.CalledOnValidThread()); | 341 DCHECK(io_thread_checker_.CalledOnValidThread()); |
| 342 | 342 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 // destructor. |metadata| is still valid for read-access at this point. | 439 // destructor. |metadata| is still valid for read-access at this point. |
| 440 double consumer_resource_utilization = -1.0; | 440 double consumer_resource_utilization = -1.0; |
| 441 if (!metadata->GetDouble(media::VideoFrameMetadata::RESOURCE_UTILIZATION, | 441 if (!metadata->GetDouble(media::VideoFrameMetadata::RESOURCE_UTILIZATION, |
| 442 &consumer_resource_utilization)) { | 442 &consumer_resource_utilization)) { |
| 443 consumer_resource_utilization = -1.0; | 443 consumer_resource_utilization = -1.0; |
| 444 } | 444 } |
| 445 callback_to_io_thread.Run(consumer_resource_utilization); | 445 callback_to_io_thread.Run(consumer_resource_utilization); |
| 446 } | 446 } |
| 447 | 447 |
| 448 } // namespace content | 448 } // namespace content |
| OLD | NEW |