| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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_decoder_host.h" | 5 #include "content/renderer/pepper/pepper_video_decoder_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
| 9 #include "content/common/gpu/client/gpu_channel_host.h" | 9 #include "content/common/gpu/client/gpu_channel_host.h" |
| 10 #include "content/common/pepper_file_util.h" | 10 #include "content/common/pepper_file_util.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoDecoder_Reset, | 106 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoDecoder_Reset, |
| 107 OnHostMsgReset) | 107 OnHostMsgReset) |
| 108 PPAPI_END_MESSAGE_MAP() | 108 PPAPI_END_MESSAGE_MAP() |
| 109 return PP_ERROR_FAILED; | 109 return PP_ERROR_FAILED; |
| 110 } | 110 } |
| 111 | 111 |
| 112 int32_t PepperVideoDecoderHost::OnHostMsgInitialize( | 112 int32_t PepperVideoDecoderHost::OnHostMsgInitialize( |
| 113 ppapi::host::HostMessageContext* context, | 113 ppapi::host::HostMessageContext* context, |
| 114 const ppapi::HostResource& graphics_context, | 114 const ppapi::HostResource& graphics_context, |
| 115 PP_VideoProfile profile, | 115 PP_VideoProfile profile, |
| 116 PP_HardwareAcceleration acceleration) { | 116 PP_HardwareAcceleration acceleration, |
| 117 uint32_t min_picture_count) { |
| 117 if (initialized_) | 118 if (initialized_) |
| 118 return PP_ERROR_FAILED; | 119 return PP_ERROR_FAILED; |
| 119 | 120 |
| 120 EnterResourceNoLock<PPB_Graphics3D_API> enter_graphics( | 121 EnterResourceNoLock<PPB_Graphics3D_API> enter_graphics( |
| 121 graphics_context.host_resource(), true); | 122 graphics_context.host_resource(), true); |
| 122 if (enter_graphics.failed()) | 123 if (enter_graphics.failed()) |
| 123 return PP_ERROR_FAILED; | 124 return PP_ERROR_FAILED; |
| 124 PPB_Graphics3D_Impl* graphics3d = | 125 PPB_Graphics3D_Impl* graphics3d = |
| 125 static_cast<PPB_Graphics3D_Impl*>(enter_graphics.object()); | 126 static_cast<PPB_Graphics3D_Impl*>(enter_graphics.object()); |
| 126 | 127 |
| 127 int command_buffer_route_id = graphics3d->GetCommandBufferRouteId(); | 128 int command_buffer_route_id = graphics3d->GetCommandBufferRouteId(); |
| 128 if (!command_buffer_route_id) | 129 if (!command_buffer_route_id) |
| 129 return PP_ERROR_FAILED; | 130 return PP_ERROR_FAILED; |
| 130 | 131 |
| 131 media::VideoCodecProfile media_profile = PepperToMediaVideoProfile(profile); | 132 media::VideoCodecProfile media_profile = PepperToMediaVideoProfile(profile); |
| 132 | 133 |
| 133 if (acceleration != PP_HARDWAREACCELERATION_NONE) { | 134 if (acceleration != PP_HARDWAREACCELERATION_NONE) { |
| 134 // This is not synchronous, but subsequent IPC messages will be buffered, so | 135 // This is not synchronous, but subsequent IPC messages will be buffered, so |
| 135 // it is okay to immediately send IPC messages through the returned channel. | 136 // it is okay to immediately send IPC messages through the returned channel. |
| 136 GpuChannelHost* channel = graphics3d->channel(); | 137 GpuChannelHost* channel = graphics3d->channel(); |
| 137 DCHECK(channel); | 138 DCHECK(channel); |
| 138 decoder_ = channel->CreateVideoDecoder(command_buffer_route_id); | 139 decoder_ = channel->CreateVideoDecoder(command_buffer_route_id); |
| 139 if (decoder_ && decoder_->Initialize(media_profile, this)) { | 140 if (decoder_ && |
| 141 decoder_->Initialize(media_profile, min_picture_count, this)) { |
| 140 initialized_ = true; | 142 initialized_ = true; |
| 141 return PP_OK; | 143 return PP_OK; |
| 142 } | 144 } |
| 143 decoder_.reset(); | 145 decoder_.reset(); |
| 144 if (acceleration == PP_HARDWAREACCELERATION_ONLY) | 146 if (acceleration == PP_HARDWAREACCELERATION_ONLY) |
| 145 return PP_ERROR_NOTSUPPORTED; | 147 return PP_ERROR_NOTSUPPORTED; |
| 146 } | 148 } |
| 147 | 149 |
| 148 #if defined(OS_ANDROID) | 150 #if defined(OS_ANDROID) |
| 149 return PP_ERROR_NOTSUPPORTED; | 151 return PP_ERROR_NOTSUPPORTED; |
| 150 #else | 152 #else |
| 151 decoder_.reset(new VideoDecoderShim(this)); | 153 decoder_.reset(new VideoDecoderShim(this)); |
| 152 initialize_reply_context_ = context->MakeReplyMessageContext(); | 154 initialize_reply_context_ = context->MakeReplyMessageContext(); |
| 153 decoder_->Initialize(media_profile, this); | 155 decoder_->Initialize(media_profile, min_picture_count, this); |
| 154 | 156 |
| 155 return PP_OK_COMPLETIONPENDING; | 157 return PP_OK_COMPLETIONPENDING; |
| 156 #endif | 158 #endif |
| 157 } | 159 } |
| 158 | 160 |
| 159 int32_t PepperVideoDecoderHost::OnHostMsgGetShm( | 161 int32_t PepperVideoDecoderHost::OnHostMsgGetShm( |
| 160 ppapi::host::HostMessageContext* context, | 162 ppapi::host::HostMessageContext* context, |
| 161 uint32_t shm_id, | 163 uint32_t shm_id, |
| 162 uint32_t shm_size) { | 164 uint32_t shm_size) { |
| 163 if (!initialized_) | 165 if (!initialized_) |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 host()->SendUnsolicitedReply( | 427 host()->SendUnsolicitedReply( |
| 426 pp_resource(), | 428 pp_resource(), |
| 427 PpapiPluginMsg_VideoDecoder_RequestTextures( | 429 PpapiPluginMsg_VideoDecoder_RequestTextures( |
| 428 requested_num_of_buffers, | 430 requested_num_of_buffers, |
| 429 PP_MakeSize(dimensions.width(), dimensions.height()), | 431 PP_MakeSize(dimensions.width(), dimensions.height()), |
| 430 texture_target, | 432 texture_target, |
| 431 mailboxes)); | 433 mailboxes)); |
| 432 } | 434 } |
| 433 | 435 |
| 434 } // namespace content | 436 } // namespace content |
| OLD | NEW |