OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 17 matching lines...) Expand all Loading... |
28 enum WavFormat { | 28 enum WavFormat { |
29 kWavFormatPcm = 1, // PCM, each sample of size bytes_per_sample | 29 kWavFormatPcm = 1, // PCM, each sample of size bytes_per_sample |
30 kWavFormatALaw = 6, // 8-bit ITU-T G.711 A-law | 30 kWavFormatALaw = 6, // 8-bit ITU-T G.711 A-law |
31 kWavFormatMuLaw = 7, // 8-bit ITU-T G.711 mu-law | 31 kWavFormatMuLaw = 7, // 8-bit ITU-T G.711 mu-law |
32 }; | 32 }; |
33 | 33 |
34 // Return true if the given parameters will make a well-formed WAV header. | 34 // Return true if the given parameters will make a well-formed WAV header. |
35 bool CheckWavParameters(int num_channels, | 35 bool CheckWavParameters(int num_channels, |
36 int sample_rate, | 36 int sample_rate, |
37 WavFormat format, | 37 WavFormat format, |
38 int bytes_per_sample, | 38 size_t bytes_per_sample, |
39 uint32_t num_samples); | 39 size_t num_samples); |
40 | 40 |
41 // Write a kWavHeaderSize bytes long WAV header to buf. The payload that | 41 // Write a kWavHeaderSize bytes long WAV header to buf. The payload that |
42 // follows the header is supposed to have the specified number of interleaved | 42 // follows the header is supposed to have the specified number of interleaved |
43 // channels and contain the specified total number of samples of the specified | 43 // channels and contain the specified total number of samples of the specified |
44 // type. CHECKs the input parameters for validity. | 44 // type. CHECKs the input parameters for validity. |
45 void WriteWavHeader(uint8_t* buf, | 45 void WriteWavHeader(uint8_t* buf, |
46 int num_channels, | 46 int num_channels, |
47 int sample_rate, | 47 int sample_rate, |
48 WavFormat format, | 48 WavFormat format, |
49 int bytes_per_sample, | 49 size_t bytes_per_sample, |
50 uint32_t num_samples); | 50 size_t num_samples); |
51 | 51 |
52 // Read a WAV header from an implemented ReadableWav and parse the values into | 52 // Read a WAV header from an implemented ReadableWav and parse the values into |
53 // the provided output parameters. ReadableWav is used because the header can | 53 // the provided output parameters. ReadableWav is used because the header can |
54 // be variably sized. Returns false if the header is invalid. | 54 // be variably sized. Returns false if the header is invalid. |
55 bool ReadWavHeader(ReadableWav* readable, | 55 bool ReadWavHeader(ReadableWav* readable, |
56 int* num_channels, | 56 int* num_channels, |
57 int* sample_rate, | 57 int* sample_rate, |
58 WavFormat* format, | 58 WavFormat* format, |
59 int* bytes_per_sample, | 59 size_t* bytes_per_sample, |
60 uint32_t* num_samples); | 60 size_t* num_samples); |
61 | 61 |
62 } // namespace webrtc | 62 } // namespace webrtc |
63 | 63 |
64 #endif // WEBRTC_COMMON_AUDIO_WAV_HEADER_H_ | 64 #endif // WEBRTC_COMMON_AUDIO_WAV_HEADER_H_ |
OLD | NEW |