OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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" |
(...skipping 16 matching lines...) Expand all Loading... |
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 // PPB_VideoDecoder_API implementation. | 36 // PPB_VideoDecoder_API implementation. |
37 virtual int32_t Decode(const PP_VideoBitstreamBuffer_Dev* bitstream_buffer, | 37 virtual int32_t Decode(const PP_VideoBitstreamBuffer_Dev* bitstream_buffer, |
38 PP_CompletionCallback callback) OVERRIDE; | 38 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
39 virtual void AssignPictureBuffers( | 39 virtual void AssignPictureBuffers( |
40 uint32_t no_of_buffers, const PP_PictureBuffer_Dev* buffers) OVERRIDE; | 40 uint32_t no_of_buffers, const PP_PictureBuffer_Dev* buffers) OVERRIDE; |
41 virtual void ReusePictureBuffer(int32_t picture_buffer_id) OVERRIDE; | 41 virtual void ReusePictureBuffer(int32_t picture_buffer_id) OVERRIDE; |
42 virtual int32_t Flush(PP_CompletionCallback callback) OVERRIDE; | 42 virtual int32_t Flush(scoped_refptr<TrackedCallback> callback) OVERRIDE; |
43 virtual int32_t Reset(PP_CompletionCallback callback) OVERRIDE; | 43 virtual int32_t Reset(scoped_refptr<TrackedCallback> callback) OVERRIDE; |
44 virtual void Destroy() OVERRIDE; | 44 virtual void Destroy() OVERRIDE; |
45 | 45 |
46 private: | 46 private: |
47 friend class PPB_VideoDecoder_Proxy; | 47 friend class PPB_VideoDecoder_Proxy; |
48 | 48 |
49 PluginDispatcher* GetDispatcher() const; | 49 PluginDispatcher* GetDispatcher() const; |
50 | 50 |
51 // Run the callbacks that were passed into the plugin interface. | 51 // Run the callbacks that were passed into the plugin interface. |
52 void FlushACK(int32_t result); | 52 void FlushACK(int32_t result); |
53 void ResetACK(int32_t result); | 53 void ResetACK(int32_t result); |
54 void EndOfBitstreamACK(int32_t buffer_id, int32_t result); | 54 void EndOfBitstreamACK(int32_t buffer_id, int32_t result); |
55 | 55 |
56 DISALLOW_COPY_AND_ASSIGN(VideoDecoder); | 56 DISALLOW_COPY_AND_ASSIGN(VideoDecoder); |
57 }; | 57 }; |
58 | 58 |
59 VideoDecoder::VideoDecoder(const HostResource& decoder) | 59 VideoDecoder::VideoDecoder(const HostResource& decoder) |
60 : PPB_VideoDecoder_Shared(decoder) { | 60 : PPB_VideoDecoder_Shared(decoder) { |
61 } | 61 } |
62 | 62 |
63 VideoDecoder::~VideoDecoder() { | 63 VideoDecoder::~VideoDecoder() { |
64 } | 64 } |
65 | 65 |
66 int32_t VideoDecoder::Decode( | 66 int32_t VideoDecoder::Decode( |
67 const PP_VideoBitstreamBuffer_Dev* bitstream_buffer, | 67 const PP_VideoBitstreamBuffer_Dev* bitstream_buffer, |
68 PP_CompletionCallback callback) { | 68 scoped_refptr<TrackedCallback> callback) { |
69 EnterResourceNoLock<PPB_Buffer_API> | 69 EnterResourceNoLock<PPB_Buffer_API> |
70 enter_buffer(bitstream_buffer->data, true); | 70 enter_buffer(bitstream_buffer->data, true); |
71 if (enter_buffer.failed()) | 71 if (enter_buffer.failed()) |
72 return PP_ERROR_BADRESOURCE; | 72 return PP_ERROR_BADRESOURCE; |
73 | 73 |
74 if (!SetBitstreamBufferCallback(bitstream_buffer->id, callback)) | 74 if (!SetBitstreamBufferCallback(bitstream_buffer->id, callback)) |
75 return PP_ERROR_BADARGUMENT; | 75 return PP_ERROR_BADARGUMENT; |
76 | 76 |
77 Buffer* ppb_buffer = | 77 Buffer* ppb_buffer = |
78 static_cast<Buffer*>(enter_buffer.object()); | 78 static_cast<Buffer*>(enter_buffer.object()); |
(...skipping 16 matching lines...) Expand all Loading... |
95 new PpapiHostMsg_PPBVideoDecoder_AssignPictureBuffers( | 95 new PpapiHostMsg_PPBVideoDecoder_AssignPictureBuffers( |
96 API_ID_PPB_VIDEO_DECODER_DEV, host_resource(), buffer_list)); | 96 API_ID_PPB_VIDEO_DECODER_DEV, host_resource(), buffer_list)); |
97 } | 97 } |
98 | 98 |
99 void VideoDecoder::ReusePictureBuffer(int32_t picture_buffer_id) { | 99 void VideoDecoder::ReusePictureBuffer(int32_t picture_buffer_id) { |
100 FlushCommandBuffer(); | 100 FlushCommandBuffer(); |
101 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoDecoder_ReusePictureBuffer( | 101 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoDecoder_ReusePictureBuffer( |
102 API_ID_PPB_VIDEO_DECODER_DEV, host_resource(), picture_buffer_id)); | 102 API_ID_PPB_VIDEO_DECODER_DEV, host_resource(), picture_buffer_id)); |
103 } | 103 } |
104 | 104 |
105 int32_t VideoDecoder::Flush(PP_CompletionCallback callback) { | 105 int32_t VideoDecoder::Flush(scoped_refptr<TrackedCallback> callback) { |
106 if (!SetFlushCallback(callback)) | 106 if (!SetFlushCallback(callback)) |
107 return PP_ERROR_INPROGRESS; | 107 return PP_ERROR_INPROGRESS; |
108 | 108 |
109 FlushCommandBuffer(); | 109 FlushCommandBuffer(); |
110 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoDecoder_Flush( | 110 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoDecoder_Flush( |
111 API_ID_PPB_VIDEO_DECODER_DEV, host_resource())); | 111 API_ID_PPB_VIDEO_DECODER_DEV, host_resource())); |
112 return PP_OK_COMPLETIONPENDING; | 112 return PP_OK_COMPLETIONPENDING; |
113 } | 113 } |
114 | 114 |
115 int32_t VideoDecoder::Reset(PP_CompletionCallback callback) { | 115 int32_t VideoDecoder::Reset(scoped_refptr<TrackedCallback> callback) { |
116 if (!SetResetCallback(callback)) | 116 if (!SetResetCallback(callback)) |
117 return PP_ERROR_INPROGRESS; | 117 return PP_ERROR_INPROGRESS; |
118 | 118 |
119 FlushCommandBuffer(); | 119 FlushCommandBuffer(); |
120 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoDecoder_Reset( | 120 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoDecoder_Reset( |
121 API_ID_PPB_VIDEO_DECODER_DEV, host_resource())); | 121 API_ID_PPB_VIDEO_DECODER_DEV, host_resource())); |
122 return PP_OK_COMPLETIONPENDING; | 122 return PP_OK_COMPLETIONPENDING; |
123 } | 123 } |
124 | 124 |
125 void VideoDecoder::Destroy() { | 125 void VideoDecoder::Destroy() { |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 | 306 |
307 void PPB_VideoDecoder_Proxy::OnMsgResetACK( | 307 void PPB_VideoDecoder_Proxy::OnMsgResetACK( |
308 const HostResource& decoder, int32_t result) { | 308 const HostResource& decoder, int32_t result) { |
309 EnterPluginFromHostResource<PPB_VideoDecoder_API> enter(decoder); | 309 EnterPluginFromHostResource<PPB_VideoDecoder_API> enter(decoder); |
310 if (enter.succeeded()) | 310 if (enter.succeeded()) |
311 static_cast<VideoDecoder*>(enter.object())->ResetACK(result); | 311 static_cast<VideoDecoder*>(enter.object())->ResetACK(result); |
312 } | 312 } |
313 | 313 |
314 } // namespace proxy | 314 } // namespace proxy |
315 } // namespace ppapi | 315 } // namespace ppapi |
OLD | NEW |