| 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> |
| 9 |
| 8 #include "base/callback.h" | 10 #include "base/callback.h" |
| 9 #include "base/macros.h" | 11 #include "base/macros.h" |
| 10 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
| 13 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 14 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 15 #include "media/base/demuxer_stream.h" | 16 #include "media/base/demuxer_stream.h" |
| 16 #include "media/base/pipeline_status.h" | 17 #include "media/base/pipeline_status.h" |
| 17 #include "media/filters/decoder_stream_traits.h" | 18 #include "media/filters/decoder_stream_traits.h" |
| 18 | 19 |
| 19 namespace base { | 20 namespace base { |
| 20 class SingleThreadTaskRunner; | 21 class SingleThreadTaskRunner; |
| 21 } | 22 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 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. |
| 50 typedef base::Callback< | 51 typedef base::Callback<void(std::unique_ptr<Decoder>, |
| 51 void(scoped_ptr<Decoder>, | 52 std::unique_ptr<DecryptingDemuxerStream>)> |
| 52 scoped_ptr<DecryptingDemuxerStream>)> | |
| 53 SelectDecoderCB; | 53 SelectDecoderCB; |
| 54 | 54 |
| 55 // |decoders| contains the Decoders to use when initializing. | 55 // |decoders| contains the Decoders to use when initializing. |
| 56 DecoderSelector( | 56 DecoderSelector( |
| 57 const scoped_refptr<base::SingleThreadTaskRunner>& message_loop, | 57 const scoped_refptr<base::SingleThreadTaskRunner>& message_loop, |
| 58 ScopedVector<Decoder> decoders, | 58 ScopedVector<Decoder> decoders, |
| 59 const scoped_refptr<MediaLog>& media_log); | 59 const scoped_refptr<MediaLog>& media_log); |
| 60 | 60 |
| 61 // Aborts pending Decoder selection and fires |select_decoder_cb| with | 61 // Aborts pending Decoder selection and fires |select_decoder_cb| with |
| 62 // NULL and NULL immediately if it's pending. | 62 // NULL and NULL immediately if it's pending. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 91 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 91 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 92 ScopedVector<Decoder> decoders_; | 92 ScopedVector<Decoder> decoders_; |
| 93 scoped_refptr<MediaLog> media_log_; | 93 scoped_refptr<MediaLog> media_log_; |
| 94 | 94 |
| 95 DemuxerStream* input_stream_; | 95 DemuxerStream* input_stream_; |
| 96 CdmContext* cdm_context_; | 96 CdmContext* cdm_context_; |
| 97 SelectDecoderCB select_decoder_cb_; | 97 SelectDecoderCB select_decoder_cb_; |
| 98 typename Decoder::OutputCB output_cb_; | 98 typename Decoder::OutputCB output_cb_; |
| 99 base::Closure waiting_for_decryption_key_cb_; | 99 base::Closure waiting_for_decryption_key_cb_; |
| 100 | 100 |
| 101 scoped_ptr<Decoder> decoder_; | 101 std::unique_ptr<Decoder> decoder_; |
| 102 scoped_ptr<DecryptingDemuxerStream> decrypted_stream_; | 102 std::unique_ptr<DecryptingDemuxerStream> decrypted_stream_; |
| 103 | 103 |
| 104 // NOTE: Weak pointers must be invalidated before all other member variables. | 104 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 105 base::WeakPtrFactory<DecoderSelector> weak_ptr_factory_; | 105 base::WeakPtrFactory<DecoderSelector> weak_ptr_factory_; |
| 106 | 106 |
| 107 DISALLOW_IMPLICIT_CONSTRUCTORS(DecoderSelector); | 107 DISALLOW_IMPLICIT_CONSTRUCTORS(DecoderSelector); |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 typedef DecoderSelector<DemuxerStream::VIDEO> VideoDecoderSelector; | 110 typedef DecoderSelector<DemuxerStream::VIDEO> VideoDecoderSelector; |
| 111 typedef DecoderSelector<DemuxerStream::AUDIO> AudioDecoderSelector; | 111 typedef DecoderSelector<DemuxerStream::AUDIO> AudioDecoderSelector; |
| 112 | 112 |
| 113 } // namespace media | 113 } // namespace media |
| 114 | 114 |
| 115 #endif // MEDIA_FILTERS_DECODER_SELECTOR_H_ | 115 #endif // MEDIA_FILTERS_DECODER_SELECTOR_H_ |
| OLD | NEW |