| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 81 |
| 82 if (!SetBitstreamBufferCallback(bitstream_buffer->id, callback)) | 82 if (!SetBitstreamBufferCallback(bitstream_buffer->id, callback)) |
| 83 return PP_ERROR_BADARGUMENT; | 83 return PP_ERROR_BADARGUMENT; |
| 84 | 84 |
| 85 Buffer* ppb_buffer = | 85 Buffer* ppb_buffer = |
| 86 static_cast<Buffer*>(enter_buffer.object()); | 86 static_cast<Buffer*>(enter_buffer.object()); |
| 87 HostResource host_buffer = ppb_buffer->host_resource(); | 87 HostResource host_buffer = ppb_buffer->host_resource(); |
| 88 | 88 |
| 89 FlushCommandBuffer(); | 89 FlushCommandBuffer(); |
| 90 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoDecoder_Decode( | 90 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoDecoder_Decode( |
| 91 INTERFACE_ID_PPB_VIDEO_DECODER_DEV, host_resource(), | 91 API_ID_PPB_VIDEO_DECODER_DEV, host_resource(), |
| 92 host_buffer, bitstream_buffer->id, | 92 host_buffer, bitstream_buffer->id, |
| 93 bitstream_buffer->size)); | 93 bitstream_buffer->size)); |
| 94 return PP_OK_COMPLETIONPENDING; | 94 return PP_OK_COMPLETIONPENDING; |
| 95 } | 95 } |
| 96 | 96 |
| 97 void VideoDecoder::AssignPictureBuffers(uint32_t no_of_buffers, | 97 void VideoDecoder::AssignPictureBuffers(uint32_t no_of_buffers, |
| 98 const PP_PictureBuffer_Dev* buffers) { | 98 const PP_PictureBuffer_Dev* buffers) { |
| 99 std::vector<PP_PictureBuffer_Dev> buffer_list( | 99 std::vector<PP_PictureBuffer_Dev> buffer_list( |
| 100 buffers, buffers + no_of_buffers); | 100 buffers, buffers + no_of_buffers); |
| 101 FlushCommandBuffer(); | 101 FlushCommandBuffer(); |
| 102 GetDispatcher()->Send( | 102 GetDispatcher()->Send( |
| 103 new PpapiHostMsg_PPBVideoDecoder_AssignPictureBuffers( | 103 new PpapiHostMsg_PPBVideoDecoder_AssignPictureBuffers( |
| 104 INTERFACE_ID_PPB_VIDEO_DECODER_DEV, host_resource(), buffer_list)); | 104 API_ID_PPB_VIDEO_DECODER_DEV, host_resource(), buffer_list)); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void VideoDecoder::ReusePictureBuffer(int32_t picture_buffer_id) { | 107 void VideoDecoder::ReusePictureBuffer(int32_t picture_buffer_id) { |
| 108 FlushCommandBuffer(); | 108 FlushCommandBuffer(); |
| 109 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoDecoder_ReusePictureBuffer( | 109 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoDecoder_ReusePictureBuffer( |
| 110 INTERFACE_ID_PPB_VIDEO_DECODER_DEV, host_resource(), picture_buffer_id)); | 110 API_ID_PPB_VIDEO_DECODER_DEV, host_resource(), picture_buffer_id)); |
| 111 } | 111 } |
| 112 | 112 |
| 113 int32_t VideoDecoder::Flush(PP_CompletionCallback callback) { | 113 int32_t VideoDecoder::Flush(PP_CompletionCallback callback) { |
| 114 if (!SetFlushCallback(callback)) | 114 if (!SetFlushCallback(callback)) |
| 115 return PP_ERROR_INPROGRESS; | 115 return PP_ERROR_INPROGRESS; |
| 116 | 116 |
| 117 FlushCommandBuffer(); | 117 FlushCommandBuffer(); |
| 118 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoDecoder_Flush( | 118 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoDecoder_Flush( |
| 119 INTERFACE_ID_PPB_VIDEO_DECODER_DEV, host_resource())); | 119 API_ID_PPB_VIDEO_DECODER_DEV, host_resource())); |
| 120 return PP_OK_COMPLETIONPENDING; | 120 return PP_OK_COMPLETIONPENDING; |
| 121 } | 121 } |
| 122 | 122 |
| 123 int32_t VideoDecoder::Reset(PP_CompletionCallback callback) { | 123 int32_t VideoDecoder::Reset(PP_CompletionCallback callback) { |
| 124 if (!SetResetCallback(callback)) | 124 if (!SetResetCallback(callback)) |
| 125 return PP_ERROR_INPROGRESS; | 125 return PP_ERROR_INPROGRESS; |
| 126 | 126 |
| 127 FlushCommandBuffer(); | 127 FlushCommandBuffer(); |
| 128 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoDecoder_Reset( | 128 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoDecoder_Reset( |
| 129 INTERFACE_ID_PPB_VIDEO_DECODER_DEV, host_resource())); | 129 API_ID_PPB_VIDEO_DECODER_DEV, host_resource())); |
| 130 return PP_OK_COMPLETIONPENDING; | 130 return PP_OK_COMPLETIONPENDING; |
| 131 } | 131 } |
| 132 | 132 |
| 133 void VideoDecoder::Destroy() { | 133 void VideoDecoder::Destroy() { |
| 134 FlushCommandBuffer(); | 134 FlushCommandBuffer(); |
| 135 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoDecoder_Destroy( | 135 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoDecoder_Destroy( |
| 136 INTERFACE_ID_PPB_VIDEO_DECODER_DEV, host_resource())); | 136 API_ID_PPB_VIDEO_DECODER_DEV, host_resource())); |
| 137 VideoDecoderImpl::Destroy(); | 137 VideoDecoderImpl::Destroy(); |
| 138 } | 138 } |
| 139 | 139 |
| 140 PluginDispatcher* VideoDecoder::GetDispatcher() const { | 140 PluginDispatcher* VideoDecoder::GetDispatcher() const { |
| 141 return PluginDispatcher::GetForResource(this); | 141 return PluginDispatcher::GetForResource(this); |
| 142 } | 142 } |
| 143 | 143 |
| 144 void VideoDecoder::ResetACK(int32_t result) { | 144 void VideoDecoder::ResetACK(int32_t result) { |
| 145 RunResetCallback(result); | 145 RunResetCallback(result); |
| 146 } | 146 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 true); | 208 true); |
| 209 if (enter_context.failed()) | 209 if (enter_context.failed()) |
| 210 return 0; | 210 return 0; |
| 211 Graphics3D* context = static_cast<Graphics3D*>(enter_context.object()); | 211 Graphics3D* context = static_cast<Graphics3D*>(enter_context.object()); |
| 212 host_context = context->host_resource(); | 212 host_context = context->host_resource(); |
| 213 gles2_impl = context->gles2_impl(); | 213 gles2_impl = context->gles2_impl(); |
| 214 } | 214 } |
| 215 | 215 |
| 216 HostResource result; | 216 HostResource result; |
| 217 dispatcher->Send(new PpapiHostMsg_PPBVideoDecoder_Create( | 217 dispatcher->Send(new PpapiHostMsg_PPBVideoDecoder_Create( |
| 218 INTERFACE_ID_PPB_VIDEO_DECODER_DEV, instance, | 218 API_ID_PPB_VIDEO_DECODER_DEV, instance, |
| 219 host_context, profile, &result)); | 219 host_context, profile, &result)); |
| 220 if (result.is_null()) | 220 if (result.is_null()) |
| 221 return 0; | 221 return 0; |
| 222 | 222 |
| 223 // Need a scoped_refptr to keep the object alive during the Init call. | 223 // Need a scoped_refptr to keep the object alive during the Init call. |
| 224 scoped_refptr<VideoDecoder> decoder(new VideoDecoder(result)); | 224 scoped_refptr<VideoDecoder> decoder(new VideoDecoder(result)); |
| 225 decoder->InitCommon(graphics_context, gles2_impl); | 225 decoder->InitCommon(graphics_context, gles2_impl); |
| 226 return decoder->GetReference(); | 226 return decoder->GetReference(); |
| 227 } | 227 } |
| 228 | 228 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 | 287 |
| 288 void PPB_VideoDecoder_Proxy::OnMsgDestroy(const HostResource& decoder) { | 288 void PPB_VideoDecoder_Proxy::OnMsgDestroy(const HostResource& decoder) { |
| 289 EnterHostFromHostResource<PPB_VideoDecoder_API> enter(decoder); | 289 EnterHostFromHostResource<PPB_VideoDecoder_API> enter(decoder); |
| 290 if (enter.succeeded()) | 290 if (enter.succeeded()) |
| 291 enter.object()->Destroy(); | 291 enter.object()->Destroy(); |
| 292 } | 292 } |
| 293 | 293 |
| 294 void PPB_VideoDecoder_Proxy::SendMsgEndOfBitstreamACKToPlugin( | 294 void PPB_VideoDecoder_Proxy::SendMsgEndOfBitstreamACKToPlugin( |
| 295 int32_t result, const HostResource& decoder, int32 id) { | 295 int32_t result, const HostResource& decoder, int32 id) { |
| 296 dispatcher()->Send(new PpapiMsg_PPBVideoDecoder_EndOfBitstreamACK( | 296 dispatcher()->Send(new PpapiMsg_PPBVideoDecoder_EndOfBitstreamACK( |
| 297 INTERFACE_ID_PPB_VIDEO_DECODER_DEV, decoder, id, result)); | 297 API_ID_PPB_VIDEO_DECODER_DEV, decoder, id, result)); |
| 298 } | 298 } |
| 299 | 299 |
| 300 void PPB_VideoDecoder_Proxy::SendMsgFlushACKToPlugin( | 300 void PPB_VideoDecoder_Proxy::SendMsgFlushACKToPlugin( |
| 301 int32_t result, const HostResource& decoder) { | 301 int32_t result, const HostResource& decoder) { |
| 302 dispatcher()->Send(new PpapiMsg_PPBVideoDecoder_FlushACK( | 302 dispatcher()->Send(new PpapiMsg_PPBVideoDecoder_FlushACK( |
| 303 INTERFACE_ID_PPB_VIDEO_DECODER_DEV, decoder, result)); | 303 API_ID_PPB_VIDEO_DECODER_DEV, decoder, result)); |
| 304 } | 304 } |
| 305 | 305 |
| 306 void PPB_VideoDecoder_Proxy::SendMsgResetACKToPlugin( | 306 void PPB_VideoDecoder_Proxy::SendMsgResetACKToPlugin( |
| 307 int32_t result, const HostResource& decoder) { | 307 int32_t result, const HostResource& decoder) { |
| 308 dispatcher()->Send(new PpapiMsg_PPBVideoDecoder_ResetACK( | 308 dispatcher()->Send(new PpapiMsg_PPBVideoDecoder_ResetACK( |
| 309 INTERFACE_ID_PPB_VIDEO_DECODER_DEV, decoder, result)); | 309 API_ID_PPB_VIDEO_DECODER_DEV, decoder, result)); |
| 310 } | 310 } |
| 311 | 311 |
| 312 void PPB_VideoDecoder_Proxy::OnMsgEndOfBitstreamACK( | 312 void PPB_VideoDecoder_Proxy::OnMsgEndOfBitstreamACK( |
| 313 const HostResource& decoder, int32_t id, int32_t result) { | 313 const HostResource& decoder, int32_t id, int32_t result) { |
| 314 EnterPluginFromHostResource<PPB_VideoDecoder_API> enter(decoder); | 314 EnterPluginFromHostResource<PPB_VideoDecoder_API> enter(decoder); |
| 315 if (enter.succeeded()) | 315 if (enter.succeeded()) |
| 316 static_cast<VideoDecoder*>(enter.object())->EndOfBitstreamACK(id, result); | 316 static_cast<VideoDecoder*>(enter.object())->EndOfBitstreamACK(id, result); |
| 317 } | 317 } |
| 318 | 318 |
| 319 void PPB_VideoDecoder_Proxy::OnMsgFlushACK( | 319 void PPB_VideoDecoder_Proxy::OnMsgFlushACK( |
| 320 const HostResource& decoder, int32_t result) { | 320 const HostResource& decoder, int32_t result) { |
| 321 EnterPluginFromHostResource<PPB_VideoDecoder_API> enter(decoder); | 321 EnterPluginFromHostResource<PPB_VideoDecoder_API> enter(decoder); |
| 322 if (enter.succeeded()) | 322 if (enter.succeeded()) |
| 323 static_cast<VideoDecoder*>(enter.object())->FlushACK(result); | 323 static_cast<VideoDecoder*>(enter.object())->FlushACK(result); |
| 324 } | 324 } |
| 325 | 325 |
| 326 void PPB_VideoDecoder_Proxy::OnMsgResetACK( | 326 void PPB_VideoDecoder_Proxy::OnMsgResetACK( |
| 327 const HostResource& decoder, int32_t result) { | 327 const HostResource& decoder, int32_t result) { |
| 328 EnterPluginFromHostResource<PPB_VideoDecoder_API> enter(decoder); | 328 EnterPluginFromHostResource<PPB_VideoDecoder_API> enter(decoder); |
| 329 if (enter.succeeded()) | 329 if (enter.succeeded()) |
| 330 static_cast<VideoDecoder*>(enter.object())->ResetACK(result); | 330 static_cast<VideoDecoder*>(enter.object())->ResetACK(result); |
| 331 } | 331 } |
| 332 | 332 |
| 333 } // namespace proxy | 333 } // namespace proxy |
| 334 } // namespace ppapi | 334 } // namespace ppapi |
| OLD | NEW |