1 // Copyright (c) 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 // From ppb_video_decoder.idl modified Mon Sep 8 16:40:15 2014. 6 7 #include "ppapi/c/pp_completion_callback.h" 8 #include "ppapi/c/pp_errors.h" 9 #include "ppapi/c/ppb_video_decoder.h" 10 #include "ppapi/shared_impl/tracked_callback.h" 11 #include "ppapi/thunk/enter.h" 12 #include "ppapi/thunk/ppapi_thunk_export.h" 13 #include "ppapi/thunk/ppb_video_decoder_api.h" 14 15 namespace ppapi { 16 namespace thunk { 17 18 namespace { 19 20 PP_Resource Create(PP_Instance instance) { 21 VLOG(4) << "PPB_VideoDecoder::Create()"; 22 EnterResourceCreation enter(instance); 23 if (enter.failed()) 24 return 0; 25 return enter.functions()->CreateVideoDecoder(instance); 26 } 27 28 PP_Bool IsVideoDecoder(PP_Resource resource) { 29 VLOG(4) << "PPB_VideoDecoder::IsVideoDecoder()"; 30 EnterResource<PPB_VideoDecoder_API> enter(resource, false); 31 return PP_FromBool(enter.succeeded()); 32 } 33 34 int32_t Initialize_0_1(PP_Resource video_decoder, 35 PP_Resource graphics3d_context, 36 PP_VideoProfile profile, 37 PP_Bool allow_software_fallback, 38 struct PP_CompletionCallback callback) { 39 VLOG(4) << "PPB_VideoDecoder::Initialize()"; 40 EnterResource<PPB_VideoDecoder_API> enter(video_decoder, callback, true); 41 if (enter.failed()) 42 return enter.retval(); 43 return enter.SetResult(enter.object()->Initialize0_1(graphics3d_context, 44 profile, 45 allow_software_fallback, 46 enter.callback())); 47 } 48 49 int32_t Initialize(PP_Resource video_decoder, 50 PP_Resource graphics3d_context, 51 PP_VideoProfile profile, 52 PP_HardwareAcceleration acceleration, 53 struct PP_CompletionCallback callback) { 54 VLOG(4) << "PPB_VideoDecoder::Initialize()"; 55 EnterResource<PPB_VideoDecoder_API> enter(video_decoder, callback, true); 56 if (enter.failed()) 57 return enter.retval(); 58 return enter.SetResult(enter.object()->Initialize(graphics3d_context, 59 profile, 60 acceleration, 61 enter.callback())); 62 } 63 64 int32_t Decode(PP_Resource video_decoder, 65 uint32_t decode_id, 66 uint32_t size, 67 const void* buffer, 68 struct PP_CompletionCallback callback) { 69 VLOG(4) << "PPB_VideoDecoder::Decode()"; 70 EnterResource<PPB_VideoDecoder_API> enter(video_decoder, callback, true); 71 if (enter.failed()) 72 return enter.retval(); 73 return enter.SetResult(enter.object()->Decode(decode_id, 74 size, 75 buffer, 76 enter.callback())); 77 } 78 79 int32_t GetPicture(PP_Resource video_decoder, 80 struct PP_VideoPicture* picture, 81 struct PP_CompletionCallback callback) { 82 VLOG(4) << "PPB_VideoDecoder::GetPicture()"; 83 EnterResource<PPB_VideoDecoder_API> enter(video_decoder, callback, true); 84 if (enter.failed()) 85 return enter.retval(); 86 return enter.SetResult(enter.object()->GetPicture(picture, enter.callback())); 87 } 88 89 void RecyclePicture(PP_Resource video_decoder, 90 const struct PP_VideoPicture* picture) { 91 VLOG(4) << "PPB_VideoDecoder::RecyclePicture()"; 92 EnterResource<PPB_VideoDecoder_API> enter(video_decoder, true); 93 if (enter.failed()) 94 return; 95 enter.object()->RecyclePicture(picture); 96 } 97 98 int32_t Flush(PP_Resource video_decoder, 99 struct PP_CompletionCallback callback) { 100 VLOG(4) << "PPB_VideoDecoder::Flush()"; 101 EnterResource<PPB_VideoDecoder_API> enter(video_decoder, callback, true); 102 if (enter.failed()) 103 return enter.retval(); 104 return enter.SetResult(enter.object()->Flush(enter.callback())); 105 } 106 107 int32_t Reset(PP_Resource video_decoder, 108 struct PP_CompletionCallback callback) { 109 VLOG(4) << "PPB_VideoDecoder::Reset()"; 110 EnterResource<PPB_VideoDecoder_API> enter(video_decoder, callback, true); 111 if (enter.failed()) 112 return enter.retval(); 113 return enter.SetResult(enter.object()->Reset(enter.callback())); 114 } 115 116 const PPB_VideoDecoder_0_1 g_ppb_videodecoder_thunk_0_1 = { 117 &Create, 118 &IsVideoDecoder, 119 &Initialize_0_1, 120 &Decode, 121 &GetPicture, 122 &RecyclePicture, 123 &Flush, 124 &Reset 125 }; 126 127 const PPB_VideoDecoder_0_2 g_ppb_videodecoder_thunk_0_2 = { 128 &Create, 129 &IsVideoDecoder, 130 &Initialize, 131 &Decode, 132 &GetPicture, 133 &RecyclePicture, 134 &Flush, 135 &Reset 136 }; 137 138 } // namespace 139 140 PPAPI_THUNK_EXPORT const PPB_VideoDecoder_0_1* 141 GetPPB_VideoDecoder_0_1_Thunk() { 142 return &g_ppb_videodecoder_thunk_0_1; 143 } 144 145 PPAPI_THUNK_EXPORT const PPB_VideoDecoder_0_2* 146 GetPPB_VideoDecoder_0_2_Thunk() { 147 return &g_ppb_videodecoder_thunk_0_2; 148 } 149 150 } // namespace thunk 151 } // namespace ppapi 152