OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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 #include "ppapi/c/pp_errors.h" |
| 6 #include "ppapi/thunk/common.h" |
| 7 #include "ppapi/thunk/enter.h" |
| 8 #include "ppapi/thunk/thunk.h" |
| 9 #include "ppapi/thunk/ppb_video_capture_api.h" |
| 10 #include "ppapi/thunk/resource_creation_api.h" |
| 11 |
| 12 namespace ppapi { |
| 13 namespace thunk { |
| 14 |
| 15 namespace { |
| 16 |
| 17 typedef EnterResource<PPB_VideoCapture_API> EnterVideoCapture; |
| 18 |
| 19 PP_Resource Create(PP_Instance instance) { |
| 20 EnterFunction<ResourceCreationAPI> enter(instance, true); |
| 21 if (enter.failed()) |
| 22 return 0; |
| 23 return enter.functions()->CreateVideoCapture(instance); |
| 24 } |
| 25 |
| 26 PP_Bool IsVideoCapture(PP_Resource resource) { |
| 27 EnterVideoCapture enter(resource, false); |
| 28 return PP_FromBool(enter.succeeded()); |
| 29 } |
| 30 |
| 31 int32_t StartCapture(PP_Resource video_capture, |
| 32 const PP_VideoCaptureDeviceInfo_Dev* requested_info, |
| 33 uint32_t buffer_count) { |
| 34 EnterVideoCapture enter(video_capture, true); |
| 35 if (enter.failed()) |
| 36 return PP_ERROR_BADRESOURCE; |
| 37 |
| 38 return enter.object()->StartCapture(*requested_info, buffer_count); |
| 39 } |
| 40 |
| 41 int32_t ReuseBuffer(PP_Resource video_capture, |
| 42 uint32_t buffer) { |
| 43 EnterVideoCapture enter(video_capture, true); |
| 44 if (enter.failed()) |
| 45 return PP_ERROR_BADRESOURCE; |
| 46 |
| 47 return enter.object()->ReuseBuffer(buffer); |
| 48 } |
| 49 |
| 50 int32_t StopCapture(PP_Resource video_capture) { |
| 51 EnterVideoCapture enter(video_capture, true); |
| 52 if (enter.failed()) |
| 53 return PP_ERROR_BADRESOURCE; |
| 54 |
| 55 return enter.object()->StopCapture(); |
| 56 } |
| 57 |
| 58 const PPB_VideoCapture_Dev g_ppb_videocapture_thunk = { |
| 59 &Create, |
| 60 &IsVideoCapture, |
| 61 &StartCapture, |
| 62 &ReuseBuffer, |
| 63 &StopCapture |
| 64 }; |
| 65 |
| 66 } // namespace |
| 67 |
| 68 const PPB_VideoCapture_Dev* GetPPB_VideoCapture_Thunk() { |
| 69 return &g_ppb_videocapture_thunk; |
| 70 } |
| 71 |
| 72 } // namespace thunk |
| 73 } // namespace ppapi |
OLD | NEW |