| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "media/filters/audio_timestamp_validator.h" | 5 #include "media/filters/audio_timestamp_validator.h" |
| 6 | 6 |
| 7 namespace media { | 7 namespace media { |
| 8 | 8 |
| 9 // Defines how many milliseconds of DecoderBuffer timestamp gap will be allowed | 9 // Defines how many milliseconds of DecoderBuffer timestamp gap will be allowed |
| 10 // before warning the user. See CheckForTimestampGap(). Value of 50 chosen, as | 10 // before warning the user. See CheckForTimestampGap(). Value of 50 chosen, as |
| 11 // this is low enough to catch issues early, but high enough to avoid noise for | 11 // this is low enough to catch issues early, but high enough to avoid noise for |
| 12 // containers like WebM that default to low granularity timestamp precision. | 12 // containers like WebM that default to low granularity timestamp precision. |
| 13 const int kGapWarningThresholdMsec = 50; | 13 const int kGapWarningThresholdMsec = 50; |
| 14 | 14 |
| 15 // Limits the number of adjustments to |audio_ts_offset_| in order to reach a | 15 // Limits the number of adjustments to |audio_ts_offset_| in order to reach a |
| 16 // stable state where gaps between encoded timestamps match decoded output | 16 // stable state where gaps between encoded timestamps match decoded output |
| 17 // intervals. See CheckForTimestampGap(). | 17 // intervals. See CheckForTimestampGap(). |
| 18 const int kLimitTriesForStableTiming = 5; | 18 const int kLimitTriesForStableTiming = 5; |
| 19 | 19 |
| 20 // Limits the milliseconds of difference between expected and actual timestamps | 20 // Limits the milliseconds of difference between expected and actual timestamps |
| 21 // gaps to consider timestamp expectations "stable". 1 chosen because some | 21 // gaps to consider timestamp expectations "stable". 1 chosen because some |
| 22 // containers (WebM) default to millisecond timestamp precision. See | 22 // containers (WebM) default to millisecond timestamp precision. See |
| 23 // CheckForTimestampGap(). | 23 // CheckForTimestampGap(). |
| 24 const int kStableTimeGapThrsholdMsec = 1; | 24 const int kStableTimeGapThrsholdMsec = 1; |
| 25 | 25 |
| 26 AudioTimestampValidator::AudioTimestampValidator( | 26 AudioTimestampValidator::AudioTimestampValidator( |
| 27 const AudioDecoderConfig& decoder_config, | 27 const AudioDecoderConfig& decoder_config, |
| 28 const scoped_refptr<MediaLog>& media_log) | 28 MediaLog* media_log) |
| 29 : has_codec_delay_(decoder_config.codec_delay() > 0), | 29 : has_codec_delay_(decoder_config.codec_delay() > 0), |
| 30 media_log_(media_log), | 30 media_log_(media_log), |
| 31 audio_base_ts_(kNoTimestamp), | 31 audio_base_ts_(kNoTimestamp), |
| 32 reached_stable_state_(false), | 32 reached_stable_state_(false), |
| 33 num_unstable_audio_tries_(0), | 33 num_unstable_audio_tries_(0), |
| 34 limit_unstable_audio_tries_(kLimitTriesForStableTiming), | 34 limit_unstable_audio_tries_(kLimitTriesForStableTiming), |
| 35 drift_warning_threshold_msec_(kGapWarningThresholdMsec) { | 35 drift_warning_threshold_msec_(kGapWarningThresholdMsec) { |
| 36 DCHECK(decoder_config.IsValidConfig()); | 36 DCHECK(decoder_config.IsValidConfig()); |
| 37 } | 37 } |
| 38 | 38 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 audio_output_ts_helper_.reset( | 135 audio_output_ts_helper_.reset( |
| 136 new AudioTimestampHelper(audio_buffer->sample_rate())); | 136 new AudioTimestampHelper(audio_buffer->sample_rate())); |
| 137 audio_output_ts_helper_->SetBaseTimestamp(audio_base_ts_); | 137 audio_output_ts_helper_->SetBaseTimestamp(audio_base_ts_); |
| 138 } | 138 } |
| 139 | 139 |
| 140 DVLOG(3) << __func__ << " " << audio_buffer->frame_count() << " frames"; | 140 DVLOG(3) << __func__ << " " << audio_buffer->frame_count() << " frames"; |
| 141 audio_output_ts_helper_->AddFrames(audio_buffer->frame_count()); | 141 audio_output_ts_helper_->AddFrames(audio_buffer->frame_count()); |
| 142 } | 142 } |
| 143 | 143 |
| 144 } // namespace media | 144 } // namespace media |
| OLD | NEW |