OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_plugin_delegate_impl.h" | 5 #include "content/renderer/pepper_plugin_delegate_impl.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <queue> | 8 #include <queue> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "content/common/pepper_plugin_registry.h" | 29 #include "content/common/pepper_plugin_registry.h" |
30 #include "content/common/pepper_messages.h" | 30 #include "content/common/pepper_messages.h" |
31 #include "content/common/quota_dispatcher.h" | 31 #include "content/common/quota_dispatcher.h" |
32 #include "content/common/view_messages.h" | 32 #include "content/common/view_messages.h" |
33 #include "content/renderer/content_renderer_client.h" | 33 #include "content/renderer/content_renderer_client.h" |
34 #include "content/renderer/gpu/command_buffer_proxy.h" | 34 #include "content/renderer/gpu/command_buffer_proxy.h" |
35 #include "content/renderer/gpu/gpu_channel_host.h" | 35 #include "content/renderer/gpu/gpu_channel_host.h" |
36 #include "content/renderer/gpu/renderer_gl_context.h" | 36 #include "content/renderer/gpu/renderer_gl_context.h" |
37 #include "content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h" | 37 #include "content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h" |
38 #include "content/renderer/media/audio_message_filter.h" | 38 #include "content/renderer/media/audio_message_filter.h" |
| 39 #include "content/renderer/media/video_capture_impl_manager.h" |
39 #include "content/renderer/p2p/p2p_transport_impl.h" | 40 #include "content/renderer/p2p/p2p_transport_impl.h" |
40 #include "content/renderer/pepper_platform_context_3d_impl.h" | 41 #include "content/renderer/pepper_platform_context_3d_impl.h" |
41 #include "content/renderer/pepper_platform_video_decoder_impl.h" | 42 #include "content/renderer/pepper_platform_video_decoder_impl.h" |
42 #include "content/renderer/render_thread.h" | 43 #include "content/renderer/render_thread.h" |
43 #include "content/renderer/render_view.h" | 44 #include "content/renderer/render_view.h" |
44 #include "content/renderer/render_widget_fullscreen_pepper.h" | 45 #include "content/renderer/render_widget_fullscreen_pepper.h" |
45 #include "content/renderer/webplugin_delegate_proxy.h" | 46 #include "content/renderer/webplugin_delegate_proxy.h" |
46 #include "ipc/ipc_channel_handle.h" | 47 #include "ipc/ipc_channel_handle.h" |
| 48 #include "media/video/capture/video_capture_proxy.h" |
47 #include "ppapi/c/dev/pp_video_dev.h" | 49 #include "ppapi/c/dev/pp_video_dev.h" |
48 #include "ppapi/c/pp_errors.h" | 50 #include "ppapi/c/pp_errors.h" |
49 #include "ppapi/c/private/ppb_flash.h" | 51 #include "ppapi/c/private/ppb_flash.h" |
50 #include "ppapi/c/private/ppb_flash_net_connector.h" | 52 #include "ppapi/c/private/ppb_flash_net_connector.h" |
51 #include "ppapi/proxy/host_dispatcher.h" | 53 #include "ppapi/proxy/host_dispatcher.h" |
52 #include "ppapi/proxy/ppapi_messages.h" | 54 #include "ppapi/proxy/ppapi_messages.h" |
53 #include "ppapi/shared_impl/ppapi_preferences.h" | 55 #include "ppapi/shared_impl/ppapi_preferences.h" |
54 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserComplet
ion.h" | 56 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserComplet
ion.h" |
55 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams.
h" | 57 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams.
h" |
56 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" | 58 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" |
57 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" | 59 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" |
58 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 60 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
59 #include "ui/gfx/size.h" | 61 #include "ui/gfx/size.h" |
60 #include "ui/gfx/surface/transport_dib.h" | 62 #include "ui/gfx/surface/transport_dib.h" |
61 #include "webkit/fileapi/file_system_callback_dispatcher.h" | 63 #include "webkit/fileapi/file_system_callback_dispatcher.h" |
62 #include "webkit/glue/context_menu.h" | 64 #include "webkit/glue/context_menu.h" |
63 #include "webkit/plugins/npapi/webplugin.h" | 65 #include "webkit/plugins/npapi/webplugin.h" |
64 #include "webkit/plugins/ppapi/file_path.h" | 66 #include "webkit/plugins/ppapi/file_path.h" |
65 #include "webkit/plugins/ppapi/ppb_file_io_impl.h" | 67 #include "webkit/plugins/ppapi/ppb_file_io_impl.h" |
66 #include "webkit/plugins/ppapi/plugin_module.h" | 68 #include "webkit/plugins/ppapi/plugin_module.h" |
67 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 69 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
68 #include "webkit/plugins/ppapi/ppb_broker_impl.h" | 70 #include "webkit/plugins/ppapi/ppb_broker_impl.h" |
69 #include "webkit/plugins/ppapi/ppb_flash_impl.h" | 71 #include "webkit/plugins/ppapi/ppb_flash_impl.h" |
70 #include "webkit/plugins/ppapi/ppb_flash_net_connector_impl.h" | 72 #include "webkit/plugins/ppapi/ppb_flash_net_connector_impl.h" |
71 | 73 |
72 using WebKit::WebView; | 74 using WebKit::WebView; |
73 | 75 |
74 namespace { | 76 namespace { |
75 | 77 |
76 const int32 kDefaultCommandBufferSize = 1024 * 1024; | |
77 | |
78 int32_t PlatformFileToInt(base::PlatformFile handle) { | 78 int32_t PlatformFileToInt(base::PlatformFile handle) { |
79 #if defined(OS_WIN) | 79 #if defined(OS_WIN) |
80 return static_cast<int32_t>(reinterpret_cast<intptr_t>(handle)); | 80 return static_cast<int32_t>(reinterpret_cast<intptr_t>(handle)); |
81 #elif defined(OS_POSIX) | 81 #elif defined(OS_POSIX) |
82 return handle; | 82 return handle; |
83 #else | 83 #else |
84 #error Not implemented. | 84 #error Not implemented. |
85 #endif | 85 #endif |
86 } | 86 } |
87 | 87 |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 virtual void DidGrantStorageQuota(int64 granted_quota) OVERRIDE { | 369 virtual void DidGrantStorageQuota(int64 granted_quota) OVERRIDE { |
370 NOTREACHED(); | 370 NOTREACHED(); |
371 } | 371 } |
372 virtual void DidFail(quota::QuotaStatusCode error) OVERRIDE { | 372 virtual void DidFail(quota::QuotaStatusCode error) OVERRIDE { |
373 callback_->Run(0); | 373 callback_->Run(0); |
374 } | 374 } |
375 private: | 375 private: |
376 scoped_ptr<PluginCallback> callback_; | 376 scoped_ptr<PluginCallback> callback_; |
377 }; | 377 }; |
378 | 378 |
| 379 class PlatformVideoCaptureImpl |
| 380 : public webkit::ppapi::PluginDelegate::PlatformVideoCapture { |
| 381 public: |
| 382 PlatformVideoCaptureImpl(media::VideoCapture::EventHandler* handler) |
| 383 : handler_proxy_(new media::VideoCaptureHandlerProxy( |
| 384 handler, base::MessageLoopProxy::CreateForCurrentThread())) { |
| 385 VideoCaptureImplManager* manager = |
| 386 RenderThread::current()->video_capture_impl_manager(); |
| 387 // 1 means the "default" video capture device. |
| 388 // TODO(piman): Add a way to enumerate devices and pass them through the |
| 389 // API. |
| 390 video_capture_ = manager->AddDevice(1, handler_proxy_.get()); |
| 391 } |
| 392 |
| 393 // Overrides from media::VideoCapture::EventHandler |
| 394 virtual ~PlatformVideoCaptureImpl() { |
| 395 VideoCaptureImplManager* manager = |
| 396 RenderThread::current()->video_capture_impl_manager(); |
| 397 manager->RemoveDevice(1, handler_proxy_.get()); |
| 398 } |
| 399 |
| 400 virtual void StartCapture( |
| 401 EventHandler* handler, |
| 402 const VideoCaptureCapability& capability) OVERRIDE { |
| 403 DCHECK(handler == handler_proxy_->proxied()); |
| 404 video_capture_->StartCapture(handler_proxy_.get(), capability); |
| 405 } |
| 406 |
| 407 virtual void StopCapture(EventHandler* handler) OVERRIDE { |
| 408 DCHECK(handler == handler_proxy_->proxied()); |
| 409 video_capture_->StopCapture(handler_proxy_.get()); |
| 410 } |
| 411 |
| 412 virtual void FeedBuffer(scoped_refptr<VideoFrameBuffer> buffer) OVERRIDE { |
| 413 video_capture_->FeedBuffer(buffer); |
| 414 } |
| 415 |
| 416 virtual bool CaptureStarted() OVERRIDE { |
| 417 return handler_proxy_->state().started; |
| 418 } |
| 419 |
| 420 virtual int CaptureWidth() OVERRIDE { |
| 421 return handler_proxy_->state().width; |
| 422 } |
| 423 |
| 424 virtual int CaptureHeight() OVERRIDE { |
| 425 return handler_proxy_->state().height; |
| 426 } |
| 427 |
| 428 virtual int CaptureFrameRate() OVERRIDE { |
| 429 return handler_proxy_->state().frame_rate; |
| 430 } |
| 431 |
| 432 private: |
| 433 scoped_ptr<media::VideoCaptureHandlerProxy> handler_proxy_; |
| 434 media::VideoCapture* video_capture_; |
| 435 }; |
| 436 |
379 } // namespace | 437 } // namespace |
380 | 438 |
381 bool DispatcherWrapper::Init( | 439 bool DispatcherWrapper::Init( |
382 RenderView* render_view, | 440 RenderView* render_view, |
383 base::ProcessHandle plugin_process_handle, | 441 base::ProcessHandle plugin_process_handle, |
384 const IPC::ChannelHandle& channel_handle, | 442 const IPC::ChannelHandle& channel_handle, |
385 PP_Module pp_module, | 443 PP_Module pp_module, |
386 pp::proxy::Dispatcher::GetInterfaceFunc local_get_interface) { | 444 pp::proxy::Dispatcher::GetInterfaceFunc local_get_interface) { |
387 dispatcher_.reset(new pp::proxy::HostDispatcher( | 445 dispatcher_.reset(new pp::proxy::HostDispatcher( |
388 plugin_process_handle, pp_module, local_get_interface)); | 446 plugin_process_handle, pp_module, local_get_interface)); |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 RendererGLContext* parent_context = context->context(); | 905 RendererGLContext* parent_context = context->context(); |
848 if (!parent_context) | 906 if (!parent_context) |
849 return NULL; | 907 return NULL; |
850 | 908 |
851 return new PlatformContext3DImpl(parent_context); | 909 return new PlatformContext3DImpl(parent_context); |
852 #else | 910 #else |
853 return NULL; | 911 return NULL; |
854 #endif | 912 #endif |
855 } | 913 } |
856 | 914 |
| 915 webkit::ppapi::PluginDelegate::PlatformVideoCapture* |
| 916 PepperPluginDelegateImpl::CreateVideoCapture( |
| 917 media::VideoCapture::EventHandler* handler) { |
| 918 return new PlatformVideoCaptureImpl(handler); |
| 919 } |
| 920 |
857 webkit::ppapi::PluginDelegate::PlatformVideoDecoder* | 921 webkit::ppapi::PluginDelegate::PlatformVideoDecoder* |
858 PepperPluginDelegateImpl::CreateVideoDecoder( | 922 PepperPluginDelegateImpl::CreateVideoDecoder( |
859 media::VideoDecodeAccelerator::Client* client, | 923 media::VideoDecodeAccelerator::Client* client, |
860 int32 command_buffer_route_id) { | 924 int32 command_buffer_route_id) { |
861 return new PlatformVideoDecoderImpl(client, command_buffer_route_id); | 925 return new PlatformVideoDecoderImpl(client, command_buffer_route_id); |
862 } | 926 } |
863 | 927 |
864 void PepperPluginDelegateImpl::NumberOfFindResultsChanged(int identifier, | 928 void PepperPluginDelegateImpl::NumberOfFindResultsChanged(int identifier, |
865 int total, | 929 int total, |
866 bool final_result) { | 930 bool final_result) { |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1403 | 1467 |
1404 ppapi::Preferences PepperPluginDelegateImpl::GetPreferences() { | 1468 ppapi::Preferences PepperPluginDelegateImpl::GetPreferences() { |
1405 return ppapi::Preferences(render_view_->webkit_preferences()); | 1469 return ppapi::Preferences(render_view_->webkit_preferences()); |
1406 } | 1470 } |
1407 | 1471 |
1408 void PepperPluginDelegateImpl::PublishInitialPolicy( | 1472 void PepperPluginDelegateImpl::PublishInitialPolicy( |
1409 scoped_refptr<webkit::ppapi::PluginInstance> instance, | 1473 scoped_refptr<webkit::ppapi::PluginInstance> instance, |
1410 const std::string& policy) { | 1474 const std::string& policy) { |
1411 instance->HandlePolicyUpdate(policy); | 1475 instance->HandlePolicyUpdate(policy); |
1412 } | 1476 } |
OLD | NEW |