Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: content/renderer/pepper_plugin_delegate_impl.cc

Issue 7553003: Video Capture Pepper API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/callback.h" 10 #include "base/callback.h"
(...skipping 15 matching lines...) Expand all
26 #include "content/common/pepper_file_messages.h" 26 #include "content/common/pepper_file_messages.h"
27 #include "content/common/pepper_plugin_registry.h" 27 #include "content/common/pepper_plugin_registry.h"
28 #include "content/common/pepper_messages.h" 28 #include "content/common/pepper_messages.h"
29 #include "content/common/view_messages.h" 29 #include "content/common/view_messages.h"
30 #include "content/renderer/content_renderer_client.h" 30 #include "content/renderer/content_renderer_client.h"
31 #include "content/renderer/gpu/command_buffer_proxy.h" 31 #include "content/renderer/gpu/command_buffer_proxy.h"
32 #include "content/renderer/gpu/gpu_channel_host.h" 32 #include "content/renderer/gpu/gpu_channel_host.h"
33 #include "content/renderer/gpu/renderer_gl_context.h" 33 #include "content/renderer/gpu/renderer_gl_context.h"
34 #include "content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h" 34 #include "content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h"
35 #include "content/renderer/media/audio_message_filter.h" 35 #include "content/renderer/media/audio_message_filter.h"
36 #include "content/renderer/media/video_capture_impl_manager.h"
36 #include "content/renderer/p2p/p2p_transport_impl.h" 37 #include "content/renderer/p2p/p2p_transport_impl.h"
37 #include "content/renderer/pepper_platform_context_3d_impl.h" 38 #include "content/renderer/pepper_platform_context_3d_impl.h"
38 #include "content/renderer/pepper_platform_video_decoder_impl.h" 39 #include "content/renderer/pepper_platform_video_decoder_impl.h"
39 #include "content/renderer/render_thread.h" 40 #include "content/renderer/render_thread.h"
40 #include "content/renderer/render_view.h" 41 #include "content/renderer/render_view.h"
41 #include "content/renderer/render_widget_fullscreen_pepper.h" 42 #include "content/renderer/render_widget_fullscreen_pepper.h"
42 #include "content/renderer/webplugin_delegate_proxy.h" 43 #include "content/renderer/webplugin_delegate_proxy.h"
43 #include "ipc/ipc_channel_handle.h" 44 #include "ipc/ipc_channel_handle.h"
45 #include "media/video/capture/video_capture_proxy.h"
44 #include "ppapi/c/dev/pp_video_dev.h" 46 #include "ppapi/c/dev/pp_video_dev.h"
45 #include "ppapi/c/pp_errors.h" 47 #include "ppapi/c/pp_errors.h"
46 #include "ppapi/c/private/ppb_flash.h" 48 #include "ppapi/c/private/ppb_flash.h"
47 #include "ppapi/c/private/ppb_flash_net_connector.h" 49 #include "ppapi/c/private/ppb_flash_net_connector.h"
48 #include "ppapi/proxy/host_dispatcher.h" 50 #include "ppapi/proxy/host_dispatcher.h"
49 #include "ppapi/proxy/ppapi_messages.h" 51 #include "ppapi/proxy/ppapi_messages.h"
50 #include "ppapi/shared_impl/ppapi_preferences.h" 52 #include "ppapi/shared_impl/ppapi_preferences.h"
51 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserComplet ion.h" 53 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserComplet ion.h"
52 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams. h" 54 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams. h"
53 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" 55 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h"
54 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" 56 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h"
55 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 57 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
56 #include "ui/gfx/size.h" 58 #include "ui/gfx/size.h"
57 #include "ui/gfx/surface/transport_dib.h" 59 #include "ui/gfx/surface/transport_dib.h"
58 #include "webkit/fileapi/file_system_callback_dispatcher.h" 60 #include "webkit/fileapi/file_system_callback_dispatcher.h"
59 #include "webkit/glue/context_menu.h" 61 #include "webkit/glue/context_menu.h"
60 #include "webkit/plugins/npapi/webplugin.h" 62 #include "webkit/plugins/npapi/webplugin.h"
61 #include "webkit/plugins/ppapi/file_path.h" 63 #include "webkit/plugins/ppapi/file_path.h"
62 #include "webkit/plugins/ppapi/ppb_file_io_impl.h" 64 #include "webkit/plugins/ppapi/ppb_file_io_impl.h"
63 #include "webkit/plugins/ppapi/plugin_module.h" 65 #include "webkit/plugins/ppapi/plugin_module.h"
64 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 66 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
65 #include "webkit/plugins/ppapi/ppb_broker_impl.h" 67 #include "webkit/plugins/ppapi/ppb_broker_impl.h"
66 #include "webkit/plugins/ppapi/ppb_flash_impl.h" 68 #include "webkit/plugins/ppapi/ppb_flash_impl.h"
67 #include "webkit/plugins/ppapi/ppb_flash_net_connector_impl.h" 69 #include "webkit/plugins/ppapi/ppb_flash_net_connector_impl.h"
68 70
69 using WebKit::WebView; 71 using WebKit::WebView;
70 72
71 namespace { 73 namespace {
72 74
73 const int32 kDefaultCommandBufferSize = 1024 * 1024;
74
75 int32_t PlatformFileToInt(base::PlatformFile handle) { 75 int32_t PlatformFileToInt(base::PlatformFile handle) {
76 #if defined(OS_WIN) 76 #if defined(OS_WIN)
77 return static_cast<int32_t>(reinterpret_cast<intptr_t>(handle)); 77 return static_cast<int32_t>(reinterpret_cast<intptr_t>(handle));
78 #elif defined(OS_POSIX) 78 #elif defined(OS_POSIX)
79 return handle; 79 return handle;
80 #else 80 #else
81 #error Not implemented. 81 #error Not implemented.
82 #endif 82 #endif
83 } 83 }
84 84
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 pp::proxy::HostDispatcher::SetForInstance(instance, dispatcher_.get()); 349 pp::proxy::HostDispatcher::SetForInstance(instance, dispatcher_.get());
350 } 350 }
351 virtual void RemoveInstance(PP_Instance instance) { 351 virtual void RemoveInstance(PP_Instance instance) {
352 pp::proxy::HostDispatcher::RemoveForInstance(instance); 352 pp::proxy::HostDispatcher::RemoveForInstance(instance);
353 } 353 }
354 354
355 private: 355 private:
356 scoped_ptr<pp::proxy::HostDispatcher> dispatcher_; 356 scoped_ptr<pp::proxy::HostDispatcher> dispatcher_;
357 }; 357 };
358 358
359 class PlatformVideoCaptureImpl
360 : public webkit::ppapi::PluginDelegate::PlatformVideoCapture {
361 public:
362 PlatformVideoCaptureImpl(media::VideoCapture::EventHandler* handler)
363 : handler_proxy_(new media::VideoCaptureHandlerProxy(
364 handler, base::MessageLoopProxy::CreateForCurrentThread())) {
365 VideoCaptureImplManager* manager =
366 RenderThread::current()->video_capture_impl_manager();
367 video_capture_ = manager->AddDevice(1, handler_proxy_.get());
wjia(left Chromium) 2011/08/02 16:22:28 Is there any plan on device management for pepper?
piman 2011/08/03 00:44:41 Yes, I wanted to look at that at some point. Added
wjia(left Chromium) 2011/08/03 02:40:00 Device enumeration is done in media stream which h
368 }
369
370 // Overrides from media::VideoCapture::EventHandler
371 virtual ~PlatformVideoCaptureImpl() OVERRIDE {
372 VideoCaptureImplManager* manager =
373 RenderThread::current()->video_capture_impl_manager();
374 manager->RemoveDevice(1, handler_proxy_.get());
375 }
376
377 virtual void StartCapture(
378 EventHandler* handler,
379 const VideoCaptureCapability& capability) OVERRIDE {
380 DCHECK(handler == handler_proxy_->proxied());
381 video_capture_->StartCapture(handler_proxy_.get(), capability);
382 }
383
384 virtual void StopCapture(EventHandler* handler) OVERRIDE {
385 DCHECK(handler == handler_proxy_->proxied());
386 video_capture_->StopCapture(handler_proxy_.get());
387 }
388
389 virtual void FeedBuffer(scoped_refptr<VideoFrameBuffer> buffer) OVERRIDE {
390 video_capture_->FeedBuffer(buffer);
391 }
392
393 virtual bool CaptureStarted() OVERRIDE {
394 return handler_proxy_->state().started;
395 }
396
397 virtual int CaptureWidth() OVERRIDE {
398 return handler_proxy_->state().width;
399 }
400
401 virtual int CaptureHeight() OVERRIDE {
402 return handler_proxy_->state().height;
403 }
404
405 virtual int CaptureFrameRate() OVERRIDE {
406 return handler_proxy_->state().frame_rate;
407 }
408
409 private:
410 scoped_ptr<media::VideoCaptureHandlerProxy> handler_proxy_;
411 media::VideoCapture* video_capture_;
412 };
413
359 } // namespace 414 } // namespace
360 415
361 bool DispatcherWrapper::Init( 416 bool DispatcherWrapper::Init(
362 RenderView* render_view, 417 RenderView* render_view,
363 base::ProcessHandle plugin_process_handle, 418 base::ProcessHandle plugin_process_handle,
364 const IPC::ChannelHandle& channel_handle, 419 const IPC::ChannelHandle& channel_handle,
365 PP_Module pp_module, 420 PP_Module pp_module,
366 pp::proxy::Dispatcher::GetInterfaceFunc local_get_interface) { 421 pp::proxy::Dispatcher::GetInterfaceFunc local_get_interface) {
367 dispatcher_.reset(new pp::proxy::HostDispatcher( 422 dispatcher_.reset(new pp::proxy::HostDispatcher(
368 plugin_process_handle, pp_module, local_get_interface)); 423 plugin_process_handle, pp_module, local_get_interface));
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 RendererGLContext* parent_context = context->context(); 880 RendererGLContext* parent_context = context->context();
826 if (!parent_context) 881 if (!parent_context)
827 return NULL; 882 return NULL;
828 883
829 return new PlatformContext3DImpl(parent_context); 884 return new PlatformContext3DImpl(parent_context);
830 #else 885 #else
831 return NULL; 886 return NULL;
832 #endif 887 #endif
833 } 888 }
834 889
890 webkit::ppapi::PluginDelegate::PlatformVideoCapture*
891 PepperPluginDelegateImpl::CreateVideoCapture(
892 media::VideoCapture::EventHandler* handler) {
893 return new PlatformVideoCaptureImpl(handler);
894 }
895
835 webkit::ppapi::PluginDelegate::PlatformVideoDecoder* 896 webkit::ppapi::PluginDelegate::PlatformVideoDecoder*
836 PepperPluginDelegateImpl::CreateVideoDecoder( 897 PepperPluginDelegateImpl::CreateVideoDecoder(
837 media::VideoDecodeAccelerator::Client* client, 898 media::VideoDecodeAccelerator::Client* client,
838 int32 command_buffer_route_id) { 899 int32 command_buffer_route_id) {
839 return new PlatformVideoDecoderImpl(client, command_buffer_route_id); 900 return new PlatformVideoDecoderImpl(client, command_buffer_route_id);
840 } 901 }
841 902
842 void PepperPluginDelegateImpl::NumberOfFindResultsChanged(int identifier, 903 void PepperPluginDelegateImpl::NumberOfFindResultsChanged(int identifier,
843 int total, 904 int total,
844 bool final_result) { 905 bool final_result) {
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 if (!base::SharedMemory::IsHandleValid(handle)) { 1405 if (!base::SharedMemory::IsHandleValid(handle)) {
1345 DLOG(WARNING) << "Browser failed to allocate shared memory"; 1406 DLOG(WARNING) << "Browser failed to allocate shared memory";
1346 return NULL; 1407 return NULL;
1347 } 1408 }
1348 return new base::SharedMemory(handle, false); 1409 return new base::SharedMemory(handle, false);
1349 } 1410 }
1350 1411
1351 ppapi::Preferences PepperPluginDelegateImpl::GetPreferences() { 1412 ppapi::Preferences PepperPluginDelegateImpl::GetPreferences() {
1352 return ppapi::Preferences(render_view_->webkit_preferences()); 1413 return ppapi::Preferences(render_view_->webkit_preferences());
1353 } 1414 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698