| 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/filter_collection.h" | 5 #include "media/base/filter_collection.h" |
| 6 | 6 |
| 7 namespace media { | 7 namespace media { |
| 8 | 8 |
| 9 FilterCollection::FilterCollection() { | 9 FilterCollection::FilterCollection() { |
| 10 } | 10 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 bool FilterCollection::IsEmpty() const { | 36 bool FilterCollection::IsEmpty() const { |
| 37 return filters_.empty(); | 37 return filters_.empty(); |
| 38 } | 38 } |
| 39 | 39 |
| 40 void FilterCollection::Clear() { | 40 void FilterCollection::Clear() { |
| 41 filters_.clear(); | 41 filters_.clear(); |
| 42 } | 42 } |
| 43 | 43 |
| 44 void FilterCollection::SelectDataSource( | 44 void FilterCollection::SelectDataSource( |
| 45 scoped_refptr<DataSource>* filter_out) { | 45 scoped_refptr<DataSource>* filter_out) { |
| 46 SelectFilter<DATA_SOURCE>(filter_out); | 46 SelectFilter<DATA_SOURCE>(filter_out, NULL); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void FilterCollection::SelectDemuxer(scoped_refptr<Demuxer>* filter_out) { | 49 void FilterCollection::SelectDemuxer(scoped_refptr<Demuxer>* filter_out) { |
| 50 SelectFilter<DEMUXER>(filter_out); | 50 SelectFilter<DEMUXER>(filter_out, NULL); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void FilterCollection::SelectVideoDecoder( | 53 void FilterCollection::SelectVideoDecoder( |
| 54 scoped_refptr<VideoDecoder>* filter_out) { | 54 scoped_refptr<VideoDecoder>* filter_out, int codec_id) { |
| 55 SelectFilter<VIDEO_DECODER>(filter_out); | 55 SelectFilter<VIDEO_DECODER>(filter_out, &codec_id); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void FilterCollection::SelectAudioDecoder( | 58 void FilterCollection::SelectAudioDecoder( |
| 59 scoped_refptr<AudioDecoder>* filter_out) { | 59 scoped_refptr<AudioDecoder>* filter_out) { |
| 60 SelectFilter<AUDIO_DECODER>(filter_out); | 60 SelectFilter<AUDIO_DECODER>(filter_out, NULL); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void FilterCollection::SelectVideoRenderer( | 63 void FilterCollection::SelectVideoRenderer( |
| 64 scoped_refptr<VideoRenderer>* filter_out) { | 64 scoped_refptr<VideoRenderer>* filter_out) { |
| 65 SelectFilter<VIDEO_RENDERER>(filter_out); | 65 SelectFilter<VIDEO_RENDERER>(filter_out, NULL); |
| 66 } | 66 } |
| 67 | 67 |
| 68 void FilterCollection::SelectAudioRenderer( | 68 void FilterCollection::SelectAudioRenderer( |
| 69 scoped_refptr<AudioRenderer>* filter_out) { | 69 scoped_refptr<AudioRenderer>* filter_out) { |
| 70 SelectFilter<AUDIO_RENDERER>(filter_out); | 70 SelectFilter<AUDIO_RENDERER>(filter_out, NULL); |
| 71 } | 71 } |
| 72 | 72 |
| 73 void FilterCollection::AddFilter(FilterType filter_type, | 73 void FilterCollection::AddFilter(FilterType filter_type, |
| 74 Filter* filter) { | 74 Filter* filter) { |
| 75 filters_.push_back(FilterListElement(filter_type, filter)); | 75 filters_.push_back(FilterListElement(filter_type, filter)); |
| 76 } | 76 } |
| 77 | 77 |
| 78 template<FilterCollection::FilterType filter_type, typename F> | 78 template<FilterCollection::FilterType filter_type, typename F> |
| 79 void FilterCollection::SelectFilter(scoped_refptr<F>* filter_out) { | 79 void FilterCollection::SelectFilter(scoped_refptr<F>* filter_out, |
| 80 void *filter_props) { |
| 80 scoped_refptr<Filter> filter; | 81 scoped_refptr<Filter> filter; |
| 81 SelectFilter(filter_type, &filter); | 82 SelectFilter(filter_type, &filter, filter_props); |
| 82 *filter_out = reinterpret_cast<F*>(filter.get()); | 83 *filter_out = reinterpret_cast<F*>(filter.get()); |
| 83 } | 84 } |
| 84 | 85 |
| 85 void FilterCollection::SelectFilter( | 86 void FilterCollection::SelectFilter( |
| 86 FilterType filter_type, | 87 FilterType filter_type, |
| 87 scoped_refptr<Filter>* filter_out) { | 88 scoped_refptr<Filter>* filter_out, void *filter_props) { |
| 88 | 89 |
| 89 FilterList::iterator it = filters_.begin(); | 90 FilterList::iterator it = filters_.begin(); |
| 90 while (it != filters_.end()) { | 91 while (it != filters_.end()) { |
| 91 if (it->first == filter_type) | 92 if (it->first == filter_type) { |
| 92 break; | 93 if (filter_props == NULL) |
| 94 break; |
| 95 // Now assume that *filter_props contains codec_id and we need |
| 96 // to select filter which supports this codec_id |
| 97 int codec_id = *(int*)filter_props; |
| 98 if (it->second->supports_codec_id(codec_id) == true) |
| 99 break; |
| 100 } |
| 93 ++it; | 101 ++it; |
| 94 } | 102 } |
| 95 | 103 |
| 96 if (it != filters_.end()) { | 104 if (it != filters_.end()) { |
| 97 *filter_out = it->second.get(); | 105 *filter_out = it->second.get(); |
| 98 filters_.erase(it); | 106 filters_.erase(it); |
| 99 } | 107 } |
| 100 } | 108 } |
| 101 | 109 |
| 102 } // namespace media | 110 } // namespace media |
| OLD | NEW |