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 "content/renderer/pepper/pepper_video_encoder_host.h" | 5 #include "content/renderer/pepper/pepper_video_encoder_host.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 DCHECK(buffer); | 624 DCHECK(buffer); |
625 uint32_t shm_offset = static_cast<uint8_t*>(buffer->video.data) - | 625 uint32_t shm_offset = static_cast<uint8_t*>(buffer->video.data) - |
626 static_cast<uint8_t*>(buffer_manager_.shm()->memory()); | 626 static_cast<uint8_t*>(buffer_manager_.shm()->memory()); |
627 | 627 |
628 scoped_refptr<media::VideoFrame> frame = | 628 scoped_refptr<media::VideoFrame> frame = |
629 media::VideoFrame::WrapExternalSharedMemory( | 629 media::VideoFrame::WrapExternalSharedMemory( |
630 media_input_format_, input_coded_size_, gfx::Rect(input_coded_size_), | 630 media_input_format_, input_coded_size_, gfx::Rect(input_coded_size_), |
631 input_coded_size_, static_cast<uint8_t*>(buffer->video.data), | 631 input_coded_size_, static_cast<uint8_t*>(buffer->video.data), |
632 buffer->video.data_size, buffer_manager_.shm()->handle(), shm_offset, | 632 buffer->video.data_size, buffer_manager_.shm()->handle(), shm_offset, |
633 base::TimeDelta()); | 633 base::TimeDelta()); |
| 634 if (!frame) { |
| 635 NotifyPepperError(PP_ERROR_FAILED); |
| 636 return frame; |
| 637 } |
634 frame->AddDestructionObserver( | 638 frame->AddDestructionObserver( |
635 base::Bind(&PepperVideoEncoderHost::FrameReleased, | 639 base::Bind(&PepperVideoEncoderHost::FrameReleased, |
636 weak_ptr_factory_.GetWeakPtr(), reply_context, frame_id)); | 640 weak_ptr_factory_.GetWeakPtr(), reply_context, frame_id)); |
637 return frame; | 641 return frame; |
638 } | 642 } |
639 | 643 |
640 void PepperVideoEncoderHost::FrameReleased( | 644 void PepperVideoEncoderHost::FrameReleased( |
641 const ppapi::host::ReplyMessageContext& reply_context, | 645 const ppapi::host::ReplyMessageContext& reply_context, |
642 uint32_t frame_id) { | 646 uint32_t frame_id) { |
643 DCHECK(RenderThreadImpl::current()); | 647 DCHECK(RenderThreadImpl::current()); |
(...skipping 14 matching lines...) Expand all Loading... |
658 } | 662 } |
659 | 663 |
660 uint8_t* PepperVideoEncoderHost::ShmHandleToAddress(int32_t buffer_id) { | 664 uint8_t* PepperVideoEncoderHost::ShmHandleToAddress(int32_t buffer_id) { |
661 DCHECK(RenderThreadImpl::current()); | 665 DCHECK(RenderThreadImpl::current()); |
662 DCHECK_GE(buffer_id, 0); | 666 DCHECK_GE(buffer_id, 0); |
663 DCHECK_LT(buffer_id, static_cast<int32_t>(shm_buffers_.size())); | 667 DCHECK_LT(buffer_id, static_cast<int32_t>(shm_buffers_.size())); |
664 return static_cast<uint8_t*>(shm_buffers_[buffer_id]->shm->memory()); | 668 return static_cast<uint8_t*>(shm_buffers_[buffer_id]->shm->memory()); |
665 } | 669 } |
666 | 670 |
667 } // namespace content | 671 } // namespace content |
OLD | NEW |