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_STREAM_H_ | 5 #ifndef MEDIA_FILTERS_DECODER_STREAM_H_ |
6 #define MEDIA_FILTERS_DECODER_STREAM_H_ | 6 #define MEDIA_FILTERS_DECODER_STREAM_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "media/base/audio_decoder.h" | 15 #include "media/base/audio_decoder.h" |
16 #include "media/base/cdm_context.h" | |
17 #include "media/base/demuxer_stream.h" | 16 #include "media/base/demuxer_stream.h" |
18 #include "media/base/media_export.h" | 17 #include "media/base/media_export.h" |
19 #include "media/base/media_log.h" | 18 #include "media/base/media_log.h" |
20 #include "media/base/moving_average.h" | 19 #include "media/base/moving_average.h" |
21 #include "media/base/pipeline_status.h" | 20 #include "media/base/pipeline_status.h" |
22 #include "media/base/timestamp_constants.h" | 21 #include "media/base/timestamp_constants.h" |
23 #include "media/filters/decoder_selector.h" | 22 #include "media/filters/decoder_selector.h" |
24 #include "media/filters/decoder_stream_traits.h" | 23 #include "media/filters/decoder_stream_traits.h" |
25 | 24 |
26 namespace base { | 25 namespace base { |
27 class SingleThreadTaskRunner; | 26 class SingleThreadTaskRunner; |
28 } | 27 } |
29 | 28 |
30 namespace media { | 29 namespace media { |
31 | 30 |
| 31 class CdmContext; |
32 class DecryptingDemuxerStream; | 32 class DecryptingDemuxerStream; |
33 | 33 |
34 // Wraps a DemuxerStream and a list of Decoders and provides decoded | 34 // Wraps a DemuxerStream and a list of Decoders and provides decoded |
35 // output to its client (e.g. Audio/VideoRendererImpl). | 35 // output to its client (e.g. Audio/VideoRendererImpl). |
36 template<DemuxerStream::Type StreamType> | 36 template<DemuxerStream::Type StreamType> |
37 class MEDIA_EXPORT DecoderStream { | 37 class MEDIA_EXPORT DecoderStream { |
38 public: | 38 public: |
39 typedef DecoderStreamTraits<StreamType> StreamTraits; | 39 typedef DecoderStreamTraits<StreamType> StreamTraits; |
40 typedef typename StreamTraits::DecoderType Decoder; | 40 typedef typename StreamTraits::DecoderType Decoder; |
41 typedef typename StreamTraits::OutputType Output; | 41 typedef typename StreamTraits::OutputType Output; |
(...skipping 16 matching lines...) Expand all Loading... |
58 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 58 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
59 ScopedVector<Decoder> decoders, | 59 ScopedVector<Decoder> decoders, |
60 const scoped_refptr<MediaLog>& media_log); | 60 const scoped_refptr<MediaLog>& media_log); |
61 virtual ~DecoderStream(); | 61 virtual ~DecoderStream(); |
62 | 62 |
63 // Returns the string representation of the StreamType for logging purpose. | 63 // Returns the string representation of the StreamType for logging purpose. |
64 std::string GetStreamTypeString(); | 64 std::string GetStreamTypeString(); |
65 | 65 |
66 // Initializes the DecoderStream and returns the initialization result | 66 // Initializes the DecoderStream and returns the initialization result |
67 // through |init_cb|. Note that |init_cb| is always called asynchronously. | 67 // through |init_cb|. Note that |init_cb| is always called asynchronously. |
| 68 // |cdm_context| can be used to handle encrypted stream. Can be null if the |
| 69 // stream is not encrypted. |
68 void Initialize(DemuxerStream* stream, | 70 void Initialize(DemuxerStream* stream, |
69 const InitCB& init_cb, | 71 const InitCB& init_cb, |
70 const SetCdmReadyCB& set_cdm_ready_cb, | 72 CdmContext* cdm_context, |
71 const StatisticsCB& statistics_cb, | 73 const StatisticsCB& statistics_cb, |
72 const base::Closure& waiting_for_decryption_key_cb); | 74 const base::Closure& waiting_for_decryption_key_cb); |
73 | 75 |
74 // Reads a decoded Output and returns it via the |read_cb|. Note that | 76 // Reads a decoded Output and returns it via the |read_cb|. Note that |
75 // |read_cb| is always called asynchronously. This method should only be | 77 // |read_cb| is always called asynchronously. This method should only be |
76 // called after initialization has succeeded and must not be called during | 78 // called after initialization has succeeded and must not be called during |
77 // pending Reset(). | 79 // pending Reset(). |
78 void Read(const ReadCB& read_cb); | 80 void Read(const ReadCB& read_cb); |
79 | 81 |
80 // Resets the decoder, flushes all decoded outputs and/or internal buffers, | 82 // Resets the decoder, flushes all decoded outputs and/or internal buffers, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 STATE_UNINITIALIZED, | 128 STATE_UNINITIALIZED, |
127 STATE_INITIALIZING, | 129 STATE_INITIALIZING, |
128 STATE_NORMAL, // Includes idle, pending decoder decode/reset. | 130 STATE_NORMAL, // Includes idle, pending decoder decode/reset. |
129 STATE_FLUSHING_DECODER, | 131 STATE_FLUSHING_DECODER, |
130 STATE_PENDING_DEMUXER_READ, | 132 STATE_PENDING_DEMUXER_READ, |
131 STATE_REINITIALIZING_DECODER, | 133 STATE_REINITIALIZING_DECODER, |
132 STATE_END_OF_STREAM, // End of stream reached; returns EOS on all reads. | 134 STATE_END_OF_STREAM, // End of stream reached; returns EOS on all reads. |
133 STATE_ERROR | 135 STATE_ERROR |
134 }; | 136 }; |
135 | 137 |
136 void SelectDecoder(const SetCdmReadyCB& set_cdm_ready_cb); | 138 void SelectDecoder(CdmContext* cdm_context); |
137 | 139 |
138 // Called when |decoder_selector| selected the |selected_decoder|. | 140 // Called when |decoder_selector| selected the |selected_decoder|. |
139 // |decrypting_demuxer_stream| was also populated if a DecryptingDemuxerStream | 141 // |decrypting_demuxer_stream| was also populated if a DecryptingDemuxerStream |
140 // is created to help decrypt the encrypted stream. | 142 // is created to help decrypt the encrypted stream. |
141 void OnDecoderSelected( | 143 void OnDecoderSelected( |
142 scoped_ptr<Decoder> selected_decoder, | 144 scoped_ptr<Decoder> selected_decoder, |
143 scoped_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream); | 145 scoped_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream); |
144 | 146 |
145 // Satisfy pending |read_cb_| with |status| and |output|. | 147 // Satisfy pending |read_cb_| with |status| and |output|. |
146 void SatisfyRead(Status status, | 148 void SatisfyRead(Status status, |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 | 235 |
234 template <> | 236 template <> |
235 int DecoderStream<DemuxerStream::AUDIO>::GetMaxDecodeRequests() const; | 237 int DecoderStream<DemuxerStream::AUDIO>::GetMaxDecodeRequests() const; |
236 | 238 |
237 typedef DecoderStream<DemuxerStream::VIDEO> VideoFrameStream; | 239 typedef DecoderStream<DemuxerStream::VIDEO> VideoFrameStream; |
238 typedef DecoderStream<DemuxerStream::AUDIO> AudioBufferStream; | 240 typedef DecoderStream<DemuxerStream::AUDIO> AudioBufferStream; |
239 | 241 |
240 } // namespace media | 242 } // namespace media |
241 | 243 |
242 #endif // MEDIA_FILTERS_DECODER_STREAM_H_ | 244 #endif // MEDIA_FILTERS_DECODER_STREAM_H_ |
OLD | NEW |