1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ppapi/c/pp_errors.h"
6 #include "ppapi/shared_impl/tracked_callback.h"
7 #include "ppapi/thunk/enter.h"
8 #include "ppapi/thunk/ppb_video_decoder_dev_api.h"
9 #include "ppapi/thunk/resource_creation_api.h"
10 #include "ppapi/thunk/thunk.h"
17 typedef EnterResource
<PPB_VideoDecoder_Dev_API
> EnterVideoDecoder
;
19 PP_Resource
Create(PP_Instance instance
,
20 PP_Resource graphics_3d
,
21 PP_VideoDecoder_Profile profile
) {
22 EnterResourceCreation
enter(instance
);
25 return enter
.functions()->CreateVideoDecoderDev(
26 instance
, graphics_3d
, profile
);
29 PP_Bool
IsVideoDecoder(PP_Resource resource
) {
30 EnterVideoDecoder
enter(resource
, false);
31 return PP_FromBool(enter
.succeeded());
34 int32_t Decode(PP_Resource video_decoder
,
35 const PP_VideoBitstreamBuffer_Dev
* bitstream_buffer
,
36 PP_CompletionCallback callback
) {
37 EnterVideoDecoder
enter(video_decoder
, callback
, true);
39 return enter
.retval();
40 return enter
.SetResult(
41 enter
.object()->Decode(bitstream_buffer
, enter
.callback()));
44 void AssignPictureBuffers(PP_Resource video_decoder
,
45 uint32_t no_of_buffers
,
46 const PP_PictureBuffer_Dev
* buffers
) {
47 EnterVideoDecoder
enter(video_decoder
, true);
48 if (enter
.succeeded())
49 enter
.object()->AssignPictureBuffers(no_of_buffers
, buffers
);
52 void ReusePictureBuffer(PP_Resource video_decoder
, int32_t picture_buffer_id
) {
53 EnterVideoDecoder
enter(video_decoder
, true);
54 if (enter
.succeeded())
55 enter
.object()->ReusePictureBuffer(picture_buffer_id
);
58 int32_t Flush(PP_Resource video_decoder
, PP_CompletionCallback callback
) {
59 EnterVideoDecoder
enter(video_decoder
, callback
, true);
61 return enter
.retval();
62 return enter
.SetResult(enter
.object()->Flush(enter
.callback()));
65 int32_t Reset(PP_Resource video_decoder
, PP_CompletionCallback callback
) {
66 EnterVideoDecoder
enter(video_decoder
, callback
, true);
68 return enter
.retval();
69 return enter
.SetResult(enter
.object()->Reset(enter
.callback()));
72 void Destroy(PP_Resource video_decoder
) {
73 EnterVideoDecoder
enter(video_decoder
, true);
74 if (enter
.succeeded())
75 enter
.object()->Destroy();
78 const PPB_VideoDecoder_Dev g_ppb_videodecoder_dev_thunk
= {
82 &AssignPictureBuffers
,
91 const PPB_VideoDecoder_Dev_0_16
* GetPPB_VideoDecoder_Dev_0_16_Thunk() {
92 return &g_ppb_videodecoder_dev_thunk
;