| 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 "content/renderer/pepper/host_globals.h" | 7 #include "content/renderer/pepper/host_globals.h" |
| 8 #include "content/renderer/pepper/pepper_media_device_manager.h" | 8 #include "content/renderer/pepper/pepper_media_device_manager.h" |
| 9 #include "content/renderer/pepper/pepper_platform_video_capture.h" | 9 #include "content/renderer/pepper/pepper_platform_video_capture.h" |
| 10 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 10 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| 11 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" | 11 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" |
| 12 #include "content/renderer/render_view_impl.h" | 12 #include "content/renderer/render_view_impl.h" |
| 13 #include "ppapi/host/dispatch_host_message.h" | 13 #include "ppapi/host/dispatch_host_message.h" |
| 14 #include "ppapi/host/ppapi_host.h" | 14 #include "ppapi/host/ppapi_host.h" |
| 15 #include "ppapi/proxy/host_dispatcher.h" | 15 #include "ppapi/proxy/host_dispatcher.h" |
| 16 #include "ppapi/proxy/ppapi_messages.h" | 16 #include "ppapi/proxy/ppapi_messages.h" |
| 17 #include "ppapi/shared_impl/host_resource.h" | 17 #include "ppapi/shared_impl/host_resource.h" |
| 18 #include "ppapi/thunk/enter.h" | 18 #include "ppapi/thunk/enter.h" |
| 19 #include "ppapi/thunk/ppb_buffer_api.h" | 19 #include "ppapi/thunk/ppb_buffer_api.h" |
| 20 #include "third_party/WebKit/public/web/WebDocument.h" | |
| 21 #include "third_party/WebKit/public/web/WebElement.h" | |
| 22 #include "third_party/WebKit/public/web/WebPluginContainer.h" | |
| 23 | 20 |
| 24 using ppapi::HostResource; | 21 using ppapi::HostResource; |
| 25 using ppapi::TrackedCallback; | 22 using ppapi::TrackedCallback; |
| 26 using ppapi::thunk::EnterResourceNoLock; | 23 using ppapi::thunk::EnterResourceNoLock; |
| 27 using ppapi::thunk::PPB_Buffer_API; | 24 using ppapi::thunk::PPB_Buffer_API; |
| 28 | 25 |
| 29 namespace { | 26 namespace { |
| 30 | 27 |
| 31 // Maximum number of buffers to actually allocate. | 28 // Maximum number of buffers to actually allocate. |
| 32 const uint32_t kMaxBuffers = 20; | 29 const uint32_t kMaxBuffers = 20; |
| 33 | 30 |
| 34 } // namespace | 31 } // namespace |
| 35 | 32 |
| 36 namespace content { | 33 namespace content { |
| 37 | 34 |
| 38 PepperVideoCaptureHost::PepperVideoCaptureHost(RendererPpapiHostImpl* host, | 35 PepperVideoCaptureHost::PepperVideoCaptureHost(RendererPpapiHostImpl* host, |
| 39 PP_Instance instance, | 36 PP_Instance instance, |
| 40 PP_Resource resource) | 37 PP_Resource resource) |
| 41 : ResourceHost(host->GetPpapiHost(), instance, resource), | 38 : ResourceHost(host->GetPpapiHost(), instance, resource), |
| 42 renderer_ppapi_host_(host), | 39 renderer_ppapi_host_(host), |
| 43 buffer_count_hint_(0), | 40 buffer_count_hint_(0), |
| 44 status_(PP_VIDEO_CAPTURE_STATUS_STOPPED), | 41 status_(PP_VIDEO_CAPTURE_STATUS_STOPPED), |
| 45 enumeration_helper_( | 42 enumeration_helper_( |
| 46 this, | 43 this, |
| 47 PepperMediaDeviceManager::GetForRenderView( | 44 PepperMediaDeviceManager::GetForRenderView( |
| 48 host->GetRenderViewForInstance(pp_instance())), | 45 host->GetRenderViewForInstance(pp_instance())), |
| 49 PP_DEVICETYPE_DEV_VIDEOCAPTURE) { | 46 PP_DEVICETYPE_DEV_VIDEOCAPTURE, |
| 47 host->GetDocumentURL(instance)) { |
| 50 } | 48 } |
| 51 | 49 |
| 52 PepperVideoCaptureHost::~PepperVideoCaptureHost() { | 50 PepperVideoCaptureHost::~PepperVideoCaptureHost() { |
| 53 Close(); | 51 Close(); |
| 54 } | 52 } |
| 55 | 53 |
| 56 bool PepperVideoCaptureHost::Init() { | 54 bool PepperVideoCaptureHost::Init() { |
| 57 return !!renderer_ppapi_host_->GetPluginInstance(pp_instance()); | 55 return !!renderer_ppapi_host_->GetPluginInstance(pp_instance()); |
| 58 } | 56 } |
| 59 | 57 |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 int32_t PepperVideoCaptureHost::OnOpen( | 266 int32_t PepperVideoCaptureHost::OnOpen( |
| 269 ppapi::host::HostMessageContext* context, | 267 ppapi::host::HostMessageContext* context, |
| 270 const std::string& device_id, | 268 const std::string& device_id, |
| 271 const PP_VideoCaptureDeviceInfo_Dev& requested_info, | 269 const PP_VideoCaptureDeviceInfo_Dev& requested_info, |
| 272 uint32_t buffer_count) { | 270 uint32_t buffer_count) { |
| 273 if (platform_video_capture_.get()) | 271 if (platform_video_capture_.get()) |
| 274 return PP_ERROR_FAILED; | 272 return PP_ERROR_FAILED; |
| 275 | 273 |
| 276 SetRequestedInfo(requested_info, buffer_count); | 274 SetRequestedInfo(requested_info, buffer_count); |
| 277 | 275 |
| 278 PepperPluginInstance* instance = | 276 GURL document_url = renderer_ppapi_host_->GetDocumentURL(pp_instance()); |
| 279 renderer_ppapi_host_->GetPluginInstance(pp_instance()); | 277 if (!document_url.is_valid()) |
| 280 if (!instance) | |
| 281 return PP_ERROR_FAILED; | 278 return PP_ERROR_FAILED; |
| 282 | 279 |
| 283 RenderViewImpl* render_view = static_cast<RenderViewImpl*>( | 280 RenderViewImpl* render_view = static_cast<RenderViewImpl*>( |
| 284 renderer_ppapi_host_->GetRenderViewForInstance(pp_instance())); | 281 renderer_ppapi_host_->GetRenderViewForInstance(pp_instance())); |
| 285 | 282 |
| 286 platform_video_capture_ = new PepperPlatformVideoCapture( | 283 platform_video_capture_ = new PepperPlatformVideoCapture( |
| 287 render_view->AsWeakPtr(), device_id, | 284 render_view->AsWeakPtr(), device_id, |
| 288 instance->GetContainer()->element().document().url(), this); | 285 document_url, this); |
| 289 | 286 |
| 290 open_reply_context_ = context->MakeReplyMessageContext(); | 287 open_reply_context_ = context->MakeReplyMessageContext(); |
| 291 | 288 |
| 292 return PP_OK_COMPLETIONPENDING; | 289 return PP_OK_COMPLETIONPENDING; |
| 293 } | 290 } |
| 294 | 291 |
| 295 int32_t PepperVideoCaptureHost::OnStartCapture( | 292 int32_t PepperVideoCaptureHost::OnStartCapture( |
| 296 ppapi::host::HostMessageContext* context) { | 293 ppapi::host::HostMessageContext* context) { |
| 297 if (!SetStatus(PP_VIDEO_CAPTURE_STATUS_STARTING, false) || | 294 if (!SetStatus(PP_VIDEO_CAPTURE_STATUS_STARTING, false) || |
| 298 !platform_video_capture_.get()) | 295 !platform_video_capture_.get()) |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 PepperVideoCaptureHost::BufferInfo::BufferInfo() | 429 PepperVideoCaptureHost::BufferInfo::BufferInfo() |
| 433 : in_use(false), | 430 : in_use(false), |
| 434 data(NULL), | 431 data(NULL), |
| 435 buffer() { | 432 buffer() { |
| 436 } | 433 } |
| 437 | 434 |
| 438 PepperVideoCaptureHost::BufferInfo::~BufferInfo() { | 435 PepperVideoCaptureHost::BufferInfo::~BufferInfo() { |
| 439 } | 436 } |
| 440 | 437 |
| 441 } // namespace content | 438 } // namespace content |
| OLD | NEW |