Index: content/renderer/pepper/pepper_video_decoder_host.cc |
diff --git a/content/renderer/pepper/pepper_video_decoder_host.cc b/content/renderer/pepper/pepper_video_decoder_host.cc |
index d3364e12be0e252065971110c68c5b42e6b16611..16019f720b29e4e6be4a8e1d236043dfecd3802e 100644 |
--- a/content/renderer/pepper/pepper_video_decoder_host.cc |
+++ b/content/renderer/pepper/pepper_video_decoder_host.cc |
@@ -10,7 +10,9 @@ |
#include "content/public/renderer/render_thread.h" |
#include "content/public/renderer/renderer_ppapi_host.h" |
#include "content/renderer/pepper/ppb_graphics_3d_impl.h" |
-#include "content/renderer/pepper/video_decoder_shim.h" |
+#include "content/renderer/render_thread_impl.h" |
+#include "content/renderer/render_view_impl.h" |
+#include "media/video/picture.h" |
#include "media/video/video_decode_accelerator.h" |
#include "ppapi/c/pp_completion_callback.h" |
#include "ppapi/c/pp_errors.h" |
@@ -117,10 +119,9 @@ |
graphics_context.host_resource(), true); |
if (enter_graphics.failed()) |
return PP_ERROR_FAILED; |
- PPB_Graphics3D_Impl* graphics3d = |
- static_cast<PPB_Graphics3D_Impl*>(enter_graphics.object()); |
- |
- int command_buffer_route_id = graphics3d->GetCommandBufferRouteId(); |
+ graphics3d_ = static_cast<PPB_Graphics3D_Impl*>(enter_graphics.object()); |
+ |
+ int command_buffer_route_id = graphics3d_->GetCommandBufferRouteId(); |
if (!command_buffer_route_id) |
return PP_ERROR_FAILED; |
@@ -128,7 +129,7 @@ |
// This is not synchronous, but subsequent IPC messages will be buffered, so |
// it is okay to immediately send IPC messages through the returned channel. |
- GpuChannelHost* channel = graphics3d->channel(); |
+ GpuChannelHost* channel = graphics3d_->channel(); |
DCHECK(channel); |
decoder_ = channel->CreateVideoDecoder(command_buffer_route_id); |
if (decoder_ && decoder_->Initialize(media_profile, this)) { |
@@ -137,14 +138,8 @@ |
} |
decoder_.reset(); |
- if (!allow_software_fallback) |
- return PP_ERROR_NOTSUPPORTED; |
- |
- decoder_.reset(new VideoDecoderShim(this)); |
- initialize_reply_context_ = context->MakeReplyMessageContext(); |
- decoder_->Initialize(media_profile, this); |
- |
- return PP_OK_COMPLETIONPENDING; |
+ // TODO(bbudge) Implement software fallback. |
+ return PP_ERROR_NOTSUPPORTED; |
} |
int32_t PepperVideoDecoderHost::OnHostMsgGetShm( |
@@ -181,8 +176,8 @@ |
shm_buffers_.push_back(shm.release()); |
shm_buffer_busy_.push_back(false); |
} else { |
- // Remove the old buffer. Delete manually since ScopedVector won't delete |
- // the existing element if we just assign over it. |
+ // Fill in the new resized buffer. Delete it manually since ScopedVector |
+ // won't delete the existing element if we just assign it. |
delete shm_buffers_[shm_id]; |
shm_buffers_[shm_id] = shm.release(); |
} |
@@ -267,6 +262,7 @@ |
return PP_ERROR_FAILED; |
decoder_->ReusePictureBuffer(texture_id); |
+ |
return PP_OK; |
} |
@@ -302,13 +298,17 @@ |
uint32 requested_num_of_buffers, |
const gfx::Size& dimensions, |
uint32 texture_target) { |
- RequestTextures(requested_num_of_buffers, |
- dimensions, |
- texture_target, |
- std::vector<gpu::Mailbox>()); |
+ DCHECK(RenderThreadImpl::current()); |
+ host()->SendUnsolicitedReply( |
+ pp_resource(), |
+ PpapiPluginMsg_VideoDecoder_RequestTextures( |
+ requested_num_of_buffers, |
+ PP_MakeSize(dimensions.width(), dimensions.height()), |
+ texture_target)); |
} |
void PepperVideoDecoderHost::PictureReady(const media::Picture& picture) { |
+ DCHECK(RenderThreadImpl::current()); |
host()->SendUnsolicitedReply( |
pp_resource(), |
PpapiPluginMsg_VideoDecoder_PictureReady(picture.bitstream_buffer_id(), |
@@ -316,40 +316,15 @@ |
} |
void PepperVideoDecoderHost::DismissPictureBuffer(int32 picture_buffer_id) { |
+ DCHECK(RenderThreadImpl::current()); |
host()->SendUnsolicitedReply( |
pp_resource(), |
PpapiPluginMsg_VideoDecoder_DismissPicture(picture_buffer_id)); |
} |
-void PepperVideoDecoderHost::NotifyEndOfBitstreamBuffer( |
- int32 bitstream_buffer_id) { |
- PendingDecodeMap::iterator it = pending_decodes_.find(bitstream_buffer_id); |
- if (it == pending_decodes_.end()) { |
- NOTREACHED(); |
- return; |
- } |
- const PendingDecode& pending_decode = it->second; |
- host()->SendReply( |
- pending_decode.reply_context, |
- PpapiPluginMsg_VideoDecoder_DecodeReply(pending_decode.shm_id)); |
- shm_buffer_busy_[pending_decode.shm_id] = false; |
- pending_decodes_.erase(it); |
-} |
- |
-void PepperVideoDecoderHost::NotifyFlushDone() { |
- host()->SendReply(flush_reply_context_, |
- PpapiPluginMsg_VideoDecoder_FlushReply()); |
- flush_reply_context_ = ppapi::host::ReplyMessageContext(); |
-} |
- |
-void PepperVideoDecoderHost::NotifyResetDone() { |
- host()->SendReply(reset_reply_context_, |
- PpapiPluginMsg_VideoDecoder_ResetReply()); |
- reset_reply_context_ = ppapi::host::ReplyMessageContext(); |
-} |
- |
void PepperVideoDecoderHost::NotifyError( |
media::VideoDecodeAccelerator::Error error) { |
+ DCHECK(RenderThreadImpl::current()); |
int32_t pp_error = PP_ERROR_FAILED; |
switch (error) { |
case media::VideoDecodeAccelerator::UNREADABLE_INPUT: |
@@ -367,35 +342,34 @@ |
pp_resource(), PpapiPluginMsg_VideoDecoder_NotifyError(pp_error)); |
} |
-void PepperVideoDecoderHost::OnInitializeComplete(int32_t result) { |
- if (!initialized_) { |
- if (result == PP_OK) |
- initialized_ = true; |
- initialize_reply_context_.params.set_result(result); |
- host()->SendReply(initialize_reply_context_, |
- PpapiPluginMsg_VideoDecoder_InitializeReply()); |
- } |
-} |
- |
-const uint8_t* PepperVideoDecoderHost::DecodeIdToAddress(uint32_t decode_id) { |
- PendingDecodeMap::const_iterator it = pending_decodes_.find(decode_id); |
- DCHECK(it != pending_decodes_.end()); |
- uint32_t shm_id = it->second.shm_id; |
- return static_cast<uint8_t*>(shm_buffers_[shm_id]->memory()); |
-} |
- |
-void PepperVideoDecoderHost::RequestTextures( |
- uint32 requested_num_of_buffers, |
- const gfx::Size& dimensions, |
- uint32 texture_target, |
- const std::vector<gpu::Mailbox>& mailboxes) { |
- host()->SendUnsolicitedReply( |
- pp_resource(), |
- PpapiPluginMsg_VideoDecoder_RequestTextures( |
- requested_num_of_buffers, |
- PP_MakeSize(dimensions.width(), dimensions.height()), |
- texture_target, |
- mailboxes)); |
+void PepperVideoDecoderHost::NotifyResetDone() { |
+ DCHECK(RenderThreadImpl::current()); |
+ host()->SendReply(reset_reply_context_, |
+ PpapiPluginMsg_VideoDecoder_ResetReply()); |
+ reset_reply_context_ = ppapi::host::ReplyMessageContext(); |
+} |
+ |
+void PepperVideoDecoderHost::NotifyEndOfBitstreamBuffer( |
+ int32 bitstream_buffer_id) { |
+ DCHECK(RenderThreadImpl::current()); |
+ PendingDecodeMap::iterator it = pending_decodes_.find(bitstream_buffer_id); |
+ if (it == pending_decodes_.end()) { |
+ NOTREACHED(); |
+ return; |
+ } |
+ const PendingDecode& pending_decode = it->second; |
+ host()->SendReply( |
+ pending_decode.reply_context, |
+ PpapiPluginMsg_VideoDecoder_DecodeReply(pending_decode.shm_id)); |
+ shm_buffer_busy_[pending_decode.shm_id] = false; |
+ pending_decodes_.erase(it); |
+} |
+ |
+void PepperVideoDecoderHost::NotifyFlushDone() { |
+ DCHECK(RenderThreadImpl::current()); |
+ host()->SendReply(flush_reply_context_, |
+ PpapiPluginMsg_VideoDecoder_FlushReply()); |
+ flush_reply_context_ = ppapi::host::ReplyMessageContext(); |
} |
} // namespace content |