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

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

Issue 2837613004: media: Support better decoder switching (Closed)
Patch Set: comments Created 3 years, 7 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 | « media/filters/decoder_selector.cc ('k') | media/filters/decoder_stream.cc » ('j') | no next file with comments »
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 <deque> 8 #include <deque>
9 #include <list> 9 #include <list>
10 #include <memory> 10 #include <memory>
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 typedef typename StreamTraits::DecoderType Decoder; 43 typedef typename StreamTraits::DecoderType Decoder;
44 typedef typename StreamTraits::OutputType Output; 44 typedef typename StreamTraits::OutputType Output;
45 45
46 enum Status { 46 enum Status {
47 OK, // Everything went as planned. 47 OK, // Everything went as planned.
48 ABORTED, // Read aborted due to Reset() during pending read. 48 ABORTED, // Read aborted due to Reset() during pending read.
49 DEMUXER_READ_ABORTED, // Demuxer returned aborted read. 49 DEMUXER_READ_ABORTED, // Demuxer returned aborted read.
50 DECODE_ERROR, // Decoder returned decode error. 50 DECODE_ERROR, // Decoder returned decode error.
51 }; 51 };
52 52
53 // Callback to create a list of decoders.
54 using CreateDecodersCB = base::RepeatingCallback<ScopedVector<Decoder>()>;
55
53 // Indicates completion of a DecoderStream initialization. 56 // Indicates completion of a DecoderStream initialization.
54 typedef base::Callback<void(bool success)> InitCB; 57 using InitCB = base::Callback<void(bool success)>;
55 58
56 // Indicates completion of a DecoderStream read. 59 // Indicates completion of a DecoderStream read.
57 typedef base::Callback<void(Status, const scoped_refptr<Output>&)> ReadCB; 60 using ReadCB = base::Callback<void(Status, const scoped_refptr<Output>&)>;
58 61
59 DecoderStream(const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 62 DecoderStream(const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
60 ScopedVector<Decoder> decoders, 63 CreateDecodersCB create_decoders_cb,
61 MediaLog* media_log); 64 MediaLog* media_log);
62 virtual ~DecoderStream(); 65 virtual ~DecoderStream();
63 66
64 // Returns the string representation of the StreamType for logging purpose. 67 // Returns the string representation of the StreamType for logging purpose.
65 std::string GetStreamTypeString(); 68 std::string GetStreamTypeString();
66 69
67 // Initializes the DecoderStream and returns the initialization result 70 // Initializes the DecoderStream and returns the initialization result
68 // through |init_cb|. Note that |init_cb| is always called asynchronously. 71 // through |init_cb|. Note that |init_cb| is always called asynchronously.
69 // |cdm_context| can be used to handle encrypted stream. Can be null if the 72 // |cdm_context| can be used to handle encrypted stream. Can be null if the
70 // stream is not encrypted. 73 // stream is not encrypted.
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 207
205 CdmContext* cdm_context_; 208 CdmContext* cdm_context_;
206 209
207 std::unique_ptr<DecoderSelector<StreamType>> decoder_selector_; 210 std::unique_ptr<DecoderSelector<StreamType>> decoder_selector_;
208 211
209 std::unique_ptr<Decoder> decoder_; 212 std::unique_ptr<Decoder> decoder_;
210 213
211 // Whether |decoder_| has produced a frame yet. Reset on fallback. 214 // Whether |decoder_| has produced a frame yet. Reset on fallback.
212 bool decoder_produced_a_frame_; 215 bool decoder_produced_a_frame_;
213 216
217 // Whether we have already fallen back once on decode error, used to prevent
218 // issues like infinite fallback like:
219 // 1. select decoder 1
220 // 2. decode error on decoder 1
221 // 3. black list decoder 1 and select decoder 2
222 // 4. decode error again on decoder 2
223 // 5. black list decoder 2 and select decoder 1
224 // 6. go to (2)
225 bool has_fallen_back_once_on_decode_error_;
watk 2017/05/04 23:58:36 +1
226
214 std::unique_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream_; 227 std::unique_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream_;
215 228
216 ConfigChangeObserverCB config_change_observer_cb_; 229 ConfigChangeObserverCB config_change_observer_cb_;
217 DecoderChangeObserverCB decoder_change_observer_cb_; 230 DecoderChangeObserverCB decoder_change_observer_cb_;
218 231
219 // An end-of-stream buffer has been sent for decoding, no more buffers should 232 // An end-of-stream buffer has been sent for decoding, no more buffers should
220 // be sent for decoding until it completes. 233 // be sent for decoding until it completes.
221 // TODO(sandersd): Turn this into a State. http://crbug.com/408316 234 // TODO(sandersd): Turn this into a State. http://crbug.com/408316
222 bool decoding_eos_; 235 bool decoding_eos_;
223 236
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 274
262 template <> 275 template <>
263 int DecoderStream<DemuxerStream::AUDIO>::GetMaxDecodeRequests() const; 276 int DecoderStream<DemuxerStream::AUDIO>::GetMaxDecodeRequests() const;
264 277
265 typedef DecoderStream<DemuxerStream::VIDEO> VideoFrameStream; 278 typedef DecoderStream<DemuxerStream::VIDEO> VideoFrameStream;
266 typedef DecoderStream<DemuxerStream::AUDIO> AudioBufferStream; 279 typedef DecoderStream<DemuxerStream::AUDIO> AudioBufferStream;
267 280
268 } // namespace media 281 } // namespace media
269 282
270 #endif // MEDIA_FILTERS_DECODER_STREAM_H_ 283 #endif // MEDIA_FILTERS_DECODER_STREAM_H_
OLDNEW
« no previous file with comments | « media/filters/decoder_selector.cc ('k') | media/filters/decoder_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698