| 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/public/renderer/render_thread.h" | 10 #include "content/public/renderer/render_thread.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoDecoder_Reset, | 104 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoDecoder_Reset, |
| 105 OnHostMsgReset) | 105 OnHostMsgReset) |
| 106 PPAPI_END_MESSAGE_MAP() | 106 PPAPI_END_MESSAGE_MAP() |
| 107 return PP_ERROR_FAILED; | 107 return PP_ERROR_FAILED; |
| 108 } | 108 } |
| 109 | 109 |
| 110 int32_t PepperVideoDecoderHost::OnHostMsgInitialize( | 110 int32_t PepperVideoDecoderHost::OnHostMsgInitialize( |
| 111 ppapi::host::HostMessageContext* context, | 111 ppapi::host::HostMessageContext* context, |
| 112 const ppapi::HostResource& graphics_context, | 112 const ppapi::HostResource& graphics_context, |
| 113 PP_VideoProfile profile, | 113 PP_VideoProfile profile, |
| 114 bool allow_software_fallback) { | 114 PP_HardwareAcceleration acceleration) { |
| 115 if (initialized_) | 115 if (initialized_) |
| 116 return PP_ERROR_FAILED; | 116 return PP_ERROR_FAILED; |
| 117 | 117 |
| 118 EnterResourceNoLock<PPB_Graphics3D_API> enter_graphics( | 118 EnterResourceNoLock<PPB_Graphics3D_API> enter_graphics( |
| 119 graphics_context.host_resource(), true); | 119 graphics_context.host_resource(), true); |
| 120 if (enter_graphics.failed()) | 120 if (enter_graphics.failed()) |
| 121 return PP_ERROR_FAILED; | 121 return PP_ERROR_FAILED; |
| 122 PPB_Graphics3D_Impl* graphics3d = | 122 PPB_Graphics3D_Impl* graphics3d = |
| 123 static_cast<PPB_Graphics3D_Impl*>(enter_graphics.object()); | 123 static_cast<PPB_Graphics3D_Impl*>(enter_graphics.object()); |
| 124 | 124 |
| 125 int command_buffer_route_id = graphics3d->GetCommandBufferRouteId(); | 125 int command_buffer_route_id = graphics3d->GetCommandBufferRouteId(); |
| 126 if (!command_buffer_route_id) | 126 if (!command_buffer_route_id) |
| 127 return PP_ERROR_FAILED; | 127 return PP_ERROR_FAILED; |
| 128 | 128 |
| 129 media::VideoCodecProfile media_profile = PepperToMediaVideoProfile(profile); | 129 media::VideoCodecProfile media_profile = PepperToMediaVideoProfile(profile); |
| 130 | 130 |
| 131 // This is not synchronous, but subsequent IPC messages will be buffered, so | 131 if (acceleration != PP_HARDWAREACCELERATION_NONE) { |
| 132 // it is okay to immediately send IPC messages through the returned channel. | 132 // This is not synchronous, but subsequent IPC messages will be buffered, so |
| 133 GpuChannelHost* channel = graphics3d->channel(); | 133 // it is okay to immediately send IPC messages through the returned channel. |
| 134 DCHECK(channel); | 134 GpuChannelHost* channel = graphics3d->channel(); |
| 135 decoder_ = channel->CreateVideoDecoder(command_buffer_route_id); | 135 DCHECK(channel); |
| 136 if (decoder_ && decoder_->Initialize(media_profile, this)) { | 136 decoder_ = channel->CreateVideoDecoder(command_buffer_route_id); |
| 137 initialized_ = true; | 137 if (decoder_ && decoder_->Initialize(media_profile, this)) { |
| 138 return PP_OK; | 138 initialized_ = true; |
| 139 return PP_OK; |
| 140 } |
| 141 decoder_.reset(); |
| 142 if (acceleration == PP_HARDWAREACCELERATION_ONLY) |
| 143 return PP_ERROR_NOTSUPPORTED; |
| 139 } | 144 } |
| 140 decoder_.reset(); | |
| 141 | 145 |
| 142 #if defined(OS_ANDROID) | 146 #if defined(OS_ANDROID) |
| 143 return PP_ERROR_NOTSUPPORTED; | 147 return PP_ERROR_NOTSUPPORTED; |
| 144 #else | 148 #else |
| 145 if (!allow_software_fallback) | |
| 146 return PP_ERROR_NOTSUPPORTED; | |
| 147 | |
| 148 decoder_.reset(new VideoDecoderShim(this)); | 149 decoder_.reset(new VideoDecoderShim(this)); |
| 149 initialize_reply_context_ = context->MakeReplyMessageContext(); | 150 initialize_reply_context_ = context->MakeReplyMessageContext(); |
| 150 decoder_->Initialize(media_profile, this); | 151 decoder_->Initialize(media_profile, this); |
| 151 | 152 |
| 152 return PP_OK_COMPLETIONPENDING; | 153 return PP_OK_COMPLETIONPENDING; |
| 153 #endif | 154 #endif |
| 154 } | 155 } |
| 155 | 156 |
| 156 int32_t PepperVideoDecoderHost::OnHostMsgGetShm( | 157 int32_t PepperVideoDecoderHost::OnHostMsgGetShm( |
| 157 ppapi::host::HostMessageContext* context, | 158 ppapi::host::HostMessageContext* context, |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 host()->SendUnsolicitedReply( | 401 host()->SendUnsolicitedReply( |
| 401 pp_resource(), | 402 pp_resource(), |
| 402 PpapiPluginMsg_VideoDecoder_RequestTextures( | 403 PpapiPluginMsg_VideoDecoder_RequestTextures( |
| 403 requested_num_of_buffers, | 404 requested_num_of_buffers, |
| 404 PP_MakeSize(dimensions.width(), dimensions.height()), | 405 PP_MakeSize(dimensions.width(), dimensions.height()), |
| 405 texture_target, | 406 texture_target, |
| 406 mailboxes)); | 407 mailboxes)); |
| 407 } | 408 } |
| 408 | 409 |
| 409 } // namespace content | 410 } // namespace content |
| OLD | NEW |