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_video_frame.idl modified Mon Jan 13 12:02:23 2014.
6
7 #include "ppapi/c/pp_errors.h"
8 #include "ppapi/c/ppb_video_frame.h"
9 #include "ppapi/shared_impl/tracked_callback.h"
10 #include "ppapi/thunk/enter.h"
11 #include "ppapi/thunk/ppapi_thunk_export.h"
12 #include "ppapi/thunk/ppb_video_frame_api.h"
13
14 namespace ppapi {
15 namespace thunk {
16
17 namespace {
18
IsVideoFrame(PP_Resource resource)19 PP_Bool IsVideoFrame(PP_Resource resource) {
20 VLOG(4) << "PPB_VideoFrame::IsVideoFrame()";
21 EnterResource<PPB_VideoFrame_API> enter(resource, false);
22 return PP_FromBool(enter.succeeded());
23 }
24
GetTimestamp(PP_Resource frame)25 PP_TimeDelta GetTimestamp(PP_Resource frame) {
26 VLOG(4) << "PPB_VideoFrame::GetTimestamp()";
27 EnterResource<PPB_VideoFrame_API> enter(frame, true);
28 if (enter.failed())
29 return 0.0;
30 return enter.object()->GetTimestamp();
31 }
32
SetTimestamp(PP_Resource frame,PP_TimeDelta timestamp)33 void SetTimestamp(PP_Resource frame, PP_TimeDelta timestamp) {
34 VLOG(4) << "PPB_VideoFrame::SetTimestamp()";
35 EnterResource<PPB_VideoFrame_API> enter(frame, true);
36 if (enter.failed())
37 return;
38 enter.object()->SetTimestamp(timestamp);
39 }
40
GetFormat(PP_Resource frame)41 PP_VideoFrame_Format GetFormat(PP_Resource frame) {
42 VLOG(4) << "PPB_VideoFrame::GetFormat()";
43 EnterResource<PPB_VideoFrame_API> enter(frame, true);
44 if (enter.failed())
45 return PP_VIDEOFRAME_FORMAT_UNKNOWN;
46 return enter.object()->GetFormat();
47 }
48
GetSize(PP_Resource frame,struct PP_Size * size)49 PP_Bool GetSize(PP_Resource frame, struct PP_Size* size) {
50 VLOG(4) << "PPB_VideoFrame::GetSize()";
51 EnterResource<PPB_VideoFrame_API> enter(frame, true);
52 if (enter.failed())
53 return PP_FALSE;
54 return enter.object()->GetSize(size);
55 }
56
GetDataBuffer(PP_Resource frame)57 void* GetDataBuffer(PP_Resource frame) {
58 VLOG(4) << "PPB_VideoFrame::GetDataBuffer()";
59 EnterResource<PPB_VideoFrame_API> enter(frame, true);
60 if (enter.failed())
61 return NULL;
62 return enter.object()->GetDataBuffer();
63 }
64
GetDataBufferSize(PP_Resource frame)65 uint32_t GetDataBufferSize(PP_Resource frame) {
66 VLOG(4) << "PPB_VideoFrame::GetDataBufferSize()";
67 EnterResource<PPB_VideoFrame_API> enter(frame, true);
68 if (enter.failed())
69 return 0;
70 return enter.object()->GetDataBufferSize();
71 }
72
73 const PPB_VideoFrame_0_1 g_ppb_videoframe_thunk_0_1 = {
74 &IsVideoFrame,
75 &GetTimestamp,
76 &SetTimestamp,
77 &GetFormat,
78 &GetSize,
79 &GetDataBuffer,
80 &GetDataBufferSize
81 };
82
83 } // namespace
84
GetPPB_VideoFrame_0_1_Thunk()85 PPAPI_THUNK_EXPORT const PPB_VideoFrame_0_1* GetPPB_VideoFrame_0_1_Thunk() {
86 return &g_ppb_videoframe_thunk_0_1;
87 }
88
89 } // namespace thunk
90 } // namespace ppapi
91