• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_video_track.idl modified Mon Mar 31 14:40:45 2014.
6 
7 #include "ppapi/c/pp_completion_callback.h"
8 #include "ppapi/c/pp_errors.h"
9 #include "ppapi/c/ppb_media_stream_video_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_video_track_api.h"
14 
15 namespace ppapi {
16 namespace thunk {
17 
18 namespace {
19 
Create(PP_Instance instance)20 PP_Resource Create(PP_Instance instance) {
21   VLOG(4) << "PPB_MediaStreamVideoTrack::Create()";
22   EnterResourceCreation enter(instance);
23   if (enter.failed())
24     return 0;
25   return enter.functions()->CreateMediaStreamVideoTrack(instance);
26 }
27 
IsMediaStreamVideoTrack(PP_Resource resource)28 PP_Bool IsMediaStreamVideoTrack(PP_Resource resource) {
29   VLOG(4) << "PPB_MediaStreamVideoTrack::IsMediaStreamVideoTrack()";
30   EnterResource<PPB_MediaStreamVideoTrack_API> enter(resource, false);
31   return PP_FromBool(enter.succeeded());
32 }
33 
Configure(PP_Resource video_track,const int32_t attrib_list[],struct PP_CompletionCallback callback)34 int32_t Configure(PP_Resource video_track,
35                   const int32_t attrib_list[],
36                   struct PP_CompletionCallback callback) {
37   VLOG(4) << "PPB_MediaStreamVideoTrack::Configure()";
38   EnterResource<PPB_MediaStreamVideoTrack_API> enter(video_track,
39                                                      callback,
40                                                      true);
41   if (enter.failed())
42     return enter.retval();
43   return enter.SetResult(enter.object()->Configure(attrib_list,
44                                                    enter.callback()));
45 }
46 
GetAttrib(PP_Resource video_track,PP_MediaStreamVideoTrack_Attrib attrib,int32_t * value)47 int32_t GetAttrib(PP_Resource video_track,
48                   PP_MediaStreamVideoTrack_Attrib attrib,
49                   int32_t* value) {
50   VLOG(4) << "PPB_MediaStreamVideoTrack::GetAttrib()";
51   EnterResource<PPB_MediaStreamVideoTrack_API> enter(video_track, true);
52   if (enter.failed())
53     return enter.retval();
54   return enter.object()->GetAttrib(attrib, value);
55 }
56 
GetId(PP_Resource video_track)57 struct PP_Var GetId(PP_Resource video_track) {
58   VLOG(4) << "PPB_MediaStreamVideoTrack::GetId()";
59   EnterResource<PPB_MediaStreamVideoTrack_API> enter(video_track, true);
60   if (enter.failed())
61     return PP_MakeUndefined();
62   return enter.object()->GetId();
63 }
64 
HasEnded(PP_Resource video_track)65 PP_Bool HasEnded(PP_Resource video_track) {
66   VLOG(4) << "PPB_MediaStreamVideoTrack::HasEnded()";
67   EnterResource<PPB_MediaStreamVideoTrack_API> enter(video_track, true);
68   if (enter.failed())
69     return PP_TRUE;
70   return enter.object()->HasEnded();
71 }
72 
GetFrame(PP_Resource video_track,PP_Resource * frame,struct PP_CompletionCallback callback)73 int32_t GetFrame(PP_Resource video_track,
74                  PP_Resource* frame,
75                  struct PP_CompletionCallback callback) {
76   VLOG(4) << "PPB_MediaStreamVideoTrack::GetFrame()";
77   EnterResource<PPB_MediaStreamVideoTrack_API> enter(video_track,
78                                                      callback,
79                                                      true);
80   if (enter.failed())
81     return enter.retval();
82   return enter.SetResult(enter.object()->GetFrame(frame, enter.callback()));
83 }
84 
RecycleFrame(PP_Resource video_track,PP_Resource frame)85 int32_t RecycleFrame(PP_Resource video_track, PP_Resource frame) {
86   VLOG(4) << "PPB_MediaStreamVideoTrack::RecycleFrame()";
87   EnterResource<PPB_MediaStreamVideoTrack_API> enter(video_track, true);
88   if (enter.failed())
89     return enter.retval();
90   return enter.object()->RecycleFrame(frame);
91 }
92 
Close(PP_Resource video_track)93 void Close(PP_Resource video_track) {
94   VLOG(4) << "PPB_MediaStreamVideoTrack::Close()";
95   EnterResource<PPB_MediaStreamVideoTrack_API> enter(video_track, true);
96   if (enter.failed())
97     return;
98   enter.object()->Close();
99 }
100 
GetEmptyFrame(PP_Resource video_track,PP_Resource * frame,struct PP_CompletionCallback callback)101 int32_t GetEmptyFrame(PP_Resource video_track,
102                       PP_Resource* frame,
103                       struct PP_CompletionCallback callback) {
104   VLOG(4) << "PPB_MediaStreamVideoTrack::GetEmptyFrame()";
105   EnterResource<PPB_MediaStreamVideoTrack_API> enter(video_track,
106                                                      callback,
107                                                      true);
108   if (enter.failed())
109     return enter.retval();
110   return enter.SetResult(enter.object()->GetEmptyFrame(frame,
111                                                        enter.callback()));
112 }
113 
PutFrame(PP_Resource video_track,PP_Resource frame)114 int32_t PutFrame(PP_Resource video_track, PP_Resource frame) {
115   VLOG(4) << "PPB_MediaStreamVideoTrack::PutFrame()";
116   EnterResource<PPB_MediaStreamVideoTrack_API> enter(video_track, true);
117   if (enter.failed())
118     return enter.retval();
119   return enter.object()->PutFrame(frame);
120 }
121 
122 const PPB_MediaStreamVideoTrack_0_1 g_ppb_mediastreamvideotrack_thunk_0_1 = {
123   &IsMediaStreamVideoTrack,
124   &Configure,
125   &GetAttrib,
126   &GetId,
127   &HasEnded,
128   &GetFrame,
129   &RecycleFrame,
130   &Close
131 };
132 
133 const PPB_MediaStreamVideoTrack_1_0 g_ppb_mediastreamvideotrack_thunk_1_0 = {
134   &Create,
135   &IsMediaStreamVideoTrack,
136   &Configure,
137   &GetAttrib,
138   &GetId,
139   &HasEnded,
140   &GetFrame,
141   &RecycleFrame,
142   &Close,
143   &GetEmptyFrame,
144   &PutFrame
145 };
146 
147 }  // namespace
148 
149 PPAPI_THUNK_EXPORT const PPB_MediaStreamVideoTrack_0_1*
GetPPB_MediaStreamVideoTrack_0_1_Thunk()150     GetPPB_MediaStreamVideoTrack_0_1_Thunk() {
151   return &g_ppb_mediastreamvideotrack_thunk_0_1;
152 }
153 
154 PPAPI_THUNK_EXPORT const PPB_MediaStreamVideoTrack_1_0*
GetPPB_MediaStreamVideoTrack_1_0_Thunk()155     GetPPB_MediaStreamVideoTrack_1_0_Thunk() {
156   return &g_ppb_mediastreamvideotrack_thunk_1_0;
157 }
158 
159 }  // namespace thunk
160 }  // namespace ppapi
161