OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_BUFFER_H_ | 5 #ifndef MEDIA_BASE_AUDIO_BUFFER_H_ |
6 #define MEDIA_BASE_AUDIO_BUFFER_H_ | 6 #define MEDIA_BASE_AUDIO_BUFFER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 // Copy frames into |dest|. |frames_to_copy| is the number of frames to copy. | 87 // Copy frames into |dest|. |frames_to_copy| is the number of frames to copy. |
88 // |source_frame_offset| specifies how many frames in the buffer to skip | 88 // |source_frame_offset| specifies how many frames in the buffer to skip |
89 // first. |dest_frame_offset| is the frame offset in |dest|. The frames are | 89 // first. |dest_frame_offset| is the frame offset in |dest|. The frames are |
90 // converted from their source format into planar float32 data (which is all | 90 // converted from their source format into planar float32 data (which is all |
91 // that AudioBus handles). | 91 // that AudioBus handles). |
92 void ReadFrames(int frames_to_copy, | 92 void ReadFrames(int frames_to_copy, |
93 int source_frame_offset, | 93 int source_frame_offset, |
94 int dest_frame_offset, | 94 int dest_frame_offset, |
95 AudioBus* dest); | 95 AudioBus* dest); |
96 | 96 |
97 // Add |silence_frames| frames of silence to the start of the buffer. Silence | |
98 // padding can be removed using any of the Trim*() methods. | |
99 void PadStart(int silence_frames); | |
100 | |
101 // Trim an AudioBuffer by removing |frames_to_trim| frames from the start. | 97 // Trim an AudioBuffer by removing |frames_to_trim| frames from the start. |
102 // Timestamp and duration are adjusted to reflect the fewer frames. | 98 // Timestamp and duration are adjusted to reflect the fewer frames. |
103 // Note that repeated calls to TrimStart() may result in timestamp() and | 99 // Note that repeated calls to TrimStart() may result in timestamp() and |
104 // duration() being off by a few microseconds due to rounding issues. | 100 // duration() being off by a few microseconds due to rounding issues. |
105 void TrimStart(int frames_to_trim); | 101 void TrimStart(int frames_to_trim); |
106 | 102 |
107 // Trim an AudioBuffer by removing |frames_to_trim| frames from the end. | 103 // Trim an AudioBuffer by removing |frames_to_trim| frames from the end. |
108 // Duration is adjusted to reflect the fewer frames. | 104 // Duration is adjusted to reflect the fewer frames. |
109 void TrimEnd(int frames_to_trim); | 105 void TrimEnd(int frames_to_trim); |
110 | 106 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 ChannelLayout channel_layout, | 154 ChannelLayout channel_layout, |
159 int channel_count, | 155 int channel_count, |
160 int sample_rate, | 156 int sample_rate, |
161 int frame_count, | 157 int frame_count, |
162 bool create_buffer, | 158 bool create_buffer, |
163 const uint8_t* const* data, | 159 const uint8_t* const* data, |
164 const base::TimeDelta timestamp); | 160 const base::TimeDelta timestamp); |
165 | 161 |
166 virtual ~AudioBuffer(); | 162 virtual ~AudioBuffer(); |
167 | 163 |
168 void AllocateAndCopy(const uint8_t* const* data, | |
169 int frame_count, | |
170 int silence_frames); | |
171 | |
172 const SampleFormat sample_format_; | 164 const SampleFormat sample_format_; |
173 const ChannelLayout channel_layout_; | 165 const ChannelLayout channel_layout_; |
174 const int channel_count_; | 166 const int channel_count_; |
175 int sample_rate_; | 167 int sample_rate_; |
176 int adjusted_frame_count_; | 168 int adjusted_frame_count_; |
177 const bool end_of_stream_; | 169 const bool end_of_stream_; |
178 base::TimeDelta timestamp_; | 170 base::TimeDelta timestamp_; |
179 base::TimeDelta duration_; | 171 base::TimeDelta duration_; |
180 | 172 |
181 // Contiguous block of channel data. | 173 // Contiguous block of channel data. |
182 std::unique_ptr<uint8_t, base::AlignedFreeDeleter> data_; | 174 std::unique_ptr<uint8_t, base::AlignedFreeDeleter> data_; |
183 size_t data_size_; | 175 size_t data_size_; |
184 | 176 |
185 // For planar data, points to each channels data. | 177 // For planar data, points to each channels data. |
186 std::vector<uint8_t*> channel_data_; | 178 std::vector<uint8_t*> channel_data_; |
187 | 179 |
188 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioBuffer); | 180 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioBuffer); |
189 }; | 181 }; |
190 | 182 |
191 } // namespace media | 183 } // namespace media |
192 | 184 |
193 #endif // MEDIA_BASE_AUDIO_BUFFER_H_ | 185 #endif // MEDIA_BASE_AUDIO_BUFFER_H_ |
OLD | NEW |