Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ppapi/proxy/ppb_video_decoder_proxy.h" | 5 #include "ppapi/proxy/ppb_video_decoder_proxy.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "gpu/command_buffer/client/gles2_implementation.h" | 8 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 9 #include "ppapi/proxy/enter_proxy.h" | 9 #include "ppapi/proxy/enter_proxy.h" |
| 10 #include "ppapi/proxy/plugin_dispatcher.h" | 10 #include "ppapi/proxy/plugin_dispatcher.h" |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 | 147 |
| 148 void VideoDecoder::FlushACK(int32_t result) { | 148 void VideoDecoder::FlushACK(int32_t result) { |
| 149 RunFlushCallback(result); | 149 RunFlushCallback(result); |
| 150 } | 150 } |
| 151 | 151 |
| 152 void VideoDecoder::EndOfBitstreamACK( | 152 void VideoDecoder::EndOfBitstreamACK( |
| 153 int32_t bitstream_buffer_id, int32_t result) { | 153 int32_t bitstream_buffer_id, int32_t result) { |
| 154 RunBitstreamBufferCallback(bitstream_buffer_id, result); | 154 RunBitstreamBufferCallback(bitstream_buffer_id, result); |
| 155 } | 155 } |
| 156 | 156 |
| 157 namespace { | 157 PPB_VideoDecoder_Proxy::PPB_VideoDecoder_Proxy(Dispatcher* dispatcher) |
| 158 | 158 : InterfaceProxy(dispatcher), |
| 159 InterfaceProxy* CreateVideoDecoderProxy(Dispatcher* dispatcher, | |
| 160 const void* target_interface) { | |
| 161 return new PPB_VideoDecoder_Proxy(dispatcher, target_interface); | |
| 162 } | |
| 163 | |
| 164 } // namespace | |
| 165 | |
| 166 PPB_VideoDecoder_Proxy::PPB_VideoDecoder_Proxy(Dispatcher* dispatcher, | |
| 167 const void* target_interface) | |
| 168 : InterfaceProxy(dispatcher, target_interface), | |
| 169 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 159 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
| 170 } | 160 } |
| 171 | 161 |
| 172 PPB_VideoDecoder_Proxy::~PPB_VideoDecoder_Proxy() { | 162 PPB_VideoDecoder_Proxy::~PPB_VideoDecoder_Proxy() { |
| 173 } | 163 } |
| 174 | 164 |
| 175 // static | |
| 176 const InterfaceProxy::Info* PPB_VideoDecoder_Proxy::GetInfo() { | |
| 177 static const Info info = { | |
| 178 thunk::GetPPB_VideoDecoder_Thunk(), | |
| 179 PPB_VIDEODECODER_DEV_INTERFACE, | |
| 180 INTERFACE_ID_PPB_VIDEO_DECODER_DEV, | |
| 181 false, | |
| 182 &CreateVideoDecoderProxy, | |
| 183 }; | |
| 184 return &info; | |
| 185 } | |
| 186 | |
| 187 bool PPB_VideoDecoder_Proxy::OnMessageReceived(const IPC::Message& msg) { | 165 bool PPB_VideoDecoder_Proxy::OnMessageReceived(const IPC::Message& msg) { |
| 188 bool handled = true; | 166 bool handled = true; |
| 189 IPC_BEGIN_MESSAGE_MAP(PPB_VideoDecoder_Proxy, msg) | 167 IPC_BEGIN_MESSAGE_MAP(PPB_VideoDecoder_Proxy, msg) |
| 190 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoDecoder_Create, | 168 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoDecoder_Create, |
| 191 OnMsgCreate) | 169 OnMsgCreate) |
| 192 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoDecoder_Decode, OnMsgDecode) | 170 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoDecoder_Decode, OnMsgDecode) |
| 193 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoDecoder_AssignPictureBuffers, | 171 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoDecoder_AssignPictureBuffers, |
| 194 OnMsgAssignPictureBuffers) | 172 OnMsgAssignPictureBuffers) |
| 195 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoDecoder_ReusePictureBuffer, | 173 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoDecoder_ReusePictureBuffer, |
| 196 OnMsgReusePictureBuffer) | 174 OnMsgReusePictureBuffer) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 246 scoped_refptr<VideoDecoder> decoder(new VideoDecoder(result)); | 224 scoped_refptr<VideoDecoder> decoder(new VideoDecoder(result)); |
| 247 decoder->InitCommon(graphics_context, gles2_impl); | 225 decoder->InitCommon(graphics_context, gles2_impl); |
| 248 return decoder->GetReference(); | 226 return decoder->GetReference(); |
| 249 } | 227 } |
| 250 | 228 |
| 251 void PPB_VideoDecoder_Proxy::OnMsgCreate( | 229 void PPB_VideoDecoder_Proxy::OnMsgCreate( |
| 252 PP_Instance instance, const HostResource& graphics_context, | 230 PP_Instance instance, const HostResource& graphics_context, |
| 253 PP_VideoDecoder_Profile profile, | 231 PP_VideoDecoder_Profile profile, |
| 254 HostResource* result) { | 232 HostResource* result) { |
| 255 thunk::EnterFunction<thunk::ResourceCreationAPI> resource_creation(instance, | 233 thunk::EnterFunction<thunk::ResourceCreationAPI> resource_creation(instance, |
| 256 true); | 234 true); |
|
noelallen_use_chromium
2011/09/08 00:47:41
Not, thunk::EnterResourceCreation enter(instance)
| |
| 257 if (resource_creation.failed()) | 235 if (resource_creation.failed()) |
| 258 return; | 236 return; |
| 259 | 237 |
| 260 // Make the resource and get the API pointer to its interface. | 238 // Make the resource and get the API pointer to its interface. |
| 261 result->SetHostResource( | 239 result->SetHostResource( |
| 262 instance, resource_creation.functions()->CreateVideoDecoder( | 240 instance, resource_creation.functions()->CreateVideoDecoder( |
| 263 instance, graphics_context.host_resource(), profile)); | 241 instance, graphics_context.host_resource(), profile)); |
| 264 } | 242 } |
| 265 | 243 |
| 266 void PPB_VideoDecoder_Proxy::OnMsgDecode( | 244 void PPB_VideoDecoder_Proxy::OnMsgDecode( |
| 267 const HostResource& decoder, | 245 const HostResource& decoder, |
| 268 const HostResource& buffer, int32 id, int32 size) { | 246 const HostResource& buffer, int32 id, int32 size) { |
| 269 pp::CompletionCallback callback = callback_factory_.NewRequiredCallback( | 247 EnterHostFromHostResourceForceCallback<PPB_VideoDecoder_API> enter( |
| 248 decoder, callback_factory_, | |
| 270 &PPB_VideoDecoder_Proxy::SendMsgEndOfBitstreamACKToPlugin, decoder, id); | 249 &PPB_VideoDecoder_Proxy::SendMsgEndOfBitstreamACKToPlugin, decoder, id); |
| 271 | 250 if (enter.failed()) |
| 251 return; | |
| 272 PP_VideoBitstreamBuffer_Dev bitstream = { id, buffer.host_resource(), size }; | 252 PP_VideoBitstreamBuffer_Dev bitstream = { id, buffer.host_resource(), size }; |
| 273 ppb_video_decoder_target()->Decode( | 253 enter.SetResult(enter.object()->Decode(&bitstream, enter.callback())); |
| 274 decoder.host_resource(), &bitstream, callback.pp_completion_callback()); | |
| 275 } | 254 } |
| 276 | 255 |
| 277 void PPB_VideoDecoder_Proxy::OnMsgAssignPictureBuffers( | 256 void PPB_VideoDecoder_Proxy::OnMsgAssignPictureBuffers( |
| 278 const HostResource& decoder, | 257 const HostResource& decoder, |
| 279 const std::vector<PP_PictureBuffer_Dev>& buffers) { | 258 const std::vector<PP_PictureBuffer_Dev>& buffers) { |
| 280 DCHECK(!buffers.empty()); | 259 EnterHostFromHostResource<PPB_VideoDecoder_API> enter(decoder); |
| 281 const PP_PictureBuffer_Dev* buffer_array = &buffers.front(); | 260 if (enter.succeeded() && !buffers.empty()) { |
| 282 | 261 const PP_PictureBuffer_Dev* buffer_array = &buffers.front(); |
| 283 ppb_video_decoder_target()->AssignPictureBuffers( | 262 enter.object()->AssignPictureBuffers(buffers.size(), buffer_array); |
| 284 decoder.host_resource(), buffers.size(), buffer_array); | 263 } |
| 285 } | 264 } |
| 286 | 265 |
| 287 void PPB_VideoDecoder_Proxy::OnMsgReusePictureBuffer( | 266 void PPB_VideoDecoder_Proxy::OnMsgReusePictureBuffer( |
| 288 const HostResource& decoder, int32 picture_buffer_id) { | 267 const HostResource& decoder, int32 picture_buffer_id) { |
| 289 ppb_video_decoder_target()->ReusePictureBuffer( | 268 EnterHostFromHostResource<PPB_VideoDecoder_API> enter(decoder); |
| 290 decoder.host_resource(), picture_buffer_id); | 269 if (enter.succeeded()) |
| 270 enter.object()->ReusePictureBuffer(picture_buffer_id); | |
| 291 } | 271 } |
| 292 | 272 |
| 293 void PPB_VideoDecoder_Proxy::OnMsgFlush(const HostResource& decoder) { | 273 void PPB_VideoDecoder_Proxy::OnMsgFlush(const HostResource& decoder) { |
| 294 pp::CompletionCallback callback = callback_factory_.NewRequiredCallback( | 274 EnterHostFromHostResourceForceCallback<PPB_VideoDecoder_API> enter( |
| 275 decoder, callback_factory_, | |
| 295 &PPB_VideoDecoder_Proxy::SendMsgFlushACKToPlugin, decoder); | 276 &PPB_VideoDecoder_Proxy::SendMsgFlushACKToPlugin, decoder); |
| 296 ppb_video_decoder_target()->Flush( | 277 if (enter.succeeded()) |
| 297 decoder.host_resource(), callback.pp_completion_callback()); | 278 enter.SetResult(enter.object()->Flush(enter.callback())); |
| 298 } | 279 } |
| 299 | 280 |
| 300 void PPB_VideoDecoder_Proxy::OnMsgReset(const HostResource& decoder) { | 281 void PPB_VideoDecoder_Proxy::OnMsgReset(const HostResource& decoder) { |
| 301 pp::CompletionCallback callback = callback_factory_.NewRequiredCallback( | 282 EnterHostFromHostResourceForceCallback<PPB_VideoDecoder_API> enter( |
| 283 decoder, callback_factory_, | |
| 302 &PPB_VideoDecoder_Proxy::SendMsgResetACKToPlugin, decoder); | 284 &PPB_VideoDecoder_Proxy::SendMsgResetACKToPlugin, decoder); |
| 303 ppb_video_decoder_target()->Reset( | 285 if (enter.succeeded()) |
| 304 decoder.host_resource(), callback.pp_completion_callback()); | 286 enter.SetResult(enter.object()->Reset(enter.callback())); |
| 305 } | 287 } |
| 306 | 288 |
| 307 void PPB_VideoDecoder_Proxy::OnMsgDestroy(const HostResource& decoder) { | 289 void PPB_VideoDecoder_Proxy::OnMsgDestroy(const HostResource& decoder) { |
| 308 ppb_video_decoder_target()->Destroy(decoder.host_resource()); | 290 EnterHostFromHostResource<PPB_VideoDecoder_API> enter(decoder); |
| 291 if (enter.succeeded()) | |
| 292 enter.object()->Destroy(); | |
| 309 } | 293 } |
| 310 | 294 |
| 311 void PPB_VideoDecoder_Proxy::SendMsgEndOfBitstreamACKToPlugin( | 295 void PPB_VideoDecoder_Proxy::SendMsgEndOfBitstreamACKToPlugin( |
| 312 int32_t result, const HostResource& decoder, int32 id) { | 296 int32_t result, const HostResource& decoder, int32 id) { |
| 313 dispatcher()->Send(new PpapiMsg_PPBVideoDecoder_EndOfBitstreamACK( | 297 dispatcher()->Send(new PpapiMsg_PPBVideoDecoder_EndOfBitstreamACK( |
| 314 INTERFACE_ID_PPB_VIDEO_DECODER_DEV, decoder, id, result)); | 298 INTERFACE_ID_PPB_VIDEO_DECODER_DEV, decoder, id, result)); |
| 315 } | 299 } |
| 316 | 300 |
| 317 void PPB_VideoDecoder_Proxy::SendMsgFlushACKToPlugin( | 301 void PPB_VideoDecoder_Proxy::SendMsgFlushACKToPlugin( |
| 318 int32_t result, const HostResource& decoder) { | 302 int32_t result, const HostResource& decoder) { |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 342 | 326 |
| 343 void PPB_VideoDecoder_Proxy::OnMsgResetACK( | 327 void PPB_VideoDecoder_Proxy::OnMsgResetACK( |
| 344 const HostResource& decoder, int32_t result) { | 328 const HostResource& decoder, int32_t result) { |
| 345 EnterPluginFromHostResource<PPB_VideoDecoder_API> enter(decoder); | 329 EnterPluginFromHostResource<PPB_VideoDecoder_API> enter(decoder); |
| 346 if (enter.succeeded()) | 330 if (enter.succeeded()) |
| 347 static_cast<VideoDecoder*>(enter.object())->ResetACK(result); | 331 static_cast<VideoDecoder*>(enter.object())->ResetACK(result); |
| 348 } | 332 } |
| 349 | 333 |
| 350 } // namespace proxy | 334 } // namespace proxy |
| 351 } // namespace ppapi | 335 } // namespace ppapi |
| OLD | NEW |