| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ppapi/c/pp_errors.h" | 5 #include "ppapi/c/pp_errors.h" |
| 6 #include "ppapi/shared_impl/ppb_device_ref_shared.h" | 6 #include "ppapi/shared_impl/ppb_device_ref_shared.h" |
| 7 #include "ppapi/shared_impl/tracked_callback.h" |
| 7 #include "ppapi/thunk/enter.h" | 8 #include "ppapi/thunk/enter.h" |
| 8 #include "ppapi/thunk/ppb_device_ref_api.h" | 9 #include "ppapi/thunk/ppb_device_ref_api.h" |
| 9 #include "ppapi/thunk/ppb_video_capture_api.h" | 10 #include "ppapi/thunk/ppb_video_capture_api.h" |
| 10 #include "ppapi/thunk/resource_creation_api.h" | 11 #include "ppapi/thunk/resource_creation_api.h" |
| 11 #include "ppapi/thunk/thunk.h" | 12 #include "ppapi/thunk/thunk.h" |
| 12 | 13 |
| 13 namespace ppapi { | 14 namespace ppapi { |
| 14 namespace thunk { | 15 namespace thunk { |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 29 return PP_FromBool(enter.succeeded()); | 30 return PP_FromBool(enter.succeeded()); |
| 30 } | 31 } |
| 31 | 32 |
| 32 int32_t EnumerateDevices(PP_Resource video_capture, | 33 int32_t EnumerateDevices(PP_Resource video_capture, |
| 33 PP_Resource* devices, | 34 PP_Resource* devices, |
| 34 PP_CompletionCallback callback) { | 35 PP_CompletionCallback callback) { |
| 35 EnterVideoCapture enter(video_capture, callback, true); | 36 EnterVideoCapture enter(video_capture, callback, true); |
| 36 if (enter.failed()) | 37 if (enter.failed()) |
| 37 return enter.retval(); | 38 return enter.retval(); |
| 38 | 39 |
| 39 return enter.SetResult(enter.object()->EnumerateDevices(devices, callback)); | 40 return enter.SetResult(enter.object()->EnumerateDevices(devices, |
| 41 enter.callback())); |
| 40 } | 42 } |
| 41 | 43 |
| 42 int32_t Open(PP_Resource video_capture, | 44 int32_t Open(PP_Resource video_capture, |
| 43 PP_Resource device_ref, | 45 PP_Resource device_ref, |
| 44 const PP_VideoCaptureDeviceInfo_Dev* requested_info, | 46 const PP_VideoCaptureDeviceInfo_Dev* requested_info, |
| 45 uint32_t buffer_count, | 47 uint32_t buffer_count, |
| 46 PP_CompletionCallback callback) { | 48 PP_CompletionCallback callback) { |
| 47 EnterVideoCapture enter(video_capture, callback, true); | 49 EnterVideoCapture enter(video_capture, callback, true); |
| 48 if (enter.failed()) | 50 if (enter.failed()) |
| 49 return enter.retval(); | 51 return enter.retval(); |
| 50 | 52 |
| 51 std::string device_id; | 53 std::string device_id; |
| 52 // |device_id| remains empty if |device_ref| is 0, which means the default | 54 // |device_id| remains empty if |device_ref| is 0, which means the default |
| 53 // device. | 55 // device. |
| 54 if (device_ref != 0) { | 56 if (device_ref != 0) { |
| 55 EnterResourceNoLock<PPB_DeviceRef_API> enter_device_ref(device_ref, true); | 57 EnterResourceNoLock<PPB_DeviceRef_API> enter_device_ref(device_ref, true); |
| 56 if (enter_device_ref.failed()) | 58 if (enter_device_ref.failed()) |
| 57 return enter.SetResult(PP_ERROR_BADRESOURCE); | 59 return enter.SetResult(PP_ERROR_BADRESOURCE); |
| 58 device_id = enter_device_ref.object()->GetDeviceRefData().id; | 60 device_id = enter_device_ref.object()->GetDeviceRefData().id; |
| 59 } | 61 } |
| 60 | 62 |
| 61 return enter.SetResult(enter.object()->Open( | 63 return enter.SetResult(enter.object()->Open( |
| 62 device_id, *requested_info, buffer_count, callback)); | 64 device_id, *requested_info, buffer_count, enter.callback())); |
| 63 } | 65 } |
| 64 | 66 |
| 65 int32_t StartCapture(PP_Resource video_capture) { | 67 int32_t StartCapture(PP_Resource video_capture) { |
| 66 EnterVideoCapture enter(video_capture, true); | 68 EnterVideoCapture enter(video_capture, true); |
| 67 if (enter.failed()) | 69 if (enter.failed()) |
| 68 return enter.retval(); | 70 return enter.retval(); |
| 69 return enter.object()->StartCapture(); | 71 return enter.object()->StartCapture(); |
| 70 } | 72 } |
| 71 | 73 |
| 72 int32_t ReuseBuffer(PP_Resource video_capture, | 74 int32_t ReuseBuffer(PP_Resource video_capture, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 const PPB_VideoCapture_Dev_0_1* GetPPB_VideoCapture_Dev_0_1_Thunk() { | 126 const PPB_VideoCapture_Dev_0_1* GetPPB_VideoCapture_Dev_0_1_Thunk() { |
| 125 return &g_ppb_video_capture_0_1_thunk; | 127 return &g_ppb_video_capture_0_1_thunk; |
| 126 } | 128 } |
| 127 | 129 |
| 128 const PPB_VideoCapture_Dev_0_2* GetPPB_VideoCapture_Dev_0_2_Thunk() { | 130 const PPB_VideoCapture_Dev_0_2* GetPPB_VideoCapture_Dev_0_2_Thunk() { |
| 129 return &g_ppb_video_capture_0_2_thunk; | 131 return &g_ppb_video_capture_0_2_thunk; |
| 130 } | 132 } |
| 131 | 133 |
| 132 } // namespace thunk | 134 } // namespace thunk |
| 133 } // namespace ppapi | 135 } // namespace ppapi |
| OLD | NEW |