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

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

Issue 1154613006: Update pepper to not assume that SharedMemoryHandle is an int. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Another nits pass. Created 5 years, 6 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 "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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 } 384 }
385 385
386 shm_buffers_.push_back(new ShmBuffer(i, shm.Pass())); 386 shm_buffers_.push_back(new ShmBuffer(i, shm.Pass()));
387 } 387 }
388 388
389 // Feed buffers to the encoder. 389 // Feed buffers to the encoder.
390 std::vector<SerializedHandle> handles; 390 std::vector<SerializedHandle> handles;
391 for (size_t i = 0; i < shm_buffers_.size(); ++i) { 391 for (size_t i = 0; i < shm_buffers_.size(); ++i) {
392 encoder_->UseOutputBitstreamBuffer(shm_buffers_[i]->ToBitstreamBuffer()); 392 encoder_->UseOutputBitstreamBuffer(shm_buffers_[i]->ToBitstreamBuffer());
393 handles.push_back(SerializedHandle( 393 handles.push_back(SerializedHandle(
394 renderer_ppapi_host_->ShareHandleWithRemote( 394 renderer_ppapi_host_->ShareSharedMemoryHandleWithRemote(
395 PlatformFileFromSharedMemoryHandle(shm_buffers_[i]->shm->handle()), 395 shm_buffers_[i]->shm->handle()),
396 false),
397 output_buffer_size)); 396 output_buffer_size));
398 } 397 }
399 398
400 host()->SendUnsolicitedReplyWithHandles( 399 host()->SendUnsolicitedReplyWithHandles(
401 pp_resource(), PpapiPluginMsg_VideoEncoder_BitstreamBuffers( 400 pp_resource(), PpapiPluginMsg_VideoEncoder_BitstreamBuffers(
402 static_cast<uint32_t>(output_buffer_size)), 401 static_cast<uint32_t>(output_buffer_size)),
403 handles); 402 handles);
404 403
405 if (!initialized_) { 404 if (!initialized_) {
406 // Tell the plugin that initialization has been successful if we 405 // Tell the plugin that initialization has been successful if we
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 &(buffer_manager_.GetBufferPointer(i)->video); 593 &(buffer_manager_.GetBufferPointer(i)->video);
595 buffer->header.size = buffer_manager_.buffer_size(); 594 buffer->header.size = buffer_manager_.buffer_size();
596 buffer->header.type = ppapi::MediaStreamBuffer::TYPE_VIDEO; 595 buffer->header.type = ppapi::MediaStreamBuffer::TYPE_VIDEO;
597 buffer->format = PP_FromMediaVideoFormat(media_input_format_); 596 buffer->format = PP_FromMediaVideoFormat(media_input_format_);
598 buffer->size.width = input_coded_size_.width(); 597 buffer->size.width = input_coded_size_.width();
599 buffer->size.height = input_coded_size_.height(); 598 buffer->size.height = input_coded_size_.height();
600 buffer->data_size = frame_size; 599 buffer->data_size = frame_size;
601 } 600 }
602 601
603 DCHECK(get_video_frames_reply_context_.is_valid()); 602 DCHECK(get_video_frames_reply_context_.is_valid());
604 get_video_frames_reply_context_.params.AppendHandle(SerializedHandle( 603 get_video_frames_reply_context_.params.AppendHandle(
605 renderer_ppapi_host_->ShareHandleWithRemote( 604 SerializedHandle(renderer_ppapi_host_->ShareSharedMemoryHandleWithRemote(
606 PlatformFileFromSharedMemoryHandle(buffer_manager_.shm()->handle()), 605 buffer_manager_.shm()->handle()),
607 false), 606 total_size));
608 total_size));
609 607
610 host()->SendReply(get_video_frames_reply_context_, 608 host()->SendReply(get_video_frames_reply_context_,
611 PpapiPluginMsg_VideoEncoder_GetVideoFramesReply( 609 PpapiPluginMsg_VideoEncoder_GetVideoFramesReply(
612 frame_count_, buffer_size_aligned, 610 frame_count_, buffer_size_aligned,
613 PP_FromGfxSize(input_coded_size_))); 611 PP_FromGfxSize(input_coded_size_)));
614 get_video_frames_reply_context_ = ppapi::host::ReplyMessageContext(); 612 get_video_frames_reply_context_ = ppapi::host::ReplyMessageContext();
615 } 613 }
616 614
617 void PepperVideoEncoderHost::SendGetFramesErrorReply(int32_t error) { 615 void PepperVideoEncoderHost::SendGetFramesErrorReply(int32_t error) {
618 get_video_frames_reply_context_.params.set_result(error); 616 get_video_frames_reply_context_.params.set_result(error);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 } 663 }
666 664
667 uint8_t* PepperVideoEncoderHost::ShmHandleToAddress(int32 buffer_id) { 665 uint8_t* PepperVideoEncoderHost::ShmHandleToAddress(int32 buffer_id) {
668 DCHECK(RenderThreadImpl::current()); 666 DCHECK(RenderThreadImpl::current());
669 DCHECK_GE(buffer_id, 0); 667 DCHECK_GE(buffer_id, 0);
670 DCHECK_LT(buffer_id, static_cast<int32>(shm_buffers_.size())); 668 DCHECK_LT(buffer_id, static_cast<int32>(shm_buffers_.size()));
671 return static_cast<uint8_t*>(shm_buffers_[buffer_id]->shm->memory()); 669 return static_cast<uint8_t*>(shm_buffers_[buffer_id]->shm->memory());
672 } 670 }
673 671
674 } // namespace content 672 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698