| 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 <vector> | 7 #include "base/compiler_specific.h" |
| 8 | |
| 9 #include "base/logging.h" | 8 #include "base/logging.h" |
| 10 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 11 #include "ppapi/c/pp_errors.h" | 10 #include "ppapi/c/pp_errors.h" |
| 12 #include "ppapi/c/pp_resource.h" | 11 #include "ppapi/c/pp_resource.h" |
| 13 #include "ppapi/c/ppb_core.h" | 12 #include "ppapi/c/ppb_core.h" |
| 14 #include "ppapi/c/dev/ppb_video_capture_dev.h" | 13 #include "ppapi/c/dev/ppb_video_capture_dev.h" |
| 15 #include "ppapi/c/dev/ppp_video_capture_dev.h" | 14 #include "ppapi/c/dev/ppp_video_capture_dev.h" |
| 16 #include "ppapi/proxy/enter_proxy.h" | 15 #include "ppapi/proxy/enter_proxy.h" |
| 17 #include "ppapi/proxy/host_dispatcher.h" | 16 #include "ppapi/proxy/host_dispatcher.h" |
| 18 #include "ppapi/proxy/plugin_dispatcher.h" | 17 #include "ppapi/proxy/plugin_dispatcher.h" |
| 19 #include "ppapi/proxy/ppapi_messages.h" | 18 #include "ppapi/proxy/ppapi_messages.h" |
| 20 #include "ppapi/proxy/ppb_buffer_proxy.h" | 19 #include "ppapi/proxy/ppb_buffer_proxy.h" |
| 20 #include "ppapi/shared_impl/ppapi_globals.h" |
| 21 #include "ppapi/shared_impl/ppb_video_capture_shared.h" |
| 22 #include "ppapi/shared_impl/resource_tracker.h" |
| 23 #include "ppapi/shared_impl/tracked_callback.h" |
| 21 #include "ppapi/thunk/ppb_buffer_api.h" | 24 #include "ppapi/thunk/ppb_buffer_api.h" |
| 22 #include "ppapi/thunk/ppb_buffer_trusted_api.h" | 25 #include "ppapi/thunk/ppb_buffer_trusted_api.h" |
| 23 #include "ppapi/thunk/ppb_video_capture_api.h" | 26 #include "ppapi/thunk/ppb_video_capture_api.h" |
| 24 #include "ppapi/thunk/resource_creation_api.h" | 27 #include "ppapi/thunk/resource_creation_api.h" |
| 25 #include "ppapi/thunk/thunk.h" | 28 #include "ppapi/thunk/thunk.h" |
| 26 | 29 |
| 27 using ppapi::thunk::EnterResourceNoLock; | 30 using ppapi::thunk::EnterResourceNoLock; |
| 28 using ppapi::thunk::PPB_Buffer_API; | 31 using ppapi::thunk::PPB_Buffer_API; |
| 29 using ppapi::thunk::PPB_BufferTrusted_API; | 32 using ppapi::thunk::PPB_BufferTrusted_API; |
| 30 using ppapi::thunk::PPB_VideoCapture_API; | 33 using ppapi::thunk::PPB_VideoCapture_API; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 133 |
| 131 PPP_VideoCapture_Dev ppp_video_capture = { | 134 PPP_VideoCapture_Dev ppp_video_capture = { |
| 132 OnDeviceInfo, | 135 OnDeviceInfo, |
| 133 OnStatus, | 136 OnStatus, |
| 134 OnError, | 137 OnError, |
| 135 OnBufferReady | 138 OnBufferReady |
| 136 }; | 139 }; |
| 137 | 140 |
| 138 } // namespace | 141 } // namespace |
| 139 | 142 |
| 140 class VideoCapture : public ppapi::thunk::PPB_VideoCapture_API, | 143 class VideoCapture : public PPB_VideoCapture_Shared { |
| 141 public Resource { | |
| 142 public: | 144 public: |
| 143 VideoCapture(const HostResource& resource); | 145 explicit VideoCapture(const HostResource& resource); |
| 144 virtual ~VideoCapture(); | 146 virtual ~VideoCapture(); |
| 145 | 147 |
| 146 // Resource overrides. | 148 bool OnStatus(PP_VideoCaptureStatus_Dev status); |
| 147 virtual ppapi::thunk::PPB_VideoCapture_API* AsPPB_VideoCapture_API() OVERRIDE; | |
| 148 | 149 |
| 149 // PPB_VideoCapture_API implementation. | 150 void set_status(PP_VideoCaptureStatus_Dev status) { |
| 150 virtual int32_t StartCapture( | 151 SetStatus(status, true); |
| 151 const PP_VideoCaptureDeviceInfo_Dev& requested_info, | |
| 152 uint32_t buffer_count) { | |
| 153 switch (status_) { | |
| 154 case PP_VIDEO_CAPTURE_STATUS_STARTING: | |
| 155 case PP_VIDEO_CAPTURE_STATUS_STARTED: | |
| 156 case PP_VIDEO_CAPTURE_STATUS_PAUSED: | |
| 157 default: | |
| 158 return PP_ERROR_FAILED; | |
| 159 case PP_VIDEO_CAPTURE_STATUS_STOPPED: | |
| 160 case PP_VIDEO_CAPTURE_STATUS_STOPPING: | |
| 161 break; | |
| 162 } | |
| 163 status_ = PP_VIDEO_CAPTURE_STATUS_STARTING; | |
| 164 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_StartCapture( | |
| 165 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource(), | |
| 166 requested_info, buffer_count)); | |
| 167 return PP_OK; | |
| 168 } | 152 } |
| 169 | 153 |
| 170 virtual int32_t ReuseBuffer(uint32_t buffer) { | |
| 171 if (buffer >= buffer_in_use_.size() || !buffer_in_use_[buffer]) | |
| 172 return PP_ERROR_BADARGUMENT; | |
| 173 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_ReuseBuffer( | |
| 174 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource(), buffer)); | |
| 175 return PP_OK; | |
| 176 } | |
| 177 | |
| 178 virtual int32_t StopCapture() { | |
| 179 switch (status_) { | |
| 180 case PP_VIDEO_CAPTURE_STATUS_STOPPED: | |
| 181 case PP_VIDEO_CAPTURE_STATUS_STOPPING: | |
| 182 default: | |
| 183 return PP_ERROR_FAILED; | |
| 184 case PP_VIDEO_CAPTURE_STATUS_STARTING: | |
| 185 case PP_VIDEO_CAPTURE_STATUS_STARTED: | |
| 186 case PP_VIDEO_CAPTURE_STATUS_PAUSED: | |
| 187 break; | |
| 188 } | |
| 189 buffer_in_use_.clear(); | |
| 190 status_ = PP_VIDEO_CAPTURE_STATUS_STOPPING; | |
| 191 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_StopCapture( | |
| 192 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource())); | |
| 193 return PP_OK; | |
| 194 } | |
| 195 | |
| 196 bool OnStatus(uint32_t status) { | |
| 197 switch (status) { | |
| 198 case PP_VIDEO_CAPTURE_STATUS_STARTING: | |
| 199 case PP_VIDEO_CAPTURE_STATUS_STOPPING: | |
| 200 default: | |
| 201 // Those states are not sent by the browser. | |
| 202 NOTREACHED(); | |
| 203 return false; | |
| 204 case PP_VIDEO_CAPTURE_STATUS_STARTED: | |
| 205 switch (status_) { | |
| 206 case PP_VIDEO_CAPTURE_STATUS_STARTING: | |
| 207 case PP_VIDEO_CAPTURE_STATUS_PAUSED: | |
| 208 break; | |
| 209 default: | |
| 210 return false; | |
| 211 } | |
| 212 break; | |
| 213 case PP_VIDEO_CAPTURE_STATUS_PAUSED: | |
| 214 switch (status_) { | |
| 215 case PP_VIDEO_CAPTURE_STATUS_STARTING: | |
| 216 case PP_VIDEO_CAPTURE_STATUS_STARTED: | |
| 217 break; | |
| 218 default: | |
| 219 return false; | |
| 220 } | |
| 221 break; | |
| 222 case PP_VIDEO_CAPTURE_STATUS_STOPPED: | |
| 223 if (status_ != PP_VIDEO_CAPTURE_STATUS_STOPPING) | |
| 224 return false; | |
| 225 break; | |
| 226 } | |
| 227 status_ = status; | |
| 228 return true; | |
| 229 } | |
| 230 | |
| 231 void set_status(uint32_t status) { status_ = status; } | |
| 232 | |
| 233 void SetBufferCount(size_t count) { | 154 void SetBufferCount(size_t count) { |
| 234 buffer_in_use_ = std::vector<bool>(count); | 155 buffer_in_use_ = std::vector<bool>(count); |
| 235 } | 156 } |
| 157 |
| 236 void SetBufferInUse(uint32_t buffer) { | 158 void SetBufferInUse(uint32_t buffer) { |
| 237 DCHECK(buffer < buffer_in_use_.size()); | 159 DCHECK(buffer < buffer_in_use_.size()); |
| 238 buffer_in_use_[buffer] = true; | 160 buffer_in_use_[buffer] = true; |
| 239 } | 161 } |
| 240 | 162 |
| 241 private: | 163 private: |
| 164 // PPB_VideoCapture_Shared implementation. |
| 165 virtual int32_t InternalEnumerateDevices( |
| 166 PP_Resource* devices, |
| 167 PP_CompletionCallback callback) OVERRIDE; |
| 168 virtual int32_t InternalOpen( |
| 169 const std::string& device_id, |
| 170 const PP_VideoCaptureDeviceInfo_Dev& requested_info, |
| 171 uint32_t buffer_count, |
| 172 PP_CompletionCallback callback) OVERRIDE; |
| 173 virtual int32_t InternalStartCapture() OVERRIDE; |
| 174 virtual int32_t InternalReuseBuffer(uint32_t buffer) OVERRIDE; |
| 175 virtual int32_t InternalStopCapture() OVERRIDE; |
| 176 virtual void InternalClose() OVERRIDE; |
| 177 virtual int32_t InternalStartCapture0_1( |
| 178 const PP_VideoCaptureDeviceInfo_Dev& requested_info, |
| 179 uint32_t buffer_count) OVERRIDE; |
| 180 virtual const std::vector<DeviceRefData>& |
| 181 InternalGetDeviceRefData() const OVERRIDE; |
| 182 |
| 242 PluginDispatcher* GetDispatcher() const { | 183 PluginDispatcher* GetDispatcher() const { |
| 243 return PluginDispatcher::GetForResource(this); | 184 return PluginDispatcher::GetForResource(this); |
| 244 } | 185 } |
| 245 | 186 |
| 246 uint32_t status_; | |
| 247 std::vector<bool> buffer_in_use_; | 187 std::vector<bool> buffer_in_use_; |
| 188 |
| 248 DISALLOW_COPY_AND_ASSIGN(VideoCapture); | 189 DISALLOW_COPY_AND_ASSIGN(VideoCapture); |
| 249 }; | 190 }; |
| 250 | 191 |
| 251 VideoCapture::VideoCapture(const HostResource& resource) | 192 VideoCapture::VideoCapture(const HostResource& resource) |
| 252 : Resource(OBJECT_IS_PROXY, resource), | 193 : PPB_VideoCapture_Shared(resource) { |
| 253 status_(PP_VIDEO_CAPTURE_STATUS_STOPPED) { | |
| 254 } | 194 } |
| 255 | 195 |
| 256 VideoCapture::~VideoCapture() { | 196 VideoCapture::~VideoCapture() { |
| 197 Close(); |
| 257 } | 198 } |
| 258 | 199 |
| 259 ppapi::thunk::PPB_VideoCapture_API* VideoCapture::AsPPB_VideoCapture_API() { | 200 bool VideoCapture::OnStatus(PP_VideoCaptureStatus_Dev status) { |
| 260 return this; | 201 switch (status) { |
| 202 case PP_VIDEO_CAPTURE_STATUS_STARTED: |
| 203 case PP_VIDEO_CAPTURE_STATUS_PAUSED: |
| 204 case PP_VIDEO_CAPTURE_STATUS_STOPPED: |
| 205 return SetStatus(status, false); |
| 206 case PP_VIDEO_CAPTURE_STATUS_STARTING: |
| 207 case PP_VIDEO_CAPTURE_STATUS_STOPPING: |
| 208 // Those states are not sent by the browser. |
| 209 break; |
| 210 } |
| 211 |
| 212 NOTREACHED(); |
| 213 return false; |
| 214 } |
| 215 |
| 216 int32_t VideoCapture::InternalEnumerateDevices(PP_Resource* devices, |
| 217 PP_CompletionCallback callback) { |
| 218 devices_ = devices; |
| 219 enumerate_devices_callback_ = new TrackedCallback(this, callback); |
| 220 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_EnumerateDevices( |
| 221 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource())); |
| 222 return PP_OK_COMPLETIONPENDING; |
| 223 } |
| 224 |
| 225 int32_t VideoCapture::InternalOpen( |
| 226 const std::string& device_id, |
| 227 const PP_VideoCaptureDeviceInfo_Dev& requested_info, |
| 228 uint32_t buffer_count, |
| 229 PP_CompletionCallback callback) { |
| 230 // Disallow blocking call. The base class doesn't check this. |
| 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( |
| 236 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource(), device_id, requested_info, |
| 237 buffer_count)); |
| 238 return PP_OK_COMPLETIONPENDING; |
| 239 } |
| 240 |
| 241 int32_t VideoCapture::InternalStartCapture() { |
| 242 buffer_in_use_.clear(); |
| 243 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_StartCapture( |
| 244 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource())); |
| 245 return PP_OK; |
| 246 } |
| 247 |
| 248 int32_t VideoCapture::InternalReuseBuffer(uint32_t buffer) { |
| 249 if (buffer >= buffer_in_use_.size() || !buffer_in_use_[buffer]) |
| 250 return PP_ERROR_BADARGUMENT; |
| 251 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_ReuseBuffer( |
| 252 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource(), buffer)); |
| 253 return PP_OK; |
| 254 } |
| 255 |
| 256 int32_t VideoCapture::InternalStopCapture() { |
| 257 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_StopCapture( |
| 258 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource())); |
| 259 return PP_OK; |
| 260 } |
| 261 |
| 262 void VideoCapture::InternalClose() { |
| 263 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_Close( |
| 264 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource())); |
| 265 } |
| 266 |
| 267 int32_t VideoCapture::InternalStartCapture0_1( |
| 268 const PP_VideoCaptureDeviceInfo_Dev& requested_info, |
| 269 uint32_t buffer_count) { |
| 270 buffer_in_use_.clear(); |
| 271 GetDispatcher()->Send(new PpapiHostMsg_PPBVideoCapture_StartCapture0_1( |
| 272 API_ID_PPB_VIDEO_CAPTURE_DEV, host_resource(), requested_info, |
| 273 buffer_count)); |
| 274 return PP_OK; |
| 275 } |
| 276 |
| 277 const std::vector<DeviceRefData>& |
| 278 VideoCapture::InternalGetDeviceRefData() const { |
| 279 // This should never be called at the plugin side. |
| 280 NOTREACHED(); |
| 281 static std::vector<DeviceRefData> result; |
| 282 return result; |
| 261 } | 283 } |
| 262 | 284 |
| 263 PPB_VideoCapture_Proxy::PPB_VideoCapture_Proxy(Dispatcher* dispatcher) | 285 PPB_VideoCapture_Proxy::PPB_VideoCapture_Proxy(Dispatcher* dispatcher) |
| 264 : InterfaceProxy(dispatcher) { | 286 : InterfaceProxy(dispatcher), |
| 287 ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)) { |
| 265 } | 288 } |
| 266 | 289 |
| 267 PPB_VideoCapture_Proxy::~PPB_VideoCapture_Proxy() { | 290 PPB_VideoCapture_Proxy::~PPB_VideoCapture_Proxy() { |
| 268 } | 291 } |
| 269 | 292 |
| 270 // static | 293 // static |
| 271 PP_Resource PPB_VideoCapture_Proxy::CreateProxyResource(PP_Instance instance) { | 294 PP_Resource PPB_VideoCapture_Proxy::CreateProxyResource(PP_Instance instance) { |
| 272 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 295 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
| 273 if (!dispatcher) | 296 if (!dispatcher) |
| 274 return 0; | 297 return 0; |
| 275 | 298 |
| 276 HostResource result; | 299 HostResource result; |
| 277 dispatcher->Send(new PpapiHostMsg_PPBVideoCapture_Create( | 300 dispatcher->Send(new PpapiHostMsg_PPBVideoCapture_Create( |
| 278 API_ID_PPB_VIDEO_CAPTURE_DEV, instance, &result)); | 301 API_ID_PPB_VIDEO_CAPTURE_DEV, instance, &result)); |
| 279 if (result.is_null()) | 302 if (result.is_null()) |
| 280 return 0; | 303 return 0; |
| 281 return (new VideoCapture(result))->GetReference(); | 304 return (new VideoCapture(result))->GetReference(); |
| 282 } | 305 } |
| 283 | 306 |
| 284 bool PPB_VideoCapture_Proxy::OnMessageReceived(const IPC::Message& msg) { | 307 bool PPB_VideoCapture_Proxy::OnMessageReceived(const IPC::Message& msg) { |
| 285 bool handled = true; | 308 bool handled = true; |
| 286 IPC_BEGIN_MESSAGE_MAP(PPB_VideoCapture_Proxy, msg) | 309 IPC_BEGIN_MESSAGE_MAP(PPB_VideoCapture_Proxy, msg) |
| 287 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_Create, OnMsgCreate) | 310 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_Create, OnMsgCreate) |
| 311 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_EnumerateDevices, |
| 312 OnMsgEnumerateDevices) |
| 313 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_Open, OnMsgOpen) |
| 288 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_StartCapture, | 314 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_StartCapture, |
| 289 OnMsgStartCapture) | 315 OnMsgStartCapture) |
| 290 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_ReuseBuffer, | 316 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_ReuseBuffer, |
| 291 OnMsgReuseBuffer) | 317 OnMsgReuseBuffer) |
| 292 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_StopCapture, | 318 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_StopCapture, |
| 293 OnMsgStopCapture) | 319 OnMsgStopCapture) |
| 320 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_Close, OnMsgClose) |
| 321 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBVideoCapture_StartCapture0_1, |
| 322 OnMsgStartCapture0_1) |
| 323 |
| 324 IPC_MESSAGE_HANDLER(PpapiMsg_PPBVideoCapture_EnumerateDevicesACK, |
| 325 OnMsgEnumerateDevicesACK) |
| 326 IPC_MESSAGE_HANDLER(PpapiMsg_PPBVideoCapture_OpenACK, |
| 327 OnMsgOpenACK) |
| 294 IPC_MESSAGE_UNHANDLED(handled = false) | 328 IPC_MESSAGE_UNHANDLED(handled = false) |
| 295 IPC_END_MESSAGE_MAP() | 329 IPC_END_MESSAGE_MAP() |
| 296 // TODO(brettw) handle bad messages! | 330 // TODO(brettw) handle bad messages! |
| 297 return handled; | 331 return handled; |
| 298 } | 332 } |
| 299 | 333 |
| 300 void PPB_VideoCapture_Proxy::OnMsgCreate(PP_Instance instance, | 334 void PPB_VideoCapture_Proxy::OnMsgCreate(PP_Instance instance, |
| 301 HostResource* result_resource) { | 335 HostResource* result_resource) { |
| 302 thunk::EnterResourceCreation enter(instance); | 336 thunk::EnterResourceCreation enter(instance); |
| 303 if (enter.succeeded()) { | 337 if (enter.succeeded()) { |
| 304 result_resource->SetHostResource( | 338 result_resource->SetHostResource( |
| 305 instance, | 339 instance, |
| 306 enter.functions()->CreateVideoCapture(instance)); | 340 enter.functions()->CreateVideoCapture(instance)); |
| 307 } | 341 } |
| 308 } | 342 } |
| 309 | 343 |
| 310 void PPB_VideoCapture_Proxy::OnMsgStartCapture( | 344 void PPB_VideoCapture_Proxy::OnMsgEnumerateDevices( |
| 311 const HostResource& resource, | 345 const HostResource& resource) { |
| 346 EnterHostFromHostResourceForceCallback<PPB_VideoCapture_API> enter( |
| 347 resource, callback_factory_, |
| 348 &PPB_VideoCapture_Proxy::EnumerateDevicesACKInHost, resource); |
| 349 |
| 350 if (enter.succeeded()) |
| 351 enter.SetResult(enter.object()->EnumerateDevices(NULL, enter.callback())); |
| 352 } |
| 353 |
| 354 void PPB_VideoCapture_Proxy::OnMsgOpen( |
| 355 const ppapi::HostResource& resource, |
| 356 const std::string& device_id, |
| 312 const PP_VideoCaptureDeviceInfo_Dev& info, | 357 const PP_VideoCaptureDeviceInfo_Dev& info, |
| 313 uint32_t buffers) { | 358 uint32_t buffers) { |
| 359 EnterHostFromHostResourceForceCallback<PPB_VideoCapture_API> enter( |
| 360 resource, callback_factory_, &PPB_VideoCapture_Proxy::OpenACKInHost, |
| 361 resource); |
| 362 |
| 363 if (enter.succeeded()) { |
| 364 enter.SetResult(enter.object()->Open(device_id, info, buffers, |
| 365 enter.callback())); |
| 366 } |
| 367 } |
| 368 |
| 369 void PPB_VideoCapture_Proxy::OnMsgStartCapture(const HostResource& resource) { |
| 314 EnterHostFromHostResource<PPB_VideoCapture_API> enter(resource); | 370 EnterHostFromHostResource<PPB_VideoCapture_API> enter(resource); |
| 315 if (enter.succeeded()) | 371 if (enter.succeeded()) |
| 316 enter.object()->StartCapture(info, buffers); | 372 enter.object()->StartCapture(); |
| 317 } | 373 } |
| 318 | 374 |
| 319 void PPB_VideoCapture_Proxy::OnMsgReuseBuffer(const HostResource& resource, | 375 void PPB_VideoCapture_Proxy::OnMsgReuseBuffer(const HostResource& resource, |
| 320 uint32_t buffer) { | 376 uint32_t buffer) { |
| 321 EnterHostFromHostResource<PPB_VideoCapture_API> enter(resource); | 377 EnterHostFromHostResource<PPB_VideoCapture_API> enter(resource); |
| 322 if (enter.succeeded()) | 378 if (enter.succeeded()) |
| 323 enter.object()->ReuseBuffer(buffer); | 379 enter.object()->ReuseBuffer(buffer); |
| 324 } | 380 } |
| 325 | 381 |
| 326 void PPB_VideoCapture_Proxy::OnMsgStopCapture(const HostResource& resource) { | 382 void PPB_VideoCapture_Proxy::OnMsgStopCapture(const HostResource& resource) { |
| 327 EnterHostFromHostResource<PPB_VideoCapture_API> enter(resource); | 383 EnterHostFromHostResource<PPB_VideoCapture_API> enter(resource); |
| 328 if (enter.succeeded()) | 384 if (enter.succeeded()) |
| 329 enter.object()->StopCapture(); | 385 enter.object()->StopCapture(); |
| 330 } | 386 } |
| 331 | 387 |
| 388 void PPB_VideoCapture_Proxy::OnMsgClose(const HostResource& resource) { |
| 389 EnterHostFromHostResource<PPB_VideoCapture_API> enter(resource); |
| 390 if (enter.succeeded()) |
| 391 enter.object()->Close(); |
| 392 } |
| 393 |
| 394 void PPB_VideoCapture_Proxy::OnMsgStartCapture0_1( |
| 395 const HostResource& resource, |
| 396 const PP_VideoCaptureDeviceInfo_Dev& info, |
| 397 uint32_t buffers) { |
| 398 EnterHostFromHostResource<PPB_VideoCapture_API> enter(resource); |
| 399 if (enter.succeeded()) |
| 400 enter.object()->StartCapture0_1(info, buffers); |
| 401 } |
| 402 |
| 403 void PPB_VideoCapture_Proxy::OnMsgEnumerateDevicesACK( |
| 404 const HostResource& resource, |
| 405 int32_t result, |
| 406 const std::vector<ppapi::DeviceRefData>& devices) { |
| 407 EnterPluginFromHostResource<PPB_VideoCapture_API> enter(resource); |
| 408 if (enter.succeeded()) { |
| 409 static_cast<VideoCapture*>(enter.object())->OnEnumerateDevicesComplete( |
| 410 result, devices); |
| 411 } |
| 412 } |
| 413 |
| 414 void PPB_VideoCapture_Proxy::OnMsgOpenACK( |
| 415 const HostResource& resource, |
| 416 int32_t result) { |
| 417 EnterPluginFromHostResource<PPB_VideoCapture_API> enter(resource); |
| 418 if (enter.succeeded()) |
| 419 static_cast<VideoCapture*>(enter.object())->OnOpenComplete(result); |
| 420 } |
| 421 |
| 422 void PPB_VideoCapture_Proxy::EnumerateDevicesACKInHost( |
| 423 int32_t result, |
| 424 const HostResource& resource) { |
| 425 EnterHostFromHostResource<PPB_VideoCapture_API> enter(resource); |
| 426 dispatcher()->Send(new PpapiMsg_PPBVideoCapture_EnumerateDevicesACK( |
| 427 API_ID_PPB_VIDEO_CAPTURE_DEV, resource, result, |
| 428 enter.succeeded() && result == PP_OK ? |
| 429 enter.object()->GetDeviceRefData() : std::vector<DeviceRefData>())); |
| 430 } |
| 431 |
| 432 void PPB_VideoCapture_Proxy::OpenACKInHost(int32_t result, |
| 433 const HostResource& resource) { |
| 434 dispatcher()->Send(new PpapiMsg_PPBVideoCapture_OpenACK( |
| 435 API_ID_PPB_VIDEO_CAPTURE_DEV, resource, result)); |
| 436 } |
| 437 |
| 332 PPP_VideoCapture_Proxy::PPP_VideoCapture_Proxy(Dispatcher* dispatcher) | 438 PPP_VideoCapture_Proxy::PPP_VideoCapture_Proxy(Dispatcher* dispatcher) |
| 333 : InterfaceProxy(dispatcher), | 439 : InterfaceProxy(dispatcher), |
| 334 ppp_video_capture_impl_(NULL) { | 440 ppp_video_capture_impl_(NULL) { |
| 335 if (dispatcher->IsPlugin()) { | 441 if (dispatcher->IsPlugin()) { |
| 336 ppp_video_capture_impl_ = static_cast<const PPP_VideoCapture_Dev*>( | 442 ppp_video_capture_impl_ = static_cast<const PPP_VideoCapture_Dev*>( |
| 337 dispatcher->local_get_interface()(PPP_VIDEO_CAPTURE_DEV_INTERFACE)); | 443 dispatcher->local_get_interface()(PPP_VIDEO_CAPTURE_DEV_INTERFACE)); |
| 338 } | 444 } |
| 339 } | 445 } |
| 340 | 446 |
| 341 PPP_VideoCapture_Proxy::~PPP_VideoCapture_Proxy() { | 447 PPP_VideoCapture_Proxy::~PPP_VideoCapture_Proxy() { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 tracker->ReleaseResource(resources[i]); | 505 tracker->ReleaseResource(resources[i]); |
| 400 } | 506 } |
| 401 | 507 |
| 402 void PPP_VideoCapture_Proxy::OnMsgOnStatus(const HostResource& host_resource, | 508 void PPP_VideoCapture_Proxy::OnMsgOnStatus(const HostResource& host_resource, |
| 403 uint32_t status) { | 509 uint32_t status) { |
| 404 EnterPluginFromHostResource<PPB_VideoCapture_API> enter(host_resource); | 510 EnterPluginFromHostResource<PPB_VideoCapture_API> enter(host_resource); |
| 405 if (enter.failed() || !ppp_video_capture_impl_) | 511 if (enter.failed() || !ppp_video_capture_impl_) |
| 406 return; | 512 return; |
| 407 | 513 |
| 408 VideoCapture* capture = static_cast<VideoCapture*>(enter.object()); | 514 VideoCapture* capture = static_cast<VideoCapture*>(enter.object()); |
| 409 if (!capture->OnStatus(status)) | 515 if (!capture->OnStatus(static_cast<PP_VideoCaptureStatus_Dev>(status))) |
| 410 return; | 516 return; |
| 411 ppp_video_capture_impl_->OnStatus( | 517 ppp_video_capture_impl_->OnStatus( |
| 412 host_resource.instance(), capture->pp_resource(), status); | 518 host_resource.instance(), capture->pp_resource(), status); |
| 413 } | 519 } |
| 414 | 520 |
| 415 void PPP_VideoCapture_Proxy::OnMsgOnError(const HostResource& host_resource, | 521 void PPP_VideoCapture_Proxy::OnMsgOnError(const HostResource& host_resource, |
| 416 uint32_t error_code) { | 522 uint32_t error_code) { |
| 417 EnterPluginFromHostResource<PPB_VideoCapture_API> enter(host_resource); | 523 EnterPluginFromHostResource<PPB_VideoCapture_API> enter(host_resource); |
| 418 if (enter.failed() || !ppp_video_capture_impl_) | 524 if (enter.failed() || !ppp_video_capture_impl_) |
| 419 return; | 525 return; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 431 return; | 537 return; |
| 432 | 538 |
| 433 VideoCapture* capture = static_cast<VideoCapture*>(enter.object()); | 539 VideoCapture* capture = static_cast<VideoCapture*>(enter.object()); |
| 434 capture->SetBufferInUse(buffer); | 540 capture->SetBufferInUse(buffer); |
| 435 ppp_video_capture_impl_->OnBufferReady( | 541 ppp_video_capture_impl_->OnBufferReady( |
| 436 host_resource.instance(), capture->pp_resource(), buffer); | 542 host_resource.instance(), capture->pp_resource(), buffer); |
| 437 } | 543 } |
| 438 | 544 |
| 439 } // namespace proxy | 545 } // namespace proxy |
| 440 } // namespace ppapi | 546 } // namespace ppapi |
| OLD | NEW |