Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(589)

Side by Side Diff: media/filters/decoder_stream.h

Issue 1879353003: Attempt decoder fallback if first decode fails (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | media/filters/decoder_stream.cc » ('j') | media/filters/decoder_stream.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 typedef base::Closure ConfigChangeObserverCB; 115 typedef base::Closure ConfigChangeObserverCB;
116 void set_config_change_observer( 116 void set_config_change_observer(
117 const ConfigChangeObserverCB& config_change_observer) { 117 const ConfigChangeObserverCB& config_change_observer) {
118 config_change_observer_cb_ = config_change_observer; 118 config_change_observer_cb_ = config_change_observer;
119 } 119 }
120 120
121 const Decoder* get_previous_decoder_for_testing() const { 121 const Decoder* get_previous_decoder_for_testing() const {
122 return previous_decoder_.get(); 122 return previous_decoder_.get();
123 } 123 }
124 124
125 int get_pending_buffers_size_for_testing() const {
126 return pending_buffers_.size();
127 }
128
125 private: 129 private:
126 enum State { 130 enum State {
127 STATE_UNINITIALIZED, 131 STATE_UNINITIALIZED,
128 STATE_INITIALIZING, 132 STATE_INITIALIZING,
129 STATE_NORMAL, // Includes idle, pending decoder decode/reset. 133 STATE_NORMAL, // Includes idle, pending decoder decode/reset.
130 STATE_FLUSHING_DECODER, 134 STATE_FLUSHING_DECODER,
131 STATE_PENDING_DEMUXER_READ, 135 STATE_PENDING_DEMUXER_READ,
132 STATE_REINITIALIZING_DECODER, 136 STATE_REINITIALIZING_DECODER,
133 STATE_END_OF_STREAM, // End of stream reached; returns EOS on all reads. 137 STATE_END_OF_STREAM, // End of stream reached; returns EOS on all reads.
134 STATE_ERROR 138 STATE_ERROR
(...skipping 13 matching lines...) Expand all
148 const scoped_refptr<Output>& output); 152 const scoped_refptr<Output>& output);
149 153
150 // Decodes |buffer| and returns the result via OnDecodeOutputReady(). 154 // Decodes |buffer| and returns the result via OnDecodeOutputReady().
151 void Decode(const scoped_refptr<DecoderBuffer>& buffer); 155 void Decode(const scoped_refptr<DecoderBuffer>& buffer);
152 156
153 // Flushes the decoder with an EOS buffer to retrieve internally buffered 157 // Flushes the decoder with an EOS buffer to retrieve internally buffered
154 // decoder output. 158 // decoder output.
155 void FlushDecoder(); 159 void FlushDecoder();
156 160
157 // Callback for Decoder::Decode(). 161 // Callback for Decoder::Decode().
158 void OnDecodeDone(int buffer_size, bool end_of_stream, DecodeStatus status); 162 void OnDecodeDone(int sequence_token,
163 int buffer_size,
164 bool end_of_stream,
165 DecodeStatus status);
159 166
160 // Output callback passed to Decoder::Initialize(). 167 // Output callback passed to Decoder::Initialize().
161 void OnDecodeOutputReady(const scoped_refptr<Output>& output); 168 void OnDecodeOutputReady(const scoped_refptr<Output>& output);
162 169
163 // Reads a buffer from |stream_| and returns the result via OnBufferReady(). 170 // Reads a buffer from |stream_| and returns the result via OnBufferReady().
164 void ReadFromDemuxerStream(); 171 void ReadFromDemuxerStream();
165 172
166 // Callback for DemuxerStream::Read(). 173 // Callback for DemuxerStream::Read().
167 void OnBufferReady(DemuxerStream::Status status, 174 void OnBufferReady(DemuxerStream::Status status,
168 const scoped_refptr<DecoderBuffer>& buffer); 175 const scoped_refptr<DecoderBuffer>& buffer);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 // Decoded buffers that haven't been read yet. Used when the decoder supports 225 // Decoded buffers that haven't been read yet. Used when the decoder supports
219 // parallel decoding. 226 // parallel decoding.
220 std::list<scoped_refptr<Output> > ready_outputs_; 227 std::list<scoped_refptr<Output> > ready_outputs_;
221 228
222 // Number of outstanding decode requests sent to the |decoder_|. 229 // Number of outstanding decode requests sent to the |decoder_|.
223 int pending_decode_requests_; 230 int pending_decode_requests_;
224 231
225 // Tracks the duration of incoming packets over time. 232 // Tracks the duration of incoming packets over time.
226 MovingAverage duration_tracker_; 233 MovingAverage duration_tracker_;
227 234
235 // Used to reattempt decoding when decode fails right after Initialize().
236 std::deque<scoped_refptr<DecoderBuffer>> pending_buffers_;
237 int sequence_token_;
238
228 // NOTE: Weak pointers must be invalidated before all other member variables. 239 // NOTE: Weak pointers must be invalidated before all other member variables.
229 base::WeakPtrFactory<DecoderStream<StreamType> > weak_factory_; 240 base::WeakPtrFactory<DecoderStream<StreamType> > weak_factory_;
230 }; 241 };
231 242
232 template <> 243 template <>
233 bool DecoderStream<DemuxerStream::AUDIO>::CanReadWithoutStalling() const; 244 bool DecoderStream<DemuxerStream::AUDIO>::CanReadWithoutStalling() const;
234 245
235 template <> 246 template <>
236 int DecoderStream<DemuxerStream::AUDIO>::GetMaxDecodeRequests() const; 247 int DecoderStream<DemuxerStream::AUDIO>::GetMaxDecodeRequests() const;
237 248
238 typedef DecoderStream<DemuxerStream::VIDEO> VideoFrameStream; 249 typedef DecoderStream<DemuxerStream::VIDEO> VideoFrameStream;
239 typedef DecoderStream<DemuxerStream::AUDIO> AudioBufferStream; 250 typedef DecoderStream<DemuxerStream::AUDIO> AudioBufferStream;
240 251
241 } // namespace media 252 } // namespace media
242 253
243 #endif // MEDIA_FILTERS_DECODER_STREAM_H_ 254 #endif // MEDIA_FILTERS_DECODER_STREAM_H_
OLDNEW
« no previous file with comments | « no previous file | media/filters/decoder_stream.cc » ('j') | media/filters/decoder_stream.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698