diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-12 21:30:25 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-12 21:30:25 +0000 |
commit | 321ad87b01c1e040f3f121044f8c255ca5548b30 (patch) | |
tree | 50a7575b7ee9d0ec0498395a6557af7b74e6ecfd /webkit/glue | |
parent | db2ff4b4607eb2a54b30ea9c4b8248e7a1cebfe5 (diff) | |
download | chromium_src-321ad87b01c1e040f3f121044f8c255ca5548b30.zip chromium_src-321ad87b01c1e040f3f121044f8c255ca5548b30.tar.gz chromium_src-321ad87b01c1e040f3f121044f8c255ca5548b30.tar.bz2 |
Working rudimentary audio in Pepper.
BUG=28292
TEST=none
Patch by neb@chromium.org
Original review: http://codereview.chromium.org/524006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36043 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r-- | webkit/glue/media/video_renderer_impl.cc | 16 | ||||
-rw-r--r-- | webkit/glue/media/video_renderer_impl.h | 3 | ||||
-rw-r--r-- | webkit/glue/plugins/npapi_extension_thunk.cc | 85 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_audio_device_delegate.h | 56 | ||||
-rw-r--r-- | webkit/glue/webplugin_delegate.h | 4 |
5 files changed, 163 insertions, 1 deletions
diff --git a/webkit/glue/media/video_renderer_impl.cc b/webkit/glue/media/video_renderer_impl.cc index a7dc980..c47b96d 100644 --- a/webkit/glue/media/video_renderer_impl.cc +++ b/webkit/glue/media/video_renderer_impl.cc @@ -7,6 +7,8 @@ #include "webkit/glue/media/video_renderer_impl.h" #include "webkit/glue/webmediaplayer_impl.h" +extern void DrawHackSendVideo(media::VideoSurface& frame, const gfx::Rect& rect); + namespace webkit_glue { VideoRendererImpl::VideoRendererImpl(WebMediaPlayerImpl::Proxy* proxy) @@ -59,6 +61,12 @@ void VideoRendererImpl::SetRect(const gfx::Rect& rect) { // This method is always called on the renderer's thread. void VideoRendererImpl::Paint(skia::PlatformCanvas* canvas, const gfx::Rect& dest_rect) { + base::TimeTicks now = base::TimeTicks::HighResNow(); + if (!last_frame_.is_null()) { + HISTOGRAM_TIMES("Video.Decode", now - last_frame_); + } + last_frame_ = now; + scoped_refptr<media::VideoFrame> video_frame; GetCurrentFrame(&video_frame); if (video_frame) { @@ -129,6 +137,10 @@ void VideoRendererImpl::SlowPaint(media::VideoFrame* video_frame, DCHECK(frame_in.strides[media::VideoSurface::kUPlane] == frame_in.strides[media::VideoSurface::kVPlane]); DCHECK(frame_in.planes == media::VideoSurface::kNumYUVPlanes); + + DrawHackSendVideo(frame_in, dest_rect); + +#if 1 bitmap_.lockPixels(); media::YUVType yuv_type = (frame_in.format == media::VideoSurface::YV12) ? media::YV12 : media::YV16; @@ -143,6 +155,8 @@ void VideoRendererImpl::SlowPaint(media::VideoFrame* video_frame, bitmap_.rowBytes(), yuv_type); bitmap_.unlockPixels(); +#endif + DrawHackSendVideo(frame_in, dest_rect); video_frame->Unlock(); } else { NOTREACHED(); @@ -150,6 +164,7 @@ void VideoRendererImpl::SlowPaint(media::VideoFrame* video_frame, } // 2. Paint the bitmap to canvas. +#if 1 SkMatrix matrix; matrix.setTranslate(static_cast<SkScalar>(dest_rect.x()), static_cast<SkScalar>(dest_rect.y())); @@ -161,6 +176,7 @@ void VideoRendererImpl::SlowPaint(media::VideoFrame* video_frame, SkIntToScalar(video_size_.height())); } canvas->drawBitmapMatrix(bitmap_, matrix, NULL); +#endif } void VideoRendererImpl::FastPaint(media::VideoFrame* video_frame, diff --git a/webkit/glue/media/video_renderer_impl.h b/webkit/glue/media/video_renderer_impl.h index b0fde12..8acd730 100644 --- a/webkit/glue/media/video_renderer_impl.h +++ b/webkit/glue/media/video_renderer_impl.h @@ -16,6 +16,7 @@ #include "base/gfx/rect.h" #include "base/gfx/size.h" +#include "base/time.h" #include "media/base/buffers.h" #include "media/base/factory.h" #include "media/base/filters.h" @@ -104,6 +105,8 @@ class VideoRendererImpl : public media::VideoRendererBase { // The size of the video. gfx::Size video_size_; + base::TimeTicks last_frame_; + DISALLOW_COPY_AND_ASSIGN(VideoRendererImpl); }; diff --git a/webkit/glue/plugins/npapi_extension_thunk.cc b/webkit/glue/plugins/npapi_extension_thunk.cc index eee6c80..5700ef5 100644 --- a/webkit/glue/plugins/npapi_extension_thunk.cc +++ b/webkit/glue/plugins/npapi_extension_thunk.cc @@ -251,6 +251,80 @@ static NPError Device3DMapBuffer(NPP id, return NPERR_GENERIC_ERROR; } +// Audio device API ------------------------------------------------------------ + +static NPError DeviceAudioQueryCapability(NPP id, int32 capability, + int32* value) { + scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); + if (plugin) { + plugin->webplugin()->delegate()->DeviceAudioQueryCapability(capability, + value); + return NPERR_NO_ERROR; + } else { + return NPERR_GENERIC_ERROR; + } +} + +static NPError DeviceAudioQueryConfig(NPP id, + const NPDeviceConfig* request, + NPDeviceConfig* obtain) { + scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); + if (plugin) { + return plugin->webplugin()->delegate()->DeviceAudioQueryConfig( + static_cast<const NPDeviceContextAudioConfig*>(request), + static_cast<NPDeviceContextAudioConfig*>(obtain)); + } + return NPERR_GENERIC_ERROR; +} + +static NPError DeviceAudioInitializeContext(NPP id, + const NPDeviceConfig* config, + NPDeviceContext* context) { + scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); + if (plugin) { + return plugin->webplugin()->delegate()->DeviceAudioInitializeContext( + static_cast<const NPDeviceContextAudioConfig*>(config), + static_cast<NPDeviceContextAudio*>(context)); + } + return NPERR_GENERIC_ERROR; +} + +static NPError DeviceAudioSetStateContext(NPP id, + NPDeviceContext* context, + int32 state, + int32 value) { + scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); + if (plugin) { + return plugin->webplugin()->delegate()->DeviceAudioSetStateContext( + static_cast<NPDeviceContextAudio*>(context), state, value); + } + return NPERR_GENERIC_ERROR; +} + +static NPError DeviceAudioGetStateContext(NPP id, + NPDeviceContext* context, + int32 state, + int32* value) { + scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); + return plugin->webplugin()->delegate()->DeviceAudioGetStateContext( + static_cast<NPDeviceContextAudio*>(context), state, value); +} + +static NPError DeviceAudioFlushContext(NPP id, + NPDeviceContext* context, + NPDeviceFlushContextCallbackPtr callback, + void* user_data) { + scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); + return plugin->webplugin()->delegate()->DeviceAudioFlushContext( + id, static_cast<NPDeviceContextAudio*>(context), callback, user_data); +} + +static NPError DeviceAudioDestroyContext(NPP id, + NPDeviceContext* context) { + scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); + return plugin->webplugin()->delegate()->DeviceAudioDestroyContext( + static_cast<NPDeviceContextAudio*>(context)); +} // ----------------------------------------------------------------------------- static NPDevice* AcquireDevice(NPP id, NPDeviceID device_id) { @@ -278,12 +352,23 @@ static NPDevice* AcquireDevice(NPP id, NPDeviceID device_id) { Device3DDestroyBuffer, Device3DMapBuffer, }; + static NPDevice device_audio = { + DeviceAudioQueryCapability, + DeviceAudioQueryConfig, + DeviceAudioInitializeContext, + DeviceAudioSetStateContext, + DeviceAudioGetStateContext, + DeviceAudioFlushContext, + DeviceAudioDestroyContext, + }; switch (device_id) { case NPPepper2DDevice: return const_cast<NPDevice*>(&device_2d); case NPPepper3DDevice: return const_cast<NPDevice*>(&device_3d); + case NPPepperAudioDevice: + return const_cast<NPDevice*>(&device_audio); default: return NULL; } diff --git a/webkit/glue/plugins/webplugin_audio_device_delegate.h b/webkit/glue/plugins/webplugin_audio_device_delegate.h new file mode 100644 index 0000000..260bcbd --- /dev/null +++ b/webkit/glue/plugins/webplugin_audio_device_delegate.h @@ -0,0 +1,56 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef WEBKIT_GLUE_PLUGINS_WEBPLUGIN_AUDIO_DEVICE_DELEGATE_H_ +#define WEBKIT_GLUE_PLUGINS_WEBPLUGIN_AUDIO_DEVICE_DELEGATE_H_ + +#include "base/basictypes.h" +#include "third_party/npapi/bindings/npapi_extensions.h" + +namespace webkit_glue { + +// Interface for the NPAPI audio device extension. This class implements "NOP" +// versions of all these functions so it can be used seamlessly by the +// "regular" plugin delegate while being overridden by the "pepper" one. +class WebPluginAudioDeviceDelegate { + public: + virtual NPError DeviceAudioQueryCapability(int32 capability, int32* value) { + return NPERR_GENERIC_ERROR; + } + virtual NPError DeviceAudioQueryConfig( + const NPDeviceContextAudioConfig* request, + NPDeviceContextAudioConfig* obtain) { + return NPERR_GENERIC_ERROR; + } + virtual NPError DeviceAudioInitializeContext( + const NPDeviceContextAudioConfig* config, + NPDeviceContextAudio* context) { + return NPERR_GENERIC_ERROR; + } + virtual NPError DeviceAudioSetStateContext(NPDeviceContextAudio* context, + int32 state, int32 value) { + return NPERR_GENERIC_ERROR; + } + virtual NPError DeviceAudioGetStateContext(NPDeviceContextAudio* context, + int32 state, int32* value) { + return NPERR_GENERIC_ERROR; + } + virtual NPError DeviceAudioFlushContext( + NPP id, NPDeviceContextAudio* context, + NPDeviceFlushContextCallbackPtr callback, void* user_data) { + return NPERR_GENERIC_ERROR; + } + virtual NPError DeviceAudioDestroyContext(NPDeviceContextAudio* context) { + return NPERR_GENERIC_ERROR; + } + + protected: + WebPluginAudioDeviceDelegate() {} + virtual ~WebPluginAudioDeviceDelegate() {} +}; + +} // namespace webkit_glue + +#endif // WEBKIT_GLUE_PLUGINS_WEBPLUGIN_AUDIO_DEVICE_DELEGATE_H_ + diff --git a/webkit/glue/webplugin_delegate.h b/webkit/glue/webplugin_delegate.h index 2920152..e88a706 100644 --- a/webkit/glue/webplugin_delegate.h +++ b/webkit/glue/webplugin_delegate.h @@ -16,6 +16,7 @@ #include "third_party/WebKit/WebKit/chromium/public/WebCanvas.h" #include "webkit/glue/plugins/webplugin_2d_device_delegate.h" #include "webkit/glue/plugins/webplugin_3d_device_delegate.h" +#include "webkit/glue/plugins/webplugin_audio_device_delegate.h" class FilePath; class GURL; @@ -37,7 +38,8 @@ class WebPluginResourceClient; // This is the interface that a plugin implementation needs to provide. class WebPluginDelegate : public WebPlugin2DDeviceDelegate, - public WebPlugin3DDeviceDelegate { + public WebPlugin3DDeviceDelegate, + public WebPluginAudioDeviceDelegate { public: virtual ~WebPluginDelegate() {} |