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/proxy/ppb_video_capture_proxy.h" | 5 #include "ppapi/proxy/ppb_video_capture_proxy.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "ppapi/c/pp_errors.h" | 10 #include "ppapi/c/pp_errors.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 | 157 |
158 void SetBufferInUse(uint32_t buffer) { | 158 void SetBufferInUse(uint32_t buffer) { |
159 DCHECK(buffer < buffer_in_use_.size()); | 159 DCHECK(buffer < buffer_in_use_.size()); |
160 buffer_in_use_[buffer] = true; | 160 buffer_in_use_[buffer] = true; |
161 } | 161 } |
162 | 162 |
163 private: | 163 private: |
164 // PPB_VideoCapture_Shared implementation. | 164 // PPB_VideoCapture_Shared implementation. |
165 virtual int32_t InternalEnumerateDevices( | 165 virtual int32_t InternalEnumerateDevices( |
166 PP_Resource* devices, | 166 PP_Resource* devices, |
167 PP_CompletionCallback callback) OVERRIDE; | 167 const PP_CompletionCallback& callback) OVERRIDE; |
168 virtual int32_t InternalOpen( | 168 virtual int32_t InternalOpen( |
169 const std::string& device_id, | 169 const std::string& device_id, |
170 const PP_VideoCaptureDeviceInfo_Dev& requested_info, | 170 const PP_VideoCaptureDeviceInfo_Dev& requested_info, |
171 uint32_t buffer_count, | 171 uint32_t buffer_count, |
172 PP_CompletionCallback callback) OVERRIDE; | 172 const PP_CompletionCallback& callback) OVERRIDE; |
173 virtual int32_t InternalStartCapture() OVERRIDE; | 173 virtual int32_t InternalStartCapture() OVERRIDE; |
174 virtual int32_t InternalReuseBuffer(uint32_t buffer) OVERRIDE; | 174 virtual int32_t InternalReuseBuffer(uint32_t buffer) OVERRIDE; |
175 virtual int32_t InternalStopCapture() OVERRIDE; | 175 virtual int32_t InternalStopCapture() OVERRIDE; |
176 virtual void InternalClose() OVERRIDE; | 176 virtual void InternalClose() OVERRIDE; |
177 virtual int32_t InternalStartCapture0_1( | 177 virtual int32_t InternalStartCapture0_1( |
178 const PP_VideoCaptureDeviceInfo_Dev& requested_info, | 178 const PP_VideoCaptureDeviceInfo_Dev& requested_info, |
179 uint32_t buffer_count) OVERRIDE; | 179 uint32_t buffer_count) OVERRIDE; |
180 virtual const std::vector<DeviceRefData>& | 180 virtual const std::vector<DeviceRefData>& |
181 InternalGetDeviceRefData() const OVERRIDE; | 181 InternalGetDeviceRefData() const OVERRIDE; |
182 | 182 |
(...skipping 23 matching lines...) Expand all Loading... |
206 case PP_VIDEO_CAPTURE_STATUS_STARTING: | 206 case PP_VIDEO_CAPTURE_STATUS_STARTING: |
207 case PP_VIDEO_CAPTURE_STATUS_STOPPING: | 207 case PP_VIDEO_CAPTURE_STATUS_STOPPING: |
208 // Those states are not sent by the browser. | 208 // Those states are not sent by the browser. |
209 break; | 209 break; |
210 } | 210 } |
211 | 211 |
212 NOTREACHED(); | 212 NOTREACHED(); |
213 return false; | 213 return false; |
214 } | 214 } |
215 | 215 |
216 int32_t VideoCapture::InternalEnumerateDevices(PP_Resource* devices, | 216 int32_t VideoCapture::InternalEnumerateDevices( |
217 PP_CompletionCallback callback) { | 217 PP_Resource* devices, const PP_CompletionCallback& callback) { |
218 devices_ = devices; | 218 devices_ = devices; |
219 enumerate_devices_callback_ = new TrackedCallback(this, callback); | 219 enumerate_devices_callback_ = new TrackedCallback(this, callback); |
220 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_EnumerateDevices( | 220 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_EnumerateDevices( |
221 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource())); | 221 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource())); |
222 return PP_OK_COMPLETIONPENDING; | 222 return PP_OK_COMPLETIONPENDING; |
223 } | 223 } |
224 | 224 |
225 int32_t VideoCapture::InternalOpen( | 225 int32_t VideoCapture::InternalOpen( |
226 const std::string& device_id, | 226 const std::string& device_id, |
227 const PP_VideoCaptureDeviceInfo_Dev& requested_info, | 227 const PP_VideoCaptureDeviceInfo_Dev& requested_info, |
228 uint32_t buffer_count, | 228 uint32_t buffer_count, |
229 PP_CompletionCallback callback) { | 229 const PP_CompletionCallback& callback) { |
230 // Disallow blocking call. The base class doesn't check this. | 230 // Disallow blocking call. The base class doesn't check this. |
231 if (!callback.func) | 231 if (!callback.func) |
232 return PP_ERROR_BLOCKS_MAIN_THREAD; | 232 return PP_ERROR_BLOCKS_MAIN_THREAD; |
233 | 233 |
234 open_callback_ = new TrackedCallback(this, callback); | 234 open_callback_ = new TrackedCallback(this, callback); |
235 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_Open( | 235 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_Open( |
236 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource(), device_id, requested_info, | 236 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource(), device_id, requested_info, |
237 buffer_count)); | 237 buffer_count)); |
238 return PP_OK_COMPLETIONPENDING; | 238 return PP_OK_COMPLETIONPENDING; |
239 } | 239 } |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 return; | 537 return; |
538 | 538 |
539 VideoCapture* capture = static_cast<VideoCapture*>(enter.object()); | 539 VideoCapture* capture = static_cast<VideoCapture*>(enter.object()); |
540 capture->SetBufferInUse(buffer); | 540 capture->SetBufferInUse(buffer); |
541 ppp_video_capture_impl_->OnBufferReady( | 541 ppp_video_capture_impl_->OnBufferReady( |
542 host_resource.instance(), capture->pp_resource(), buffer); | 542 host_resource.instance(), capture->pp_resource(), buffer); |
543 } | 543 } |
544 | 544 |
545 } // namespace proxy | 545 } // namespace proxy |
546 } // namespace ppapi | 546 } // namespace ppapi |
OLD | NEW |