Roll Libjingle 8093:8097
[chromium-blink-merge.git] / ppapi / thunk / ppb_video_decoder_thunk.cc
blob14bd55a083ffd40d5de3b304a4fab1a136f5e453
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 Fri Nov 7 14:49:08 2014.
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()";
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(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()";
53 EnterResource<PPB_VideoDecoder_API> enter(video_decoder, callback, true);
54 if (enter.failed())
55 return enter.retval();
56 return enter.SetResult(enter.object()->Initialize(
57 graphics3d_context, profile, acceleration, enter.callback()));
60 int32_t Decode(PP_Resource video_decoder,
61 uint32_t decode_id,
62 uint32_t size,
63 const void* buffer,
64 struct PP_CompletionCallback callback) {
65 VLOG(4) << "PPB_VideoDecoder::Decode()";
66 EnterResource<PPB_VideoDecoder_API> enter(video_decoder, callback, true);
67 if (enter.failed())
68 return enter.retval();
69 return enter.SetResult(
70 enter.object()->Decode(decode_id, size, buffer, enter.callback()));
73 int32_t GetPicture_0_1(PP_Resource video_decoder,
74 struct PP_VideoPicture_0_1* picture,
75 struct PP_CompletionCallback callback) {
76 VLOG(4) << "PPB_VideoDecoder::GetPicture()";
77 EnterResource<PPB_VideoDecoder_API> enter(video_decoder, callback, true);
78 if (enter.failed())
79 return enter.retval();
80 return enter.SetResult(
81 enter.object()->GetPicture0_1(picture, enter.callback()));
84 int32_t GetPicture(PP_Resource video_decoder,
85 struct PP_VideoPicture* picture,
86 struct PP_CompletionCallback callback) {
87 VLOG(4) << "PPB_VideoDecoder::GetPicture()";
88 EnterResource<PPB_VideoDecoder_API> enter(video_decoder, callback, true);
89 if (enter.failed())
90 return enter.retval();
91 return enter.SetResult(enter.object()->GetPicture(picture, enter.callback()));
94 void RecyclePicture(PP_Resource video_decoder,
95 const struct PP_VideoPicture* picture) {
96 VLOG(4) << "PPB_VideoDecoder::RecyclePicture()";
97 EnterResource<PPB_VideoDecoder_API> enter(video_decoder, true);
98 if (enter.failed())
99 return;
100 enter.object()->RecyclePicture(picture);
103 int32_t Flush(PP_Resource video_decoder,
104 struct PP_CompletionCallback callback) {
105 VLOG(4) << "PPB_VideoDecoder::Flush()";
106 EnterResource<PPB_VideoDecoder_API> enter(video_decoder, callback, true);
107 if (enter.failed())
108 return enter.retval();
109 return enter.SetResult(enter.object()->Flush(enter.callback()));
112 int32_t Reset(PP_Resource video_decoder,
113 struct PP_CompletionCallback callback) {
114 VLOG(4) << "PPB_VideoDecoder::Reset()";
115 EnterResource<PPB_VideoDecoder_API> enter(video_decoder, callback, true);
116 if (enter.failed())
117 return enter.retval();
118 return enter.SetResult(enter.object()->Reset(enter.callback()));
121 const PPB_VideoDecoder_0_1 g_ppb_videodecoder_thunk_0_1 = {&Create,
122 &IsVideoDecoder,
123 &Initialize_0_1,
124 &Decode,
125 &GetPicture_0_1,
126 &RecyclePicture,
127 &Flush,
128 &Reset};
130 const PPB_VideoDecoder_0_2 g_ppb_videodecoder_thunk_0_2 = {&Create,
131 &IsVideoDecoder,
132 &Initialize,
133 &Decode,
134 &GetPicture_0_1,
135 &RecyclePicture,
136 &Flush,
137 &Reset};
139 const PPB_VideoDecoder_1_0 g_ppb_videodecoder_thunk_1_0 = {&Create,
140 &IsVideoDecoder,
141 &Initialize,
142 &Decode,
143 &GetPicture,
144 &RecyclePicture,
145 &Flush,
146 &Reset};
148 } // namespace
150 PPAPI_THUNK_EXPORT const PPB_VideoDecoder_0_1* GetPPB_VideoDecoder_0_1_Thunk() {
151 return &g_ppb_videodecoder_thunk_0_1;
154 PPAPI_THUNK_EXPORT const PPB_VideoDecoder_0_2* GetPPB_VideoDecoder_0_2_Thunk() {
155 return &g_ppb_videodecoder_thunk_0_2;
158 PPAPI_THUNK_EXPORT const PPB_VideoDecoder_1_0* GetPPB_VideoDecoder_1_0_Thunk() {
159 return &g_ppb_videodecoder_thunk_1_0;
162 } // namespace thunk
163 } // namespace ppapi