2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
11 #ifndef WEBRTC_COMMON_AUDIO_WAV_HEADER_H_
12 #define WEBRTC_COMMON_AUDIO_WAV_HEADER_H_
19 static const size_t kWavHeaderSize = 44;
22 kWavFormatPcm = 1, // PCM, each sample of size bytes_per_sample
23 kWavFormatALaw = 6, // 8-bit ITU-T G.711 A-law
24 kWavFormatMuLaw = 7, // 8-bit ITU-T G.711 mu-law
27 // Return true if the given parameters will make a well-formed WAV header.
28 bool CheckWavParameters(int num_channels,
32 uint32_t num_samples);
34 // Write a kWavHeaderSize bytes long WAV header to buf. The payload that
35 // follows the header is supposed to have the specified number of interleaved
36 // channels and contain the specified total number of samples of the specified
37 // type. CHECKs the input parameters for validity.
38 void WriteWavHeader(uint8_t* buf,
43 uint32_t num_samples);
45 // Read a kWavHeaderSize bytes long WAV header from buf and parse the values
46 // into the provided output parameters. Returns false if the header is invalid.
47 bool ReadWavHeader(const uint8_t* buf,
51 int* bytes_per_sample,
52 uint32_t* num_samples);
56 #endif // WEBRTC_COMMON_AUDIO_WAV_HEADER_H_