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 #include "media/base/filter_collection.h" | 5 #include "media/base/filter_collection.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "media/base/audio_decoder.h" |
8 | 9 |
9 namespace media { | 10 namespace media { |
10 | 11 |
11 FilterCollection::FilterCollection() {} | 12 FilterCollection::FilterCollection() {} |
12 | 13 |
13 FilterCollection::~FilterCollection() {} | 14 FilterCollection::~FilterCollection() {} |
14 | 15 |
15 void FilterCollection::SetDemuxerFactory(scoped_ptr<DemuxerFactory> factory) { | 16 void FilterCollection::SetDemuxerFactory(scoped_ptr<DemuxerFactory> factory) { |
16 DCHECK(factory.get()); | 17 DCHECK(factory.get()); |
17 demuxer_factory_ = factory.Pass(); | 18 demuxer_factory_ = factory.Pass(); |
18 } | 19 } |
19 | 20 |
20 DemuxerFactory* FilterCollection::GetDemuxerFactory() { | 21 DemuxerFactory* FilterCollection::GetDemuxerFactory() { |
21 return demuxer_factory_.get(); | 22 return demuxer_factory_.get(); |
22 } | 23 } |
23 | 24 |
24 void FilterCollection::AddVideoDecoder(VideoDecoder* filter) { | 25 void FilterCollection::AddVideoDecoder(VideoDecoder* filter) { |
25 AddFilter(VIDEO_DECODER, filter); | 26 AddFilter(VIDEO_DECODER, filter); |
26 } | 27 } |
27 | 28 |
28 void FilterCollection::AddAudioDecoder(AudioDecoder* filter) { | 29 void FilterCollection::AddAudioDecoder(AudioDecoder* audio_decoder) { |
29 AddFilter(AUDIO_DECODER, filter); | 30 audio_decoders_.push_back(audio_decoder); |
30 } | 31 } |
31 | 32 |
32 void FilterCollection::AddVideoRenderer(VideoRenderer* filter) { | 33 void FilterCollection::AddVideoRenderer(VideoRenderer* filter) { |
33 AddFilter(VIDEO_RENDERER, filter); | 34 AddFilter(VIDEO_RENDERER, filter); |
34 } | 35 } |
35 | 36 |
36 void FilterCollection::AddAudioRenderer(AudioRenderer* filter) { | 37 void FilterCollection::AddAudioRenderer(AudioRenderer* filter) { |
37 AddFilter(AUDIO_RENDERER, filter); | 38 AddFilter(AUDIO_RENDERER, filter); |
38 } | 39 } |
39 | 40 |
40 bool FilterCollection::IsEmpty() const { | 41 bool FilterCollection::IsEmpty() const { |
41 return filters_.empty(); | 42 return filters_.empty() && audio_decoders_.empty(); |
42 } | 43 } |
43 | 44 |
44 void FilterCollection::Clear() { | 45 void FilterCollection::Clear() { |
45 filters_.clear(); | 46 filters_.clear(); |
| 47 audio_decoders_.clear(); |
46 } | 48 } |
47 | 49 |
48 void FilterCollection::SelectVideoDecoder( | 50 void FilterCollection::SelectVideoDecoder( |
49 scoped_refptr<VideoDecoder>* filter_out) { | 51 scoped_refptr<VideoDecoder>* filter_out) { |
50 SelectFilter<VIDEO_DECODER>(filter_out); | 52 SelectFilter<VIDEO_DECODER>(filter_out); |
51 } | 53 } |
52 | 54 |
53 void FilterCollection::SelectAudioDecoder( | 55 void FilterCollection::SelectAudioDecoder(scoped_refptr<AudioDecoder>* out) { |
54 scoped_refptr<AudioDecoder>* filter_out) { | 56 if (audio_decoders_.empty()) { |
55 SelectFilter<AUDIO_DECODER>(filter_out); | 57 *out = NULL; |
| 58 return; |
| 59 } |
| 60 *out = audio_decoders_.front(); |
| 61 audio_decoders_.pop_front(); |
56 } | 62 } |
57 | 63 |
58 void FilterCollection::SelectVideoRenderer( | 64 void FilterCollection::SelectVideoRenderer( |
59 scoped_refptr<VideoRenderer>* filter_out) { | 65 scoped_refptr<VideoRenderer>* filter_out) { |
60 SelectFilter<VIDEO_RENDERER>(filter_out); | 66 SelectFilter<VIDEO_RENDERER>(filter_out); |
61 } | 67 } |
62 | 68 |
63 void FilterCollection::SelectAudioRenderer( | 69 void FilterCollection::SelectAudioRenderer( |
64 scoped_refptr<AudioRenderer>* filter_out) { | 70 scoped_refptr<AudioRenderer>* filter_out) { |
65 SelectFilter<AUDIO_RENDERER>(filter_out); | 71 SelectFilter<AUDIO_RENDERER>(filter_out); |
(...skipping 22 matching lines...) Expand all Loading... |
88 ++it; | 94 ++it; |
89 } | 95 } |
90 | 96 |
91 if (it != filters_.end()) { | 97 if (it != filters_.end()) { |
92 *filter_out = it->second.get(); | 98 *filter_out = it->second.get(); |
93 filters_.erase(it); | 99 filters_.erase(it); |
94 } | 100 } |
95 } | 101 } |
96 | 102 |
97 } // namespace media | 103 } // namespace media |
OLD | NEW |