OLD | NEW |
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_BASE_AUDIO_DISCARD_HELPER_H_ | 5 #ifndef MEDIA_BASE_AUDIO_DISCARD_HELPER_H_ |
6 #define MEDIA_BASE_AUDIO_DISCARD_HELPER_H_ | 6 #define MEDIA_BASE_AUDIO_DISCARD_HELPER_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "media/base/audio_timestamp_helper.h" | 10 #include "media/base/audio_timestamp_helper.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 // | 24 // |
25 // |decoder_delay| is the number of frames a decoder will output before data | 25 // |decoder_delay| is the number of frames a decoder will output before data |
26 // corresponding to the first encoded buffer is output. Callers only need to | 26 // corresponding to the first encoded buffer is output. Callers only need to |
27 // specify this if the decoder inserts frames which have no corresponding | 27 // specify this if the decoder inserts frames which have no corresponding |
28 // encoded buffer. | 28 // encoded buffer. |
29 // | 29 // |
30 // For example, most MP3 decoders will output 529 junk frames before the data | 30 // For example, most MP3 decoders will output 529 junk frames before the data |
31 // corresponding to the first encoded buffer is output. These frames are not | 31 // corresponding to the first encoded buffer is output. These frames are not |
32 // represented in the encoded data stream and instead are an artifact of how | 32 // represented in the encoded data stream and instead are an artifact of how |
33 // most MP3 decoders work. See http://lame.sourceforge.net/tech-FAQ.txt | 33 // most MP3 decoders work. See http://lame.sourceforge.net/tech-FAQ.txt |
34 // | |
35 // NOTE: End discard is only supported when there is no |decoder_delay|. | |
36 AudioDiscardHelper(int sample_rate, size_t decoder_delay); | 34 AudioDiscardHelper(int sample_rate, size_t decoder_delay); |
37 ~AudioDiscardHelper(); | 35 ~AudioDiscardHelper(); |
38 | 36 |
39 // Converts a TimeDelta to a frame count based on the constructed sample rate. | 37 // Converts a TimeDelta to a frame count based on the constructed sample rate. |
40 // |duration| must be positive. | 38 // |duration| must be positive. |
41 size_t TimeDeltaToFrames(base::TimeDelta duration) const; | 39 size_t TimeDeltaToFrames(base::TimeDelta duration) const; |
42 | 40 |
43 // Resets internal state and indicates that |initial_discard| of upcoming | 41 // Resets internal state and indicates that |initial_discard| of upcoming |
44 // frames should be discarded. | 42 // frames should be discarded. |
45 void Reset(size_t initial_discard); | 43 void Reset(size_t initial_discard); |
(...skipping 20 matching lines...) Expand all Loading... |
66 const int sample_rate_; | 64 const int sample_rate_; |
67 const size_t decoder_delay_; | 65 const size_t decoder_delay_; |
68 AudioTimestampHelper timestamp_helper_; | 66 AudioTimestampHelper timestamp_helper_; |
69 | 67 |
70 size_t discard_frames_; | 68 size_t discard_frames_; |
71 base::TimeDelta last_input_timestamp_; | 69 base::TimeDelta last_input_timestamp_; |
72 | 70 |
73 bool delayed_discard_; | 71 bool delayed_discard_; |
74 DecoderBuffer::DiscardPadding delayed_discard_padding_; | 72 DecoderBuffer::DiscardPadding delayed_discard_padding_; |
75 | 73 |
| 74 // Index into the next buffer received by ProcessBuffers() at which a discard |
| 75 // of |decoder_delay_| - |delayed_end_discard_| frames should be discarded. |
| 76 size_t delayed_end_discard_; |
| 77 |
76 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioDiscardHelper); | 78 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioDiscardHelper); |
77 }; | 79 }; |
78 | 80 |
79 } // namespace media | 81 } // namespace media |
80 | 82 |
81 #endif // MEDIA_BASE_AUDIO_DISCARD_HELPER_H_ | 83 #endif // MEDIA_BASE_AUDIO_DISCARD_HELPER_H_ |
OLD | NEW |