| 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" |
| 11 #include "ppapi/proxy/ppapi_messages.h" | 11 #include "ppapi/proxy/ppapi_messages.h" |
| 12 #include "ppapi/proxy/ppb_buffer_proxy.h" | 12 #include "ppapi/proxy/ppb_buffer_proxy.h" |
| 13 #include "ppapi/proxy/ppb_graphics_3d_proxy.h" | 13 #include "ppapi/proxy/ppb_graphics_3d_proxy.h" |
| 14 #include "ppapi/thunk/enter.h" | 14 #include "ppapi/thunk/enter.h" |
| 15 #include "ppapi/thunk/resource_creation_api.h" | 15 #include "ppapi/thunk/resource_creation_api.h" |
| 16 #include "ppapi/thunk/thunk.h" | 16 #include "ppapi/thunk/thunk.h" |
| 17 | 17 |
| 18 using ppapi::thunk::EnterResourceNoLock; | 18 using ppapi::thunk::EnterResourceNoLock; |
| 19 using ppapi::thunk::PPB_Buffer_API; | 19 using ppapi::thunk::PPB_Buffer_API; |
| 20 using ppapi::thunk::PPB_Graphics3D_API; | 20 using ppapi::thunk::PPB_Graphics3D_API; |
| 21 using ppapi::thunk::PPB_VideoDecoder_API; | 21 using ppapi::thunk::PPB_VideoDecoder_API; |
| 22 | 22 |
| 23 namespace ppapi { | 23 namespace ppapi { |
| 24 namespace proxy { | 24 namespace proxy { |
| 25 | 25 |
| 26 class VideoDecoder : public Resource, public PPB_VideoDecoder_Shared { | 26 class VideoDecoder : public PPB_VideoDecoder_Shared { |
| 27 public: | 27 public: |
| 28 // You must call Init() before using this class. | 28 // You must call Init() before using this class. |
| 29 explicit VideoDecoder(const HostResource& resource); | 29 explicit VideoDecoder(const HostResource& resource); |
| 30 virtual ~VideoDecoder(); | 30 virtual ~VideoDecoder(); |
| 31 | 31 |
| 32 static VideoDecoder* Create(const HostResource& resource, | 32 static VideoDecoder* Create(const HostResource& resource, |
| 33 PP_Resource graphics_context, | 33 PP_Resource graphics_context, |
| 34 PP_VideoDecoder_Profile profile); | 34 PP_VideoDecoder_Profile profile); |
| 35 | 35 |
| 36 // Resource overrides. | |
| 37 virtual PPB_VideoDecoder_API* AsPPB_VideoDecoder_API() OVERRIDE; | |
| 38 | |
| 39 // PPB_VideoDecoder_API implementation. | 36 // PPB_VideoDecoder_API implementation. |
| 40 virtual int32_t Decode(const PP_VideoBitstreamBuffer_Dev* bitstream_buffer, | 37 virtual int32_t Decode(const PP_VideoBitstreamBuffer_Dev* bitstream_buffer, |
| 41 PP_CompletionCallback callback) OVERRIDE; | 38 PP_CompletionCallback callback) OVERRIDE; |
| 42 virtual void AssignPictureBuffers( | 39 virtual void AssignPictureBuffers( |
| 43 uint32_t no_of_buffers, const PP_PictureBuffer_Dev* buffers) OVERRIDE; | 40 uint32_t no_of_buffers, const PP_PictureBuffer_Dev* buffers) OVERRIDE; |
| 44 virtual void ReusePictureBuffer(int32_t picture_buffer_id) OVERRIDE; | 41 virtual void ReusePictureBuffer(int32_t picture_buffer_id) OVERRIDE; |
| 45 virtual int32_t Flush(PP_CompletionCallback callback) OVERRIDE; | 42 virtual int32_t Flush(PP_CompletionCallback callback) OVERRIDE; |
| 46 virtual int32_t Reset(PP_CompletionCallback callback) OVERRIDE; | 43 virtual int32_t Reset(PP_CompletionCallback callback) OVERRIDE; |
| 47 virtual void Destroy() OVERRIDE; | 44 virtual void Destroy() OVERRIDE; |
| 48 | 45 |
| 49 private: | 46 private: |
| 50 friend class PPB_VideoDecoder_Proxy; | 47 friend class PPB_VideoDecoder_Proxy; |
| 51 | 48 |
| 52 PluginDispatcher* GetDispatcher() const; | 49 PluginDispatcher* GetDispatcher() const; |
| 53 | 50 |
| 54 // Run the callbacks that were passed into the plugin interface. | 51 // Run the callbacks that were passed into the plugin interface. |
| 55 void FlushACK(int32_t result); | 52 void FlushACK(int32_t result); |
| 56 void ResetACK(int32_t result); | 53 void ResetACK(int32_t result); |
| 57 void EndOfBitstreamACK(int32_t buffer_id, int32_t result); | 54 void EndOfBitstreamACK(int32_t buffer_id, int32_t result); |
| 58 | 55 |
| 59 DISALLOW_COPY_AND_ASSIGN(VideoDecoder); | 56 DISALLOW_COPY_AND_ASSIGN(VideoDecoder); |
| 60 }; | 57 }; |
| 61 | 58 |
| 62 VideoDecoder::VideoDecoder(const HostResource& decoder) : Resource(decoder) { | 59 VideoDecoder::VideoDecoder(const HostResource& decoder) |
| 60 : PPB_VideoDecoder_Shared(decoder) { |
| 63 } | 61 } |
| 64 | 62 |
| 65 VideoDecoder::~VideoDecoder() { | 63 VideoDecoder::~VideoDecoder() { |
| 66 } | 64 } |
| 67 | 65 |
| 68 PPB_VideoDecoder_API* VideoDecoder::AsPPB_VideoDecoder_API() { | |
| 69 return this; | |
| 70 } | |
| 71 | |
| 72 int32_t VideoDecoder::Decode( | 66 int32_t VideoDecoder::Decode( |
| 73 const PP_VideoBitstreamBuffer_Dev* bitstream_buffer, | 67 const PP_VideoBitstreamBuffer_Dev* bitstream_buffer, |
| 74 PP_CompletionCallback callback) { | 68 PP_CompletionCallback callback) { |
| 75 EnterResourceNoLock<PPB_Buffer_API> | 69 EnterResourceNoLock<PPB_Buffer_API> |
| 76 enter_buffer(bitstream_buffer->data, true); | 70 enter_buffer(bitstream_buffer->data, true); |
| 77 if (enter_buffer.failed()) | 71 if (enter_buffer.failed()) |
| 78 return PP_ERROR_BADRESOURCE; | 72 return PP_ERROR_BADRESOURCE; |
| 79 | 73 |
| 80 if (!SetBitstreamBufferCallback(bitstream_buffer->id, callback)) | 74 if (!SetBitstreamBufferCallback(bitstream_buffer->id, callback)) |
| 81 return PP_ERROR_BADARGUMENT; | 75 return PP_ERROR_BADARGUMENT; |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 | 306 |
| 313 void PPB_VideoDecoder_Proxy::OnMsgResetACK( | 307 void PPB_VideoDecoder_Proxy::OnMsgResetACK( |
| 314 const HostResource& decoder, int32_t result) { | 308 const HostResource& decoder, int32_t result) { |
| 315 EnterPluginFromHostResource<PPB_VideoDecoder_API> enter(decoder); | 309 EnterPluginFromHostResource<PPB_VideoDecoder_API> enter(decoder); |
| 316 if (enter.succeeded()) | 310 if (enter.succeeded()) |
| 317 static_cast<VideoDecoder*>(enter.object())->ResetACK(result); | 311 static_cast<VideoDecoder*>(enter.object())->ResetACK(result); |
| 318 } | 312 } |
| 319 | 313 |
| 320 } // namespace proxy | 314 } // namespace proxy |
| 321 } // namespace ppapi | 315 } // namespace ppapi |
| OLD | NEW |