blob: f9ed8a576bd9a6167e005bc972fbf7f335eeb903 [file] [log] [blame]
kwiberg@webrtc.org877083c2014-08-20 07:42:46 +00001/*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3 *
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.
9 */
10
11#ifndef WEBRTC_COMMON_AUDIO_WAV_HEADER_H_
12#define WEBRTC_COMMON_AUDIO_WAV_HEADER_H_
13
14#include <stdint.h>
15
16namespace webrtc {
17
18static const int kWavHeaderSize = 44;
19
20enum WavFormat {
21 kWavFormatPcm = 1, // PCM, each sample of size bytes_per_sample
22 kWavFormatALaw = 6, // 8-bit ITU-T G.711 A-law
23 kWavFormatMuLaw = 7, // 8-bit ITU-T G.711 mu-law
24};
25
26// Return true if the given parameters will make a well-formed WAV header.
27bool CheckWavParameters(int num_channels,
28 int sample_rate,
29 WavFormat format,
30 int bytes_per_sample,
31 uint32_t num_samples);
32
33// Write a kWavHeaderSize bytes long WAV header to buf. The payload that
34// follows the header is supposed to have the specified number of interleaved
35// channels and contain the specified total number of samples of the specified
36// type.
37void WriteWavHeader(uint8_t* buf,
38 int num_channels,
39 int sample_rate,
40 WavFormat format,
41 int bytes_per_sample,
42 uint32_t num_samples);
43
44} // namespace webrtc
45
46#endif // WEBRTC_COMMON_AUDIO_WAV_HEADER_H_