| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef MEDIA_FILTERS_DECODER_SELECTOR_H_ | 5 #ifndef MEDIA_FILTERS_DECODER_SELECTOR_H_ |
| 6 #define MEDIA_FILTERS_DECODER_SELECTOR_H_ | 6 #define MEDIA_FILTERS_DECODER_SELECTOR_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "media/base/decryptor.h" | 12 #include "media/base/cdm_context.h" |
| 13 #include "media/base/demuxer_stream.h" | 13 #include "media/base/demuxer_stream.h" |
| 14 #include "media/base/pipeline_status.h" | 14 #include "media/base/pipeline_status.h" |
| 15 #include "media/filters/decoder_stream_traits.h" | 15 #include "media/filters/decoder_stream_traits.h" |
| 16 | 16 |
| 17 namespace base { | 17 namespace base { |
| 18 class SingleThreadTaskRunner; | 18 class SingleThreadTaskRunner; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace media { | 21 namespace media { |
| 22 | 22 |
| 23 class DecoderBuffer; | 23 class DecoderBuffer; |
| 24 class DecryptingDemuxerStream; | 24 class DecryptingDemuxerStream; |
| 25 class Decryptor; | |
| 26 class MediaLog; | 25 class MediaLog; |
| 27 | 26 |
| 28 // DecoderSelector (creates if necessary and) initializes the proper | 27 // DecoderSelector (creates if necessary and) initializes the proper |
| 29 // Decoder for a given DemuxerStream. If the given DemuxerStream is | 28 // Decoder for a given DemuxerStream. If the given DemuxerStream is |
| 30 // encrypted, a DecryptingDemuxerStream may also be created. | 29 // encrypted, a DecryptingDemuxerStream may also be created. |
| 31 // The template parameter |StreamType| is the type of stream we will be | 30 // The template parameter |StreamType| is the type of stream we will be |
| 32 // selecting a decoder for. | 31 // selecting a decoder for. |
| 33 template<DemuxerStream::Type StreamType> | 32 template<DemuxerStream::Type StreamType> |
| 34 class MEDIA_EXPORT DecoderSelector { | 33 class MEDIA_EXPORT DecoderSelector { |
| 35 public: | 34 public: |
| (...skipping 24 matching lines...) Expand all Loading... |
| 60 // NULL and NULL immediately if it's pending. | 59 // NULL and NULL immediately if it's pending. |
| 61 ~DecoderSelector(); | 60 ~DecoderSelector(); |
| 62 | 61 |
| 63 // Initializes and selects the first Decoder that can decode the |stream|. | 62 // Initializes and selects the first Decoder that can decode the |stream|. |
| 64 // The selected Decoder (and DecryptingDemuxerStream) is returned via | 63 // The selected Decoder (and DecryptingDemuxerStream) is returned via |
| 65 // the |select_decoder_cb|. | 64 // the |select_decoder_cb|. |
| 66 // Notes: | 65 // Notes: |
| 67 // 1. This must not be called again before |select_decoder_cb| is run. | 66 // 1. This must not be called again before |select_decoder_cb| is run. |
| 68 // 2. Decoders that fail to initialize will be deleted. Future calls will | 67 // 2. Decoders that fail to initialize will be deleted. Future calls will |
| 69 // select from the decoders following the decoder that was last returned. | 68 // select from the decoders following the decoder that was last returned. |
| 70 // 3. |set_decryptor_ready_cb| is optional. If |set_decryptor_ready_cb| is | 69 // 3. |set_cdm_ready_cb| is optional. If |set_cdm_ready_cb| is |
| 71 // null, no decryptor will be available to perform decryption. | 70 // null, no CDM will be available to perform decryption. |
| 72 void SelectDecoder(DemuxerStream* stream, | 71 void SelectDecoder(DemuxerStream* stream, |
| 73 const SetDecryptorReadyCB& set_decryptor_ready_cb, | 72 const SetCdmReadyCB& set_cdm_ready_cb, |
| 74 const SelectDecoderCB& select_decoder_cb, | 73 const SelectDecoderCB& select_decoder_cb, |
| 75 const typename Decoder::OutputCB& output_cb, | 74 const typename Decoder::OutputCB& output_cb, |
| 76 const base::Closure& waiting_for_decryption_key_cb); | 75 const base::Closure& waiting_for_decryption_key_cb); |
| 77 | 76 |
| 78 private: | 77 private: |
| 79 #if !defined(OS_ANDROID) | 78 #if !defined(OS_ANDROID) |
| 80 void InitializeDecryptingDecoder(); | 79 void InitializeDecryptingDecoder(); |
| 81 void DecryptingDecoderInitDone(bool success); | 80 void DecryptingDecoderInitDone(bool success); |
| 82 #endif | 81 #endif |
| 83 void InitializeDecryptingDemuxerStream(); | 82 void InitializeDecryptingDemuxerStream(); |
| 84 void DecryptingDemuxerStreamInitDone(PipelineStatus status); | 83 void DecryptingDemuxerStreamInitDone(PipelineStatus status); |
| 85 void InitializeDecoder(); | 84 void InitializeDecoder(); |
| 86 void DecoderInitDone(bool success); | 85 void DecoderInitDone(bool success); |
| 87 void ReturnNullDecoder(); | 86 void ReturnNullDecoder(); |
| 88 | 87 |
| 89 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 88 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 90 ScopedVector<Decoder> decoders_; | 89 ScopedVector<Decoder> decoders_; |
| 91 scoped_refptr<MediaLog> media_log_; | 90 scoped_refptr<MediaLog> media_log_; |
| 92 | 91 |
| 93 DemuxerStream* input_stream_; | 92 DemuxerStream* input_stream_; |
| 94 SetDecryptorReadyCB set_decryptor_ready_cb_; | 93 SetCdmReadyCB set_cdm_ready_cb_; |
| 95 SelectDecoderCB select_decoder_cb_; | 94 SelectDecoderCB select_decoder_cb_; |
| 96 typename Decoder::OutputCB output_cb_; | 95 typename Decoder::OutputCB output_cb_; |
| 97 base::Closure waiting_for_decryption_key_cb_; | 96 base::Closure waiting_for_decryption_key_cb_; |
| 98 | 97 |
| 99 scoped_ptr<Decoder> decoder_; | 98 scoped_ptr<Decoder> decoder_; |
| 100 scoped_ptr<DecryptingDemuxerStream> decrypted_stream_; | 99 scoped_ptr<DecryptingDemuxerStream> decrypted_stream_; |
| 101 | 100 |
| 102 // NOTE: Weak pointers must be invalidated before all other member variables. | 101 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 103 base::WeakPtrFactory<DecoderSelector> weak_ptr_factory_; | 102 base::WeakPtrFactory<DecoderSelector> weak_ptr_factory_; |
| 104 | 103 |
| 105 DISALLOW_IMPLICIT_CONSTRUCTORS(DecoderSelector); | 104 DISALLOW_IMPLICIT_CONSTRUCTORS(DecoderSelector); |
| 106 }; | 105 }; |
| 107 | 106 |
| 108 typedef DecoderSelector<DemuxerStream::VIDEO> VideoDecoderSelector; | 107 typedef DecoderSelector<DemuxerStream::VIDEO> VideoDecoderSelector; |
| 109 typedef DecoderSelector<DemuxerStream::AUDIO> AudioDecoderSelector; | 108 typedef DecoderSelector<DemuxerStream::AUDIO> AudioDecoderSelector; |
| 110 | 109 |
| 111 } // namespace media | 110 } // namespace media |
| 112 | 111 |
| 113 #endif // MEDIA_FILTERS_DECODER_SELECTOR_H_ | 112 #endif // MEDIA_FILTERS_DECODER_SELECTOR_H_ |
| OLD | NEW |