summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-06 03:15:48 +0000
committerpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-06 03:15:48 +0000
commit97dd433374f7a5e5195fb6c65bdab33740b98e86 (patch)
tree9d75e9732ff0a56929c24fd5ffd82d5865382e3e /content
parenta82aa8513ec8f638ab2d68fca5e6a1a1d5fd1e67 (diff)
downloadchromium_src-97dd433374f7a5e5195fb6c65bdab33740b98e86.zip
chromium_src-97dd433374f7a5e5195fb6c65bdab33740b98e86.tar.gz
chromium_src-97dd433374f7a5e5195fb6c65bdab33740b98e86.tar.bz2
Video Capture Pepper API
The API is very simple at this point but works end-to-end. BUG=None TEST=VideoCapture sample (in a later CL) Review URL: http://codereview.chromium.org/7553003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95719 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/renderer/pepper_plugin_delegate_impl.cc68
-rw-r--r--content/renderer/pepper_plugin_delegate_impl.h2
2 files changed, 68 insertions, 2 deletions
diff --git a/content/renderer/pepper_plugin_delegate_impl.cc b/content/renderer/pepper_plugin_delegate_impl.cc
index 2ce1076..c061b80 100644
--- a/content/renderer/pepper_plugin_delegate_impl.cc
+++ b/content/renderer/pepper_plugin_delegate_impl.cc
@@ -36,6 +36,7 @@
#include "content/renderer/gpu/renderer_gl_context.h"
#include "content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h"
#include "content/renderer/media/audio_message_filter.h"
+#include "content/renderer/media/video_capture_impl_manager.h"
#include "content/renderer/p2p/p2p_transport_impl.h"
#include "content/renderer/pepper_platform_context_3d_impl.h"
#include "content/renderer/pepper_platform_video_decoder_impl.h"
@@ -44,6 +45,7 @@
#include "content/renderer/render_widget_fullscreen_pepper.h"
#include "content/renderer/webplugin_delegate_proxy.h"
#include "ipc/ipc_channel_handle.h"
+#include "media/video/capture/video_capture_proxy.h"
#include "ppapi/c/dev/pp_video_dev.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/private/ppb_flash.h"
@@ -73,8 +75,6 @@ using WebKit::WebView;
namespace {
-const int32 kDefaultCommandBufferSize = 1024 * 1024;
-
int32_t PlatformFileToInt(base::PlatformFile handle) {
#if defined(OS_WIN)
return static_cast<int32_t>(reinterpret_cast<intptr_t>(handle));
@@ -376,6 +376,64 @@ class QuotaCallbackTranslator : public QuotaDispatcher::Callback {
scoped_ptr<PluginCallback> callback_;
};
+class PlatformVideoCaptureImpl
+ : public webkit::ppapi::PluginDelegate::PlatformVideoCapture {
+ public:
+ PlatformVideoCaptureImpl(media::VideoCapture::EventHandler* handler)
+ : handler_proxy_(new media::VideoCaptureHandlerProxy(
+ handler, base::MessageLoopProxy::CreateForCurrentThread())) {
+ VideoCaptureImplManager* manager =
+ RenderThread::current()->video_capture_impl_manager();
+ // 1 means the "default" video capture device.
+ // TODO(piman): Add a way to enumerate devices and pass them through the
+ // API.
+ video_capture_ = manager->AddDevice(1, handler_proxy_.get());
+ }
+
+ // Overrides from media::VideoCapture::EventHandler
+ virtual ~PlatformVideoCaptureImpl() {
+ VideoCaptureImplManager* manager =
+ RenderThread::current()->video_capture_impl_manager();
+ manager->RemoveDevice(1, handler_proxy_.get());
+ }
+
+ virtual void StartCapture(
+ EventHandler* handler,
+ const VideoCaptureCapability& capability) OVERRIDE {
+ DCHECK(handler == handler_proxy_->proxied());
+ video_capture_->StartCapture(handler_proxy_.get(), capability);
+ }
+
+ virtual void StopCapture(EventHandler* handler) OVERRIDE {
+ DCHECK(handler == handler_proxy_->proxied());
+ video_capture_->StopCapture(handler_proxy_.get());
+ }
+
+ virtual void FeedBuffer(scoped_refptr<VideoFrameBuffer> buffer) OVERRIDE {
+ video_capture_->FeedBuffer(buffer);
+ }
+
+ virtual bool CaptureStarted() OVERRIDE {
+ return handler_proxy_->state().started;
+ }
+
+ virtual int CaptureWidth() OVERRIDE {
+ return handler_proxy_->state().width;
+ }
+
+ virtual int CaptureHeight() OVERRIDE {
+ return handler_proxy_->state().height;
+ }
+
+ virtual int CaptureFrameRate() OVERRIDE {
+ return handler_proxy_->state().frame_rate;
+ }
+
+ private:
+ scoped_ptr<media::VideoCaptureHandlerProxy> handler_proxy_;
+ media::VideoCapture* video_capture_;
+};
+
} // namespace
bool DispatcherWrapper::Init(
@@ -854,6 +912,12 @@ webkit::ppapi::PluginDelegate::PlatformContext3D*
#endif
}
+webkit::ppapi::PluginDelegate::PlatformVideoCapture*
+PepperPluginDelegateImpl::CreateVideoCapture(
+ media::VideoCapture::EventHandler* handler) {
+ return new PlatformVideoCaptureImpl(handler);
+}
+
webkit::ppapi::PluginDelegate::PlatformVideoDecoder*
PepperPluginDelegateImpl::CreateVideoDecoder(
media::VideoDecodeAccelerator::Client* client,
diff --git a/content/renderer/pepper_plugin_delegate_impl.h b/content/renderer/pepper_plugin_delegate_impl.h
index e465dfe..c7f9886 100644
--- a/content/renderer/pepper_plugin_delegate_impl.h
+++ b/content/renderer/pepper_plugin_delegate_impl.h
@@ -178,6 +178,8 @@ class PepperPluginDelegateImpl
PlatformAudio::Client* client);
virtual PlatformImage2D* CreateImage2D(int width, int height);
virtual PlatformContext3D* CreateContext3D();
+ virtual PlatformVideoCapture* CreateVideoCapture(
+ media::VideoCapture::EventHandler* handler) OVERRIDE;
virtual PlatformVideoDecoder* CreateVideoDecoder(
media::VideoDecodeAccelerator::Client* client,
int32 command_buffer_route_id);