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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 << ", storage:" << info->storage_type; | 269 << ", storage:" << info->storage_type; |
270 } | 270 } |
271 if (!consume_buffer) { | 271 if (!consume_buffer) { |
272 GetVideoCaptureHost()->ReleaseBuffer(device_id_, buffer_id, | 272 GetVideoCaptureHost()->ReleaseBuffer(device_id_, buffer_id, |
273 gpu::SyncToken(), -1.0); | 273 gpu::SyncToken(), -1.0); |
274 return; | 274 return; |
275 } | 275 } |
276 | 276 |
277 base::TimeTicks reference_time; | 277 base::TimeTicks reference_time; |
278 media::VideoFrameMetadata frame_metadata; | 278 media::VideoFrameMetadata frame_metadata; |
279 frame_metadata.MergeInternalValuesFrom(info->metadata); | 279 frame_metadata.MergeInternalValuesFrom(*info->metadata); |
280 const bool success = frame_metadata.GetTimeTicks( | 280 const bool success = frame_metadata.GetTimeTicks( |
281 media::VideoFrameMetadata::REFERENCE_TIME, &reference_time); | 281 media::VideoFrameMetadata::REFERENCE_TIME, &reference_time); |
282 DCHECK(success); | 282 DCHECK(success); |
283 | 283 |
284 if (first_frame_ref_time_.is_null()) | 284 if (first_frame_ref_time_.is_null()) |
285 first_frame_ref_time_ = reference_time; | 285 first_frame_ref_time_ = reference_time; |
286 | 286 |
287 // If the timestamp is not prepared, we use reference time to make a rough | 287 // If the timestamp is not prepared, we use reference time to make a rough |
288 // estimate. e.g. ThreadSafeCaptureOracle::DidCaptureFrame(). | 288 // estimate. e.g. ThreadSafeCaptureOracle::DidCaptureFrame(). |
289 // TODO(miu): Fix upstream capturers to always set timestamp and reference | 289 // TODO(miu): Fix upstream capturers to always set timestamp and reference |
(...skipping 26 matching lines...) Expand all Loading... |
316 } | 316 } |
317 | 317 |
318 BufferFinishedCallback buffer_finished_callback = media::BindToCurrentLoop( | 318 BufferFinishedCallback buffer_finished_callback = media::BindToCurrentLoop( |
319 base::Bind(&VideoCaptureImpl::OnClientBufferFinished, | 319 base::Bind(&VideoCaptureImpl::OnClientBufferFinished, |
320 weak_factory_.GetWeakPtr(), buffer_id, buffer)); | 320 weak_factory_.GetWeakPtr(), buffer_id, buffer)); |
321 std::unique_ptr<gpu::SyncToken> release_sync_token(new gpu::SyncToken); | 321 std::unique_ptr<gpu::SyncToken> release_sync_token(new gpu::SyncToken); |
322 frame->AddDestructionObserver( | 322 frame->AddDestructionObserver( |
323 base::Bind(&VideoCaptureImpl::DidFinishConsumingFrame, frame->metadata(), | 323 base::Bind(&VideoCaptureImpl::DidFinishConsumingFrame, frame->metadata(), |
324 base::Passed(&release_sync_token), buffer_finished_callback)); | 324 base::Passed(&release_sync_token), buffer_finished_callback)); |
325 | 325 |
326 frame->metadata()->MergeInternalValuesFrom(info->metadata); | 326 frame->metadata()->MergeInternalValuesFrom(*info->metadata); |
327 | 327 |
328 // TODO(qiangchen): Dive into the full code path to let frame metadata hold | 328 // TODO(qiangchen): Dive into the full code path to let frame metadata hold |
329 // reference time rather than using an extra parameter. | 329 // reference time rather than using an extra parameter. |
330 for (const auto& client : clients_) | 330 for (const auto& client : clients_) |
331 client.second.deliver_frame_cb.Run(frame, reference_time); | 331 client.second.deliver_frame_cb.Run(frame, reference_time); |
332 } | 332 } |
333 | 333 |
334 void VideoCaptureImpl::OnBufferDestroyed(int32_t buffer_id) { | 334 void VideoCaptureImpl::OnBufferDestroyed(int32_t buffer_id) { |
335 DCHECK(io_thread_checker_.CalledOnValidThread()); | 335 DCHECK(io_thread_checker_.CalledOnValidThread()); |
336 | 336 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 double consumer_resource_utilization = -1.0; | 435 double consumer_resource_utilization = -1.0; |
436 if (!metadata->GetDouble(media::VideoFrameMetadata::RESOURCE_UTILIZATION, | 436 if (!metadata->GetDouble(media::VideoFrameMetadata::RESOURCE_UTILIZATION, |
437 &consumer_resource_utilization)) { | 437 &consumer_resource_utilization)) { |
438 consumer_resource_utilization = -1.0; | 438 consumer_resource_utilization = -1.0; |
439 } | 439 } |
440 | 440 |
441 callback_to_io_thread.Run(*release_sync_token, consumer_resource_utilization); | 441 callback_to_io_thread.Run(*release_sync_token, consumer_resource_utilization); |
442 } | 442 } |
443 | 443 |
444 } // namespace content | 444 } // namespace content |
OLD | NEW |