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