Home | History | Annotate | Download | only in common_audio
      1 /*
      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 
     16 namespace webrtc {
     17 
     18 static const int kWavHeaderSize = 44;
     19 
     20 enum 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.
     27 bool 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.
     37 void 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_
     47