diff options
author | ralphl@chromium.org <ralphl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-24 01:25:14 +0000 |
---|---|---|
committer | ralphl@chromium.org <ralphl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-24 01:25:14 +0000 |
commit | ce553ab757aa9f46bbced6392fda9bdf8da4bd8b (patch) | |
tree | 1e51f83cc956027064d06279f40a79b1aa83d5d1 /media/base | |
parent | c96d5309cee28f5b839e10ba9525fdfc6913a61c (diff) | |
download | chromium_src-ce553ab757aa9f46bbced6392fda9bdf8da4bd8b.zip chromium_src-ce553ab757aa9f46bbced6392fda9bdf8da4bd8b.tar.gz chromium_src-ce553ab757aa9f46bbced6392fda9bdf8da4bd8b.tar.bz2 |
Moved most functionality of video renderer into a base class (video_renderer_base) and implemented mock filter will full
functionality execpt that it never draws anything.
Review URL: http://codereview.chromium.org/20343
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10239 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base')
-rw-r--r-- | media/base/factory.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/media/base/factory.h b/media/base/factory.h index 41a73aa..66bc377 100644 --- a/media/base/factory.h +++ b/media/base/factory.h @@ -156,6 +156,48 @@ class FilterFactoryImpl1 : public FilterFactory { DISALLOW_COPY_AND_ASSIGN(FilterFactoryImpl1); }; + +//------------------------------------------------------------------------------ + +// This specialized factory is typically used by test programs that create +// a filter instance, and want to return that specific instance of the test +// filter to the pipeline. It takes an already created filter in the +// constructor, and then hands that instance out when the Create method is +// called. The factory makes sure to only return a single copy of the +// filter. The normal patern of use for this factory is: +// scoped_refptr<MyTestFilter> my_test_filter = new MyTestFilter(); +// filter_factory_collection->AddFactory( +// new InstanceFilterFactory<MyTestFilter>(my_test_filter)); +template <class Filter> +class InstanceFilterFactory : public FilterFactory { + public: + explicit InstanceFilterFactory(Filter* filter) + : filter_(filter), + create_called_(false) { + } + + protected: + virtual MediaFilter* Create(FilterType filter_type, + const MediaFormat* media_format) { + if (Filter::filter_type() == filter_type && + Filter::IsMediaFormatSupported(media_format)) { + if (!create_called_) { + create_called_ = true; + return filter_; + } else { + NOTREACHED(); + } + } + return NULL; + } + + private: + scoped_refptr<Filter> filter_; + bool create_called_; + + DISALLOW_COPY_AND_ASSIGN(InstanceFilterFactory); +}; + } // namespace media #endif // MEDIA_BASE_FACTORY_H_ |