1 // Copyright 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_media_stream_audio_track.idl modified Thu Feb 6 15:43:37 2014.
6
7 #include "ppapi/c/pp_completion_callback.h"
8 #include "ppapi/c/pp_errors.h"
9 #include "ppapi/c/ppb_media_stream_audio_track.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_media_stream_audio_track_api.h"
14
15 namespace ppapi {
16 namespace thunk {
17
18 namespace {
19
IsMediaStreamAudioTrack(PP_Resource resource)20 PP_Bool IsMediaStreamAudioTrack(PP_Resource resource) {
21 VLOG(4) << "PPB_MediaStreamAudioTrack::IsMediaStreamAudioTrack()";
22 EnterResource<PPB_MediaStreamAudioTrack_API> enter(resource, false);
23 return PP_FromBool(enter.succeeded());
24 }
25
Configure(PP_Resource audio_track,const int32_t attrib_list[],struct PP_CompletionCallback callback)26 int32_t Configure(PP_Resource audio_track,
27 const int32_t attrib_list[],
28 struct PP_CompletionCallback callback) {
29 VLOG(4) << "PPB_MediaStreamAudioTrack::Configure()";
30 EnterResource<PPB_MediaStreamAudioTrack_API> enter(audio_track,
31 callback,
32 true);
33 if (enter.failed())
34 return enter.retval();
35 return enter.SetResult(enter.object()->Configure(attrib_list,
36 enter.callback()));
37 }
38
GetAttrib(PP_Resource audio_track,PP_MediaStreamAudioTrack_Attrib attrib,int32_t * value)39 int32_t GetAttrib(PP_Resource audio_track,
40 PP_MediaStreamAudioTrack_Attrib attrib,
41 int32_t* value) {
42 VLOG(4) << "PPB_MediaStreamAudioTrack::GetAttrib()";
43 EnterResource<PPB_MediaStreamAudioTrack_API> enter(audio_track, true);
44 if (enter.failed())
45 return enter.retval();
46 return enter.object()->GetAttrib(attrib, value);
47 }
48
GetId(PP_Resource audio_track)49 struct PP_Var GetId(PP_Resource audio_track) {
50 VLOG(4) << "PPB_MediaStreamAudioTrack::GetId()";
51 EnterResource<PPB_MediaStreamAudioTrack_API> enter(audio_track, true);
52 if (enter.failed())
53 return PP_MakeUndefined();
54 return enter.object()->GetId();
55 }
56
HasEnded(PP_Resource audio_track)57 PP_Bool HasEnded(PP_Resource audio_track) {
58 VLOG(4) << "PPB_MediaStreamAudioTrack::HasEnded()";
59 EnterResource<PPB_MediaStreamAudioTrack_API> enter(audio_track, true);
60 if (enter.failed())
61 return PP_TRUE;
62 return enter.object()->HasEnded();
63 }
64
GetBuffer(PP_Resource audio_track,PP_Resource * buffer,struct PP_CompletionCallback callback)65 int32_t GetBuffer(PP_Resource audio_track,
66 PP_Resource* buffer,
67 struct PP_CompletionCallback callback) {
68 VLOG(4) << "PPB_MediaStreamAudioTrack::GetBuffer()";
69 EnterResource<PPB_MediaStreamAudioTrack_API> enter(audio_track,
70 callback,
71 true);
72 if (enter.failed())
73 return enter.retval();
74 return enter.SetResult(enter.object()->GetBuffer(buffer, enter.callback()));
75 }
76
RecycleBuffer(PP_Resource audio_track,PP_Resource buffer)77 int32_t RecycleBuffer(PP_Resource audio_track, PP_Resource buffer) {
78 VLOG(4) << "PPB_MediaStreamAudioTrack::RecycleBuffer()";
79 EnterResource<PPB_MediaStreamAudioTrack_API> enter(audio_track, true);
80 if (enter.failed())
81 return enter.retval();
82 return enter.object()->RecycleBuffer(buffer);
83 }
84
Close(PP_Resource audio_track)85 void Close(PP_Resource audio_track) {
86 VLOG(4) << "PPB_MediaStreamAudioTrack::Close()";
87 EnterResource<PPB_MediaStreamAudioTrack_API> enter(audio_track, true);
88 if (enter.failed())
89 return;
90 enter.object()->Close();
91 }
92
93 const PPB_MediaStreamAudioTrack_0_1 g_ppb_mediastreamaudiotrack_thunk_0_1 = {
94 &IsMediaStreamAudioTrack,
95 &Configure,
96 &GetAttrib,
97 &GetId,
98 &HasEnded,
99 &GetBuffer,
100 &RecycleBuffer,
101 &Close
102 };
103
104 } // namespace
105
106 PPAPI_THUNK_EXPORT const PPB_MediaStreamAudioTrack_0_1*
GetPPB_MediaStreamAudioTrack_0_1_Thunk()107 GetPPB_MediaStreamAudioTrack_0_1_Thunk() {
108 return &g_ppb_mediastreamaudiotrack_thunk_0_1;
109 }
110
111 } // namespace thunk
112 } // namespace ppapi
113