[email protected] | aed9653 | 2012-06-23 14:27:42 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "ppapi/proxy/ppb_video_decoder_proxy.h" |
| 6 | |
| 7 | #include "base/logging.h" |
avi | e029c413 | 2015-12-23 06:45:22 | [diff] [blame] | 8 | #include "base/macros.h" |
brettw | 669d47b1 | 2015-02-13 21:17:38 | [diff] [blame] | 9 | #include "base/numerics/safe_conversions.h" |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 10 | #include "gpu/command_buffer/client/gles2_implementation.h" |
| 11 | #include "ppapi/proxy/enter_proxy.h" |
| 12 | #include "ppapi/proxy/plugin_dispatcher.h" |
| 13 | #include "ppapi/proxy/ppapi_messages.h" |
| 14 | #include "ppapi/proxy/ppb_buffer_proxy.h" |
[email protected] | 1b2ec22e | 2011-08-30 00:48:33 | [diff] [blame] | 15 | #include "ppapi/proxy/ppb_graphics_3d_proxy.h" |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 16 | #include "ppapi/thunk/enter.h" |
| 17 | #include "ppapi/thunk/resource_creation_api.h" |
| 18 | #include "ppapi/thunk/thunk.h" |
| 19 | |
| 20 | using ppapi::thunk::EnterResourceNoLock; |
| 21 | using ppapi::thunk::PPB_Buffer_API; |
[email protected] | 1b2ec22e | 2011-08-30 00:48:33 | [diff] [blame] | 22 | using ppapi::thunk::PPB_Graphics3D_API; |
[email protected] | 4ba60db | 2014-05-06 07:08:19 | [diff] [blame] | 23 | using ppapi::thunk::PPB_VideoDecoder_Dev_API; |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 24 | |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 25 | namespace ppapi { |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 26 | namespace proxy { |
| 27 | |
[email protected] | 614888b | 2012-01-05 06:18:12 | [diff] [blame] | 28 | class VideoDecoder : public PPB_VideoDecoder_Shared { |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 29 | public: |
[email protected] | 7f8b26b | 2011-08-18 15:41:01 | [diff] [blame] | 30 | // You must call Init() before using this class. |
| 31 | explicit VideoDecoder(const HostResource& resource); |
nick | e478443 | 2015-04-23 14:01:48 | [diff] [blame] | 32 | ~VideoDecoder() override; |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 33 | |
| 34 | static VideoDecoder* Create(const HostResource& resource, |
[email protected] | 1b2ec22e | 2011-08-30 00:48:33 | [diff] [blame] | 35 | PP_Resource graphics_context, |
[email protected] | 2ffc31a | 2011-09-01 03:18:28 | [diff] [blame] | 36 | PP_VideoDecoder_Profile profile); |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 37 | |
[email protected] | 4ba60db | 2014-05-06 07:08:19 | [diff] [blame] | 38 | // PPB_VideoDecoder_Dev_API implementation. |
nick | e478443 | 2015-04-23 14:01:48 | [diff] [blame] | 39 | int32_t Decode(const PP_VideoBitstreamBuffer_Dev* bitstream_buffer, |
| 40 | scoped_refptr<TrackedCallback> callback) override; |
| 41 | void AssignPictureBuffers(uint32_t no_of_buffers, |
| 42 | const PP_PictureBuffer_Dev* buffers) override; |
| 43 | void ReusePictureBuffer(int32_t picture_buffer_id) override; |
| 44 | int32_t Flush(scoped_refptr<TrackedCallback> callback) override; |
| 45 | int32_t Reset(scoped_refptr<TrackedCallback> callback) override; |
| 46 | void Destroy() override; |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 47 | |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 48 | private: |
| 49 | friend class PPB_VideoDecoder_Proxy; |
[email protected] | 7f8b26b | 2011-08-18 15:41:01 | [diff] [blame] | 50 | |
| 51 | PluginDispatcher* GetDispatcher() const; |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 52 | |
| 53 | // Run the callbacks that were passed into the plugin interface. |
| 54 | void FlushACK(int32_t result); |
| 55 | void ResetACK(int32_t result); |
| 56 | void EndOfBitstreamACK(int32_t buffer_id, int32_t result); |
| 57 | |
| 58 | DISALLOW_COPY_AND_ASSIGN(VideoDecoder); |
| 59 | }; |
| 60 | |
[email protected] | 614888b | 2012-01-05 06:18:12 | [diff] [blame] | 61 | VideoDecoder::VideoDecoder(const HostResource& decoder) |
| 62 | : PPB_VideoDecoder_Shared(decoder) { |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | VideoDecoder::~VideoDecoder() { |
[email protected] | c1e77f1a | 2013-03-28 18:12:04 | [diff] [blame] | 66 | FlushCommandBuffer(); |
| 67 | PPB_VideoDecoder_Shared::Destroy(); |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 68 | } |
| 69 | |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 70 | int32_t VideoDecoder::Decode( |
| 71 | const PP_VideoBitstreamBuffer_Dev* bitstream_buffer, |
[email protected] | aed9653 | 2012-06-23 14:27:42 | [diff] [blame] | 72 | scoped_refptr<TrackedCallback> callback) { |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 73 | EnterResourceNoLock<PPB_Buffer_API> |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 74 | enter_buffer(bitstream_buffer->data, true); |
| 75 | if (enter_buffer.failed()) |
| 76 | return PP_ERROR_BADRESOURCE; |
| 77 | |
[email protected] | d527cdd8 | 2011-08-12 22:50:19 | [diff] [blame] | 78 | if (!SetBitstreamBufferCallback(bitstream_buffer->id, callback)) |
| 79 | return PP_ERROR_BADARGUMENT; |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 80 | |
| 81 | Buffer* ppb_buffer = |
| 82 | static_cast<Buffer*>(enter_buffer.object()); |
| 83 | HostResource host_buffer = ppb_buffer->host_resource(); |
| 84 | |
| 85 | FlushCommandBuffer(); |
| 86 | GetDispatcher()->Send(new PpapiHostMsg_PPBVideoDecoder_Decode( |
[email protected] | ac4b54d | 2011-10-20 23:09:28 | [diff] [blame] | 87 | API_ID_PPB_VIDEO_DECODER_DEV, host_resource(), |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 88 | host_buffer, bitstream_buffer->id, |
| 89 | bitstream_buffer->size)); |
| 90 | return PP_OK_COMPLETIONPENDING; |
| 91 | } |
| 92 | |
| 93 | void VideoDecoder::AssignPictureBuffers(uint32_t no_of_buffers, |
| 94 | const PP_PictureBuffer_Dev* buffers) { |
| 95 | std::vector<PP_PictureBuffer_Dev> buffer_list( |
| 96 | buffers, buffers + no_of_buffers); |
| 97 | FlushCommandBuffer(); |
| 98 | GetDispatcher()->Send( |
| 99 | new PpapiHostMsg_PPBVideoDecoder_AssignPictureBuffers( |
[email protected] | ac4b54d | 2011-10-20 23:09:28 | [diff] [blame] | 100 | API_ID_PPB_VIDEO_DECODER_DEV, host_resource(), buffer_list)); |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | void VideoDecoder::ReusePictureBuffer(int32_t picture_buffer_id) { |
| 104 | FlushCommandBuffer(); |
| 105 | GetDispatcher()->Send(new PpapiHostMsg_PPBVideoDecoder_ReusePictureBuffer( |
[email protected] | ac4b54d | 2011-10-20 23:09:28 | [diff] [blame] | 106 | API_ID_PPB_VIDEO_DECODER_DEV, host_resource(), picture_buffer_id)); |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 107 | } |
| 108 | |
[email protected] | aed9653 | 2012-06-23 14:27:42 | [diff] [blame] | 109 | int32_t VideoDecoder::Flush(scoped_refptr<TrackedCallback> callback) { |
[email protected] | d527cdd8 | 2011-08-12 22:50:19 | [diff] [blame] | 110 | if (!SetFlushCallback(callback)) |
| 111 | return PP_ERROR_INPROGRESS; |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 112 | |
| 113 | FlushCommandBuffer(); |
| 114 | GetDispatcher()->Send(new PpapiHostMsg_PPBVideoDecoder_Flush( |
[email protected] | ac4b54d | 2011-10-20 23:09:28 | [diff] [blame] | 115 | API_ID_PPB_VIDEO_DECODER_DEV, host_resource())); |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 116 | return PP_OK_COMPLETIONPENDING; |
| 117 | } |
| 118 | |
[email protected] | aed9653 | 2012-06-23 14:27:42 | [diff] [blame] | 119 | int32_t VideoDecoder::Reset(scoped_refptr<TrackedCallback> callback) { |
[email protected] | d527cdd8 | 2011-08-12 22:50:19 | [diff] [blame] | 120 | if (!SetResetCallback(callback)) |
| 121 | return PP_ERROR_INPROGRESS; |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 122 | |
| 123 | FlushCommandBuffer(); |
| 124 | GetDispatcher()->Send(new PpapiHostMsg_PPBVideoDecoder_Reset( |
[email protected] | ac4b54d | 2011-10-20 23:09:28 | [diff] [blame] | 125 | API_ID_PPB_VIDEO_DECODER_DEV, host_resource())); |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 126 | return PP_OK_COMPLETIONPENDING; |
| 127 | } |
| 128 | |
| 129 | void VideoDecoder::Destroy() { |
| 130 | FlushCommandBuffer(); |
| 131 | GetDispatcher()->Send(new PpapiHostMsg_PPBVideoDecoder_Destroy( |
[email protected] | ac4b54d | 2011-10-20 23:09:28 | [diff] [blame] | 132 | API_ID_PPB_VIDEO_DECODER_DEV, host_resource())); |
[email protected] | 9a57839 | 2011-12-07 18:59:27 | [diff] [blame] | 133 | PPB_VideoDecoder_Shared::Destroy(); |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 134 | } |
| 135 | |
[email protected] | 7f8b26b | 2011-08-18 15:41:01 | [diff] [blame] | 136 | PluginDispatcher* VideoDecoder::GetDispatcher() const { |
| 137 | return PluginDispatcher::GetForResource(this); |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | void VideoDecoder::ResetACK(int32_t result) { |
| 141 | RunResetCallback(result); |
| 142 | } |
| 143 | |
| 144 | void VideoDecoder::FlushACK(int32_t result) { |
| 145 | RunFlushCallback(result); |
| 146 | } |
| 147 | |
| 148 | void VideoDecoder::EndOfBitstreamACK( |
| 149 | int32_t bitstream_buffer_id, int32_t result) { |
| 150 | RunBitstreamBufferCallback(bitstream_buffer_id, result); |
| 151 | } |
| 152 | |
[email protected] | 5c96602 | 2011-09-13 18:09:37 | [diff] [blame] | 153 | PPB_VideoDecoder_Proxy::PPB_VideoDecoder_Proxy(Dispatcher* dispatcher) |
| 154 | : InterfaceProxy(dispatcher), |
[email protected] | a2f53dc | 2013-04-30 01:06:35 | [diff] [blame] | 155 | callback_factory_(this) { |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | PPB_VideoDecoder_Proxy::~PPB_VideoDecoder_Proxy() { |
| 159 | } |
| 160 | |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 161 | bool PPB_VideoDecoder_Proxy::OnMessageReceived(const IPC::Message& msg) { |
[email protected] | 17cd29a | 2012-11-15 20:43:23 | [diff] [blame] | 162 | if (!dispatcher()->permissions().HasPermission(PERMISSION_DEV)) |
| 163 | return false; |
| 164 | |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 165 | bool handled = true; |
| 166 | IPC_BEGIN_MESSAGE_MAP(PPB_VideoDecoder_Proxy, msg) |
| 167 | IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoDecoder_Create, |
| 168 | OnMsgCreate) |
| 169 | IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoDecoder_Decode, OnMsgDecode) |
| 170 | IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoDecoder_AssignPictureBuffers, |
| 171 | OnMsgAssignPictureBuffers) |
| 172 | IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoDecoder_ReusePictureBuffer, |
| 173 | OnMsgReusePictureBuffer) |
| 174 | IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoDecoder_Flush, OnMsgFlush) |
| 175 | IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoDecoder_Reset, OnMsgReset) |
| 176 | IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoDecoder_Destroy, OnMsgDestroy) |
| 177 | IPC_MESSAGE_HANDLER(PpapiMsg_PPBVideoDecoder_ResetACK, OnMsgResetACK) |
| 178 | IPC_MESSAGE_HANDLER(PpapiMsg_PPBVideoDecoder_EndOfBitstreamACK, |
| 179 | OnMsgEndOfBitstreamACK) |
| 180 | IPC_MESSAGE_HANDLER(PpapiMsg_PPBVideoDecoder_FlushACK, OnMsgFlushACK) |
| 181 | IPC_MESSAGE_UNHANDLED(handled = false) |
| 182 | IPC_END_MESSAGE_MAP() |
| 183 | DCHECK(handled); |
| 184 | return handled; |
| 185 | } |
| 186 | |
| 187 | PP_Resource PPB_VideoDecoder_Proxy::CreateProxyResource( |
[email protected] | 1b2ec22e | 2011-08-30 00:48:33 | [diff] [blame] | 188 | PP_Instance instance, |
| 189 | PP_Resource graphics_context, |
[email protected] | 2ffc31a | 2011-09-01 03:18:28 | [diff] [blame] | 190 | PP_VideoDecoder_Profile profile) { |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 191 | PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
| 192 | // Dispatcher is null if it cannot find the instance passed to it (i.e. if the |
| 193 | // client passes in an invalid instance). |
| 194 | if (!dispatcher) |
| 195 | return 0; |
| 196 | |
[email protected] | 6013c79 | 2014-03-07 00:18:33 | [diff] [blame] | 197 | if (!dispatcher->preferences().is_accelerated_video_decode_enabled) |
| 198 | return 0; |
| 199 | |
[email protected] | 88cc7818 | 2011-12-01 06:47:09 | [diff] [blame] | 200 | EnterResourceNoLock<PPB_Graphics3D_API> enter_context(graphics_context, |
| 201 | true); |
| 202 | if (enter_context.failed()) |
| 203 | return 0; |
[email protected] | 1b2ec22e | 2011-08-30 00:48:33 | [diff] [blame] | 204 | |
[email protected] | 88cc7818 | 2011-12-01 06:47:09 | [diff] [blame] | 205 | Graphics3D* context = static_cast<Graphics3D*>(enter_context.object()); |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 206 | |
| 207 | HostResource result; |
| 208 | dispatcher->Send(new PpapiHostMsg_PPBVideoDecoder_Create( |
[email protected] | ac4b54d | 2011-10-20 23:09:28 | [diff] [blame] | 209 | API_ID_PPB_VIDEO_DECODER_DEV, instance, |
[email protected] | 88cc7818 | 2011-12-01 06:47:09 | [diff] [blame] | 210 | context->host_resource(), profile, &result)); |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 211 | if (result.is_null()) |
| 212 | return 0; |
| 213 | |
[email protected] | 7f8b26b | 2011-08-18 15:41:01 | [diff] [blame] | 214 | // Need a scoped_refptr to keep the object alive during the Init call. |
| 215 | scoped_refptr<VideoDecoder> decoder(new VideoDecoder(result)); |
[email protected] | 88cc7818 | 2011-12-01 06:47:09 | [diff] [blame] | 216 | decoder->InitCommon(graphics_context, context->gles2_impl()); |
[email protected] | 7f8b26b | 2011-08-18 15:41:01 | [diff] [blame] | 217 | return decoder->GetReference(); |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | void PPB_VideoDecoder_Proxy::OnMsgCreate( |
[email protected] | 1b2ec22e | 2011-08-30 00:48:33 | [diff] [blame] | 221 | PP_Instance instance, const HostResource& graphics_context, |
[email protected] | 2ffc31a | 2011-09-01 03:18:28 | [diff] [blame] | 222 | PP_VideoDecoder_Profile profile, |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 223 | HostResource* result) { |
[email protected] | 5c96602 | 2011-09-13 18:09:37 | [diff] [blame] | 224 | thunk::EnterResourceCreation resource_creation(instance); |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 225 | if (resource_creation.failed()) |
| 226 | return; |
| 227 | |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 228 | // Make the resource and get the API pointer to its interface. |
| 229 | result->SetHostResource( |
[email protected] | 4ba60db | 2014-05-06 07:08:19 | [diff] [blame] | 230 | instance, resource_creation.functions()->CreateVideoDecoderDev( |
[email protected] | 2ffc31a | 2011-09-01 03:18:28 | [diff] [blame] | 231 | instance, graphics_context.host_resource(), profile)); |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 232 | } |
| 233 | |
avi | e029c413 | 2015-12-23 06:45:22 | [diff] [blame] | 234 | void PPB_VideoDecoder_Proxy::OnMsgDecode(const HostResource& decoder, |
| 235 | const HostResource& buffer, |
| 236 | int32_t id, |
| 237 | uint32_t size) { |
[email protected] | 4ba60db | 2014-05-06 07:08:19 | [diff] [blame] | 238 | EnterHostFromHostResourceForceCallback<PPB_VideoDecoder_Dev_API> enter( |
[email protected] | 5c96602 | 2011-09-13 18:09:37 | [diff] [blame] | 239 | decoder, callback_factory_, |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 240 | &PPB_VideoDecoder_Proxy::SendMsgEndOfBitstreamACKToPlugin, decoder, id); |
[email protected] | 5c96602 | 2011-09-13 18:09:37 | [diff] [blame] | 241 | if (enter.failed()) |
| 242 | return; |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 243 | PP_VideoBitstreamBuffer_Dev bitstream = { id, buffer.host_resource(), size }; |
[email protected] | 5c96602 | 2011-09-13 18:09:37 | [diff] [blame] | 244 | enter.SetResult(enter.object()->Decode(&bitstream, enter.callback())); |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | void PPB_VideoDecoder_Proxy::OnMsgAssignPictureBuffers( |
| 248 | const HostResource& decoder, |
| 249 | const std::vector<PP_PictureBuffer_Dev>& buffers) { |
[email protected] | 4ba60db | 2014-05-06 07:08:19 | [diff] [blame] | 250 | EnterHostFromHostResource<PPB_VideoDecoder_Dev_API> enter(decoder); |
[email protected] | 5c96602 | 2011-09-13 18:09:37 | [diff] [blame] | 251 | if (enter.succeeded() && !buffers.empty()) { |
| 252 | const PP_PictureBuffer_Dev* buffer_array = &buffers.front(); |
brettw | 669d47b1 | 2015-02-13 21:17:38 | [diff] [blame] | 253 | enter.object()->AssignPictureBuffers( |
| 254 | base::checked_cast<uint32_t>(buffers.size()), buffer_array); |
[email protected] | 5c96602 | 2011-09-13 18:09:37 | [diff] [blame] | 255 | } |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 256 | } |
| 257 | |
| 258 | void PPB_VideoDecoder_Proxy::OnMsgReusePictureBuffer( |
avi | e029c413 | 2015-12-23 06:45:22 | [diff] [blame] | 259 | const HostResource& decoder, |
| 260 | int32_t picture_buffer_id) { |
[email protected] | 4ba60db | 2014-05-06 07:08:19 | [diff] [blame] | 261 | EnterHostFromHostResource<PPB_VideoDecoder_Dev_API> enter(decoder); |
[email protected] | 5c96602 | 2011-09-13 18:09:37 | [diff] [blame] | 262 | if (enter.succeeded()) |
| 263 | enter.object()->ReusePictureBuffer(picture_buffer_id); |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | void PPB_VideoDecoder_Proxy::OnMsgFlush(const HostResource& decoder) { |
[email protected] | 4ba60db | 2014-05-06 07:08:19 | [diff] [blame] | 267 | EnterHostFromHostResourceForceCallback<PPB_VideoDecoder_Dev_API> enter( |
[email protected] | 5c96602 | 2011-09-13 18:09:37 | [diff] [blame] | 268 | decoder, callback_factory_, |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 269 | &PPB_VideoDecoder_Proxy::SendMsgFlushACKToPlugin, decoder); |
[email protected] | 5c96602 | 2011-09-13 18:09:37 | [diff] [blame] | 270 | if (enter.succeeded()) |
| 271 | enter.SetResult(enter.object()->Flush(enter.callback())); |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | void PPB_VideoDecoder_Proxy::OnMsgReset(const HostResource& decoder) { |
[email protected] | 4ba60db | 2014-05-06 07:08:19 | [diff] [blame] | 275 | EnterHostFromHostResourceForceCallback<PPB_VideoDecoder_Dev_API> enter( |
[email protected] | 5c96602 | 2011-09-13 18:09:37 | [diff] [blame] | 276 | decoder, callback_factory_, |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 277 | &PPB_VideoDecoder_Proxy::SendMsgResetACKToPlugin, decoder); |
[email protected] | 5c96602 | 2011-09-13 18:09:37 | [diff] [blame] | 278 | if (enter.succeeded()) |
| 279 | enter.SetResult(enter.object()->Reset(enter.callback())); |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | void PPB_VideoDecoder_Proxy::OnMsgDestroy(const HostResource& decoder) { |
[email protected] | 4ba60db | 2014-05-06 07:08:19 | [diff] [blame] | 283 | EnterHostFromHostResource<PPB_VideoDecoder_Dev_API> enter(decoder); |
[email protected] | 5c96602 | 2011-09-13 18:09:37 | [diff] [blame] | 284 | if (enter.succeeded()) |
| 285 | enter.object()->Destroy(); |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | void PPB_VideoDecoder_Proxy::SendMsgEndOfBitstreamACKToPlugin( |
avi | e029c413 | 2015-12-23 06:45:22 | [diff] [blame] | 289 | int32_t result, |
| 290 | const HostResource& decoder, |
| 291 | int32_t id) { |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 292 | dispatcher()->Send(new PpapiMsg_PPBVideoDecoder_EndOfBitstreamACK( |
[email protected] | ac4b54d | 2011-10-20 23:09:28 | [diff] [blame] | 293 | API_ID_PPB_VIDEO_DECODER_DEV, decoder, id, result)); |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 294 | } |
| 295 | |
| 296 | void PPB_VideoDecoder_Proxy::SendMsgFlushACKToPlugin( |
| 297 | int32_t result, const HostResource& decoder) { |
| 298 | dispatcher()->Send(new PpapiMsg_PPBVideoDecoder_FlushACK( |
[email protected] | ac4b54d | 2011-10-20 23:09:28 | [diff] [blame] | 299 | API_ID_PPB_VIDEO_DECODER_DEV, decoder, result)); |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | void PPB_VideoDecoder_Proxy::SendMsgResetACKToPlugin( |
| 303 | int32_t result, const HostResource& decoder) { |
| 304 | dispatcher()->Send(new PpapiMsg_PPBVideoDecoder_ResetACK( |
[email protected] | ac4b54d | 2011-10-20 23:09:28 | [diff] [blame] | 305 | API_ID_PPB_VIDEO_DECODER_DEV, decoder, result)); |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 306 | } |
| 307 | |
| 308 | void PPB_VideoDecoder_Proxy::OnMsgEndOfBitstreamACK( |
| 309 | const HostResource& decoder, int32_t id, int32_t result) { |
[email protected] | 4ba60db | 2014-05-06 07:08:19 | [diff] [blame] | 310 | EnterPluginFromHostResource<PPB_VideoDecoder_Dev_API> enter(decoder); |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 311 | if (enter.succeeded()) |
| 312 | static_cast<VideoDecoder*>(enter.object())->EndOfBitstreamACK(id, result); |
| 313 | } |
| 314 | |
| 315 | void PPB_VideoDecoder_Proxy::OnMsgFlushACK( |
| 316 | const HostResource& decoder, int32_t result) { |
[email protected] | 4ba60db | 2014-05-06 07:08:19 | [diff] [blame] | 317 | EnterPluginFromHostResource<PPB_VideoDecoder_Dev_API> enter(decoder); |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 318 | if (enter.succeeded()) |
| 319 | static_cast<VideoDecoder*>(enter.object())->FlushACK(result); |
| 320 | } |
| 321 | |
| 322 | void PPB_VideoDecoder_Proxy::OnMsgResetACK( |
| 323 | const HostResource& decoder, int32_t result) { |
[email protected] | 4ba60db | 2014-05-06 07:08:19 | [diff] [blame] | 324 | EnterPluginFromHostResource<PPB_VideoDecoder_Dev_API> enter(decoder); |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 325 | if (enter.succeeded()) |
| 326 | static_cast<VideoDecoder*>(enter.object())->ResetACK(result); |
| 327 | } |
| 328 | |
| 329 | } // namespace proxy |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 330 | } // namespace ppapi |