OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 // Update codecInst according to the current audio codec being used for | 173 // Update codecInst according to the current audio codec being used for |
174 // reading or writing. | 174 // reading or writing. |
175 int32_t codec_info(CodecInst& codecInst); | 175 int32_t codec_info(CodecInst& codecInst); |
176 | 176 |
177 private: | 177 private: |
178 // Biggest WAV frame supported is 10 ms at 48kHz of 2 channel, 16 bit audio. | 178 // Biggest WAV frame supported is 10 ms at 48kHz of 2 channel, 16 bit audio. |
179 static const size_t WAV_MAX_BUFFER_SIZE = 480 * 2 * 2; | 179 static const size_t WAV_MAX_BUFFER_SIZE = 480 * 2 * 2; |
180 | 180 |
181 | 181 |
182 int32_t InitWavCodec(uint32_t samplesPerSec, | 182 int32_t InitWavCodec(uint32_t samplesPerSec, |
183 uint32_t channels, | 183 size_t channels, |
184 uint32_t bitsPerSample, | 184 uint32_t bitsPerSample, |
185 uint32_t formatTag); | 185 uint32_t formatTag); |
186 | 186 |
187 // Parse the WAV header in stream. | 187 // Parse the WAV header in stream. |
188 int32_t ReadWavHeader(InStream& stream); | 188 int32_t ReadWavHeader(InStream& stream); |
189 | 189 |
190 // Update the WAV header. freqInHz, bytesPerSample, channels, format, | 190 // Update the WAV header. freqInHz, bytesPerSample, channels, format, |
191 // lengthInBytes specify characterists of the audio data. | 191 // lengthInBytes specify characterists of the audio data. |
192 // freqInHz is the sampling frequency. bytesPerSample is the sample size in | 192 // freqInHz is the sampling frequency. bytesPerSample is the sample size in |
193 // bytes. channels is the number of channels, e.g. 1 is mono and 2 is | 193 // bytes. channels is the number of channels, e.g. 1 is mono and 2 is |
194 // stereo. format is the encode format (e.g. PCMU, PCMA, PCM etc). | 194 // stereo. format is the encode format (e.g. PCMU, PCMA, PCM etc). |
195 // lengthInBytes is the number of bytes the audio samples are using up. | 195 // lengthInBytes is the number of bytes the audio samples are using up. |
196 int32_t WriteWavHeader(OutStream& stream, | 196 int32_t WriteWavHeader(OutStream& stream, |
197 uint32_t freqInHz, | 197 uint32_t freqInHz, |
198 size_t bytesPerSample, | 198 size_t bytesPerSample, |
199 uint32_t channels, | 199 size_t channels, |
200 uint32_t format, | 200 uint32_t format, |
201 size_t lengthInBytes); | 201 size_t lengthInBytes); |
202 | 202 |
203 // Put dataLengthInBytes of audio data from stream into the audioBuffer. | 203 // Put dataLengthInBytes of audio data from stream into the audioBuffer. |
204 // The return value is the number of bytes written to audioBuffer. | 204 // The return value is the number of bytes written to audioBuffer. |
205 int32_t ReadWavData(InStream& stream, uint8_t* audioBuffer, | 205 int32_t ReadWavData(InStream& stream, uint8_t* audioBuffer, |
206 size_t dataLengthInBytes); | 206 size_t dataLengthInBytes); |
207 | 207 |
208 // Update the current audio codec being used for reading or writing | 208 // Update the current audio codec being used for reading or writing |
209 // according to codecInst. | 209 // according to codecInst. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 | 275 |
276 // Only reading or writing can be enabled, not both. | 276 // Only reading or writing can be enabled, not both. |
277 bool _reading; | 277 bool _reading; |
278 bool _writing; | 278 bool _writing; |
279 | 279 |
280 // Scratch buffer used for turning stereo audio to mono. | 280 // Scratch buffer used for turning stereo audio to mono. |
281 uint8_t _tempData[WAV_MAX_BUFFER_SIZE]; | 281 uint8_t _tempData[WAV_MAX_BUFFER_SIZE]; |
282 }; | 282 }; |
283 } // namespace webrtc | 283 } // namespace webrtc |
284 #endif // WEBRTC_MODULES_MEDIA_FILE_MEDIA_FILE_UTILITY_H_ | 284 #endif // WEBRTC_MODULES_MEDIA_FILE_MEDIA_FILE_UTILITY_H_ |
OLD | NEW |