OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef MEDIA_FILTERS_AUDIO_DECODER_SELECTOR_H_ |
| 6 #define MEDIA_FILTERS_AUDIO_DECODER_SELECTOR_H_ |
| 7 |
| 8 #include <list> |
| 9 |
| 10 #include "base/callback.h" |
| 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/weak_ptr.h" |
| 13 #include "media/base/audio_decoder.h" |
| 14 #include "media/base/decryptor.h" |
| 15 #include "media/base/demuxer_stream.h" |
| 16 |
| 17 namespace base { |
| 18 class MessageLoopProxy; |
| 19 } |
| 20 |
| 21 namespace media { |
| 22 |
| 23 class DecoderBuffer; |
| 24 class DecryptingDemuxerStream; |
| 25 class Decryptor; |
| 26 |
| 27 // AudioDecoderSelector (creates if necessary and) initializes the proper |
| 28 // AudioDecoder for a given DemuxerStream. If the given DemuxerStream is |
| 29 // encrypted, a DecryptingDemuxerStream may also be created. |
| 30 class MEDIA_EXPORT AudioDecoderSelector { |
| 31 public: |
| 32 typedef std::list<scoped_refptr<AudioDecoder> > AudioDecoderList; |
| 33 |
| 34 // Indicates completion of AudioDecoder selection. |
| 35 // - First parameter: The initialized AudioDecoder. If it's set to NULL, then |
| 36 // AudioDecoder initialization failed. |
| 37 // - Second parameter: The initialized DecryptingDemuxerStream. If it's not |
| 38 // NULL, then a DecryptingDemuxerStream is created and initialized to do |
| 39 // decryption for the initialized AudioDecoder. |
| 40 // Note: The caller owns selected AudioDecoder and DecryptingDemuxerStream. |
| 41 // The caller should call DecryptingDemuxerStream::Reset() before |
| 42 // calling AudioDecoder::Reset() to release any pending decryption or read. |
| 43 typedef base::Callback< |
| 44 void(const scoped_refptr<AudioDecoder>&, |
| 45 const scoped_refptr<DecryptingDemuxerStream>&)> SelectDecoderCB; |
| 46 |
| 47 // |set_decryptor_ready_cb| is optional. If |set_decryptor_ready_cb| is null, |
| 48 // no decryptor will be available to perform decryption. |
| 49 AudioDecoderSelector( |
| 50 const scoped_refptr<base::MessageLoopProxy>& message_loop, |
| 51 const AudioDecoderList& decoders, |
| 52 const SetDecryptorReadyCB& set_decryptor_ready_cb); |
| 53 ~AudioDecoderSelector(); |
| 54 |
| 55 // Initializes and selects an AudioDecoder that can decode the |stream|. |
| 56 // Selected AudioDecoder (and DecryptingDemuxerStream) is returned via |
| 57 // the |select_decoder_cb|. |
| 58 void SelectAudioDecoder(const scoped_refptr<DemuxerStream>& stream, |
| 59 const StatisticsCB& statistics_cb, |
| 60 const SelectDecoderCB& select_decoder_cb); |
| 61 |
| 62 private: |
| 63 void DecryptingAudioDecoderInitDone(PipelineStatus status); |
| 64 void DecryptingDemuxerStreamInitDone(PipelineStatus status); |
| 65 void InitializeNextDecoder(); |
| 66 void DecoderInitDone(PipelineStatus status); |
| 67 |
| 68 scoped_refptr<base::MessageLoopProxy> message_loop_; |
| 69 AudioDecoderList decoders_; |
| 70 SetDecryptorReadyCB set_decryptor_ready_cb_; |
| 71 |
| 72 scoped_refptr<DemuxerStream> input_stream_; |
| 73 StatisticsCB statistics_cb_; |
| 74 SelectDecoderCB select_decoder_cb_; |
| 75 |
| 76 scoped_refptr<AudioDecoder> audio_decoder_; |
| 77 scoped_refptr<DecryptingDemuxerStream> decrypted_stream_; |
| 78 |
| 79 base::WeakPtrFactory<AudioDecoderSelector> weak_ptr_factory_; |
| 80 |
| 81 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioDecoderSelector); |
| 82 }; |
| 83 |
| 84 } // namespace media |
| 85 |
| 86 #endif // MEDIA_FILTERS_AUDIO_DECODER_SELECTOR_H_ |
OLD | NEW |