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