Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/memory/shared_memory.h" | 6 #include "base/memory/shared_memory.h" |
| 7 #include "base/numerics/safe_math.h" | 7 #include "base/numerics/safe_math.h" |
| 8 #include "content/common/gpu/client/command_buffer_proxy_impl.h" | 8 #include "content/common/gpu/client/command_buffer_proxy_impl.h" |
| 9 #include "content/common/gpu/media/gpu_video_accelerator_util.h" | 9 #include "content/common/gpu/media/gpu_video_accelerator_util.h" |
| 10 #include "content/common/pepper_file_util.h" | 10 #include "content/common/pepper_file_util.h" |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 625 DCHECK(buffer); | 625 DCHECK(buffer); |
| 626 uint32_t shm_offset = static_cast<uint8*>(buffer->video.data) - | 626 uint32_t shm_offset = static_cast<uint8*>(buffer->video.data) - |
| 627 static_cast<uint8*>(buffer_manager_.shm()->memory()); | 627 static_cast<uint8*>(buffer_manager_.shm()->memory()); |
| 628 | 628 |
| 629 scoped_refptr<media::VideoFrame> frame = | 629 scoped_refptr<media::VideoFrame> frame = |
| 630 media::VideoFrame::WrapExternalSharedMemory( | 630 media::VideoFrame::WrapExternalSharedMemory( |
| 631 media_input_format_, input_coded_size_, gfx::Rect(input_coded_size_), | 631 media_input_format_, input_coded_size_, gfx::Rect(input_coded_size_), |
| 632 input_coded_size_, static_cast<uint8*>(buffer->video.data), | 632 input_coded_size_, static_cast<uint8*>(buffer->video.data), |
| 633 buffer->video.data_size, buffer_manager_.shm()->handle(), shm_offset, | 633 buffer->video.data_size, buffer_manager_.shm()->handle(), shm_offset, |
| 634 base::TimeDelta()); | 634 base::TimeDelta()); |
| 635 frame->AddDestructionObserver( | 635 if (frame) { |
| 636 base::Bind(&PepperVideoEncoderHost::FrameReleased, | 636 frame->AddDestructionObserver( |
| 637 weak_ptr_factory_.GetWeakPtr(), reply_context, frame_id)); | 637 base::Bind(&PepperVideoEncoderHost::FrameReleased, |
| 638 weak_ptr_factory_.GetWeakPtr(), reply_context, frame_id)); | |
| 639 } else { | |
|
Pawel Osciak
2015/11/26 01:19:03
Personally I'd prefer a clear error path, but up t
emircan
2015/12/04 04:20:09
Done.
| |
| 640 DLOG(ERROR) << "Couldn't create video frame"; | |
| 641 NotifyPepperError(PP_ERROR_FAILED); | |
| 642 } | |
| 643 | |
| 638 return frame; | 644 return frame; |
| 639 } | 645 } |
| 640 | 646 |
| 641 void PepperVideoEncoderHost::FrameReleased( | 647 void PepperVideoEncoderHost::FrameReleased( |
| 642 const ppapi::host::ReplyMessageContext& reply_context, | 648 const ppapi::host::ReplyMessageContext& reply_context, |
| 643 uint32_t frame_id) { | 649 uint32_t frame_id) { |
| 644 DCHECK(RenderThreadImpl::current()); | 650 DCHECK(RenderThreadImpl::current()); |
| 645 | 651 |
| 646 ppapi::host::ReplyMessageContext context = reply_context; | 652 ppapi::host::ReplyMessageContext context = reply_context; |
| 647 context.params.set_result(encoder_last_error_); | 653 context.params.set_result(encoder_last_error_); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 659 } | 665 } |
| 660 | 666 |
| 661 uint8_t* PepperVideoEncoderHost::ShmHandleToAddress(int32 buffer_id) { | 667 uint8_t* PepperVideoEncoderHost::ShmHandleToAddress(int32 buffer_id) { |
| 662 DCHECK(RenderThreadImpl::current()); | 668 DCHECK(RenderThreadImpl::current()); |
| 663 DCHECK_GE(buffer_id, 0); | 669 DCHECK_GE(buffer_id, 0); |
| 664 DCHECK_LT(buffer_id, static_cast<int32>(shm_buffers_.size())); | 670 DCHECK_LT(buffer_id, static_cast<int32>(shm_buffers_.size())); |
| 665 return static_cast<uint8_t*>(shm_buffers_[buffer_id]->shm->memory()); | 671 return static_cast<uint8_t*>(shm_buffers_[buffer_id]->shm->memory()); |
| 666 } | 672 } |
| 667 | 673 |
| 668 } // namespace content | 674 } // namespace content |
| OLD | NEW |