Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ppapi / thunk / ppb_video_decoder_thunk.cc
blob4039c3e6d312adfb260aa37b6f012cd119bce008
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.
5 // From ppb_video_decoder.idl modified Wed Aug 12 17:59:47 2015.
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"
15 namespace ppapi {
16 namespace thunk {
18 namespace {
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);
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());
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_0_1()";
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(
44 graphics3d_context, profile, allow_software_fallback, enter.callback()));
47 int32_t Initialize_0_2(PP_Resource video_decoder,
48 PP_Resource graphics3d_context,
49 PP_VideoProfile profile,
50 PP_HardwareAcceleration acceleration,
51 struct PP_CompletionCallback callback) {
52 VLOG(4) << "PPB_VideoDecoder::Initialize_0_2()";
53 EnterResource<PPB_VideoDecoder_API> enter(video_decoder, callback, true);
54 if (enter.failed())
55 return enter.retval();
56 return enter.SetResult(enter.object()->Initialize0_2(
57 graphics3d_context, profile, acceleration, enter.callback()));
60 int32_t Initialize(PP_Resource video_decoder,
61 PP_Resource graphics3d_context,
62 PP_VideoProfile profile,
63 PP_HardwareAcceleration acceleration,
64 uint32_t min_picture_count,
65 struct PP_CompletionCallback callback) {
66 VLOG(4) << "PPB_VideoDecoder::Initialize()";
67 EnterResource<PPB_VideoDecoder_API> enter(video_decoder, callback, true);
68 if (enter.failed())
69 return enter.retval();
70 return enter.SetResult(
71 enter.object()->Initialize(graphics3d_context, profile, acceleration,
72 min_picture_count, enter.callback()));
75 int32_t Decode(PP_Resource video_decoder,
76 uint32_t decode_id,
77 uint32_t size,
78 const void* buffer,
79 struct PP_CompletionCallback callback) {
80 VLOG(4) << "PPB_VideoDecoder::Decode()";
81 EnterResource<PPB_VideoDecoder_API> enter(video_decoder, callback, true);
82 if (enter.failed())
83 return enter.retval();
84 return enter.SetResult(
85 enter.object()->Decode(decode_id, size, buffer, enter.callback()));
88 int32_t GetPicture_0_1(PP_Resource video_decoder,
89 struct PP_VideoPicture_0_1* picture,
90 struct PP_CompletionCallback callback) {
91 VLOG(4) << "PPB_VideoDecoder::GetPicture_0_1()";
92 EnterResource<PPB_VideoDecoder_API> enter(video_decoder, callback, true);
93 if (enter.failed())
94 return enter.retval();
95 return enter.SetResult(
96 enter.object()->GetPicture0_1(picture, enter.callback()));
99 int32_t GetPicture(PP_Resource video_decoder,
100 struct PP_VideoPicture* picture,
101 struct PP_CompletionCallback callback) {
102 VLOG(4) << "PPB_VideoDecoder::GetPicture()";
103 EnterResource<PPB_VideoDecoder_API> enter(video_decoder, callback, true);
104 if (enter.failed())
105 return enter.retval();
106 return enter.SetResult(enter.object()->GetPicture(picture, enter.callback()));
109 void RecyclePicture(PP_Resource video_decoder,
110 const struct PP_VideoPicture* picture) {
111 VLOG(4) << "PPB_VideoDecoder::RecyclePicture()";
112 EnterResource<PPB_VideoDecoder_API> enter(video_decoder, true);
113 if (enter.failed())
114 return;
115 enter.object()->RecyclePicture(picture);
118 int32_t Flush(PP_Resource video_decoder,
119 struct PP_CompletionCallback callback) {
120 VLOG(4) << "PPB_VideoDecoder::Flush()";
121 EnterResource<PPB_VideoDecoder_API> enter(video_decoder, callback, true);
122 if (enter.failed())
123 return enter.retval();
124 return enter.SetResult(enter.object()->Flush(enter.callback()));
127 int32_t Reset(PP_Resource video_decoder,
128 struct PP_CompletionCallback callback) {
129 VLOG(4) << "PPB_VideoDecoder::Reset()";
130 EnterResource<PPB_VideoDecoder_API> enter(video_decoder, callback, true);
131 if (enter.failed())
132 return enter.retval();
133 return enter.SetResult(enter.object()->Reset(enter.callback()));
136 const PPB_VideoDecoder_0_1 g_ppb_videodecoder_thunk_0_1 = {
137 &Create, &IsVideoDecoder, &Initialize_0_1, &Decode,
138 &GetPicture_0_1, &RecyclePicture, &Flush, &Reset};
140 const PPB_VideoDecoder_0_2 g_ppb_videodecoder_thunk_0_2 = {
141 &Create, &IsVideoDecoder, &Initialize_0_2, &Decode,
142 &GetPicture_0_1, &RecyclePicture, &Flush, &Reset};
144 const PPB_VideoDecoder_1_0 g_ppb_videodecoder_thunk_1_0 = {
145 &Create, &IsVideoDecoder, &Initialize_0_2, &Decode,
146 &GetPicture, &RecyclePicture, &Flush, &Reset};
148 const PPB_VideoDecoder_1_1 g_ppb_videodecoder_thunk_1_1 = {
149 &Create, &IsVideoDecoder, &Initialize, &Decode,
150 &GetPicture, &RecyclePicture, &Flush, &Reset};
152 } // namespace
154 PPAPI_THUNK_EXPORT const PPB_VideoDecoder_0_1* GetPPB_VideoDecoder_0_1_Thunk() {
155 return &g_ppb_videodecoder_thunk_0_1;
158 PPAPI_THUNK_EXPORT const PPB_VideoDecoder_0_2* GetPPB_VideoDecoder_0_2_Thunk() {
159 return &g_ppb_videodecoder_thunk_0_2;
162 PPAPI_THUNK_EXPORT const PPB_VideoDecoder_1_0* GetPPB_VideoDecoder_1_0_Thunk() {
163 return &g_ppb_videodecoder_thunk_1_0;
166 PPAPI_THUNK_EXPORT const PPB_VideoDecoder_1_1* GetPPB_VideoDecoder_1_1_Thunk() {
167 return &g_ppb_videodecoder_thunk_1_1;
170 } // namespace thunk
171 } // namespace ppapi