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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 64 |
65 // Initializes and selects the first Decoder that can decode the |stream|. | 65 // Initializes and selects the first Decoder that can decode the |stream|. |
66 // The selected Decoder (and DecryptingDemuxerStream) is returned via | 66 // The selected Decoder (and DecryptingDemuxerStream) is returned via |
67 // the |select_decoder_cb|. | 67 // the |select_decoder_cb|. |
68 // Notes: | 68 // Notes: |
69 // 1. This must not be called again before |select_decoder_cb| is run. | 69 // 1. This must not be called again before |select_decoder_cb| is run. |
70 // 2. Decoders that fail to initialize will be deleted. Future calls will | 70 // 2. Decoders that fail to initialize will be deleted. Future calls will |
71 // select from the decoders following the decoder that was last returned. | 71 // select from the decoders following the decoder that was last returned. |
72 // 3. |cdm_context| is optional. If |cdm_context| is | 72 // 3. |cdm_context| is optional. If |cdm_context| is |
73 // null, no CDM will be available to perform decryption. | 73 // null, no CDM will be available to perform decryption. |
74 void SelectDecoder(DemuxerStream* stream, | 74 void SelectDecoder(StreamTraits* traits, |
| 75 DemuxerStream* stream, |
75 CdmContext* cdm_context, | 76 CdmContext* cdm_context, |
76 const SelectDecoderCB& select_decoder_cb, | 77 const SelectDecoderCB& select_decoder_cb, |
77 const typename Decoder::OutputCB& output_cb, | 78 const typename Decoder::OutputCB& output_cb, |
78 const base::Closure& waiting_for_decryption_key_cb); | 79 const base::Closure& waiting_for_decryption_key_cb); |
79 | 80 |
80 private: | 81 private: |
81 #if !defined(OS_ANDROID) | 82 #if !defined(OS_ANDROID) |
82 void InitializeDecryptingDecoder(); | 83 void InitializeDecryptingDecoder(); |
83 void DecryptingDecoderInitDone(bool success); | 84 void DecryptingDecoderInitDone(bool success); |
84 #endif | 85 #endif |
85 void InitializeDecryptingDemuxerStream(); | 86 void InitializeDecryptingDemuxerStream(); |
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 |
| 96 StreamTraits* traits_; |
95 DemuxerStream* input_stream_; | 97 DemuxerStream* input_stream_; |
96 CdmContext* cdm_context_; | 98 CdmContext* cdm_context_; |
97 SelectDecoderCB select_decoder_cb_; | 99 SelectDecoderCB select_decoder_cb_; |
98 typename Decoder::OutputCB output_cb_; | 100 typename Decoder::OutputCB output_cb_; |
99 base::Closure waiting_for_decryption_key_cb_; | 101 base::Closure waiting_for_decryption_key_cb_; |
100 | 102 |
101 std::unique_ptr<Decoder> decoder_; | 103 std::unique_ptr<Decoder> decoder_; |
102 std::unique_ptr<DecryptingDemuxerStream> decrypted_stream_; | 104 std::unique_ptr<DecryptingDemuxerStream> decrypted_stream_; |
103 | 105 |
104 // NOTE: Weak pointers must be invalidated before all other member variables. | 106 // NOTE: Weak pointers must be invalidated before all other member variables. |
105 base::WeakPtrFactory<DecoderSelector> weak_ptr_factory_; | 107 base::WeakPtrFactory<DecoderSelector> weak_ptr_factory_; |
106 | 108 |
107 DISALLOW_IMPLICIT_CONSTRUCTORS(DecoderSelector); | 109 DISALLOW_IMPLICIT_CONSTRUCTORS(DecoderSelector); |
108 }; | 110 }; |
109 | 111 |
110 typedef DecoderSelector<DemuxerStream::VIDEO> VideoDecoderSelector; | 112 typedef DecoderSelector<DemuxerStream::VIDEO> VideoDecoderSelector; |
111 typedef DecoderSelector<DemuxerStream::AUDIO> AudioDecoderSelector; | 113 typedef DecoderSelector<DemuxerStream::AUDIO> AudioDecoderSelector; |
112 | 114 |
113 } // namespace media | 115 } // namespace media |
114 | 116 |
115 #endif // MEDIA_FILTERS_DECODER_SELECTOR_H_ | 117 #endif // MEDIA_FILTERS_DECODER_SELECTOR_H_ |
OLD | NEW |