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

Side by Side Diff: media/filters/audio_timestamp_validator.cc

Issue 2158923004: Convert media constants to constexpr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 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
(...skipping 10 matching lines...) Expand all
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 const scoped_refptr<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
39 AudioTimestampValidator::~AudioTimestampValidator() {} 39 AudioTimestampValidator::~AudioTimestampValidator() {}
40 40
41 void AudioTimestampValidator::CheckForTimestampGap( 41 void AudioTimestampValidator::CheckForTimestampGap(
42 const scoped_refptr<DecoderBuffer>& buffer) { 42 const scoped_refptr<DecoderBuffer>& buffer) {
43 if (buffer->end_of_stream()) 43 if (buffer->end_of_stream())
44 return; 44 return;
45 DCHECK_NE(kNoTimestamp(), buffer->timestamp()); 45 DCHECK_NE(kNoTimestamp, buffer->timestamp());
46 46
47 // If audio_base_ts_ == kNoTimestamp(), we are processing our first buffer. 47 // If audio_base_ts_ == kNoTimestamp, we are processing our first buffer.
48 // If stream has neither codec delay nor discard padding, we should expect 48 // If stream has neither codec delay nor discard padding, we should expect
49 // timestamps and output durations to line up from the start (i.e. be stable). 49 // timestamps and output durations to line up from the start (i.e. be stable).
50 if (audio_base_ts_ == kNoTimestamp() && !has_codec_delay_ && 50 if (audio_base_ts_ == kNoTimestamp && !has_codec_delay_ &&
51 buffer->discard_padding().first == base::TimeDelta() && 51 buffer->discard_padding().first == base::TimeDelta() &&
52 buffer->discard_padding().second == base::TimeDelta()) { 52 buffer->discard_padding().second == base::TimeDelta()) {
53 DVLOG(3) << __FUNCTION__ 53 DVLOG(3) << __FUNCTION__
54 << " Expecting stable timestamps - stream has neither codec delay" 54 << " Expecting stable timestamps - stream has neither codec delay"
55 << " nor discard padding."; 55 << " nor discard padding.";
56 limit_unstable_audio_tries_ = 0; 56 limit_unstable_audio_tries_ = 0;
57 } 57 }
58 58
59 // Don't continue checking timestamps if we've exhausted tries to reach stable 59 // Don't continue checking timestamps if we've exhausted tries to reach stable
60 // state. This suggests the media's encoded timestamps are way off. 60 // state. This suggests the media's encoded timestamps are way off.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 DVLOG(3) << __FUNCTION__ << " delta:" << ts_delta.InMicroseconds() 124 DVLOG(3) << __FUNCTION__ << " delta:" << ts_delta.InMicroseconds()
125 << " expected_ts:" << expected_ts.InMicroseconds() 125 << " expected_ts:" << expected_ts.InMicroseconds()
126 << " actual_ts:" << buffer->timestamp().InMicroseconds() 126 << " actual_ts:" << buffer->timestamp().InMicroseconds()
127 << " audio_ts_offset:" 127 << " audio_ts_offset:"
128 << audio_output_ts_helper_->base_timestamp().InMicroseconds(); 128 << audio_output_ts_helper_->base_timestamp().InMicroseconds();
129 } 129 }
130 130
131 void AudioTimestampValidator::RecordOutputDuration( 131 void AudioTimestampValidator::RecordOutputDuration(
132 const scoped_refptr<AudioBuffer>& audio_buffer) { 132 const scoped_refptr<AudioBuffer>& audio_buffer) {
133 if (!audio_output_ts_helper_) { 133 if (!audio_output_ts_helper_) {
134 DCHECK_NE(audio_base_ts_, kNoTimestamp()); 134 DCHECK_NE(audio_base_ts_, kNoTimestamp);
135 // SUBTLE: deliberately creating this with output buffer sample rate because 135 // SUBTLE: deliberately creating this with output buffer sample rate because
136 // demuxer stream config is potentially stale for implicit AAC. 136 // demuxer stream config is potentially stale for implicit AAC.
137 audio_output_ts_helper_.reset( 137 audio_output_ts_helper_.reset(
138 new AudioTimestampHelper(audio_buffer->sample_rate())); 138 new AudioTimestampHelper(audio_buffer->sample_rate()));
139 audio_output_ts_helper_->SetBaseTimestamp(audio_base_ts_); 139 audio_output_ts_helper_->SetBaseTimestamp(audio_base_ts_);
140 } 140 }
141 141
142 DVLOG(3) << __FUNCTION__ << " " << audio_buffer->frame_count() << " frames"; 142 DVLOG(3) << __FUNCTION__ << " " << audio_buffer->frame_count() << " frames";
143 audio_output_ts_helper_->AddFrames(audio_buffer->frame_count()); 143 audio_output_ts_helper_->AddFrames(audio_buffer->frame_count());
144 } 144 }
145 145
146 } // namespace media 146 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698