diff options
Diffstat (limited to 'common_audio/wav_header.h')
-rw-r--r-- | common_audio/wav_header.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/common_audio/wav_header.h b/common_audio/wav_header.h index f9ed8a57..37f78a6f 100644 --- a/common_audio/wav_header.h +++ b/common_audio/wav_header.h @@ -11,11 +11,12 @@ #ifndef WEBRTC_COMMON_AUDIO_WAV_HEADER_H_ #define WEBRTC_COMMON_AUDIO_WAV_HEADER_H_ +#include <stddef.h> #include <stdint.h> namespace webrtc { -static const int kWavHeaderSize = 44; +static const size_t kWavHeaderSize = 44; enum WavFormat { kWavFormatPcm = 1, // PCM, each sample of size bytes_per_sample @@ -33,7 +34,7 @@ bool CheckWavParameters(int num_channels, // Write a kWavHeaderSize bytes long WAV header to buf. The payload that // follows the header is supposed to have the specified number of interleaved // channels and contain the specified total number of samples of the specified -// type. +// type. CHECKs the input parameters for validity. void WriteWavHeader(uint8_t* buf, int num_channels, int sample_rate, @@ -41,6 +42,15 @@ void WriteWavHeader(uint8_t* buf, int bytes_per_sample, uint32_t num_samples); +// Read a kWavHeaderSize bytes long WAV header from buf and parse the values +// into the provided output parameters. Returns false if the header is invalid. +bool ReadWavHeader(const uint8_t* buf, + int* num_channels, + int* sample_rate, + WavFormat* format, + int* bytes_per_sample, + uint32_t* num_samples); + } // namespace webrtc #endif // WEBRTC_COMMON_AUDIO_WAV_HEADER_H_ |