summaryrefslogtreecommitdiffstats
path: root/webkit/glue/media
diff options
context:
space:
mode:
authorhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-23 01:20:37 +0000
committerhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-23 01:20:37 +0000
commit457d83467c00c236e806bb150796a2efdc88bfcf (patch)
tree36c58186b34d36300374b232fb79540457307b23 /webkit/glue/media
parent77a397cc5cf8106e559aa87a5228478afc28cec1 (diff)
downloadchromium_src-457d83467c00c236e806bb150796a2efdc88bfcf.zip
chromium_src-457d83467c00c236e806bb150796a2efdc88bfcf.tar.gz
chromium_src-457d83467c00c236e806bb150796a2efdc88bfcf.tar.bz2
Terminate FilterFactory and his nasty friends
FilterFactory, IsMediaFormatSupported and CreateFactory are the source of evil. They also have have a gang of template functions. This patch terminate them all and make the world a better place. BUG=28207 TEST=<video> runs Review URL: http://codereview.chromium.org/3878001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63609 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/media')
-rw-r--r--webkit/glue/media/buffered_data_source.cc32
-rw-r--r--webkit/glue/media/buffered_data_source.h33
-rw-r--r--webkit/glue/media/buffered_data_source_unittest.cc29
-rw-r--r--webkit/glue/media/simple_data_source.cc13
-rw-r--r--webkit/glue/media/simple_data_source.h27
-rw-r--r--webkit/glue/media/simple_data_source_unittest.cc27
-rw-r--r--webkit/glue/media/video_renderer_impl.cc29
-rw-r--r--webkit/glue/media/video_renderer_impl.h38
-rw-r--r--webkit/glue/media/web_video_renderer.h4
9 files changed, 43 insertions, 189 deletions
diff --git a/webkit/glue/media/buffered_data_source.cc b/webkit/glue/media/buffered_data_source.cc
index a4e3901..43d21f7 100644
--- a/webkit/glue/media/buffered_data_source.cc
+++ b/webkit/glue/media/buffered_data_source.cc
@@ -522,29 +522,10 @@ void BufferedResourceLoader::NotifyNetworkEvent() {
}
/////////////////////////////////////////////////////////////////////////////
-// BufferedDataSource, static methods
-bool BufferedDataSource::IsMediaFormatSupported(
- const media::MediaFormat& media_format) {
- std::string mime_type;
- std::string url;
- if (media_format.GetAsString(media::MediaFormat::kMimeType, &mime_type) &&
- media_format.GetAsString(media::MediaFormat::kURL, &url)) {
- GURL gurl(url);
-
- // This data source doesn't support data:// protocol, so reject it
- // explicitly.
- if (IsProtocolSupportedForMedia(gurl) && !IsDataProtocol(gurl))
- return true;
- }
- return false;
-}
-
-/////////////////////////////////////////////////////////////////////////////
-// BufferedDataSource, protected
+// BufferedDataSource
BufferedDataSource::BufferedDataSource(
MessageLoop* render_loop,
- webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory,
- webkit_glue::WebMediaPlayerImpl::Proxy* proxy)
+ webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory)
: total_bytes_(kPositionNotSpecified),
loaded_(false),
streaming_(false),
@@ -564,8 +545,6 @@ BufferedDataSource::BufferedDataSource(
stopped_on_render_loop_(false),
media_is_paused_(true),
using_range_request_(true) {
- if (proxy)
- proxy->SetDataSource(this);
}
BufferedDataSource::~BufferedDataSource() {
@@ -618,6 +597,13 @@ void BufferedDataSource::Initialize(const std::string& url,
NewRunnableMethod(this, &BufferedDataSource::InitializeTask));
}
+bool BufferedDataSource::IsUrlSupported(const std::string& url) {
+ GURL gurl(url);
+
+ // This data source doesn't support data:// protocol so reject it.
+ return IsProtocolSupportedForMedia(gurl) && !IsDataProtocol(gurl);
+}
+
void BufferedDataSource::Stop(media::FilterCallback* callback) {
{
AutoLock auto_lock(lock_);
diff --git a/webkit/glue/media/buffered_data_source.h b/webkit/glue/media/buffered_data_source.h
index 6b740c9..d6a7e24 100644
--- a/webkit/glue/media/buffered_data_source.h
+++ b/webkit/glue/media/buffered_data_source.h
@@ -13,7 +13,6 @@
#include "base/timer.h"
#include "base/condition_variable.h"
#include "googleurl/src/gurl.h"
-#include "media/base/factory.h"
#include "media/base/filters.h"
#include "media/base/media_format.h"
#include "media/base/pipeline.h"
@@ -216,27 +215,16 @@ class BufferedResourceLoader :
class BufferedDataSource : public WebDataSource {
public:
- // Methods called from pipeline thread
- // Static methods for creating this class.
- static media::FilterFactory* CreateFactory(
- MessageLoop* message_loop,
- webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory,
- webkit_glue::WebMediaPlayerImpl::Proxy* proxy) {
- return new media::FilterFactoryImpl3<
- BufferedDataSource,
- MessageLoop*,
- webkit_glue::MediaResourceLoaderBridgeFactory*,
- webkit_glue::WebMediaPlayerImpl::Proxy*>(
- message_loop, bridge_factory, proxy);
- }
+ BufferedDataSource(
+ MessageLoop* render_loop,
+ webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory);
- // media::FilterFactoryImpl2 implementation.
- static bool IsMediaFormatSupported(
- const media::MediaFormat& media_format);
+ virtual ~BufferedDataSource();
// media::MediaFilter implementation.
virtual void Initialize(const std::string& url,
media::FilterCallback* callback);
+ virtual bool IsUrlSupported(const std::string& url);
virtual void Stop(media::FilterCallback* callback);
virtual void SetPlaybackRate(float playback_rate);
@@ -256,11 +244,6 @@ class BufferedDataSource : public WebDataSource {
virtual void Abort();
protected:
- BufferedDataSource(
- MessageLoop* render_loop,
- webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory,
- webkit_glue::WebMediaPlayerImpl::Proxy* proxy);
- virtual ~BufferedDataSource();
// A factory method to create a BufferedResourceLoader based on the read
// parameters. We can override this file to object a mock
@@ -274,12 +257,6 @@ class BufferedDataSource : public WebDataSource {
virtual base::TimeDelta GetTimeoutMilliseconds();
private:
- friend class media::FilterFactoryImpl3<
- BufferedDataSource,
- MessageLoop*,
- webkit_glue::MediaResourceLoaderBridgeFactory*,
- webkit_glue::WebMediaPlayerImpl::Proxy*>;
-
// Posted to perform initialization on render thread and start resource
// loading.
void InitializeTask();
diff --git a/webkit/glue/media/buffered_data_source_unittest.cc b/webkit/glue/media/buffered_data_source_unittest.cc
index 25e5192..7e6fd54 100644
--- a/webkit/glue/media/buffered_data_source_unittest.cc
+++ b/webkit/glue/media/buffered_data_source_unittest.cc
@@ -539,15 +539,9 @@ class MockBufferedResourceLoader : public BufferedResourceLoader {
// CreateResourceLoader() method.
class MockBufferedDataSource : public BufferedDataSource {
public:
- // Static methods for creating this class.
- static media::FilterFactory* CreateFactory(
- MessageLoop* message_loop,
- MediaResourceLoaderBridgeFactory* bridge_factory) {
- return new media::FilterFactoryImpl2<
- MockBufferedDataSource,
- MessageLoop*,
- MediaResourceLoaderBridgeFactory*>(message_loop,
- bridge_factory);
+ MockBufferedDataSource(
+ MessageLoop* message_loop, MediaResourceLoaderBridgeFactory* factory)
+ : BufferedDataSource(message_loop, factory) {
}
virtual base::TimeDelta GetTimeoutMilliseconds() {
@@ -558,18 +552,7 @@ class MockBufferedDataSource : public BufferedDataSource {
MOCK_METHOD2(CreateResourceLoader, BufferedResourceLoader*(
int64 first_position, int64 last_position));
- protected:
- MockBufferedDataSource(
- MessageLoop* message_loop, MediaResourceLoaderBridgeFactory* factory)
- : BufferedDataSource(message_loop, factory, NULL) {
- }
-
private:
- friend class media::FilterFactoryImpl2<
- MockBufferedDataSource,
- MessageLoop*,
- MediaResourceLoaderBridgeFactory*>;
-
DISALLOW_COPY_AND_ASSIGN(MockBufferedDataSource);
};
@@ -579,8 +562,6 @@ class BufferedDataSourceTest : public testing::Test {
message_loop_ = MessageLoop::current();
bridge_factory_.reset(
new StrictMock<MockMediaResourceLoaderBridgeFactory>());
- factory_ = MockBufferedDataSource::CreateFactory(message_loop_,
- bridge_factory_.get());
// Prepare test data.
for (size_t i = 0; i < sizeof(data_); ++i) {
@@ -619,7 +600,8 @@ class BufferedDataSourceTest : public testing::Test {
url_format.SetAsString(media::MediaFormat::kMimeType,
media::mime_type::kURL);
url_format.SetAsString(media::MediaFormat::kURL, url);
- data_source_ = factory_->Create<MockBufferedDataSource>(url_format);
+ data_source_ = new MockBufferedDataSource(MessageLoop::current(),
+ bridge_factory_.get());
CHECK(data_source_);
// There is no need to provide a message loop to data source.
@@ -901,7 +883,6 @@ class BufferedDataSourceTest : public testing::Test {
bridge_factory_;
scoped_refptr<NiceMock<MockBufferedResourceLoader> > loader_;
scoped_refptr<MockBufferedDataSource> data_source_;
- scoped_refptr<media::FilterFactory> factory_;
StrictMock<media::MockFilterHost> host_;
GURL gurl_;
diff --git a/webkit/glue/media/simple_data_source.cc b/webkit/glue/media/simple_data_source.cc
index 0b09edf..256c910 100644
--- a/webkit/glue/media/simple_data_source.cc
+++ b/webkit/glue/media/simple_data_source.cc
@@ -28,19 +28,6 @@ bool IsDataProtocol(const GURL& url) {
namespace webkit_glue {
-bool SimpleDataSource::IsMediaFormatSupported(
- const media::MediaFormat& media_format) {
- std::string mime_type;
- std::string url;
- if (media_format.GetAsString(media::MediaFormat::kMimeType, &mime_type) &&
- media_format.GetAsString(media::MediaFormat::kURL, &url)) {
- GURL gurl(url);
- if (IsProtocolSupportedForMedia(gurl))
- return true;
- }
- return false;
-}
-
SimpleDataSource::SimpleDataSource(
MessageLoop* render_loop,
webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory)
diff --git a/webkit/glue/media/simple_data_source.h b/webkit/glue/media/simple_data_source.h
index d649c0d..2ff851e 100644
--- a/webkit/glue/media/simple_data_source.h
+++ b/webkit/glue/media/simple_data_source.h
@@ -12,7 +12,6 @@
#include "base/message_loop.h"
#include "base/scoped_ptr.h"
-#include "media/base/factory.h"
#include "media/base/filters.h"
#include "webkit/glue/media/media_resource_loader_bridge_factory.h"
@@ -24,19 +23,10 @@ namespace webkit_glue {
class SimpleDataSource : public media::DataSource,
public webkit_glue::ResourceLoaderBridge::Peer {
public:
- static media::FilterFactory* CreateFactory(
- MessageLoop* message_loop,
- webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory) {
- return new media::FilterFactoryImpl2<
- SimpleDataSource,
- MessageLoop*,
- webkit_glue::MediaResourceLoaderBridgeFactory*>(message_loop,
- bridge_factory);
- }
-
- // media::FilterFactoryImpl2 implementation.
- static bool IsMediaFormatSupported(
- const media::MediaFormat& media_format);
+ SimpleDataSource(
+ MessageLoop* render_loop,
+ webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory);
+ virtual ~SimpleDataSource();
// MediaFilter implementation.
virtual void Stop(media::FilterCallback* callback);
@@ -68,15 +58,6 @@ class SimpleDataSource : public media::DataSource,
virtual GURL GetURLForDebugging() const;
private:
- friend class media::FilterFactoryImpl2<
- SimpleDataSource,
- MessageLoop*,
- webkit_glue::MediaResourceLoaderBridgeFactory*>;
- SimpleDataSource(
- MessageLoop* render_loop,
- webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory);
- virtual ~SimpleDataSource();
-
// Updates |url_| and |media_format_| with the given URL.
void SetURL(const GURL& url);
diff --git a/webkit/glue/media/simple_data_source_unittest.cc b/webkit/glue/media/simple_data_source_unittest.cc
index 50c8910..537798f 100644
--- a/webkit/glue/media/simple_data_source_unittest.cc
+++ b/webkit/glue/media/simple_data_source_unittest.cc
@@ -42,8 +42,6 @@ class SimpleDataSourceTest : public testing::Test {
bridge_factory_.reset(
new NiceMock<MockMediaResourceLoaderBridgeFactory>());
bridge_.reset(new NiceMock<MockResourceLoaderBridge>());
- factory_ = SimpleDataSource::CreateFactory(MessageLoop::current(),
- bridge_factory_.get());
for (int i = 0; i < kDataSize; ++i) {
data_[i] = i;
@@ -58,11 +56,8 @@ class SimpleDataSourceTest : public testing::Test {
}
void InitializeDataSource(const char* url) {
- media::MediaFormat url_format;
- url_format.SetAsString(media::MediaFormat::kMimeType,
- media::mime_type::kURL);
- url_format.SetAsString(media::MediaFormat::kURL, url);
- data_source_ = factory_->Create<SimpleDataSource>(url_format);
+ data_source_ = new SimpleDataSource(MessageLoop::current(),
+ bridge_factory_.get());
CHECK(data_source_);
// There is no need to provide a message loop to data source.
@@ -167,7 +162,6 @@ class SimpleDataSourceTest : public testing::Test {
scoped_ptr<MessageLoop> message_loop_;
scoped_ptr<NiceMock<MockMediaResourceLoaderBridgeFactory> > bridge_factory_;
scoped_ptr<NiceMock<MockResourceLoaderBridge> > bridge_;
- scoped_refptr<media::FilterFactory> factory_;
scoped_refptr<SimpleDataSource> data_source_;
StrictMock<media::MockFilterHost> host_;
StrictMock<media::MockFilterCallback> callback_;
@@ -195,11 +189,9 @@ TEST_F(SimpleDataSourceTest, InitializeFile) {
}
TEST_F(SimpleDataSourceTest, InitializeData) {
- media::MediaFormat url_format;
- url_format.SetAsString(media::MediaFormat::kMimeType,
- media::mime_type::kURL);
- url_format.SetAsString(media::MediaFormat::kURL, kDataUrl);
- data_source_ = factory_->Create<SimpleDataSource>(url_format);
+ data_source_ = new SimpleDataSource(MessageLoop::current(),
+ bridge_factory_.get());
+ EXPECT_TRUE(data_source_->IsUrlSupported(kDataUrl));
CHECK(data_source_);
// There is no need to provide a message loop to data source.
@@ -217,15 +209,6 @@ TEST_F(SimpleDataSourceTest, InitializeData) {
DestroyDataSource();
}
-TEST_F(SimpleDataSourceTest, InitializeInvalid) {
- media::MediaFormat url_format;
- url_format.SetAsString(media::MediaFormat::kMimeType,
- media::mime_type::kURL);
- url_format.SetAsString(media::MediaFormat::kURL, kInvalidUrl);
- data_source_ = factory_->Create<SimpleDataSource>(url_format);
- EXPECT_FALSE(data_source_);
-}
-
TEST_F(SimpleDataSourceTest, RequestFailed) {
InitializeDataSource(kHttpUrl);
RequestFailed();
diff --git a/webkit/glue/media/video_renderer_impl.cc b/webkit/glue/media/video_renderer_impl.cc
index 16c9ef6..3bbd626 100644
--- a/webkit/glue/media/video_renderer_impl.cc
+++ b/webkit/glue/media/video_renderer_impl.cc
@@ -10,33 +10,13 @@
namespace webkit_glue {
-VideoRendererImpl::VideoRendererImpl(WebMediaPlayerImpl::Proxy* proxy,
- bool pts_logging)
- : proxy_(proxy),
- last_converted_frame_(NULL),
+VideoRendererImpl::VideoRendererImpl(bool pts_logging)
+ : last_converted_frame_(NULL),
pts_logging_(pts_logging) {
- // TODO(hclam): decide whether to do the following line in this thread or
- // in the render thread.
- proxy_->SetVideoRenderer(this);
}
VideoRendererImpl::~VideoRendererImpl() {}
-// static
-media::FilterFactory* VideoRendererImpl::CreateFactory(
- WebMediaPlayerImpl::Proxy* proxy,
- bool pts_logging) {
- return new media::FilterFactoryImpl2<VideoRendererImpl,
- WebMediaPlayerImpl::Proxy*,
- bool>(proxy, pts_logging);
-}
-
-// static
-bool VideoRendererImpl::IsMediaFormatSupported(
- const media::MediaFormat& media_format) {
- return ParseMediaFormat(media_format, NULL, NULL, NULL, NULL);
-}
-
bool VideoRendererImpl::OnInitialize(media::VideoDecoder* decoder) {
video_size_.SetSize(width(), height());
bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width(), height());
@@ -60,6 +40,11 @@ void VideoRendererImpl::OnFrameAvailable() {
proxy_->Repaint();
}
+void VideoRendererImpl::SetWebMediaPlayerImplProxy(
+ WebMediaPlayerImpl::Proxy* proxy) {
+ proxy_ = proxy;
+}
+
void VideoRendererImpl::SetRect(const gfx::Rect& rect) {
}
diff --git a/webkit/glue/media/video_renderer_impl.h b/webkit/glue/media/video_renderer_impl.h
index 38e88514..34c67d3 100644
--- a/webkit/glue/media/video_renderer_impl.h
+++ b/webkit/glue/media/video_renderer_impl.h
@@ -24,39 +24,16 @@ namespace webkit_glue {
class VideoRendererImpl : public WebVideoRenderer {
public:
+ explicit VideoRendererImpl(bool pts_logging);
+ virtual ~VideoRendererImpl();
+
// WebVideoRenderer implementation.
+ virtual void SetWebMediaPlayerImplProxy(WebMediaPlayerImpl::Proxy* proxy);
virtual void SetRect(const gfx::Rect& rect);
virtual void Paint(skia::PlatformCanvas* canvas, const gfx::Rect& dest_rect);
virtual void GetCurrentFrame(scoped_refptr<media::VideoFrame>* frame_out);
virtual void PutCurrentFrame(scoped_refptr<media::VideoFrame> frame);
- // Static method for creating factory for this object.
- static media::FilterFactory* CreateFactory(WebMediaPlayerImpl::Proxy* proxy,
- bool pts_logging);
-
- // FilterFactoryImpl2 implementation.
- static bool IsMediaFormatSupported(const media::MediaFormat& media_format);
-
- // TODO(scherkus): remove this mega-hack, see http://crbug.com/28207
- class FactoryFactory : public webkit_glue::WebVideoRendererFactoryFactory {
- public:
- FactoryFactory(bool pts_logging)
- : webkit_glue::WebVideoRendererFactoryFactory(),
- pts_logging_(pts_logging) {
- }
-
- virtual media::FilterFactory* CreateFactory(
- webkit_glue::WebMediaPlayerImpl::Proxy* proxy) {
- return VideoRendererImpl::CreateFactory(proxy, pts_logging_);
- }
-
- private:
- // Whether we're logging video presentation timestamps (PTS).
- bool pts_logging_;
-
- DISALLOW_COPY_AND_ASSIGN(FactoryFactory);
- };
-
protected:
// Method called by VideoRendererBase during initialization.
virtual bool OnInitialize(media::VideoDecoder* decoder);
@@ -68,13 +45,6 @@ class VideoRendererImpl : public WebVideoRenderer {
virtual void OnFrameAvailable();
private:
- // Only the filter factories can create instances.
- friend class media::FilterFactoryImpl2<VideoRendererImpl,
- WebMediaPlayerImpl::Proxy*,
- bool>;
- VideoRendererImpl(WebMediaPlayerImpl::Proxy* proxy, bool pts_logging);
- virtual ~VideoRendererImpl();
-
// Determine the conditions to perform fast paint. Returns true if we can do
// fast paint otherwise false.
bool CanFastPaint(skia::PlatformCanvas* canvas, const gfx::Rect& dest_rect);
diff --git a/webkit/glue/media/web_video_renderer.h b/webkit/glue/media/web_video_renderer.h
index d8b47ad0..efd3109 100644
--- a/webkit/glue/media/web_video_renderer.h
+++ b/webkit/glue/media/web_video_renderer.h
@@ -7,6 +7,7 @@
#include "media/base/video_frame.h"
#include "media/filters/video_renderer_base.h"
+#include "webkit/glue/webmediaplayer_impl.h"
namespace webkit_glue {
@@ -16,6 +17,9 @@ class WebVideoRenderer : public media::VideoRendererBase {
WebVideoRenderer() : media::VideoRendererBase() {}
virtual ~WebVideoRenderer() {}
+ // Saves the reference to WebMediaPlayerImpl::Proxy.
+ virtual void SetWebMediaPlayerImplProxy(WebMediaPlayerImpl::Proxy* proxy) = 0;
+
// 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 separate thread. Since we always do the stretch on the