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 PPB_VideoDecoder_Proxy::PPB_VideoDecoder_Proxy(Dispatcher* dispatcher) | 157 namespace { |
158 : InterfaceProxy(dispatcher), | 158 |
| 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), |
159 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 169 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
160 } | 170 } |
161 | 171 |
162 PPB_VideoDecoder_Proxy::~PPB_VideoDecoder_Proxy() { | 172 PPB_VideoDecoder_Proxy::~PPB_VideoDecoder_Proxy() { |
163 } | 173 } |
164 | 174 |
| 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 |
165 bool PPB_VideoDecoder_Proxy::OnMessageReceived(const IPC::Message& msg) { | 187 bool PPB_VideoDecoder_Proxy::OnMessageReceived(const IPC::Message& msg) { |
166 bool handled = true; | 188 bool handled = true; |
167 IPC_BEGIN_MESSAGE_MAP(PPB_VideoDecoder_Proxy, msg) | 189 IPC_BEGIN_MESSAGE_MAP(PPB_VideoDecoder_Proxy, msg) |
168 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoDecoder_Create, | 190 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoDecoder_Create, |
169 OnMsgCreate) | 191 OnMsgCreate) |
170 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoDecoder_Decode, OnMsgDecode) | 192 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoDecoder_Decode, OnMsgDecode) |
171 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoDecoder_AssignPictureBuffers, | 193 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoDecoder_AssignPictureBuffers, |
172 OnMsgAssignPictureBuffers) | 194 OnMsgAssignPictureBuffers) |
173 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoDecoder_ReusePictureBuffer, | 195 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoDecoder_ReusePictureBuffer, |
174 OnMsgReusePictureBuffer) | 196 OnMsgReusePictureBuffer) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 // Need a scoped_refptr to keep the object alive during the Init call. | 245 // Need a scoped_refptr to keep the object alive during the Init call. |
224 scoped_refptr<VideoDecoder> decoder(new VideoDecoder(result)); | 246 scoped_refptr<VideoDecoder> decoder(new VideoDecoder(result)); |
225 decoder->InitCommon(graphics_context, gles2_impl); | 247 decoder->InitCommon(graphics_context, gles2_impl); |
226 return decoder->GetReference(); | 248 return decoder->GetReference(); |
227 } | 249 } |
228 | 250 |
229 void PPB_VideoDecoder_Proxy::OnMsgCreate( | 251 void PPB_VideoDecoder_Proxy::OnMsgCreate( |
230 PP_Instance instance, const HostResource& graphics_context, | 252 PP_Instance instance, const HostResource& graphics_context, |
231 PP_VideoDecoder_Profile profile, | 253 PP_VideoDecoder_Profile profile, |
232 HostResource* result) { | 254 HostResource* result) { |
233 thunk::EnterResourceCreation resource_creation(instance); | 255 thunk::EnterFunction<thunk::ResourceCreationAPI> resource_creation(instance, |
| 256 true); |
234 if (resource_creation.failed()) | 257 if (resource_creation.failed()) |
235 return; | 258 return; |
236 | 259 |
237 // Make the resource and get the API pointer to its interface. | 260 // Make the resource and get the API pointer to its interface. |
238 result->SetHostResource( | 261 result->SetHostResource( |
239 instance, resource_creation.functions()->CreateVideoDecoder( | 262 instance, resource_creation.functions()->CreateVideoDecoder( |
240 instance, graphics_context.host_resource(), profile)); | 263 instance, graphics_context.host_resource(), profile)); |
241 } | 264 } |
242 | 265 |
243 void PPB_VideoDecoder_Proxy::OnMsgDecode( | 266 void PPB_VideoDecoder_Proxy::OnMsgDecode( |
244 const HostResource& decoder, | 267 const HostResource& decoder, |
245 const HostResource& buffer, int32 id, int32 size) { | 268 const HostResource& buffer, int32 id, int32 size) { |
246 EnterHostFromHostResourceForceCallback<PPB_VideoDecoder_API> enter( | 269 pp::CompletionCallback callback = callback_factory_.NewRequiredCallback( |
247 decoder, callback_factory_, | |
248 &PPB_VideoDecoder_Proxy::SendMsgEndOfBitstreamACKToPlugin, decoder, id); | 270 &PPB_VideoDecoder_Proxy::SendMsgEndOfBitstreamACKToPlugin, decoder, id); |
249 if (enter.failed()) | 271 |
250 return; | |
251 PP_VideoBitstreamBuffer_Dev bitstream = { id, buffer.host_resource(), size }; | 272 PP_VideoBitstreamBuffer_Dev bitstream = { id, buffer.host_resource(), size }; |
252 enter.SetResult(enter.object()->Decode(&bitstream, enter.callback())); | 273 ppb_video_decoder_target()->Decode( |
| 274 decoder.host_resource(), &bitstream, callback.pp_completion_callback()); |
253 } | 275 } |
254 | 276 |
255 void PPB_VideoDecoder_Proxy::OnMsgAssignPictureBuffers( | 277 void PPB_VideoDecoder_Proxy::OnMsgAssignPictureBuffers( |
256 const HostResource& decoder, | 278 const HostResource& decoder, |
257 const std::vector<PP_PictureBuffer_Dev>& buffers) { | 279 const std::vector<PP_PictureBuffer_Dev>& buffers) { |
258 EnterHostFromHostResource<PPB_VideoDecoder_API> enter(decoder); | 280 DCHECK(!buffers.empty()); |
259 if (enter.succeeded() && !buffers.empty()) { | 281 const PP_PictureBuffer_Dev* buffer_array = &buffers.front(); |
260 const PP_PictureBuffer_Dev* buffer_array = &buffers.front(); | 282 |
261 enter.object()->AssignPictureBuffers(buffers.size(), buffer_array); | 283 ppb_video_decoder_target()->AssignPictureBuffers( |
262 } | 284 decoder.host_resource(), buffers.size(), buffer_array); |
263 } | 285 } |
264 | 286 |
265 void PPB_VideoDecoder_Proxy::OnMsgReusePictureBuffer( | 287 void PPB_VideoDecoder_Proxy::OnMsgReusePictureBuffer( |
266 const HostResource& decoder, int32 picture_buffer_id) { | 288 const HostResource& decoder, int32 picture_buffer_id) { |
267 EnterHostFromHostResource<PPB_VideoDecoder_API> enter(decoder); | 289 ppb_video_decoder_target()->ReusePictureBuffer( |
268 if (enter.succeeded()) | 290 decoder.host_resource(), picture_buffer_id); |
269 enter.object()->ReusePictureBuffer(picture_buffer_id); | |
270 } | 291 } |
271 | 292 |
272 void PPB_VideoDecoder_Proxy::OnMsgFlush(const HostResource& decoder) { | 293 void PPB_VideoDecoder_Proxy::OnMsgFlush(const HostResource& decoder) { |
273 EnterHostFromHostResourceForceCallback<PPB_VideoDecoder_API> enter( | 294 pp::CompletionCallback callback = callback_factory_.NewRequiredCallback( |
274 decoder, callback_factory_, | |
275 &PPB_VideoDecoder_Proxy::SendMsgFlushACKToPlugin, decoder); | 295 &PPB_VideoDecoder_Proxy::SendMsgFlushACKToPlugin, decoder); |
276 if (enter.succeeded()) | 296 ppb_video_decoder_target()->Flush( |
277 enter.SetResult(enter.object()->Flush(enter.callback())); | 297 decoder.host_resource(), callback.pp_completion_callback()); |
278 } | 298 } |
279 | 299 |
280 void PPB_VideoDecoder_Proxy::OnMsgReset(const HostResource& decoder) { | 300 void PPB_VideoDecoder_Proxy::OnMsgReset(const HostResource& decoder) { |
281 EnterHostFromHostResourceForceCallback<PPB_VideoDecoder_API> enter( | 301 pp::CompletionCallback callback = callback_factory_.NewRequiredCallback( |
282 decoder, callback_factory_, | |
283 &PPB_VideoDecoder_Proxy::SendMsgResetACKToPlugin, decoder); | 302 &PPB_VideoDecoder_Proxy::SendMsgResetACKToPlugin, decoder); |
284 if (enter.succeeded()) | 303 ppb_video_decoder_target()->Reset( |
285 enter.SetResult(enter.object()->Reset(enter.callback())); | 304 decoder.host_resource(), callback.pp_completion_callback()); |
286 } | 305 } |
287 | 306 |
288 void PPB_VideoDecoder_Proxy::OnMsgDestroy(const HostResource& decoder) { | 307 void PPB_VideoDecoder_Proxy::OnMsgDestroy(const HostResource& decoder) { |
289 EnterHostFromHostResource<PPB_VideoDecoder_API> enter(decoder); | 308 ppb_video_decoder_target()->Destroy(decoder.host_resource()); |
290 if (enter.succeeded()) | |
291 enter.object()->Destroy(); | |
292 } | 309 } |
293 | 310 |
294 void PPB_VideoDecoder_Proxy::SendMsgEndOfBitstreamACKToPlugin( | 311 void PPB_VideoDecoder_Proxy::SendMsgEndOfBitstreamACKToPlugin( |
295 int32_t result, const HostResource& decoder, int32 id) { | 312 int32_t result, const HostResource& decoder, int32 id) { |
296 dispatcher()->Send(new PpapiMsg_PPBVideoDecoder_EndOfBitstreamACK( | 313 dispatcher()->Send(new PpapiMsg_PPBVideoDecoder_EndOfBitstreamACK( |
297 INTERFACE_ID_PPB_VIDEO_DECODER_DEV, decoder, id, result)); | 314 INTERFACE_ID_PPB_VIDEO_DECODER_DEV, decoder, id, result)); |
298 } | 315 } |
299 | 316 |
300 void PPB_VideoDecoder_Proxy::SendMsgFlushACKToPlugin( | 317 void PPB_VideoDecoder_Proxy::SendMsgFlushACKToPlugin( |
301 int32_t result, const HostResource& decoder) { | 318 int32_t result, const HostResource& decoder) { |
(...skipping 23 matching lines...) Expand all Loading... |
325 | 342 |
326 void PPB_VideoDecoder_Proxy::OnMsgResetACK( | 343 void PPB_VideoDecoder_Proxy::OnMsgResetACK( |
327 const HostResource& decoder, int32_t result) { | 344 const HostResource& decoder, int32_t result) { |
328 EnterPluginFromHostResource<PPB_VideoDecoder_API> enter(decoder); | 345 EnterPluginFromHostResource<PPB_VideoDecoder_API> enter(decoder); |
329 if (enter.succeeded()) | 346 if (enter.succeeded()) |
330 static_cast<VideoDecoder*>(enter.object())->ResetACK(result); | 347 static_cast<VideoDecoder*>(enter.object())->ResetACK(result); |
331 } | 348 } |
332 | 349 |
333 } // namespace proxy | 350 } // namespace proxy |
334 } // namespace ppapi | 351 } // namespace ppapi |
OLD | NEW |