Index: media/base/media_filter_collection.h |
diff --git a/media/base/media_filter_collection.h b/media/base/media_filter_collection.h |
index 31ea69c315dfcc100905dcb7c14894bb50029d62..c4a403abf185e8c1966bf57f0f1a9aaa6f004524 100644 |
--- a/media/base/media_filter_collection.h |
+++ b/media/base/media_filter_collection.h |
@@ -19,7 +19,12 @@ class MediaFilterCollection { |
MediaFilterCollection(); |
// Adds a filter to the collection. |
- void AddFilter(MediaFilter* filter); |
+ void AddDataSource(DataSource* filter); |
+ void AddDemuxer(Demuxer* filter); |
+ void AddVideoDecoder(VideoDecoder* filter); |
+ void AddAudioDecoder(AudioDecoder* filter); |
+ void AddVideoRenderer(VideoRenderer* filter); |
+ void AddAudioRenderer(AudioRenderer* filter); |
// Is the collection empty? |
bool IsEmpty() const; |
@@ -30,16 +35,38 @@ class MediaFilterCollection { |
// Selects a filter of the specified type from the collection. |
// If the required filter cannot be found, NULL is returned. |
// If a filter is returned it is removed from the collection. |
- template <class Filter> |
- void SelectFilter(scoped_refptr<Filter>* filter_out) { |
- scoped_refptr<MediaFilter> filter; |
- SelectFilter(Filter::static_filter_type(), &filter); |
- *filter_out = reinterpret_cast<Filter*>(filter.get()); |
- } |
+ void SelectDataSource(scoped_refptr<DataSource>* filter_out); |
+ void SelectDemuxer(scoped_refptr<Demuxer>* filter_out); |
+ void SelectVideoDecoder(scoped_refptr<VideoDecoder>* filter_out); |
+ void SelectAudioDecoder(scoped_refptr<AudioDecoder>* filter_out); |
+ void SelectVideoRenderer(scoped_refptr<VideoRenderer>* filter_out); |
+ void SelectAudioRenderer(scoped_refptr<AudioRenderer>* filter_out); |
private: |
+ // Identifies the type of filter implementation. Each filter has to be one of |
+ // the following types. This is used to mark, identify, and support |
+ // downcasting of different filter types stored in the filters_ list. |
+ enum FilterType { |
+ DATA_SOURCE, |
+ DEMUXER, |
+ AUDIO_DECODER, |
+ VIDEO_DECODER, |
+ AUDIO_RENDERER, |
+ VIDEO_RENDERER |
+ }; |
+ |
// List of filters managed by this collection. |
- std::list<scoped_refptr<MediaFilter> > filters_; |
+ typedef std::pair<FilterType, scoped_refptr<MediaFilter> > FilterListElement; |
+ typedef std::list<FilterListElement> FilterList; |
+ FilterList filters_; |
+ |
+ // Helper function that adds a filter to the filter list. |
+ void AddFilter(FilterType filter_type, MediaFilter* filter); |
+ |
+ // Helper function for SelectXXX() methods. It manages the |
+ // downcasting and mapping between FilterType and Filter class. |
+ template<FilterType filter_type, class Filter> |
+ void SelectFilter(scoped_refptr<Filter>* filter_out); |
// Helper function that searches the filters list for a specific |
// filter type. |