Android WebView: build debug/release based on variant.
[chromium-blink-merge.git] / ppapi / thunk / ppb_video_decoder_thunk.cc
blob2472d8ab321f641e3327deaa78150640b42c5955
1 // Copyright (c) 2012 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/thunk.h"
9 #include "ppapi/thunk/ppb_video_decoder_api.h"
10 #include "ppapi/thunk/resource_creation_api.h"
12 namespace ppapi {
13 namespace thunk {
15 namespace {
17 typedef EnterResource<PPB_VideoDecoder_API> EnterVideoDecoder;
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()->CreateVideoDecoder(instance, graphics_3d, profile);
28 PP_Bool IsVideoDecoder(PP_Resource resource) {
29 EnterVideoDecoder enter(resource, false);
30 return PP_FromBool(enter.succeeded());
33 int32_t Decode(PP_Resource video_decoder,
34 const PP_VideoBitstreamBuffer_Dev* bitstream_buffer,
35 PP_CompletionCallback callback) {
36 EnterVideoDecoder enter(video_decoder, callback, true);
37 if (enter.failed())
38 return enter.retval();
39 return enter.SetResult(enter.object()->Decode(bitstream_buffer,
40 enter.callback()));
43 void AssignPictureBuffers(PP_Resource video_decoder,
44 uint32_t no_of_buffers,
45 const PP_PictureBuffer_Dev* buffers) {
46 EnterVideoDecoder enter(video_decoder, true);
47 if (enter.succeeded())
48 enter.object()->AssignPictureBuffers(no_of_buffers, buffers);
51 void ReusePictureBuffer(PP_Resource video_decoder, int32_t picture_buffer_id) {
52 EnterVideoDecoder enter(video_decoder, true);
53 if (enter.succeeded())
54 enter.object()->ReusePictureBuffer(picture_buffer_id);
57 int32_t Flush(PP_Resource video_decoder, PP_CompletionCallback callback) {
58 EnterVideoDecoder enter(video_decoder, callback, true);
59 if (enter.failed())
60 return enter.retval();
61 return enter.SetResult(enter.object()->Flush(enter.callback()));
64 int32_t Reset(PP_Resource video_decoder,
65 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()));
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_thunk = {
79 &Create,
80 &IsVideoDecoder,
81 &Decode,
82 &AssignPictureBuffers,
83 &ReusePictureBuffer,
84 &Flush,
85 &Reset,
86 &Destroy
89 } // namespace
91 const PPB_VideoDecoder_Dev_0_16* GetPPB_VideoDecoder_Dev_0_16_Thunk() {
92 return &g_ppb_videodecoder_thunk;
95 } // namespace thunk
96 } // namespace ppapi