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

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: halliwell@ comments. Created 4 years, 11 months 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 "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
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
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
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_media_stream_video_track_host.cc ('k') | media/base/video_frame.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698