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 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 uint32_t frame_id, | 626 uint32_t frame_id, |
627 const ppapi::host::ReplyMessageContext& reply_context) { | 627 const ppapi::host::ReplyMessageContext& reply_context) { |
628 DCHECK(RenderThreadImpl::current()); | 628 DCHECK(RenderThreadImpl::current()); |
629 | 629 |
630 ppapi::MediaStreamBuffer* buffer = buffer_manager_.GetBufferPointer(frame_id); | 630 ppapi::MediaStreamBuffer* buffer = buffer_manager_.GetBufferPointer(frame_id); |
631 DCHECK(buffer); | 631 DCHECK(buffer); |
632 uint32_t shm_offset = static_cast<uint8*>(buffer->video.data) - | 632 uint32_t shm_offset = static_cast<uint8*>(buffer->video.data) - |
633 static_cast<uint8*>(buffer_manager_.shm()->memory()); | 633 static_cast<uint8*>(buffer_manager_.shm()->memory()); |
634 | 634 |
635 scoped_refptr<media::VideoFrame> frame = | 635 scoped_refptr<media::VideoFrame> frame = |
636 media::VideoFrame::WrapExternalPackedMemory( | 636 media::VideoFrame::WrapExternalSharedMemory( |
637 media_input_format_, input_coded_size_, gfx::Rect(input_coded_size_), | 637 media_input_format_, input_coded_size_, gfx::Rect(input_coded_size_), |
638 input_coded_size_, static_cast<uint8*>(buffer->video.data), | 638 input_coded_size_, static_cast<uint8*>(buffer->video.data), |
639 buffer->video.data_size, buffer_manager_.shm()->handle(), shm_offset, | 639 buffer->video.data_size, buffer_manager_.shm()->handle(), shm_offset, |
640 base::TimeDelta()); | 640 base::TimeDelta()); |
641 frame->AddDestructionObserver( | 641 frame->AddDestructionObserver( |
642 base::Bind(&PepperVideoEncoderHost::FrameReleased, | 642 base::Bind(&PepperVideoEncoderHost::FrameReleased, |
643 weak_ptr_factory_.GetWeakPtr(), reply_context, frame_id)); | 643 weak_ptr_factory_.GetWeakPtr(), reply_context, frame_id)); |
644 return frame; | 644 return frame; |
645 } | 645 } |
646 | 646 |
(...skipping 18 matching lines...) Expand all Loading... |
665 } | 665 } |
666 | 666 |
667 uint8_t* PepperVideoEncoderHost::ShmHandleToAddress(int32 buffer_id) { | 667 uint8_t* PepperVideoEncoderHost::ShmHandleToAddress(int32 buffer_id) { |
668 DCHECK(RenderThreadImpl::current()); | 668 DCHECK(RenderThreadImpl::current()); |
669 DCHECK_GE(buffer_id, 0); | 669 DCHECK_GE(buffer_id, 0); |
670 DCHECK_LT(buffer_id, static_cast<int32>(shm_buffers_.size())); | 670 DCHECK_LT(buffer_id, static_cast<int32>(shm_buffers_.size())); |
671 return static_cast<uint8_t*>(shm_buffers_[buffer_id]->shm->memory()); | 671 return static_cast<uint8_t*>(shm_buffers_[buffer_id]->shm->memory()); |
672 } | 672 } |
673 | 673 |
674 } // namespace content | 674 } // namespace content |
OLD | NEW |