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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 scoped_refptr<TrackedCallback> callback) OVERRIDE; | 167 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
| 168 virtual int32_t InternalStopEnumerateDevices( |
| 169 PP_Resource* devices) OVERRIDE; |
168 virtual int32_t InternalOpen( | 170 virtual int32_t InternalOpen( |
169 const std::string& device_id, | 171 const std::string& device_id, |
170 const PP_VideoCaptureDeviceInfo_Dev& requested_info, | 172 const PP_VideoCaptureDeviceInfo_Dev& requested_info, |
171 uint32_t buffer_count, | 173 uint32_t buffer_count, |
172 scoped_refptr<TrackedCallback> callback) OVERRIDE; | 174 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
173 virtual int32_t InternalStartCapture() OVERRIDE; | 175 virtual int32_t InternalStartCapture() OVERRIDE; |
174 virtual int32_t InternalReuseBuffer(uint32_t buffer) OVERRIDE; | 176 virtual int32_t InternalReuseBuffer(uint32_t buffer) OVERRIDE; |
175 virtual int32_t InternalStopCapture() OVERRIDE; | 177 virtual int32_t InternalStopCapture() OVERRIDE; |
176 virtual void InternalClose() OVERRIDE; | 178 virtual void InternalClose() OVERRIDE; |
177 virtual int32_t InternalStartCapture0_1( | 179 virtual int32_t InternalStartCapture0_1( |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 int32_t VideoCapture::InternalEnumerateDevices( | 218 int32_t VideoCapture::InternalEnumerateDevices( |
217 PP_Resource* devices, | 219 PP_Resource* devices, |
218 scoped_refptr<TrackedCallback> callback) { | 220 scoped_refptr<TrackedCallback> callback) { |
219 devices_ = devices; | 221 devices_ = devices; |
220 enumerate_devices_callback_ = callback; | 222 enumerate_devices_callback_ = callback; |
221 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_EnumerateDevices( | 223 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_EnumerateDevices( |
222 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource())); | 224 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource())); |
223 return PP_OK_COMPLETIONPENDING; | 225 return PP_OK_COMPLETIONPENDING; |
224 } | 226 } |
225 | 227 |
| 228 int32_t VideoCapture::InternalStopEnumerateDevices(PP_Resource* devices) { |
| 229 if (devices_ == devices) { |
| 230 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_StopEnumerateDevices( |
| 231 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource())); |
| 232 } |
| 233 return PP_OK; |
| 234 } |
| 235 |
226 int32_t VideoCapture::InternalOpen( | 236 int32_t VideoCapture::InternalOpen( |
227 const std::string& device_id, | 237 const std::string& device_id, |
228 const PP_VideoCaptureDeviceInfo_Dev& requested_info, | 238 const PP_VideoCaptureDeviceInfo_Dev& requested_info, |
229 uint32_t buffer_count, | 239 uint32_t buffer_count, |
230 scoped_refptr<TrackedCallback> callback) { | 240 scoped_refptr<TrackedCallback> callback) { |
231 open_callback_ = callback; | 241 open_callback_ = callback; |
232 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_Open( | 242 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_Open( |
233 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource(), device_id, requested_info, | 243 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource(), device_id, requested_info, |
234 buffer_count)); | 244 buffer_count)); |
235 return PP_OK_COMPLETIONPENDING; | 245 return PP_OK_COMPLETIONPENDING; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 return 0; | 310 return 0; |
301 return (new VideoCapture(result))->GetReference(); | 311 return (new VideoCapture(result))->GetReference(); |
302 } | 312 } |
303 | 313 |
304 bool PPB_VideoCapture_Proxy::OnMessageReceived(const IPC::Message& msg) { | 314 bool PPB_VideoCapture_Proxy::OnMessageReceived(const IPC::Message& msg) { |
305 bool handled = true; | 315 bool handled = true; |
306 IPC_BEGIN_MESSAGE_MAP(PPB_VideoCapture_Proxy, msg) | 316 IPC_BEGIN_MESSAGE_MAP(PPB_VideoCapture_Proxy, msg) |
307 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_Create, OnMsgCreate) | 317 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_Create, OnMsgCreate) |
308 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_EnumerateDevices, | 318 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_EnumerateDevices, |
309 OnMsgEnumerateDevices) | 319 OnMsgEnumerateDevices) |
| 320 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_StopEnumerateDevices, |
| 321 OnMsgStopEnumerateDevices) |
310 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_Open, OnMsgOpen) | 322 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_Open, OnMsgOpen) |
311 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_StartCapture, | 323 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_StartCapture, |
312 OnMsgStartCapture) | 324 OnMsgStartCapture) |
313 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_ReuseBuffer, | 325 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_ReuseBuffer, |
314 OnMsgReuseBuffer) | 326 OnMsgReuseBuffer) |
315 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_StopCapture, | 327 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_StopCapture, |
316 OnMsgStopCapture) | 328 OnMsgStopCapture) |
317 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_Close, OnMsgClose) | 329 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_Close, OnMsgClose) |
318 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_StartCapture0_1, | 330 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_StartCapture0_1, |
319 OnMsgStartCapture0_1) | 331 OnMsgStartCapture0_1) |
(...skipping 21 matching lines...) Expand all Loading... |
341 void PPB_VideoCapture_Proxy::OnMsgEnumerateDevices( | 353 void PPB_VideoCapture_Proxy::OnMsgEnumerateDevices( |
342 const HostResource& resource) { | 354 const HostResource& resource) { |
343 EnterHostFromHostResourceForceCallback<PPB_VideoCapture_API> enter( | 355 EnterHostFromHostResourceForceCallback<PPB_VideoCapture_API> enter( |
344 resource, callback_factory_, | 356 resource, callback_factory_, |
345 &PPB_VideoCapture_Proxy::EnumerateDevicesACKInHost, resource); | 357 &PPB_VideoCapture_Proxy::EnumerateDevicesACKInHost, resource); |
346 | 358 |
347 if (enter.succeeded()) | 359 if (enter.succeeded()) |
348 enter.SetResult(enter.object()->EnumerateDevices(NULL, enter.callback())); | 360 enter.SetResult(enter.object()->EnumerateDevices(NULL, enter.callback())); |
349 } | 361 } |
350 | 362 |
| 363 void PPB_VideoCapture_Proxy::OnMsgStopEnumerateDevices( |
| 364 const HostResource& resource) { |
| 365 EnterHostFromHostResource<PPB_VideoCapture_API> enter(resource); |
| 366 if (enter.succeeded()) |
| 367 enter.object()->StopEnumerateDevices(NULL); |
| 368 } |
| 369 |
351 void PPB_VideoCapture_Proxy::OnMsgOpen( | 370 void PPB_VideoCapture_Proxy::OnMsgOpen( |
352 const ppapi::HostResource& resource, | 371 const ppapi::HostResource& resource, |
353 const std::string& device_id, | 372 const std::string& device_id, |
354 const PP_VideoCaptureDeviceInfo_Dev& info, | 373 const PP_VideoCaptureDeviceInfo_Dev& info, |
355 uint32_t buffers) { | 374 uint32_t buffers) { |
356 EnterHostFromHostResourceForceCallback<PPB_VideoCapture_API> enter( | 375 EnterHostFromHostResourceForceCallback<PPB_VideoCapture_API> enter( |
357 resource, callback_factory_, &PPB_VideoCapture_Proxy::OpenACKInHost, | 376 resource, callback_factory_, &PPB_VideoCapture_Proxy::OpenACKInHost, |
358 resource); | 377 resource); |
359 | 378 |
360 if (enter.succeeded()) { | 379 if (enter.succeeded()) { |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 return; | 553 return; |
535 | 554 |
536 VideoCapture* capture = static_cast<VideoCapture*>(enter.object()); | 555 VideoCapture* capture = static_cast<VideoCapture*>(enter.object()); |
537 capture->SetBufferInUse(buffer); | 556 capture->SetBufferInUse(buffer); |
538 ppp_video_capture_impl_->OnBufferReady( | 557 ppp_video_capture_impl_->OnBufferReady( |
539 host_resource.instance(), capture->pp_resource(), buffer); | 558 host_resource.instance(), capture->pp_resource(), buffer); |
540 } | 559 } |
541 | 560 |
542 } // namespace proxy | 561 } // namespace proxy |
543 } // namespace ppapi | 562 } // namespace ppapi |
OLD | NEW |