| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 // Initializes the DecoderStream and returns the initialization result | 58 // Initializes the DecoderStream and returns the initialization result |
| 59 // through |init_cb|. Note that |init_cb| is always called asynchronously. | 59 // through |init_cb|. Note that |init_cb| is always called asynchronously. |
| 60 void Initialize(DemuxerStream* stream, | 60 void Initialize(DemuxerStream* stream, |
| 61 bool low_delay, | 61 bool low_delay, |
| 62 const StatisticsCB& statistics_cb, | 62 const StatisticsCB& statistics_cb, |
| 63 const InitCB& init_cb); | 63 const InitCB& init_cb); |
| 64 | 64 |
| 65 // Reads a decoded Output and returns it via the |read_cb|. Note that | 65 // Reads a decoded Output and returns it via the |read_cb|. Note that |
| 66 // |read_cb| is always called asynchronously. This method should only be | 66 // |read_cb| is always called asynchronously. This method should only be |
| 67 // called after initialization has succeeded and must not be called during | 67 // called after initialization has succeeded and must not be called during |
| 68 // any pending Reset() and/or Stop(). | 68 // pending Reset(). |
| 69 void Read(const ReadCB& read_cb); | 69 void Read(const ReadCB& read_cb); |
| 70 | 70 |
| 71 // Resets the decoder, flushes all decoded outputs and/or internal buffers, | 71 // Resets the decoder, flushes all decoded outputs and/or internal buffers, |
| 72 // fires any existing pending read callback and calls |closure| on completion. | 72 // fires any existing pending read callback and calls |closure| on completion. |
| 73 // Note that |closure| is always called asynchronously. This method should | 73 // Note that |closure| is always called asynchronously. This method should |
| 74 // only be called after initialization has succeeded and must not be called | 74 // only be called after initialization has succeeded and must not be called |
| 75 // during any pending Reset() and/or Stop(). | 75 // during pending Reset(). |
| 76 void Reset(const base::Closure& closure); | 76 void Reset(const base::Closure& closure); |
| 77 | 77 |
| 78 // Stops the decoder, fires any existing pending read callback or reset | |
| 79 // callback and calls |closure| on completion. Note that |closure| is always | |
| 80 // called asynchronously. The DecoderStream cannot be used anymore after | |
| 81 // it is stopped. This method can be called at any time but not during another | |
| 82 // pending Stop(). | |
| 83 void Stop(const base::Closure& closure); | |
| 84 | |
| 85 // Returns true if the decoder currently has the ability to decode and return | 78 // Returns true if the decoder currently has the ability to decode and return |
| 86 // an Output. | 79 // an Output. |
| 87 // TODO(rileya): Remove the need for this by refactoring Decoder queueing | 80 // TODO(rileya): Remove the need for this by refactoring Decoder queueing |
| 88 // behavior. | 81 // behavior. |
| 89 bool CanReadWithoutStalling() const; | 82 bool CanReadWithoutStalling() const; |
| 90 | 83 |
| 91 // Returns maximum concurrent decode requests for the current |decoder_|. | 84 // Returns maximum concurrent decode requests for the current |decoder_|. |
| 92 int GetMaxDecodeRequests() const; | 85 int GetMaxDecodeRequests() const; |
| 93 | 86 |
| 94 // Returns true if one more decode request can be submitted to the decoder. | 87 // Returns true if one more decode request can be submitted to the decoder. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 110 typedef base::Closure ConfigChangeObserverCB; | 103 typedef base::Closure ConfigChangeObserverCB; |
| 111 void set_config_change_observer( | 104 void set_config_change_observer( |
| 112 const ConfigChangeObserverCB& config_change_observer) { | 105 const ConfigChangeObserverCB& config_change_observer) { |
| 113 config_change_observer_cb_ = config_change_observer; | 106 config_change_observer_cb_ = config_change_observer; |
| 114 } | 107 } |
| 115 | 108 |
| 116 private: | 109 private: |
| 117 enum State { | 110 enum State { |
| 118 STATE_UNINITIALIZED, | 111 STATE_UNINITIALIZED, |
| 119 STATE_INITIALIZING, | 112 STATE_INITIALIZING, |
| 120 STATE_NORMAL, // Includes idle, pending decoder decode/reset/stop. | 113 STATE_NORMAL, // Includes idle, pending decoder decode/reset. |
| 121 STATE_FLUSHING_DECODER, | 114 STATE_FLUSHING_DECODER, |
| 122 STATE_PENDING_DEMUXER_READ, | 115 STATE_PENDING_DEMUXER_READ, |
| 123 STATE_REINITIALIZING_DECODER, | 116 STATE_REINITIALIZING_DECODER, |
| 124 STATE_END_OF_STREAM, // End of stream reached; returns EOS on all reads. | 117 STATE_END_OF_STREAM, // End of stream reached; returns EOS on all reads. |
| 125 STATE_STOPPED, | |
| 126 STATE_ERROR | 118 STATE_ERROR |
| 127 }; | 119 }; |
| 128 | 120 |
| 129 // Called when |decoder_selector| selected the |selected_decoder|. | 121 // Called when |decoder_selector| selected the |selected_decoder|. |
| 130 // |decrypting_demuxer_stream| was also populated if a DecryptingDemuxerStream | 122 // |decrypting_demuxer_stream| was also populated if a DecryptingDemuxerStream |
| 131 // is created to help decrypt the encrypted stream. | 123 // is created to help decrypt the encrypted stream. |
| 132 void OnDecoderSelected( | 124 void OnDecoderSelected( |
| 133 scoped_ptr<Decoder> selected_decoder, | 125 scoped_ptr<Decoder> selected_decoder, |
| 134 scoped_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream); | 126 scoped_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream); |
| 135 | 127 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 | 159 |
| 168 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 160 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 169 | 161 |
| 170 State state_; | 162 State state_; |
| 171 | 163 |
| 172 StatisticsCB statistics_cb_; | 164 StatisticsCB statistics_cb_; |
| 173 InitCB init_cb_; | 165 InitCB init_cb_; |
| 174 | 166 |
| 175 ReadCB read_cb_; | 167 ReadCB read_cb_; |
| 176 base::Closure reset_cb_; | 168 base::Closure reset_cb_; |
| 177 base::Closure stop_cb_; | |
| 178 | 169 |
| 179 DemuxerStream* stream_; | 170 DemuxerStream* stream_; |
| 180 bool low_delay_; | 171 bool low_delay_; |
| 181 | 172 |
| 182 scoped_ptr<DecoderSelector<StreamType> > decoder_selector_; | 173 scoped_ptr<DecoderSelector<StreamType> > decoder_selector_; |
| 183 | 174 |
| 184 // These two will be set by DecoderSelector::SelectDecoder(). | 175 // These two will be set by DecoderSelector::SelectDecoder(). |
| 185 scoped_ptr<Decoder> decoder_; | 176 scoped_ptr<Decoder> decoder_; |
| 186 scoped_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream_; | 177 scoped_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream_; |
| 187 | 178 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 212 | 203 |
| 213 template <> | 204 template <> |
| 214 int DecoderStream<DemuxerStream::AUDIO>::GetMaxDecodeRequests() const; | 205 int DecoderStream<DemuxerStream::AUDIO>::GetMaxDecodeRequests() const; |
| 215 | 206 |
| 216 typedef DecoderStream<DemuxerStream::VIDEO> VideoFrameStream; | 207 typedef DecoderStream<DemuxerStream::VIDEO> VideoFrameStream; |
| 217 typedef DecoderStream<DemuxerStream::AUDIO> AudioBufferStream; | 208 typedef DecoderStream<DemuxerStream::AUDIO> AudioBufferStream; |
| 218 | 209 |
| 219 } // namespace media | 210 } // namespace media |
| 220 | 211 |
| 221 #endif // MEDIA_FILTERS_DECODER_STREAM_H_ | 212 #endif // MEDIA_FILTERS_DECODER_STREAM_H_ |
| OLD | NEW |