- add sources.
[platform/framework/web/crosswalk.git] / src / ppapi / thunk / ppb_content_decryptor_private_thunk.cc
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.
4
5 // From private/ppb_content_decryptor_private.idl,
6 //   modified Thu Oct 10 14:49:51 2013.
7
8 #include "ppapi/c/pp_errors.h"
9 #include "ppapi/c/private/ppb_content_decryptor_private.h"
10 #include "ppapi/shared_impl/tracked_callback.h"
11 #include "ppapi/thunk/enter.h"
12 #include "ppapi/thunk/ppb_instance_api.h"
13 #include "ppapi/thunk/resource_creation_api.h"
14 #include "ppapi/thunk/thunk.h"
15
16 namespace ppapi {
17 namespace thunk {
18
19 namespace {
20
21 void KeyAdded(PP_Instance instance,
22               struct PP_Var key_system,
23               struct PP_Var session_id) {
24   VLOG(4) << "PPB_ContentDecryptor_Private::KeyAdded()";
25   EnterInstance enter(instance);
26   if (enter.failed())
27     return;
28   enter.functions()->KeyAdded(instance, key_system, session_id);
29 }
30
31 void KeyMessage(PP_Instance instance,
32                 struct PP_Var key_system,
33                 struct PP_Var session_id,
34                 struct PP_Var message,
35                 struct PP_Var default_url) {
36   VLOG(4) << "PPB_ContentDecryptor_Private::KeyMessage()";
37   EnterInstance enter(instance);
38   if (enter.failed())
39     return;
40   enter.functions()->KeyMessage(instance,
41                                 key_system,
42                                 session_id,
43                                 message,
44                                 default_url);
45 }
46
47 void KeyError(PP_Instance instance,
48               struct PP_Var key_system,
49               struct PP_Var session_id,
50               int32_t media_error,
51               int32_t system_code) {
52   VLOG(4) << "PPB_ContentDecryptor_Private::KeyError()";
53   EnterInstance enter(instance);
54   if (enter.failed())
55     return;
56   enter.functions()->KeyError(instance,
57                               key_system,
58                               session_id,
59                               media_error,
60                               system_code);
61 }
62
63 void DeliverBlock(PP_Instance instance,
64                   PP_Resource decrypted_block,
65                   const struct PP_DecryptedBlockInfo* decrypted_block_info) {
66   VLOG(4) << "PPB_ContentDecryptor_Private::DeliverBlock()";
67   EnterInstance enter(instance);
68   if (enter.failed())
69     return;
70   enter.functions()->DeliverBlock(instance,
71                                   decrypted_block,
72                                   decrypted_block_info);
73 }
74
75 void DecoderInitializeDone(PP_Instance instance,
76                            PP_DecryptorStreamType decoder_type,
77                            uint32_t request_id,
78                            PP_Bool success) {
79   VLOG(4) << "PPB_ContentDecryptor_Private::DecoderInitializeDone()";
80   EnterInstance enter(instance);
81   if (enter.failed())
82     return;
83   enter.functions()->DecoderInitializeDone(instance,
84                                            decoder_type,
85                                            request_id,
86                                            success);
87 }
88
89 void DecoderDeinitializeDone(PP_Instance instance,
90                              PP_DecryptorStreamType decoder_type,
91                              uint32_t request_id) {
92   VLOG(4) << "PPB_ContentDecryptor_Private::DecoderDeinitializeDone()";
93   EnterInstance enter(instance);
94   if (enter.failed())
95     return;
96   enter.functions()->DecoderDeinitializeDone(instance,
97                                              decoder_type,
98                                              request_id);
99 }
100
101 void DecoderResetDone(PP_Instance instance,
102                       PP_DecryptorStreamType decoder_type,
103                       uint32_t request_id) {
104   VLOG(4) << "PPB_ContentDecryptor_Private::DecoderResetDone()";
105   EnterInstance enter(instance);
106   if (enter.failed())
107     return;
108   enter.functions()->DecoderResetDone(instance, decoder_type, request_id);
109 }
110
111 void DeliverFrame(PP_Instance instance,
112                   PP_Resource decrypted_frame,
113                   const struct PP_DecryptedFrameInfo* decrypted_frame_info) {
114   VLOG(4) << "PPB_ContentDecryptor_Private::DeliverFrame()";
115   EnterInstance enter(instance);
116   if (enter.failed())
117     return;
118   enter.functions()->DeliverFrame(instance,
119                                   decrypted_frame,
120                                   decrypted_frame_info);
121 }
122
123 void DeliverSamples(
124     PP_Instance instance,
125     PP_Resource audio_frames,
126     const struct PP_DecryptedSampleInfo* decrypted_sample_info) {
127   VLOG(4) << "PPB_ContentDecryptor_Private::DeliverSamples()";
128   EnterInstance enter(instance);
129   if (enter.failed())
130     return;
131   enter.functions()->DeliverSamples(instance,
132                                     audio_frames,
133                                     decrypted_sample_info);
134 }
135
136 const PPB_ContentDecryptor_Private_0_7
137     g_ppb_contentdecryptor_private_thunk_0_7 = {
138   &KeyAdded,
139   &KeyMessage,
140   &KeyError,
141   &DeliverBlock,
142   &DecoderInitializeDone,
143   &DecoderDeinitializeDone,
144   &DecoderResetDone,
145   &DeliverFrame,
146   &DeliverSamples
147 };
148
149 }  // namespace
150
151 const PPB_ContentDecryptor_Private_0_7*
152     GetPPB_ContentDecryptor_Private_0_7_Thunk() {
153   return &g_ppb_contentdecryptor_private_thunk_0_7;
154 }
155
156 }  // namespace thunk
157 }  // namespace ppapi