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 14 matching lines...) Expand all Loading... | |
60 // Whether any buffers have been processed. | 58 // Whether any buffers have been processed. |
61 bool initialized() const { | 59 bool initialized() const { |
62 return timestamp_helper_.base_timestamp() != kNoTimestamp(); | 60 return timestamp_helper_.base_timestamp() != kNoTimestamp(); |
63 } | 61 } |
64 | 62 |
65 private: | 63 private: |
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_; |
wolenetz
2014/07/30 22:04:31
nit: Please document these members that are missin
DaleCurtis
2014/07/30 22:51:59
Done.
| |
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 // When |decoder_delay_| > 0, the number of frames which should be discarded | |
75 // from the next buffer. The index at which to start discarding is calculated | |
76 // by subtracting |delayed_end_discard_| from |decoder_delay_|. | |
77 size_t delayed_end_discard_; | |
78 | |
76 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioDiscardHelper); | 79 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioDiscardHelper); |
77 }; | 80 }; |
78 | 81 |
79 } // namespace media | 82 } // namespace media |
80 | 83 |
81 #endif // MEDIA_BASE_AUDIO_DISCARD_HELPER_H_ | 84 #endif // MEDIA_BASE_AUDIO_DISCARD_HELPER_H_ |
OLD | NEW |