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/shared_impl/ppb_video_capture_shared.h" | 5 #include "ppapi/shared_impl/ppb_video_capture_shared.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ppapi/c/pp_errors.h" | 8 #include "ppapi/c/pp_errors.h" |
9 #include "ppapi/shared_impl/ppb_device_ref_shared.h" | 9 #include "ppapi/shared_impl/ppb_device_ref_shared.h" |
10 #include "ppapi/shared_impl/ppb_resource_array_shared.h" | 10 #include "ppapi/shared_impl/ppb_resource_array_shared.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 int32_t PPB_VideoCapture_Shared::EnumerateDevices( | 38 int32_t PPB_VideoCapture_Shared::EnumerateDevices( |
39 PP_Resource* devices, | 39 PP_Resource* devices, |
40 scoped_refptr<TrackedCallback> callback) { | 40 scoped_refptr<TrackedCallback> callback) { |
41 if (TrackedCallback::IsPending(enumerate_devices_callback_)) | 41 if (TrackedCallback::IsPending(enumerate_devices_callback_)) |
42 return PP_ERROR_INPROGRESS; | 42 return PP_ERROR_INPROGRESS; |
43 | 43 |
44 return InternalEnumerateDevices(devices, callback); | 44 return InternalEnumerateDevices(devices, callback); |
45 } | 45 } |
46 | 46 |
| 47 int32_t PPB_VideoCapture_Shared::StopEnumerateDevices( |
| 48 PP_Resource* devices) { |
| 49 devices_ = NULL; |
| 50 enumerate_devices_callback_ = NULL; |
| 51 return InternalStopEnumerateDevices(devices); |
| 52 } |
| 53 |
47 int32_t PPB_VideoCapture_Shared::Open( | 54 int32_t PPB_VideoCapture_Shared::Open( |
48 const std::string& device_id, | 55 const std::string& device_id, |
49 const PP_VideoCaptureDeviceInfo_Dev& requested_info, | 56 const PP_VideoCaptureDeviceInfo_Dev& requested_info, |
50 uint32_t buffer_count, | 57 uint32_t buffer_count, |
51 scoped_refptr<TrackedCallback> callback) { | 58 scoped_refptr<TrackedCallback> callback) { |
52 if (open_state_ != BEFORE_OPEN) | 59 if (open_state_ != BEFORE_OPEN) |
53 return PP_ERROR_FAILED; | 60 return PP_ERROR_FAILED; |
54 | 61 |
55 if (TrackedCallback::IsPending(open_callback_)) | 62 if (TrackedCallback::IsPending(open_callback_)) |
56 return PP_ERROR_INPROGRESS; | 63 return PP_ERROR_INPROGRESS; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 122 |
116 void PPB_VideoCapture_Shared::OnEnumerateDevicesComplete( | 123 void PPB_VideoCapture_Shared::OnEnumerateDevicesComplete( |
117 int32_t result, | 124 int32_t result, |
118 const std::vector<DeviceRefData>& devices) { | 125 const std::vector<DeviceRefData>& devices) { |
119 DCHECK(TrackedCallback::IsPending(enumerate_devices_callback_)); | 126 DCHECK(TrackedCallback::IsPending(enumerate_devices_callback_)); |
120 | 127 |
121 if (result == PP_OK && devices_) { | 128 if (result == PP_OK && devices_) { |
122 *devices_ = PPB_DeviceRef_Shared::CreateResourceArray( | 129 *devices_ = PPB_DeviceRef_Shared::CreateResourceArray( |
123 resource_object_type_, pp_instance(), devices); | 130 resource_object_type_, pp_instance(), devices); |
124 } | 131 } |
125 devices_ = NULL; | 132 enumerate_devices_callback_->Run(result); |
126 | |
127 TrackedCallback::ClearAndRun(&enumerate_devices_callback_, result); | |
128 } | 133 } |
129 | 134 |
130 void PPB_VideoCapture_Shared::OnOpenComplete(int32_t result) { | 135 void PPB_VideoCapture_Shared::OnOpenComplete(int32_t result) { |
131 if (open_state_ == BEFORE_OPEN && result == PP_OK) | 136 if (open_state_ == BEFORE_OPEN && result == PP_OK) |
132 open_state_ = OPENED; | 137 open_state_ = OPENED; |
133 | 138 |
134 // The callback may have been aborted by Close(), or the open operation is | 139 // The callback may have been aborted by Close(), or the open operation is |
135 // completed synchronously. | 140 // completed synchronously. |
136 if (TrackedCallback::IsPending(open_callback_)) | 141 if (TrackedCallback::IsPending(open_callback_)) |
137 TrackedCallback::ClearAndRun(&open_callback_, result); | 142 TrackedCallback::ClearAndRun(&open_callback_, result); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 } | 183 } |
179 break; | 184 break; |
180 } | 185 } |
181 } | 186 } |
182 | 187 |
183 status_ = status; | 188 status_ = status; |
184 return true; | 189 return true; |
185 } | 190 } |
186 | 191 |
187 } // namespace ppapi | 192 } // namespace ppapi |
OLD | NEW |