Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(985)

Side by Side Diff: content/renderer/pepper/pepper_video_encoder_host.cc

Issue 1476523005: Verify returned frames from media::VideoFrame::Wrap*() methods (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: LOG in video_Frame and CHECK/return outside. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 if (!frame) {
636 NotifyPepperError(PP_ERROR_FAILED);
637 return frame;
638 }
635 frame->AddDestructionObserver( 639 frame->AddDestructionObserver(
636 base::Bind(&PepperVideoEncoderHost::FrameReleased, 640 base::Bind(&PepperVideoEncoderHost::FrameReleased,
637 weak_ptr_factory_.GetWeakPtr(), reply_context, frame_id)); 641 weak_ptr_factory_.GetWeakPtr(), reply_context, frame_id));
638 return frame; 642 return frame;
639 } 643 }
640 644
641 void PepperVideoEncoderHost::FrameReleased( 645 void PepperVideoEncoderHost::FrameReleased(
642 const ppapi::host::ReplyMessageContext& reply_context, 646 const ppapi::host::ReplyMessageContext& reply_context,
643 uint32_t frame_id) { 647 uint32_t frame_id) {
644 DCHECK(RenderThreadImpl::current()); 648 DCHECK(RenderThreadImpl::current());
(...skipping 14 matching lines...) Expand all
659 } 663 }
660 664
661 uint8_t* PepperVideoEncoderHost::ShmHandleToAddress(int32 buffer_id) { 665 uint8_t* PepperVideoEncoderHost::ShmHandleToAddress(int32 buffer_id) {
662 DCHECK(RenderThreadImpl::current()); 666 DCHECK(RenderThreadImpl::current());
663 DCHECK_GE(buffer_id, 0); 667 DCHECK_GE(buffer_id, 0);
664 DCHECK_LT(buffer_id, static_cast<int32>(shm_buffers_.size())); 668 DCHECK_LT(buffer_id, static_cast<int32>(shm_buffers_.size()));
665 return static_cast<uint8_t*>(shm_buffers_[buffer_id]->shm->memory()); 669 return static_cast<uint8_t*>(shm_buffers_[buffer_id]->shm->memory());
666 } 670 }
667 671
668 } // namespace content 672 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698