| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 buffer_in_use_ = std::vector<bool>(count); | 155 buffer_in_use_ = std::vector<bool>(count); |
| 156 } | 156 } |
| 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(PP_Resource* devices, |
| 166 PP_Resource* devices, | 166 ApiCallbackType callback) OVERRIDE; |
| 167 const PP_CompletionCallback& callback) OVERRIDE; | |
| 168 virtual int32_t InternalOpen( | 167 virtual int32_t InternalOpen( |
| 169 const std::string& device_id, | 168 const std::string& device_id, |
| 170 const PP_VideoCaptureDeviceInfo_Dev& requested_info, | 169 const PP_VideoCaptureDeviceInfo_Dev& requested_info, |
| 171 uint32_t buffer_count, | 170 uint32_t buffer_count, |
| 172 const PP_CompletionCallback& callback) OVERRIDE; | 171 ApiCallbackType callback) OVERRIDE; |
| 173 virtual int32_t InternalStartCapture() OVERRIDE; | 172 virtual int32_t InternalStartCapture() OVERRIDE; |
| 174 virtual int32_t InternalReuseBuffer(uint32_t buffer) OVERRIDE; | 173 virtual int32_t InternalReuseBuffer(uint32_t buffer) OVERRIDE; |
| 175 virtual int32_t InternalStopCapture() OVERRIDE; | 174 virtual int32_t InternalStopCapture() OVERRIDE; |
| 176 virtual void InternalClose() OVERRIDE; | 175 virtual void InternalClose() OVERRIDE; |
| 177 virtual int32_t InternalStartCapture0_1( | 176 virtual int32_t InternalStartCapture0_1( |
| 178 const PP_VideoCaptureDeviceInfo_Dev& requested_info, | 177 const PP_VideoCaptureDeviceInfo_Dev& requested_info, |
| 179 uint32_t buffer_count) OVERRIDE; | 178 uint32_t buffer_count) OVERRIDE; |
| 180 virtual const std::vector<DeviceRefData>& | 179 virtual const std::vector<DeviceRefData>& |
| 181 InternalGetDeviceRefData() const OVERRIDE; | 180 InternalGetDeviceRefData() const OVERRIDE; |
| 182 | 181 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 206 case PP_VIDEO_CAPTURE_STATUS_STARTING: | 205 case PP_VIDEO_CAPTURE_STATUS_STARTING: |
| 207 case PP_VIDEO_CAPTURE_STATUS_STOPPING: | 206 case PP_VIDEO_CAPTURE_STATUS_STOPPING: |
| 208 // Those states are not sent by the browser. | 207 // Those states are not sent by the browser. |
| 209 break; | 208 break; |
| 210 } | 209 } |
| 211 | 210 |
| 212 NOTREACHED(); | 211 NOTREACHED(); |
| 213 return false; | 212 return false; |
| 214 } | 213 } |
| 215 | 214 |
| 216 int32_t VideoCapture::InternalEnumerateDevices( | 215 int32_t VideoCapture::InternalEnumerateDevices(PP_Resource* devices, |
| 217 PP_Resource* devices, const PP_CompletionCallback& callback) { | 216 ApiCallbackType callback) { |
| 218 devices_ = devices; | 217 devices_ = devices; |
| 219 enumerate_devices_callback_ = new TrackedCallback(this, callback); | 218 enumerate_devices_callback_ = callback; |
| 220 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_EnumerateDevices( | 219 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_EnumerateDevices( |
| 221 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource())); | 220 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource())); |
| 222 return PP_OK_COMPLETIONPENDING; | 221 return PP_OK_COMPLETIONPENDING; |
| 223 } | 222 } |
| 224 | 223 |
| 225 int32_t VideoCapture::InternalOpen( | 224 int32_t VideoCapture::InternalOpen( |
| 226 const std::string& device_id, | 225 const std::string& device_id, |
| 227 const PP_VideoCaptureDeviceInfo_Dev& requested_info, | 226 const PP_VideoCaptureDeviceInfo_Dev& requested_info, |
| 228 uint32_t buffer_count, | 227 uint32_t buffer_count, |
| 229 const PP_CompletionCallback& callback) { | 228 ApiCallbackType callback) { |
| 230 // Disallow blocking call. The base class doesn't check this. | 229 open_callback_ = callback; |
| 231 if (!callback.func) | |
| 232 return PP_ERROR_BLOCKS_MAIN_THREAD; | |
| 233 | |
| 234 open_callback_ = new TrackedCallback(this, callback); | |
| 235 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_Open( | 230 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_Open( |
| 236 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource(), device_id, requested_info, | 231 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource(), device_id, requested_info, |
| 237 buffer_count)); | 232 buffer_count)); |
| 238 return PP_OK_COMPLETIONPENDING; | 233 return PP_OK_COMPLETIONPENDING; |
| 239 } | 234 } |
| 240 | 235 |
| 241 int32_t VideoCapture::InternalStartCapture() { | 236 int32_t VideoCapture::InternalStartCapture() { |
| 242 buffer_in_use_.clear(); | 237 buffer_in_use_.clear(); |
| 243 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_StartCapture( | 238 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_StartCapture( |
| 244 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource())); | 239 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource())); |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 return; | 532 return; |
| 538 | 533 |
| 539 VideoCapture* capture = static_cast<VideoCapture*>(enter.object()); | 534 VideoCapture* capture = static_cast<VideoCapture*>(enter.object()); |
| 540 capture->SetBufferInUse(buffer); | 535 capture->SetBufferInUse(buffer); |
| 541 ppp_video_capture_impl_->OnBufferReady( | 536 ppp_video_capture_impl_->OnBufferReady( |
| 542 host_resource.instance(), capture->pp_resource(), buffer); | 537 host_resource.instance(), capture->pp_resource(), buffer); |
| 543 } | 538 } |
| 544 | 539 |
| 545 } // namespace proxy | 540 } // namespace proxy |
| 546 } // namespace ppapi | 541 } // namespace ppapi |
| OLD | NEW |