summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/media
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-14 18:55:42 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-14 18:55:42 +0000
commit957b7b518251ba16abca74ff04e370564a826a74 (patch)
treedd94fc60728020475cdff2a60992247b5ec374be /chrome/renderer/media
parent94100156abc9d9a36470867075f0c3b2b6ea0578 (diff)
downloadchromium_src-957b7b518251ba16abca74ff04e370564a826a74.zip
chromium_src-957b7b518251ba16abca74ff04e370564a826a74.tar.gz
chromium_src-957b7b518251ba16abca74ff04e370564a826a74.tar.bz2
Change VideoRendererImpl to use VideoThread as opposed to VideoRendererBase.
Now with less jitter! Review URL: http://codereview.chromium.org/115358 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16087 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/media')
-rw-r--r--chrome/renderer/media/video_renderer_impl.cc21
-rw-r--r--chrome/renderer/media/video_renderer_impl.h30
2 files changed, 34 insertions, 17 deletions
diff --git a/chrome/renderer/media/video_renderer_impl.cc b/chrome/renderer/media/video_renderer_impl.cc
index be3466c..d643283 100644
--- a/chrome/renderer/media/video_renderer_impl.cc
+++ b/chrome/renderer/media/video_renderer_impl.cc
@@ -13,22 +13,37 @@ VideoRendererImpl::VideoRendererImpl(WebMediaPlayerImpl* delegate)
delegate_->SetVideoRenderer(this);
}
-void VideoRendererImpl::OnStop() {
+// static
+bool VideoRendererImpl::IsMediaFormatSupported(
+ const media::MediaFormat& media_format) {
+ int width = 0;
+ int height = 0;
+ return ParseMediaFormat(media_format, &width, &height);
+}
+
+void VideoRendererImpl::Stop() {
+ VideoThread::Stop();
delegate_->SetVideoRenderer(NULL);
}
-bool VideoRendererImpl::OnInitialize(size_t width, size_t height) {
+bool VideoRendererImpl::OnInitialize(media::VideoDecoder* decoder) {
+ int width = 0;
+ int height = 0;
+ if (!ParseMediaFormat(decoder->media_format(), &width, &height))
+ return false;
+
video_size_.SetSize(width, height);
bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height);
if (bitmap_.allocPixels(NULL, NULL)) {
bitmap_.eraseRGB(0x00, 0x00, 0x00);
return true;
}
+
NOTREACHED();
return false;
}
-void VideoRendererImpl::OnPaintNeeded() {
+void VideoRendererImpl::OnFrameAvailable() {
delegate_->PostRepaintTask();
}
diff --git a/chrome/renderer/media/video_renderer_impl.h b/chrome/renderer/media/video_renderer_impl.h
index 0453fa0..2be93a0 100644
--- a/chrome/renderer/media/video_renderer_impl.h
+++ b/chrome/renderer/media/video_renderer_impl.h
@@ -21,20 +21,20 @@
#include "media/base/buffers.h"
#include "media/base/factory.h"
#include "media/base/filters.h"
-#include "media/filters/video_renderer_base.h"
+#include "media/filters/video_thread.h"
#include "webkit/api/public/WebMediaPlayer.h"
-class VideoRendererImpl : public media::VideoRendererBase {
+class VideoRendererImpl : public media::VideoThread {
public:
// Methods for painting called by the WebMediaPlayerDelegateImpl
// This method is called with the same rect as the Paint method and could
// be used by future implementations to implement an improved color space +
- // scale code on a seperate thread. Since we always do the streach on the
+ // scale code on a separate thread. Since we always do the stretch on the
// same thread as the Paint method, we just ignore the call for now.
virtual void SetRect(const gfx::Rect& rect) {}
- // Paint the current front frame on the |canvas| streaching it to fit the
+ // Paint the current front frame on the |canvas| stretching it to fit the
// |dest_rect|
virtual void Paint(skia::PlatformCanvas* canvas, const gfx::Rect& dest_rect);
@@ -44,21 +44,23 @@ class VideoRendererImpl : public media::VideoRendererBase {
WebMediaPlayerImpl*>(delegate);
}
- private:
- // Method called by base class during initialization.
- virtual bool OnInitialize(size_t width, size_t height);
+ // FilterFactoryImpl1 implementation.
+ static bool IsMediaFormatSupported(const media::MediaFormat& media_format);
+
+ // Override VideoThread implementation of Stop().
+ virtual void Stop();
- // Method called by VideoRendererBase to tell us to stop.
- virtual void OnStop();
+ protected:
+ // Method called by VideoThread during initialization.
+ virtual bool OnInitialize(media::VideoDecoder* decoder);
- // Method called by the VideoRendererBase when a repaint is needed.
- virtual void OnPaintNeeded();
+ // Method called by the VideoThread when a frame is available.
+ virtual void OnFrameAvailable();
+ private:
+ // Only the filter factories can create instances.
friend class media::FilterFactoryImpl1<VideoRendererImpl,
WebMediaPlayerImpl*>;
-
- // Constructor and destructor are private. Only the filter factory is
- // allowed to create instances.
explicit VideoRendererImpl(WebMediaPlayerImpl* delegate);
virtual ~VideoRendererImpl() {}