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