diff options
author | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-23 01:20:37 +0000 |
---|---|---|
committer | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-23 01:20:37 +0000 |
commit | 457d83467c00c236e806bb150796a2efdc88bfcf (patch) | |
tree | 36c58186b34d36300374b232fb79540457307b23 /chrome/renderer/media | |
parent | 77a397cc5cf8106e559aa87a5228478afc28cec1 (diff) | |
download | chromium_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 'chrome/renderer/media')
-rw-r--r-- | chrome/renderer/media/audio_renderer_impl.cc | 8 | ||||
-rw-r--r-- | chrome/renderer/media/audio_renderer_impl.h | 18 | ||||
-rw-r--r-- | chrome/renderer/media/ipc_video_decoder.cc | 20 | ||||
-rw-r--r-- | chrome/renderer/media/ipc_video_decoder.h | 7 | ||||
-rw-r--r-- | chrome/renderer/media/ipc_video_renderer.cc | 31 | ||||
-rw-r--r-- | chrome/renderer/media/ipc_video_renderer.h | 41 |
6 files changed, 16 insertions, 109 deletions
diff --git a/chrome/renderer/media/audio_renderer_impl.cc b/chrome/renderer/media/audio_renderer_impl.cc index 2ce02ab..e5c2f0c 100644 --- a/chrome/renderer/media/audio_renderer_impl.cc +++ b/chrome/renderer/media/audio_renderer_impl.cc @@ -51,14 +51,6 @@ base::TimeDelta AudioRendererImpl::ConvertToDuration(int bytes) { return base::TimeDelta(); } -bool AudioRendererImpl::IsMediaFormatSupported( - const media::MediaFormat& media_format) { - int channels; - int sample_rate; - int sample_bits; - return ParseMediaFormat(media_format, &channels, &sample_rate, &sample_bits); -} - bool AudioRendererImpl::OnInitialize(const media::MediaFormat& media_format) { // Parse integer values in MediaFormat. if (!ParseMediaFormat(media_format, diff --git a/chrome/renderer/media/audio_renderer_impl.h b/chrome/renderer/media/audio_renderer_impl.h index 57fb8eb..5c27ef3 100644 --- a/chrome/renderer/media/audio_renderer_impl.h +++ b/chrome/renderer/media/audio_renderer_impl.h @@ -46,7 +46,6 @@ #include "chrome/renderer/audio_message_filter.h" #include "media/audio/audio_io.h" #include "media/audio/audio_manager.h" -#include "media/base/factory.h" #include "media/base/filters.h" #include "media/filters/audio_renderer_base.h" @@ -56,13 +55,9 @@ class AudioRendererImpl : public media::AudioRendererBase, public AudioMessageFilter::Delegate, public MessageLoop::DestructionObserver { public: - // Methods called on render thread ------------------------------------------ - // Methods called during construction. - static media::FilterFactory* CreateFactory(AudioMessageFilter* filter) { - return new media::FilterFactoryImpl1<AudioRendererImpl, - AudioMessageFilter*>(filter); - } - static bool IsMediaFormatSupported(const media::MediaFormat& format); + // Methods called on Render thread ------------------------------------------ + explicit AudioRendererImpl(AudioMessageFilter* filter); + virtual ~AudioRendererImpl(); // Methods called on IO thread ---------------------------------------------- // AudioMessageFilter::Delegate methods, called by AudioMessageFilter. @@ -94,18 +89,11 @@ class AudioRendererImpl : public media::AudioRendererBase, virtual void OnReadComplete(media::Buffer* buffer_in); private: - friend class media::FilterFactoryImpl1<AudioRendererImpl, - AudioMessageFilter*>; - // For access to constructor and IO thread methods. friend class AudioRendererImplTest; FRIEND_TEST_ALL_PREFIXES(AudioRendererImplTest, Stop); FRIEND_TEST_ALL_PREFIXES(AudioRendererImplTest, DestroyedMessageLoop_OnReadComplete); - - explicit AudioRendererImpl(AudioMessageFilter* filter); - virtual ~AudioRendererImpl(); - // Helper methods. // Convert number of bytes to duration of time using information about the // number of channels, sample rate and sample bits. diff --git a/chrome/renderer/media/ipc_video_decoder.cc b/chrome/renderer/media/ipc_video_decoder.cc index d06130e..12b262a 100644 --- a/chrome/renderer/media/ipc_video_decoder.cc +++ b/chrome/renderer/media/ipc_video_decoder.cc @@ -188,23 +188,3 @@ void IpcVideoDecoder::ConsumeVideoFrame( void IpcVideoDecoder::ProduceVideoSample(scoped_refptr<media::Buffer> buffer) { demuxer_stream_->Read(NewCallback(this, &IpcVideoDecoder::OnReadComplete)); } - -// static -media::FilterFactory* IpcVideoDecoder::CreateFactory( - MessageLoop* message_loop, ggl::Context* ggl_context) { - return new media::FilterFactoryImpl2< - IpcVideoDecoder, MessageLoop*, ggl::Context*>(message_loop, ggl_context); -} - -// static -bool IpcVideoDecoder::IsMediaFormatSupported(const media::MediaFormat& format) { - std::string mime_type; - if (!format.GetAsString(media::MediaFormat::kMimeType, &mime_type) && - media::mime_type::kFFmpegVideo != mime_type) - return false; - - // TODO(jiesun): Although we current only support H264 hardware decoding, - // in the future, we should query GpuVideoService for capabilities. - int codec_id; - return format.GetAsInteger(media::MediaFormat::kFFmpegCodecID, &codec_id); -} diff --git a/chrome/renderer/media/ipc_video_decoder.h b/chrome/renderer/media/ipc_video_decoder.h index c9d800d..c1f12fb 100644 --- a/chrome/renderer/media/ipc_video_decoder.h +++ b/chrome/renderer/media/ipc_video_decoder.h @@ -21,14 +21,9 @@ class Context; class IpcVideoDecoder : public media::VideoDecoder, public media::VideoDecodeEngine::EventHandler { public: - explicit IpcVideoDecoder(MessageLoop* message_loop, - ggl::Context* ggl_context); + IpcVideoDecoder(MessageLoop* message_loop, ggl::Context* ggl_context); virtual ~IpcVideoDecoder(); - static media::FilterFactory* CreateFactory(MessageLoop* message_loop, - ggl::Context* ggl_context); - static bool IsMediaFormatSupported(const media::MediaFormat& media_format); - // MediaFilter implementation. virtual void Stop(media::FilterCallback* callback); virtual void Seek(base::TimeDelta time, media::FilterCallback* callback); diff --git a/chrome/renderer/media/ipc_video_renderer.cc b/chrome/renderer/media/ipc_video_renderer.cc index d9a194d..fcf8c61 100644 --- a/chrome/renderer/media/ipc_video_renderer.cc +++ b/chrome/renderer/media/ipc_video_renderer.cc @@ -9,37 +9,15 @@ #include "media/base/video_frame.h" #include "media/base/media_format.h" -IPCVideoRenderer::IPCVideoRenderer( - webkit_glue::WebMediaPlayerImpl::Proxy* proxy, - int routing_id) - : proxy_(proxy), - created_(false), +IPCVideoRenderer::IPCVideoRenderer(int routing_id) + : created_(false), routing_id_(routing_id), stopped_(false, false) { - // TODO(hclam): decide whether to do the following line in this thread or - // in the render thread. - proxy->SetVideoRenderer(this); } IPCVideoRenderer::~IPCVideoRenderer() { } -// static -media::FilterFactory* IPCVideoRenderer::CreateFactory( - webkit_glue::WebMediaPlayerImpl::Proxy* proxy, - int routing_id) { - return new media::FilterFactoryImpl2< - IPCVideoRenderer, - webkit_glue::WebMediaPlayerImpl::Proxy*, - int>(proxy, routing_id); -} - -// static -bool IPCVideoRenderer::IsMediaFormatSupported( - const media::MediaFormat& media_format) { - return ParseMediaFormat(media_format, NULL, NULL, NULL, NULL); -} - bool IPCVideoRenderer::OnInitialize(media::VideoDecoder* decoder) { video_size_.SetSize(width(), height()); @@ -64,6 +42,11 @@ void IPCVideoRenderer::OnFrameAvailable() { NewRunnableMethod(this, &IPCVideoRenderer::DoUpdateVideo)); } +void IPCVideoRenderer::SetWebMediaPlayerImplProxy( + webkit_glue::WebMediaPlayerImpl::Proxy* proxy) { + proxy_ = proxy; +} + void IPCVideoRenderer::SetRect(const gfx::Rect& rect) { DCHECK(MessageLoop::current() == proxy_->message_loop()); diff --git a/chrome/renderer/media/ipc_video_renderer.h b/chrome/renderer/media/ipc_video_renderer.h index c934291..d032469 100644 --- a/chrome/renderer/media/ipc_video_renderer.h +++ b/chrome/renderer/media/ipc_video_renderer.h @@ -22,7 +22,12 @@ class IPCVideoRenderer : public webkit_glue::WebVideoRenderer { public: + explicit IPCVideoRenderer(int routing_id); + virtual ~IPCVideoRenderer(); + // WebVideoRenderer implementation. + virtual void SetWebMediaPlayerImplProxy( + webkit_glue::WebMediaPlayerImpl::Proxy* proxy); virtual void SetRect(const gfx::Rect& rect); virtual void Paint(skia::PlatformCanvas* canvas, const gfx::Rect& dest_rect); @@ -30,33 +35,6 @@ class IPCVideoRenderer : public webkit_glue::WebVideoRenderer { void OnUpdateVideoAck(); void OnDestroyVideo(); - // Static method for creating factory for this object. - static media::FilterFactory* CreateFactory( - webkit_glue::WebMediaPlayerImpl::Proxy* proxy, - int routing_id); - - // 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: - explicit FactoryFactory(int routing_id) - : webkit_glue::WebVideoRendererFactoryFactory(), - routing_id_(routing_id) { - } - - virtual media::FilterFactory* CreateFactory( - webkit_glue::WebMediaPlayerImpl::Proxy* proxy) { - return IPCVideoRenderer::CreateFactory(proxy, routing_id_); - } - - private: - int routing_id_; - - DISALLOW_COPY_AND_ASSIGN(FactoryFactory); - }; - protected: // VideoRendererBase implementation. virtual bool OnInitialize(media::VideoDecoder* decoder); @@ -64,15 +42,6 @@ class IPCVideoRenderer : public webkit_glue::WebVideoRenderer { virtual void OnFrameAvailable(); private: - // Only the filter factories can create instances. - friend class media::FilterFactoryImpl2< - IPCVideoRenderer, - webkit_glue::WebMediaPlayerImpl::Proxy*, - int>; - IPCVideoRenderer(webkit_glue::WebMediaPlayerImpl::Proxy* proxy, - int routing_id); - virtual ~IPCVideoRenderer(); - // Send an IPC message to the browser process. The routing ID of the message // is assumed to match |routing_id_|. void Send(IPC::Message* msg); |