| 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 "content/renderer/pepper/pepper_video_capture_host.h" | 5 #include "content/renderer/pepper/pepper_video_capture_host.h" |
| 6 | 6 |
| 7 #include "ppapi/host/dispatch_host_message.h" | 7 #include "ppapi/host/dispatch_host_message.h" |
| 8 #include "ppapi/host/ppapi_host.h" | 8 #include "ppapi/host/ppapi_host.h" |
| 9 #include "ppapi/proxy/host_dispatcher.h" | 9 #include "ppapi/proxy/host_dispatcher.h" |
| 10 #include "ppapi/proxy/ppapi_messages.h" | 10 #include "ppapi/proxy/ppapi_messages.h" |
| 11 #include "ppapi/shared_impl/host_resource.h" | 11 #include "ppapi/shared_impl/host_resource.h" |
| 12 #include "ppapi/thunk/enter.h" | 12 #include "ppapi/thunk/enter.h" |
| 13 #include "ppapi/thunk/ppb_buffer_api.h" | 13 #include "ppapi/thunk/ppb_buffer_api.h" |
| 14 #include "third_party/WebKit/public/web/WebDocument.h" | 14 #include "third_party/WebKit/public/web/WebDocument.h" |
| 15 #include "third_party/WebKit/public/web/WebElement.h" | 15 #include "third_party/WebKit/public/web/WebElement.h" |
| 16 #include "third_party/WebKit/public/web/WebPluginContainer.h" | 16 #include "third_party/WebKit/public/web/WebPluginContainer.h" |
| 17 #include "webkit/plugins/ppapi/host_globals.h" | 17 #include "webkit/plugins/ppapi/host_globals.h" |
| 18 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 18 #include "webkit/plugins/ppapi/ppapi_plugin_instance_impl.h" |
| 19 | 19 |
| 20 using ppapi::HostResource; | 20 using ppapi::HostResource; |
| 21 using ppapi::TrackedCallback; | 21 using ppapi::TrackedCallback; |
| 22 using ppapi::thunk::EnterResourceNoLock; | 22 using ppapi::thunk::EnterResourceNoLock; |
| 23 using ppapi::thunk::PPB_Buffer_API; | 23 using ppapi::thunk::PPB_Buffer_API; |
| 24 using webkit::ppapi::HostGlobals; | 24 using webkit::ppapi::HostGlobals; |
| 25 using webkit::ppapi::PPB_Buffer_Impl; | 25 using webkit::ppapi::PPB_Buffer_Impl; |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 OnError(capture, PP_ERROR_NOMEMORY); | 234 OnError(capture, PP_ERROR_NOMEMORY); |
| 235 return; | 235 return; |
| 236 } | 236 } |
| 237 | 237 |
| 238 host()->Send(new PpapiPluginMsg_ResourceReply( | 238 host()->Send(new PpapiPluginMsg_ResourceReply( |
| 239 params, PpapiPluginMsg_VideoCapture_OnDeviceInfo( | 239 params, PpapiPluginMsg_VideoCapture_OnDeviceInfo( |
| 240 info, buffer_host_resources, size))); | 240 info, buffer_host_resources, size))); |
| 241 } | 241 } |
| 242 | 242 |
| 243 webkit::ppapi::PluginDelegate* PepperVideoCaptureHost::GetPluginDelegate() { | 243 webkit::ppapi::PluginDelegate* PepperVideoCaptureHost::GetPluginDelegate() { |
| 244 webkit::ppapi::PluginInstance* instance = | 244 webkit::ppapi::PluginInstanceImpl* instance = |
| 245 renderer_ppapi_host_->GetPluginInstance(pp_instance()); | 245 static_cast<webkit::ppapi::PluginInstanceImpl*>( |
| 246 renderer_ppapi_host_->GetPluginInstance(pp_instance())); |
| 246 if (instance) | 247 if (instance) |
| 247 return instance->delegate(); | 248 return instance->delegate(); |
| 248 return NULL; | 249 return NULL; |
| 249 } | 250 } |
| 250 | 251 |
| 251 int32_t PepperVideoCaptureHost::OnOpen( | 252 int32_t PepperVideoCaptureHost::OnOpen( |
| 252 ppapi::host::HostMessageContext* context, | 253 ppapi::host::HostMessageContext* context, |
| 253 const std::string& device_id, | 254 const std::string& device_id, |
| 254 const PP_VideoCaptureDeviceInfo_Dev& requested_info, | 255 const PP_VideoCaptureDeviceInfo_Dev& requested_info, |
| 255 uint32_t buffer_count) { | 256 uint32_t buffer_count) { |
| 256 if (platform_video_capture_.get()) | 257 if (platform_video_capture_.get()) |
| 257 return PP_ERROR_FAILED; | 258 return PP_ERROR_FAILED; |
| 258 | 259 |
| 259 webkit::ppapi::PluginDelegate* plugin_delegate = GetPluginDelegate(); | 260 webkit::ppapi::PluginDelegate* plugin_delegate = GetPluginDelegate(); |
| 260 if (!plugin_delegate) | 261 if (!plugin_delegate) |
| 261 return PP_ERROR_FAILED; | 262 return PP_ERROR_FAILED; |
| 262 | 263 |
| 263 SetRequestedInfo(requested_info, buffer_count); | 264 SetRequestedInfo(requested_info, buffer_count); |
| 264 | 265 |
| 265 webkit::ppapi::PluginInstance* instance = | 266 webkit::ppapi::PluginInstance* instance = |
| 266 renderer_ppapi_host_->GetPluginInstance(pp_instance()); | 267 renderer_ppapi_host_->GetPluginInstance(pp_instance()); |
| 267 if (!instance) | 268 if (!instance) |
| 268 return PP_ERROR_FAILED; | 269 return PP_ERROR_FAILED; |
| 269 | 270 |
| 270 platform_video_capture_ = | 271 platform_video_capture_ = |
| 271 plugin_delegate->CreateVideoCapture(device_id, | 272 plugin_delegate->CreateVideoCapture(device_id, |
| 272 instance->container()->element().document().url(), this); | 273 instance->GetContainer()->element().document().url(), this); |
| 273 | 274 |
| 274 open_reply_context_ = context->MakeReplyMessageContext(); | 275 open_reply_context_ = context->MakeReplyMessageContext(); |
| 275 | 276 |
| 276 return PP_OK_COMPLETIONPENDING; | 277 return PP_OK_COMPLETIONPENDING; |
| 277 } | 278 } |
| 278 | 279 |
| 279 int32_t PepperVideoCaptureHost::OnStartCapture( | 280 int32_t PepperVideoCaptureHost::OnStartCapture( |
| 280 ppapi::host::HostMessageContext* context) { | 281 ppapi::host::HostMessageContext* context) { |
| 281 if (!SetStatus(PP_VIDEO_CAPTURE_STATUS_STARTING, false) || | 282 if (!SetStatus(PP_VIDEO_CAPTURE_STATUS_STARTING, false) || |
| 282 !platform_video_capture_.get()) | 283 !platform_video_capture_.get()) |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 PepperVideoCaptureHost::BufferInfo::BufferInfo() | 418 PepperVideoCaptureHost::BufferInfo::BufferInfo() |
| 418 : in_use(false), | 419 : in_use(false), |
| 419 data(NULL), | 420 data(NULL), |
| 420 buffer() { | 421 buffer() { |
| 421 } | 422 } |
| 422 | 423 |
| 423 PepperVideoCaptureHost::BufferInfo::~BufferInfo() { | 424 PepperVideoCaptureHost::BufferInfo::~BufferInfo() { |
| 424 } | 425 } |
| 425 | 426 |
| 426 } // namespace content | 427 } // namespace content |
| OLD | NEW |