| 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 const PP_CompletionCallback& callback) OVERRIDE; | 167 scoped_refptr<TrackedCallback> 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 const PP_CompletionCallback& callback) OVERRIDE; | 172 scoped_refptr<TrackedCallback> 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 24 matching lines...) Expand all Loading... |
| 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( | 216 int32_t VideoCapture::InternalEnumerateDevices( |
| 217 PP_Resource* devices, const PP_CompletionCallback& callback) { | 217 PP_Resource* devices, |
| 218 scoped_refptr<TrackedCallback> callback) { |
| 218 devices_ = devices; | 219 devices_ = devices; |
| 219 enumerate_devices_callback_ = new TrackedCallback(this, callback); | 220 enumerate_devices_callback_ = callback; |
| 220 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_EnumerateDevices( | 221 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_EnumerateDevices( |
| 221 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource())); | 222 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource())); |
| 222 return PP_OK_COMPLETIONPENDING; | 223 return PP_OK_COMPLETIONPENDING; |
| 223 } | 224 } |
| 224 | 225 |
| 225 int32_t VideoCapture::InternalOpen( | 226 int32_t VideoCapture::InternalOpen( |
| 226 const std::string& device_id, | 227 const std::string& device_id, |
| 227 const PP_VideoCaptureDeviceInfo_Dev& requested_info, | 228 const PP_VideoCaptureDeviceInfo_Dev& requested_info, |
| 228 uint32_t buffer_count, | 229 uint32_t buffer_count, |
| 229 const PP_CompletionCallback& callback) { | 230 scoped_refptr<TrackedCallback> callback) { |
| 230 // Disallow blocking call. The base class doesn't check this. | 231 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( | 232 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_Open( |
| 236 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource(), device_id, requested_info, | 233 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource(), device_id, requested_info, |
| 237 buffer_count)); | 234 buffer_count)); |
| 238 return PP_OK_COMPLETIONPENDING; | 235 return PP_OK_COMPLETIONPENDING; |
| 239 } | 236 } |
| 240 | 237 |
| 241 int32_t VideoCapture::InternalStartCapture() { | 238 int32_t VideoCapture::InternalStartCapture() { |
| 242 buffer_in_use_.clear(); | 239 buffer_in_use_.clear(); |
| 243 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_StartCapture( | 240 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_StartCapture( |
| 244 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource())); | 241 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource())); |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 return; | 534 return; |
| 538 | 535 |
| 539 VideoCapture* capture = static_cast<VideoCapture*>(enter.object()); | 536 VideoCapture* capture = static_cast<VideoCapture*>(enter.object()); |
| 540 capture->SetBufferInUse(buffer); | 537 capture->SetBufferInUse(buffer); |
| 541 ppp_video_capture_impl_->OnBufferReady( | 538 ppp_video_capture_impl_->OnBufferReady( |
| 542 host_resource.instance(), capture->pp_resource(), buffer); | 539 host_resource.instance(), capture->pp_resource(), buffer); |
| 543 } | 540 } |
| 544 | 541 |
| 545 } // namespace proxy | 542 } // namespace proxy |
| 546 } // namespace ppapi | 543 } // namespace ppapi |
| OLD | NEW |