Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MEDIA_BASE_FILTER_COLLECTION_H_ | 5 #ifndef MEDIA_BASE_FILTER_COLLECTION_H_ |
| 6 #define MEDIA_BASE_FILTER_COLLECTION_H_ | 6 #define MEDIA_BASE_FILTER_COLLECTION_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "media/base/demuxer_factory.h" | 11 #include "media/base/demuxer_factory.h" |
| 12 #include "media/base/filters.h" | 12 #include "media/base/filters.h" |
| 13 | 13 |
| 14 namespace media { | 14 namespace media { |
| 15 | 15 |
| 16 class AudioDecoder; | 16 class AudioDecoder; |
| 17 | 17 |
| 18 // This is a collection of Filter objects used to form a media playback | 18 // This is a collection of Filter objects used to form a media playback |
| 19 // pipeline. See src/media/base/pipeline.h for more information. | 19 // pipeline. See src/media/base/pipeline.h for more information. |
| 20 class MEDIA_EXPORT FilterCollection { | 20 class MEDIA_EXPORT FilterCollection { |
| 21 public: | 21 public: |
| 22 FilterCollection(); | 22 FilterCollection(); |
| 23 ~FilterCollection(); | 23 ~FilterCollection(); |
| 24 | 24 |
| 25 // DemuxerFactory accessor methods. | 25 // DemuxerFactory accessor methods. |
| 26 void SetDemuxerFactory(scoped_ptr<DemuxerFactory> factory); | 26 void SetDemuxerFactory(scoped_ptr<DemuxerFactory> factory); |
| 27 DemuxerFactory* GetDemuxerFactory(); | 27 DemuxerFactory* GetDemuxerFactory(); |
| 28 | 28 |
| 29 // Adds a filter to the collection. | 29 // Adds a filter to the collection. |
| 30 void AddVideoDecoder(VideoDecoder* filter); | 30 void AddVideoDecoder(VideoDecoder* video_decoder); |
| 31 void AddAudioDecoder(AudioDecoder* audio_decoder); | 31 void AddAudioDecoder(AudioDecoder* audio_decoder); |
| 32 void AddVideoRenderer(VideoRenderer* filter); | 32 void AddVideoRenderer(VideoRenderer* filter); |
| 33 void AddAudioRenderer(AudioRenderer* filter); | 33 void AddAudioRenderer(AudioRenderer* filter); |
| 34 | 34 |
| 35 // Is the collection empty? | 35 // Is the collection empty? |
| 36 bool IsEmpty() const; | 36 bool IsEmpty() const; |
| 37 | 37 |
| 38 // Remove remaining filters. | 38 // Remove remaining filters. |
| 39 void Clear(); | 39 void Clear(); |
| 40 | 40 |
| 41 // Selects a filter of the specified type from the collection. | 41 // Selects a filter of the specified type from the collection. |
| 42 // If the required filter cannot be found, NULL is returned. | 42 // If the required filter cannot be found, NULL is returned. |
| 43 // If a filter is returned it is removed from the collection. | 43 // If a filter is returned it is removed from the collection. |
| 44 // Filters are selected in FIFO order. | 44 // Filters are selected in FIFO order. |
| 45 void SelectVideoDecoder(scoped_refptr<VideoDecoder>* filter_out); | 45 void SelectVideoDecoder(scoped_refptr<VideoDecoder>* out); |
| 46 void SelectAudioDecoder(scoped_refptr<AudioDecoder>* out); | 46 void SelectAudioDecoder(scoped_refptr<AudioDecoder>* out); |
| 47 void SelectVideoRenderer(scoped_refptr<VideoRenderer>* filter_out); | 47 void SelectVideoRenderer(scoped_refptr<VideoRenderer>* filter_out); |
| 48 void SelectAudioRenderer(scoped_refptr<AudioRenderer>* filter_out); | 48 void SelectAudioRenderer(scoped_refptr<AudioRenderer>* filter_out); |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 // Identifies the type of filter implementation. Each filter has to be one of | 51 // Identifies the type of filter implementation. Each filter has to be one of |
| 52 // the following types. This is used to mark, identify, and support | 52 // the following types. This is used to mark, identify, and support |
| 53 // downcasting of different filter types stored in the filters_ list. | 53 // downcasting of different filter types stored in the filters_ list. |
| 54 enum FilterType { | 54 enum FilterType { |
| 55 VIDEO_DECODER, | |
| 56 AUDIO_RENDERER, | 55 AUDIO_RENDERER, |
| 57 VIDEO_RENDERER, | 56 VIDEO_RENDERER, |
| 58 }; | 57 }; |
| 59 | 58 |
| 60 // List of filters managed by this collection. | 59 // List of filters managed by this collection. |
| 61 typedef std::pair<FilterType, scoped_refptr<Filter> > FilterListElement; | 60 typedef std::pair<FilterType, scoped_refptr<Filter> > FilterListElement; |
| 62 typedef std::list<FilterListElement> FilterList; | 61 typedef std::list<FilterListElement> FilterList; |
| 63 FilterList filters_; | 62 FilterList filters_; |
| 64 scoped_ptr<DemuxerFactory> demuxer_factory_; | 63 scoped_ptr<DemuxerFactory> demuxer_factory_; |
| 64 std::list<scoped_refptr<VideoDecoder> > video_decoders_; | |
|
Ami GONE FROM CHROMIUM
2012/03/14 20:05:01
nit: IWBN to have _V_ideoDecoders follow _A_udio_d
xhwang
2012/03/14 22:28:41
Done.
| |
| 65 std::list<scoped_refptr<AudioDecoder> > audio_decoders_; | 65 std::list<scoped_refptr<AudioDecoder> > audio_decoders_; |
| 66 | 66 |
| 67 // Helper function that adds a filter to the filter list. | 67 // Helper function that adds a filter to the filter list. |
| 68 void AddFilter(FilterType filter_type, Filter* filter); | 68 void AddFilter(FilterType filter_type, Filter* filter); |
| 69 | 69 |
| 70 // Helper function for SelectXXX() methods. It manages the | 70 // Helper function for SelectXXX() methods. It manages the |
| 71 // downcasting and mapping between FilterType and Filter class. | 71 // downcasting and mapping between FilterType and Filter class. |
| 72 template<FilterType filter_type, typename F> | 72 template<FilterType filter_type, typename F> |
| 73 void SelectFilter(scoped_refptr<F>* filter_out); | 73 void SelectFilter(scoped_refptr<F>* filter_out); |
| 74 | 74 |
| 75 // Helper function that searches the filters list for a specific filter type. | 75 // Helper function that searches the filters list for a specific filter type. |
| 76 void SelectFilter(FilterType filter_type, scoped_refptr<Filter>* filter_out); | 76 void SelectFilter(FilterType filter_type, scoped_refptr<Filter>* filter_out); |
| 77 | 77 |
| 78 DISALLOW_COPY_AND_ASSIGN(FilterCollection); | 78 DISALLOW_COPY_AND_ASSIGN(FilterCollection); |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 } // namespace media | 81 } // namespace media |
| 82 | 82 |
| 83 #endif // MEDIA_BASE_FILTER_COLLECTION_H_ | 83 #endif // MEDIA_BASE_FILTER_COLLECTION_H_ |
| OLD | NEW |