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