• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
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"
11 
12 namespace ppapi {
13 namespace thunk {
14 
15 namespace {
16 
17 typedef EnterResource<PPB_VideoDecoder_Dev_API> EnterVideoDecoder;
18 
Create(PP_Instance instance,PP_Resource graphics_3d,PP_VideoDecoder_Profile profile)19 PP_Resource Create(PP_Instance instance,
20                    PP_Resource graphics_3d,
21                    PP_VideoDecoder_Profile profile) {
22   EnterResourceCreation enter(instance);
23   if (enter.failed())
24     return 0;
25   return enter.functions()->CreateVideoDecoderDev(
26       instance, graphics_3d, profile);
27 }
28 
IsVideoDecoder(PP_Resource resource)29 PP_Bool IsVideoDecoder(PP_Resource resource) {
30   EnterVideoDecoder enter(resource, false);
31   return PP_FromBool(enter.succeeded());
32 }
33 
Decode(PP_Resource video_decoder,const PP_VideoBitstreamBuffer_Dev * bitstream_buffer,PP_CompletionCallback callback)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);
38   if (enter.failed())
39     return enter.retval();
40   return enter.SetResult(
41       enter.object()->Decode(bitstream_buffer, enter.callback()));
42 }
43 
AssignPictureBuffers(PP_Resource video_decoder,uint32_t no_of_buffers,const PP_PictureBuffer_Dev * buffers)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);
50 }
51 
ReusePictureBuffer(PP_Resource video_decoder,int32_t picture_buffer_id)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);
56 }
57 
Flush(PP_Resource video_decoder,PP_CompletionCallback callback)58 int32_t Flush(PP_Resource video_decoder, PP_CompletionCallback callback) {
59   EnterVideoDecoder enter(video_decoder, callback, true);
60   if (enter.failed())
61     return enter.retval();
62   return enter.SetResult(enter.object()->Flush(enter.callback()));
63 }
64 
Reset(PP_Resource video_decoder,PP_CompletionCallback callback)65 int32_t Reset(PP_Resource video_decoder, PP_CompletionCallback callback) {
66   EnterVideoDecoder enter(video_decoder, callback, true);
67   if (enter.failed())
68     return enter.retval();
69   return enter.SetResult(enter.object()->Reset(enter.callback()));
70 }
71 
Destroy(PP_Resource video_decoder)72 void Destroy(PP_Resource video_decoder) {
73   EnterVideoDecoder enter(video_decoder, true);
74   if (enter.succeeded())
75     enter.object()->Destroy();
76 }
77 
78 const PPB_VideoDecoder_Dev g_ppb_videodecoder_dev_thunk = {
79   &Create,
80   &IsVideoDecoder,
81   &Decode,
82   &AssignPictureBuffers,
83   &ReusePictureBuffer,
84   &Flush,
85   &Reset,
86   &Destroy
87 };
88 
89 }  // namespace
90 
GetPPB_VideoDecoder_Dev_0_16_Thunk()91 const PPB_VideoDecoder_Dev_0_16* GetPPB_VideoDecoder_Dev_0_16_Thunk() {
92   return &g_ppb_videodecoder_dev_thunk;
93 }
94 
95 }  // namespace thunk
96 }  // namespace ppapi
97