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 <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 // DecoderSelector (creates if necessary and) initializes the proper | 30 // DecoderSelector (creates if necessary and) initializes the proper |
31 // Decoder for a given DemuxerStream. If the given DemuxerStream is | 31 // Decoder for a given DemuxerStream. If the given DemuxerStream is |
32 // encrypted, a DecryptingDemuxerStream may also be created. | 32 // encrypted, a DecryptingDemuxerStream may also be created. |
33 // The template parameter |StreamType| is the type of stream we will be | 33 // The template parameter |StreamType| is the type of stream we will be |
34 // selecting a decoder for. | 34 // selecting a decoder for. |
35 template<DemuxerStream::Type StreamType> | 35 template<DemuxerStream::Type StreamType> |
36 class MEDIA_EXPORT DecoderSelector { | 36 class MEDIA_EXPORT DecoderSelector { |
37 public: | 37 public: |
38 typedef DecoderStreamTraits<StreamType> StreamTraits; | 38 typedef DecoderStreamTraits<StreamType> StreamTraits; |
39 typedef typename StreamTraits::DecoderType Decoder; | 39 typedef typename StreamTraits::DecoderType Decoder; |
| 40 typedef typename StreamTraits::DecoderConfigType DecoderConfig; |
40 | 41 |
41 // Indicates completion of Decoder selection. | 42 // Indicates completion of Decoder selection. |
42 // - First parameter: The initialized Decoder. If it's set to NULL, then | 43 // - First parameter: The initialized Decoder. If it's set to NULL, then |
43 // Decoder initialization failed. | 44 // Decoder initialization failed. |
44 // - Second parameter: The initialized DecryptingDemuxerStream. If it's not | 45 // - Second parameter: The initialized DecryptingDemuxerStream. If it's not |
45 // NULL, then a DecryptingDemuxerStream is created and initialized to do | 46 // NULL, then a DecryptingDemuxerStream is created and initialized to do |
46 // decryption for the initialized Decoder. | 47 // decryption for the initialized Decoder. |
47 // Note: The caller owns selected Decoder and DecryptingDemuxerStream. | 48 // Note: The caller owns selected Decoder and DecryptingDemuxerStream. |
48 // The caller should call DecryptingDemuxerStream::Reset() before | 49 // The caller should call DecryptingDemuxerStream::Reset() before |
49 // calling Decoder::Reset() to release any pending decryption or read. | 50 // calling Decoder::Reset() to release any pending decryption or read. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 void DecryptingDemuxerStreamInitDone(PipelineStatus status); | 87 void DecryptingDemuxerStreamInitDone(PipelineStatus status); |
87 void InitializeDecoder(); | 88 void InitializeDecoder(); |
88 void DecoderInitDone(bool success); | 89 void DecoderInitDone(bool success); |
89 void ReturnNullDecoder(); | 90 void ReturnNullDecoder(); |
90 | 91 |
91 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 92 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
92 ScopedVector<Decoder> decoders_; | 93 ScopedVector<Decoder> decoders_; |
93 scoped_refptr<MediaLog> media_log_; | 94 scoped_refptr<MediaLog> media_log_; |
94 | 95 |
95 StreamTraits* traits_; | 96 StreamTraits* traits_; |
| 97 |
| 98 // Could be the |stream| passed in SelectDecoder, or |decrypted_stream_| when |
| 99 // a DecryptingDemuxerStream is selected. |
96 DemuxerStream* input_stream_; | 100 DemuxerStream* input_stream_; |
| 101 |
97 CdmContext* cdm_context_; | 102 CdmContext* cdm_context_; |
98 SelectDecoderCB select_decoder_cb_; | 103 SelectDecoderCB select_decoder_cb_; |
99 typename Decoder::OutputCB output_cb_; | 104 typename Decoder::OutputCB output_cb_; |
100 base::Closure waiting_for_decryption_key_cb_; | 105 base::Closure waiting_for_decryption_key_cb_; |
101 | 106 |
102 std::unique_ptr<Decoder> decoder_; | 107 std::unique_ptr<Decoder> decoder_; |
103 std::unique_ptr<DecryptingDemuxerStream> decrypted_stream_; | 108 std::unique_ptr<DecryptingDemuxerStream> decrypted_stream_; |
104 | 109 |
| 110 // Config of the |input_stream| used to initialize decoders. |
| 111 DecoderConfig config_; |
| 112 |
105 // NOTE: Weak pointers must be invalidated before all other member variables. | 113 // NOTE: Weak pointers must be invalidated before all other member variables. |
106 base::WeakPtrFactory<DecoderSelector> weak_ptr_factory_; | 114 base::WeakPtrFactory<DecoderSelector> weak_ptr_factory_; |
107 | 115 |
108 DISALLOW_IMPLICIT_CONSTRUCTORS(DecoderSelector); | 116 DISALLOW_IMPLICIT_CONSTRUCTORS(DecoderSelector); |
109 }; | 117 }; |
110 | 118 |
111 typedef DecoderSelector<DemuxerStream::VIDEO> VideoDecoderSelector; | 119 typedef DecoderSelector<DemuxerStream::VIDEO> VideoDecoderSelector; |
112 typedef DecoderSelector<DemuxerStream::AUDIO> AudioDecoderSelector; | 120 typedef DecoderSelector<DemuxerStream::AUDIO> AudioDecoderSelector; |
113 | 121 |
114 } // namespace media | 122 } // namespace media |
115 | 123 |
116 #endif // MEDIA_FILTERS_DECODER_SELECTOR_H_ | 124 #endif // MEDIA_FILTERS_DECODER_SELECTOR_H_ |
OLD | NEW |