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

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

Issue 1954633002: MEDIA_LOG for large encoded timestamp gaps in decoder stream. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: New strategy, only check gaps after meeting initial (offset) expectations. Created 4 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
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 #include <memory>
9 10
10 #include "base/callback.h" 11 #include "base/callback.h"
11 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
12 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_vector.h" 14 #include "base/memory/scoped_vector.h"
14 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
15 #include "media/base/audio_decoder.h" 16 #include "media/base/audio_decoder.h"
17 #include "media/base/audio_timestamp_helper.h"
16 #include "media/base/demuxer_stream.h" 18 #include "media/base/demuxer_stream.h"
17 #include "media/base/media_export.h" 19 #include "media/base/media_export.h"
18 #include "media/base/media_log.h" 20 #include "media/base/media_log.h"
19 #include "media/base/moving_average.h" 21 #include "media/base/moving_average.h"
20 #include "media/base/pipeline_status.h" 22 #include "media/base/pipeline_status.h"
21 #include "media/base/timestamp_constants.h" 23 #include "media/base/timestamp_constants.h"
22 #include "media/filters/decoder_selector.h" 24 #include "media/filters/decoder_selector.h"
23 #include "media/filters/decoder_stream_traits.h" 25 #include "media/filters/decoder_stream_traits.h"
24 26
25 namespace base { 27 namespace base {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 void ReinitializeDecoder(); 186 void ReinitializeDecoder();
185 187
186 // Callback for Decoder reinitialization. 188 // Callback for Decoder reinitialization.
187 void OnDecoderReinitialized(bool success); 189 void OnDecoderReinitialized(bool success);
188 190
189 void CompleteDecoderReinitialization(bool success); 191 void CompleteDecoderReinitialization(bool success);
190 192
191 void ResetDecoder(); 193 void ResetDecoder();
192 void OnDecoderReset(); 194 void OnDecoderReset();
193 195
196 // These methods monitor DecoderBuffer timestamps for gaps for the purpose of
197 // warning developers when gaps may cause AV sync drift. A DecoderBuffer's
198 // timestamp should roughly equal the timestamp of the previous buffer offset
199 // by the previous buffer's duration.
200 void CheckForTimestampGap(const scoped_refptr<DecoderBuffer>& buffer);
201 void RecordOutputDuration(const scoped_refptr<Output>& output);
202
194 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 203 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
195 204
196 scoped_refptr<MediaLog> media_log_; 205 scoped_refptr<MediaLog> media_log_;
197 206
198 State state_; 207 State state_;
199 208
200 StatisticsCB statistics_cb_; 209 StatisticsCB statistics_cb_;
201 InitCB init_cb_; 210 InitCB init_cb_;
202 base::Closure waiting_for_decryption_key_cb_; 211 base::Closure waiting_for_decryption_key_cb_;
203 212
204 ReadCB read_cb_; 213 ReadCB read_cb_;
205 base::Closure reset_cb_; 214 base::Closure reset_cb_;
206 215
207 DemuxerStream* stream_; 216 DemuxerStream* stream_;
208 217
218 // Stores the timestamp from the DecoderBuffer corresponding to the first
219 // decoded output. See CheckForTimestampGap().
220 base::TimeDelta audio_base_ts_;
221
222 // Initially false, set to true when we observe gap between encoded timestamps
223 // match gap between output decoder buffers.
224 bool stable_audio_times_;
225
226 // Counts attempts to adjust |audio_ts_offset_| while trying to meet
227 // audio timestamp expectations. Give up making adjustments when count exceeds
228 // |kLimitTriesForStableTiming|.
229 int num_unstable_audio_tries_;
230
231 // Initially zero, we adjust the offset as needed for the first few buffers
DaleCurtis 2016/05/17 21:32:54 Am I understanding correctly that this is equivale
chcunningham 2016/05/18 00:18:00 I would say that, once stable, this is = last_prov
232 // of decoded output to make encoded buffer timestamp gaps line up with
233 // expectations. See implementation of CheckForTimestampGap().
234 base::TimeDelta audio_ts_offset_;
235
236 // Accumulates time as from decoded audio frames. See CheckForTimestampGap().
237 std::unique_ptr<AudioTimestampHelper> audio_output_ts_helper_;
238
239 // How many milliseconds can DecoderBuffer timestamps differ from expectations
240 // before we MEDIA_LOG warn developers. Threshold initially set from
241 // kGapWarningThresholdMsec. Once hit, the threshold is increased by
242 // the detected gap amount. This avoids log spam while still emitting
243 // logs if things get worse. See CheckTimestampForGap().
244 uint32_t drift_warning_threshold_msec_;
245
209 std::unique_ptr<DecoderSelector<StreamType>> decoder_selector_; 246 std::unique_ptr<DecoderSelector<StreamType>> decoder_selector_;
210 247
211 std::unique_ptr<Decoder> decoder_; 248 std::unique_ptr<Decoder> decoder_;
212 // When falling back from H/W decoding to S/W decoding, destructing the 249 // When falling back from H/W decoding to S/W decoding, destructing the
213 // GpuVideoDecoder too early results in black frames being displayed. 250 // GpuVideoDecoder too early results in black frames being displayed.
214 // |previous_decoder_| is used to keep it alive. It is destroyed once we've 251 // |previous_decoder_| is used to keep it alive. It is destroyed once we've
215 // decoded at least media::limits::kMaxVideoFrames frames after fallback. 252 // decoded at least media::limits::kMaxVideoFrames frames after fallback.
216 int decoded_frames_since_fallback_; 253 int decoded_frames_since_fallback_;
217 std::unique_ptr<Decoder> previous_decoder_; 254 std::unique_ptr<Decoder> previous_decoder_;
218 std::unique_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream_; 255 std::unique_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream_;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 306
270 template <> 307 template <>
271 int DecoderStream<DemuxerStream::AUDIO>::GetMaxDecodeRequests() const; 308 int DecoderStream<DemuxerStream::AUDIO>::GetMaxDecodeRequests() const;
272 309
273 typedef DecoderStream<DemuxerStream::VIDEO> VideoFrameStream; 310 typedef DecoderStream<DemuxerStream::VIDEO> VideoFrameStream;
274 typedef DecoderStream<DemuxerStream::AUDIO> AudioBufferStream; 311 typedef DecoderStream<DemuxerStream::AUDIO> AudioBufferStream;
275 312
276 } // namespace media 313 } // namespace media
277 314
278 #endif // MEDIA_FILTERS_DECODER_STREAM_H_ 315 #endif // MEDIA_FILTERS_DECODER_STREAM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698