Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ppapi / thunk / ppb_media_stream_video_track_thunk.cc
blob8a26a41426c2e09f7ec9552c1b1388dd325b5671
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.
5 // From ppb_media_stream_video_track.idl modified Mon Mar 31 14:40:45 2014.
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"
15 namespace ppapi {
16 namespace thunk {
18 namespace {
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);
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());
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()));
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);
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();
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();
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()));
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);
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();
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()));
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);
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
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
147 } // namespace
149 PPAPI_THUNK_EXPORT const PPB_MediaStreamVideoTrack_0_1*
150 GetPPB_MediaStreamVideoTrack_0_1_Thunk() {
151 return &g_ppb_mediastreamvideotrack_thunk_0_1;
154 PPAPI_THUNK_EXPORT const PPB_MediaStreamVideoTrack_1_0*
155 GetPPB_MediaStreamVideoTrack_1_0_Thunk() {
156 return &g_ppb_mediastreamvideotrack_thunk_1_0;
159 } // namespace thunk
160 } // namespace ppapi