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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 int channel_count, | 71 int channel_count, |
72 int sample_rate, | 72 int sample_rate, |
73 int frame_count, | 73 int frame_count, |
74 const base::TimeDelta timestamp); | 74 const base::TimeDelta timestamp); |
75 | 75 |
76 // Create a AudioBuffer indicating we've reached end of stream. | 76 // Create a AudioBuffer indicating we've reached end of stream. |
77 // Calling any method other than end_of_stream() on the resulting buffer | 77 // Calling any method other than end_of_stream() on the resulting buffer |
78 // is disallowed. | 78 // is disallowed. |
79 static scoped_refptr<AudioBuffer> CreateEOSBuffer(); | 79 static scoped_refptr<AudioBuffer> CreateEOSBuffer(); |
80 | 80 |
| 81 // Update sample rate and computed duration. |
| 82 // TODO(chcunningham): Remove this upon patching FFmpeg's AAC decoder to |
| 83 // provide the correct sample rate at the boundary of an implicit config |
| 84 // change. |
| 85 void AdjustSampleRate(int sample_rate); |
| 86 |
81 // 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. |
82 // |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 |
83 // 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 |
84 // 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 |
85 // that AudioBus handles). | 91 // that AudioBus handles). |
86 void ReadFrames(int frames_to_copy, | 92 void ReadFrames(int frames_to_copy, |
87 int source_frame_offset, | 93 int source_frame_offset, |
88 int dest_frame_offset, | 94 int dest_frame_offset, |
89 AudioBus* dest); | 95 AudioBus* dest); |
90 | 96 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 int frame_count, | 167 int frame_count, |
162 bool create_buffer, | 168 bool create_buffer, |
163 const uint8_t* const* data, | 169 const uint8_t* const* data, |
164 const base::TimeDelta timestamp); | 170 const base::TimeDelta timestamp); |
165 | 171 |
166 virtual ~AudioBuffer(); | 172 virtual ~AudioBuffer(); |
167 | 173 |
168 const SampleFormat sample_format_; | 174 const SampleFormat sample_format_; |
169 const ChannelLayout channel_layout_; | 175 const ChannelLayout channel_layout_; |
170 const int channel_count_; | 176 const int channel_count_; |
171 const int sample_rate_; | 177 int sample_rate_; |
172 int adjusted_frame_count_; | 178 int adjusted_frame_count_; |
173 int trim_start_; | 179 int trim_start_; |
174 const bool end_of_stream_; | 180 const bool end_of_stream_; |
175 base::TimeDelta timestamp_; | 181 base::TimeDelta timestamp_; |
176 base::TimeDelta duration_; | 182 base::TimeDelta duration_; |
177 | 183 |
178 // Contiguous block of channel data. | 184 // Contiguous block of channel data. |
179 scoped_ptr<uint8_t, base::AlignedFreeDeleter> data_; | 185 scoped_ptr<uint8_t, base::AlignedFreeDeleter> data_; |
180 size_t data_size_; | 186 size_t data_size_; |
181 | 187 |
182 // For planar data, points to each channels data. | 188 // For planar data, points to each channels data. |
183 std::vector<uint8_t*> channel_data_; | 189 std::vector<uint8_t*> channel_data_; |
184 | 190 |
185 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioBuffer); | 191 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioBuffer); |
186 }; | 192 }; |
187 | 193 |
188 } // namespace media | 194 } // namespace media |
189 | 195 |
190 #endif // MEDIA_BASE_AUDIO_BUFFER_H_ | 196 #endif // MEDIA_BASE_AUDIO_BUFFER_H_ |
OLD | NEW |