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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
352 handles[media::VideoFrame::kYPlane], | 352 handles[media::VideoFrame::kYPlane], |
353 handles[media::VideoFrame::kUPlane], | 353 handles[media::VideoFrame::kUPlane], |
354 handles[media::VideoFrame::kVPlane], | 354 handles[media::VideoFrame::kVPlane], |
355 timestamp - first_frame_timestamp_); | 355 timestamp - first_frame_timestamp_); |
356 DCHECK(frame); | 356 DCHECK(frame); |
357 buffer_finished_callback = media::BindToCurrentLoop( | 357 buffer_finished_callback = media::BindToCurrentLoop( |
358 base::Bind(&VideoCaptureImpl::OnClientBufferFinished2, | 358 base::Bind(&VideoCaptureImpl::OnClientBufferFinished2, |
359 weak_factory_.GetWeakPtr(), buffer_id, buffer)); | 359 weak_factory_.GetWeakPtr(), buffer_id, buffer)); |
360 } else { | 360 } else { |
361 scoped_refptr<ClientBuffer> buffer; | 361 scoped_refptr<ClientBuffer> buffer; |
362 if (storage_type == media::VideoFrame::STORAGE_UNOWNED_MEMORY) { | 362 if (storage_type == media::VideoFrame::STORAGE_OPAQUE) { |
363 DCHECK(mailbox_holder.mailbox.Verify()); | |
364 DCHECK_EQ(media::PIXEL_FORMAT_ARGB, pixel_format); | |
365 frame = media::VideoFrame::WrapNativeTexture( | |
366 pixel_format, | |
367 mailbox_holder, | |
368 base::Bind(&SaveReleaseSyncToken, release_sync_token.get()), | |
369 coded_size, | |
370 gfx::Rect(coded_size), | |
371 coded_size, | |
372 timestamp - first_frame_timestamp_); | |
373 } | |
374 else { | |
375 DCHECK(storage_type == media::VideoFrame::STORAGE_UNOWNED_MEMORY || | |
376 storage_type == media::VideoFrame::STORAGE_SHMEM); | |
363 DCHECK_EQ(media::PIXEL_FORMAT_I420, pixel_format); | 377 DCHECK_EQ(media::PIXEL_FORMAT_I420, pixel_format); |
364 const auto& iter = client_buffers_.find(buffer_id); | 378 const auto& iter = client_buffers_.find(buffer_id); |
365 DCHECK(iter != client_buffers_.end()); | 379 DCHECK(iter != client_buffers_.end()); |
366 buffer = iter->second; | 380 buffer = iter->second; |
367 frame = media::VideoFrame::WrapExternalSharedMemory( | 381 frame = media::VideoFrame::WrapExternalSharedMemory( |
368 pixel_format, | 382 pixel_format, |
369 coded_size, | 383 coded_size, |
370 visible_rect, | 384 visible_rect, |
371 gfx::Size(visible_rect.width(), | 385 gfx::Size(visible_rect.width(), |
372 visible_rect.height()), | 386 visible_rect.height()), |
373 reinterpret_cast<uint8*>(buffer->buffer()->memory()), | 387 reinterpret_cast<uint8*>(buffer->buffer()->memory()), |
374 buffer->buffer_size(), | 388 buffer->buffer_size(), |
375 buffer->buffer()->handle(), | 389 buffer->buffer()->handle(), |
376 0 /* shared_memory_offset */, | 390 0 /* shared_memory_offset */, |
377 timestamp - first_frame_timestamp_); | 391 timestamp - first_frame_timestamp_); |
378 } else { | |
379 DCHECK_EQ(storage_type, media::VideoFrame::STORAGE_OPAQUE); | |
380 DCHECK(mailbox_holder.mailbox.Verify()); | |
381 DCHECK_EQ(media::PIXEL_FORMAT_ARGB, pixel_format); | |
382 frame = media::VideoFrame::WrapNativeTexture( | |
383 pixel_format, mailbox_holder, | |
384 base::Bind(&SaveReleaseSyncToken, release_sync_token.get()), | |
385 coded_size, gfx::Rect(coded_size), coded_size, | |
386 timestamp - first_frame_timestamp_); | |
387 } | 392 } |
393 DCHECK(frame); | |
Pawel Osciak
2015/11/05 23:49:26
nullptr is a valid return value from Wrap*() metho
| |
388 buffer_finished_callback = media::BindToCurrentLoop( | 394 buffer_finished_callback = media::BindToCurrentLoop( |
389 base::Bind(&VideoCaptureImpl::OnClientBufferFinished, | 395 base::Bind(&VideoCaptureImpl::OnClientBufferFinished, |
390 weak_factory_.GetWeakPtr(), buffer_id, buffer)); | 396 weak_factory_.GetWeakPtr(), buffer_id, buffer)); |
391 } | 397 } |
392 frame->metadata()->SetTimeTicks(media::VideoFrameMetadata::REFERENCE_TIME, | 398 frame->metadata()->SetTimeTicks(media::VideoFrameMetadata::REFERENCE_TIME, |
393 timestamp); | 399 timestamp); |
394 frame->AddDestructionObserver( | 400 frame->AddDestructionObserver( |
395 base::Bind(&VideoCaptureImpl::DidFinishConsumingFrame, frame->metadata(), | 401 base::Bind(&VideoCaptureImpl::DidFinishConsumingFrame, frame->metadata(), |
396 base::Passed(&release_sync_token), buffer_finished_callback)); | 402 base::Passed(&release_sync_token), buffer_finished_callback)); |
397 | 403 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
560 double consumer_resource_utilization = -1.0; | 566 double consumer_resource_utilization = -1.0; |
561 if (!metadata->GetDouble(media::VideoFrameMetadata::RESOURCE_UTILIZATION, | 567 if (!metadata->GetDouble(media::VideoFrameMetadata::RESOURCE_UTILIZATION, |
562 &consumer_resource_utilization)) { | 568 &consumer_resource_utilization)) { |
563 consumer_resource_utilization = -1.0; | 569 consumer_resource_utilization = -1.0; |
564 } | 570 } |
565 | 571 |
566 callback_to_io_thread.Run(*release_sync_token, consumer_resource_utilization); | 572 callback_to_io_thread.Run(*release_sync_token, consumer_resource_utilization); |
567 } | 573 } |
568 | 574 |
569 } // namespace content | 575 } // namespace content |
OLD | NEW |