OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "media/base/media_filter_collection.h" | 5 #include "media/base/media_filter_collection.h" |
6 | 6 |
7 namespace media { | 7 namespace media { |
8 | 8 |
9 MediaFilterCollection::MediaFilterCollection() { | 9 MediaFilterCollection::MediaFilterCollection() { |
10 } | 10 } |
11 | 11 |
12 void MediaFilterCollection::AddFilter(MediaFilter* filter) { | 12 void MediaFilterCollection::AddFilter(DataSource* filter) { |
13 filters_.push_back(filter); | 13 AddFilter(FILTER_DATA_SOURCE, filter); |
| 14 } |
| 15 |
| 16 void MediaFilterCollection::AddFilter(Demuxer* filter) { |
| 17 AddFilter(FILTER_DEMUXER, filter); |
| 18 } |
| 19 |
| 20 void MediaFilterCollection::AddFilter(VideoDecoder* filter) { |
| 21 AddFilter(FILTER_VIDEO_DECODER, filter); |
| 22 } |
| 23 |
| 24 void MediaFilterCollection::AddFilter(AudioDecoder* filter) { |
| 25 AddFilter(FILTER_AUDIO_DECODER, filter); |
| 26 } |
| 27 |
| 28 void MediaFilterCollection::AddFilter(VideoRenderer* filter) { |
| 29 AddFilter(FILTER_VIDEO_RENDERER, filter); |
| 30 } |
| 31 |
| 32 void MediaFilterCollection::AddFilter(AudioRenderer* filter) { |
| 33 AddFilter(FILTER_AUDIO_RENDERER, filter); |
14 } | 34 } |
15 | 35 |
16 bool MediaFilterCollection::IsEmpty() const { | 36 bool MediaFilterCollection::IsEmpty() const { |
17 return filters_.empty(); | 37 return filters_.empty(); |
18 } | 38 } |
19 | 39 |
20 void MediaFilterCollection::Clear() { | 40 void MediaFilterCollection::Clear() { |
21 filters_.clear(); | 41 filters_.clear(); |
22 } | 42 } |
23 | 43 |
24 void MediaFilterCollection::SelectFilter( | 44 void MediaFilterCollection::SelectFilter( |
| 45 scoped_refptr<DataSource>* filter_out) { |
| 46 SelectFilter<FILTER_DATA_SOURCE>(filter_out); |
| 47 } |
| 48 |
| 49 void MediaFilterCollection::SelectFilter(scoped_refptr<Demuxer>* filter_out) { |
| 50 SelectFilter<FILTER_DEMUXER>(filter_out); |
| 51 } |
| 52 |
| 53 void MediaFilterCollection::SelectFilter( |
| 54 scoped_refptr<VideoDecoder>* filter_out) { |
| 55 SelectFilter<FILTER_VIDEO_DECODER>(filter_out); |
| 56 } |
| 57 |
| 58 void MediaFilterCollection::SelectFilter( |
| 59 scoped_refptr<AudioDecoder>* filter_out) { |
| 60 SelectFilter<FILTER_AUDIO_DECODER>(filter_out); |
| 61 } |
| 62 |
| 63 void MediaFilterCollection::SelectFilter( |
| 64 scoped_refptr<VideoRenderer>* filter_out) { |
| 65 SelectFilter<FILTER_VIDEO_RENDERER>(filter_out); |
| 66 } |
| 67 |
| 68 void MediaFilterCollection::SelectFilter( |
| 69 scoped_refptr<AudioRenderer>* filter_out) { |
| 70 SelectFilter<FILTER_AUDIO_RENDERER>(filter_out); |
| 71 } |
| 72 |
| 73 void MediaFilterCollection::AddFilter(FilterType filter_type, |
| 74 MediaFilter* filter) { |
| 75 filters_.push_back(Tuple2<FilterType, scoped_refptr<MediaFilter> >( |
| 76 filter_type, |
| 77 filter)); |
| 78 } |
| 79 |
| 80 template<MediaFilterCollection::FilterType filter_type, class Filter> |
| 81 void MediaFilterCollection::SelectFilter(scoped_refptr<Filter>* filter_out) { |
| 82 scoped_refptr<MediaFilter> filter; |
| 83 SelectFilter(filter_type, &filter); |
| 84 *filter_out = reinterpret_cast<Filter*>(filter.get()); |
| 85 } |
| 86 |
| 87 void MediaFilterCollection::SelectFilter( |
25 FilterType filter_type, | 88 FilterType filter_type, |
26 scoped_refptr<MediaFilter>* filter_out) { | 89 scoped_refptr<MediaFilter>* filter_out) { |
27 | 90 |
28 std::list<scoped_refptr<MediaFilter> >::iterator it = filters_.begin(); | 91 FilterList::iterator it = filters_.begin(); |
29 while (it != filters_.end()) { | 92 while (it != filters_.end()) { |
30 if ((*it)->filter_type() == filter_type) | 93 if (it->a == filter_type) |
31 break; | 94 break; |
32 ++it; | 95 ++it; |
33 } | 96 } |
34 | 97 |
35 if (it != filters_.end()) { | 98 if (it != filters_.end()) { |
36 *filter_out = it->get(); | 99 *filter_out = it->b.get(); |
37 filters_.erase(it); | 100 filters_.erase(it); |
38 } | 101 } |
39 } | 102 } |
40 | 103 |
41 } // namespace media | 104 } // namespace media |
OLD | NEW |