chrome/browser/extensions: Remove use of MessageLoopProxy and deprecated MessageLoop...
[chromium-blink-merge.git] / ppapi / thunk / ppb_video_frame_thunk.cc
blob46b627597ebe9ea4130152555be6aa28d970e21a
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_video_frame.idl modified Mon Apr 7 08:56:43 2014.
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"
14 namespace ppapi {
15 namespace thunk {
17 namespace {
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());
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();
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);
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();
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);
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();
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();
73 const PPB_VideoFrame_0_1 g_ppb_videoframe_thunk_0_1 = {&IsVideoFrame,
74 &GetTimestamp,
75 &SetTimestamp,
76 &GetFormat,
77 &GetSize,
78 &GetDataBuffer,
79 &GetDataBufferSize};
81 } // namespace
83 PPAPI_THUNK_EXPORT const PPB_VideoFrame_0_1* GetPPB_VideoFrame_0_1_Thunk() {
84 return &g_ppb_videoframe_thunk_0_1;
87 } // namespace thunk
88 } // namespace ppapi