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/thunk/enter.h" | 7 #include "ppapi/thunk/enter.h" |
8 #include "ppapi/thunk/ppb_device_ref_api.h" | 8 #include "ppapi/thunk/ppb_device_ref_api.h" |
9 #include "ppapi/thunk/ppb_video_capture_api.h" | 9 #include "ppapi/thunk/ppb_video_capture_api.h" |
10 #include "ppapi/thunk/resource_creation_api.h" | 10 #include "ppapi/thunk/resource_creation_api.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 return PP_FromBool(enter.succeeded()); | 29 return PP_FromBool(enter.succeeded()); |
30 } | 30 } |
31 | 31 |
32 int32_t EnumerateDevices(PP_Resource video_capture, | 32 int32_t EnumerateDevices(PP_Resource video_capture, |
33 PP_Resource* devices, | 33 PP_Resource* devices, |
34 PP_CompletionCallback callback) { | 34 PP_CompletionCallback callback) { |
35 EnterVideoCapture enter(video_capture, callback, true); | 35 EnterVideoCapture enter(video_capture, callback, true); |
36 if (enter.failed()) | 36 if (enter.failed()) |
37 return enter.retval(); | 37 return enter.retval(); |
38 | 38 |
39 return enter.SetResult(enter.object()->EnumerateDevices(devices, callback)); | 39 return enter.SetResult(enter.object()->EnumerateDevices(devices, |
| 40 enter.callback())); |
40 } | 41 } |
41 | 42 |
42 int32_t Open(PP_Resource video_capture, | 43 int32_t Open(PP_Resource video_capture, |
43 PP_Resource device_ref, | 44 PP_Resource device_ref, |
44 const PP_VideoCaptureDeviceInfo_Dev* requested_info, | 45 const PP_VideoCaptureDeviceInfo_Dev* requested_info, |
45 uint32_t buffer_count, | 46 uint32_t buffer_count, |
46 PP_CompletionCallback callback) { | 47 PP_CompletionCallback callback) { |
47 EnterVideoCapture enter(video_capture, callback, true); | 48 EnterVideoCapture enter(video_capture, callback, true); |
48 if (enter.failed()) | 49 if (enter.failed()) |
49 return enter.retval(); | 50 return enter.retval(); |
50 | 51 |
51 std::string device_id; | 52 std::string device_id; |
52 // |device_id| remains empty if |device_ref| is 0, which means the default | 53 // |device_id| remains empty if |device_ref| is 0, which means the default |
53 // device. | 54 // device. |
54 if (device_ref != 0) { | 55 if (device_ref != 0) { |
55 EnterResourceNoLock<PPB_DeviceRef_API> enter_device_ref(device_ref, true); | 56 EnterResourceNoLock<PPB_DeviceRef_API> enter_device_ref(device_ref, true); |
56 if (enter_device_ref.failed()) | 57 if (enter_device_ref.failed()) |
57 return enter.SetResult(PP_ERROR_BADRESOURCE); | 58 return enter.SetResult(PP_ERROR_BADRESOURCE); |
58 device_id = enter_device_ref.object()->GetDeviceRefData().id; | 59 device_id = enter_device_ref.object()->GetDeviceRefData().id; |
59 } | 60 } |
60 | 61 |
61 return enter.SetResult(enter.object()->Open( | 62 return enter.SetResult(enter.object()->Open( |
62 device_id, *requested_info, buffer_count, callback)); | 63 device_id, *requested_info, buffer_count, enter.callback())); |
63 } | 64 } |
64 | 65 |
65 int32_t StartCapture(PP_Resource video_capture) { | 66 int32_t StartCapture(PP_Resource video_capture) { |
66 EnterVideoCapture enter(video_capture, true); | 67 EnterVideoCapture enter(video_capture, true); |
67 if (enter.failed()) | 68 if (enter.failed()) |
68 return enter.retval(); | 69 return enter.retval(); |
69 return enter.object()->StartCapture(); | 70 return enter.object()->StartCapture(); |
70 } | 71 } |
71 | 72 |
72 int32_t ReuseBuffer(PP_Resource video_capture, | 73 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() { | 125 const PPB_VideoCapture_Dev_0_1* GetPPB_VideoCapture_Dev_0_1_Thunk() { |
125 return &g_ppb_video_capture_0_1_thunk; | 126 return &g_ppb_video_capture_0_1_thunk; |
126 } | 127 } |
127 | 128 |
128 const PPB_VideoCapture_Dev_0_2* GetPPB_VideoCapture_Dev_0_2_Thunk() { | 129 const PPB_VideoCapture_Dev_0_2* GetPPB_VideoCapture_Dev_0_2_Thunk() { |
129 return &g_ppb_video_capture_0_2_thunk; | 130 return &g_ppb_video_capture_0_2_thunk; |
130 } | 131 } |
131 | 132 |
132 } // namespace thunk | 133 } // namespace thunk |
133 } // namespace ppapi | 134 } // namespace ppapi |
OLD | NEW |