| 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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 // it is stopped. This method can be called at any time but not during another | 81 // it is stopped. This method can be called at any time but not during another |
| 82 // pending Stop(). | 82 // pending Stop(). |
| 83 void Stop(const base::Closure& closure); | 83 void Stop(const base::Closure& closure); |
| 84 | 84 |
| 85 // Returns true if the decoder currently has the ability to decode and return | 85 // Returns true if the decoder currently has the ability to decode and return |
| 86 // an Output. | 86 // an Output. |
| 87 // TODO(rileya): Remove the need for this by refactoring Decoder queueing | 87 // TODO(rileya): Remove the need for this by refactoring Decoder queueing |
| 88 // behavior. | 88 // behavior. |
| 89 bool CanReadWithoutStalling() const; | 89 bool CanReadWithoutStalling() const; |
| 90 | 90 |
| 91 // Returns true if one more decode request can be submitted to the decoder. |
| 92 bool CanDecodeMore() const; |
| 93 |
| 91 // Allows callers to register for notification of splice buffers from the | 94 // Allows callers to register for notification of splice buffers from the |
| 92 // demuxer. I.e., DecoderBuffer::splice_timestamp() is not kNoTimestamp(). | 95 // demuxer. I.e., DecoderBuffer::splice_timestamp() is not kNoTimestamp(). |
| 93 // | 96 // |
| 94 // The observer will be notified of all buffers with a splice_timestamp() and | 97 // The observer will be notified of all buffers with a splice_timestamp() and |
| 95 // the first buffer after which has a splice_timestamp() of kNoTimestamp(). | 98 // the first buffer after which has a splice_timestamp() of kNoTimestamp(). |
| 96 typedef base::Callback<void(base::TimeDelta)> SpliceObserverCB; | 99 typedef base::Callback<void(base::TimeDelta)> SpliceObserverCB; |
| 97 void set_splice_observer(const SpliceObserverCB& splice_observer) { | 100 void set_splice_observer(const SpliceObserverCB& splice_observer) { |
| 98 splice_observer_cb_ = splice_observer; | 101 splice_observer_cb_ = splice_observer; |
| 99 } | 102 } |
| 100 | 103 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 123 // |decrypting_demuxer_stream| was also populated if a DecryptingDemuxerStream | 126 // |decrypting_demuxer_stream| was also populated if a DecryptingDemuxerStream |
| 124 // is created to help decrypt the encrypted stream. | 127 // is created to help decrypt the encrypted stream. |
| 125 void OnDecoderSelected( | 128 void OnDecoderSelected( |
| 126 scoped_ptr<Decoder> selected_decoder, | 129 scoped_ptr<Decoder> selected_decoder, |
| 127 scoped_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream); | 130 scoped_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream); |
| 128 | 131 |
| 129 // Satisfy pending |read_cb_| with |status| and |output|. | 132 // Satisfy pending |read_cb_| with |status| and |output|. |
| 130 void SatisfyRead(Status status, | 133 void SatisfyRead(Status status, |
| 131 const scoped_refptr<Output>& output); | 134 const scoped_refptr<Output>& output); |
| 132 | 135 |
| 133 // Abort pending |read_cb_|. | |
| 134 void AbortRead(); | |
| 135 | |
| 136 // Decodes |buffer| and returns the result via OnDecodeOutputReady(). | 136 // Decodes |buffer| and returns the result via OnDecodeOutputReady(). |
| 137 void Decode(const scoped_refptr<DecoderBuffer>& buffer); | 137 void Decode(const scoped_refptr<DecoderBuffer>& buffer); |
| 138 | 138 |
| 139 // Flushes the decoder with an EOS buffer to retrieve internally buffered | 139 // Flushes the decoder with an EOS buffer to retrieve internally buffered |
| 140 // decoder output. | 140 // decoder output. |
| 141 void FlushDecoder(); | 141 void FlushDecoder(); |
| 142 | 142 |
| 143 // Callback for Decoder::Decode(). | 143 // Callback for Decoder::Decode(). |
| 144 void OnDecodeOutputReady(int buffer_size, | 144 void OnDecodeOutputReady(int buffer_size, |
| 145 DecoderStatus status, | 145 DecoderStatus status, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 scoped_ptr<Decoder> decoder_; | 182 scoped_ptr<Decoder> decoder_; |
| 183 scoped_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream_; | 183 scoped_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream_; |
| 184 | 184 |
| 185 SpliceObserverCB splice_observer_cb_; | 185 SpliceObserverCB splice_observer_cb_; |
| 186 ConfigChangeObserverCB config_change_observer_cb_; | 186 ConfigChangeObserverCB config_change_observer_cb_; |
| 187 | 187 |
| 188 // If a splice_timestamp() has been seen, this is true until a | 188 // If a splice_timestamp() has been seen, this is true until a |
| 189 // splice_timestamp() of kNoTimestamp() is encountered. | 189 // splice_timestamp() of kNoTimestamp() is encountered. |
| 190 bool active_splice_; | 190 bool active_splice_; |
| 191 | 191 |
| 192 // Decoded buffers that haven't been read yet. Used when the decoder supports |
| 193 // parallel decoding. |
| 194 std::list<scoped_refptr<Output> > ready_outputs_; |
| 195 |
| 196 // Number of outstanding decode requests sent to the |decoder_|. |
| 197 int pending_decode_requests_; |
| 198 |
| 192 // NOTE: Weak pointers must be invalidated before all other member variables. | 199 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 193 base::WeakPtrFactory<DecoderStream<StreamType> > weak_factory_; | 200 base::WeakPtrFactory<DecoderStream<StreamType> > weak_factory_; |
| 194 | 201 |
| 195 // This is required so the VideoFrameStream can access private members in | 202 // This is required so the VideoFrameStream can access private members in |
| 196 // FinishInitialization() and ReportStatistics(). | 203 // FinishInitialization() and ReportStatistics(). |
| 197 DISALLOW_IMPLICIT_CONSTRUCTORS(DecoderStream); | 204 DISALLOW_IMPLICIT_CONSTRUCTORS(DecoderStream); |
| 198 }; | 205 }; |
| 199 | 206 |
| 200 template <> | 207 template <> |
| 201 bool DecoderStream<DemuxerStream::AUDIO>::CanReadWithoutStalling() const; | 208 bool DecoderStream<DemuxerStream::AUDIO>::CanReadWithoutStalling() const; |
| 202 | 209 |
| 210 template <> |
| 211 bool DecoderStream<DemuxerStream::AUDIO>::CanDecodeMore() const; |
| 212 |
| 203 typedef DecoderStream<DemuxerStream::VIDEO> VideoFrameStream; | 213 typedef DecoderStream<DemuxerStream::VIDEO> VideoFrameStream; |
| 204 typedef DecoderStream<DemuxerStream::AUDIO> AudioBufferStream; | 214 typedef DecoderStream<DemuxerStream::AUDIO> AudioBufferStream; |
| 205 | 215 |
| 206 } // namespace media | 216 } // namespace media |
| 207 | 217 |
| 208 #endif // MEDIA_FILTERS_DECODER_STREAM_H_ | 218 #endif // MEDIA_FILTERS_DECODER_STREAM_H_ |
| OLD | NEW |