Chromium Code Reviews| Index: media/filters/decoder_stream.h |
| diff --git a/media/filters/decoder_stream.h b/media/filters/decoder_stream.h |
| index 7e2519ddd1bd7eaec5a64019b694c127b21f5232..1bb707c9b0b39c91997904665045946ccb302999 100644 |
| --- a/media/filters/decoder_stream.h |
| +++ b/media/filters/decoder_stream.h |
| @@ -6,6 +6,7 @@ |
| #define MEDIA_FILTERS_DECODER_STREAM_H_ |
| #include <list> |
| +#include <memory> |
| #include "base/callback.h" |
| #include "base/compiler_specific.h" |
| @@ -13,6 +14,7 @@ |
| #include "base/memory/scoped_vector.h" |
| #include "base/memory/weak_ptr.h" |
| #include "media/base/audio_decoder.h" |
| +#include "media/base/audio_timestamp_helper.h" |
| #include "media/base/demuxer_stream.h" |
| #include "media/base/media_export.h" |
| #include "media/base/media_log.h" |
| @@ -191,6 +193,13 @@ class MEDIA_EXPORT DecoderStream { |
| void ResetDecoder(); |
| void OnDecoderReset(); |
| + // These methods monitor DecoderBuffer timestamps for gaps for the purpose of |
| + // warning developers when gaps may cause AV sync drift. A DecoderBuffer's |
| + // timestamp should roughly equal the timestamp of the previous buffer offset |
| + // by the previous buffer's duration. |
| + void CheckForTimestampGap(const scoped_refptr<DecoderBuffer>& buffer); |
| + void RecordOutputDuration(const scoped_refptr<Output>& output); |
| + |
| scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| scoped_refptr<MediaLog> media_log_; |
| @@ -206,6 +215,34 @@ class MEDIA_EXPORT DecoderStream { |
| DemuxerStream* stream_; |
| + // Stores the timestamp from the DecoderBuffer corresponding to the first |
| + // decoded output. See CheckForTimestampGap(). |
| + base::TimeDelta audio_base_ts_; |
| + |
| + // Initially false, set to true when we observe gap between encoded timestamps |
| + // match gap between output decoder buffers. |
| + bool stable_audio_times_; |
| + |
| + // Counts attempts to adjust |audio_ts_offset_| while trying to meet |
| + // audio timestamp expectations. Give up making adjustments when count exceeds |
| + // |kLimitTriesForStableTiming|. |
| + int num_unstable_audio_tries_; |
| + |
| + // 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
|
| + // of decoded output to make encoded buffer timestamp gaps line up with |
| + // expectations. See implementation of CheckForTimestampGap(). |
| + base::TimeDelta audio_ts_offset_; |
| + |
| + // Accumulates time as from decoded audio frames. See CheckForTimestampGap(). |
| + std::unique_ptr<AudioTimestampHelper> audio_output_ts_helper_; |
| + |
| + // How many milliseconds can DecoderBuffer timestamps differ from expectations |
| + // before we MEDIA_LOG warn developers. Threshold initially set from |
| + // kGapWarningThresholdMsec. Once hit, the threshold is increased by |
| + // the detected gap amount. This avoids log spam while still emitting |
| + // logs if things get worse. See CheckTimestampForGap(). |
| + uint32_t drift_warning_threshold_msec_; |
| + |
| std::unique_ptr<DecoderSelector<StreamType>> decoder_selector_; |
| std::unique_ptr<Decoder> decoder_; |