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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 static inline uint16_t BlockAlign(int num_channels, int bytes_per_sample) { | 144 static inline uint16_t BlockAlign(int num_channels, int bytes_per_sample) { |
145 return num_channels * bytes_per_sample; | 145 return num_channels * bytes_per_sample; |
146 } | 146 } |
147 | 147 |
148 void WriteWavHeader(uint8_t* buf, | 148 void WriteWavHeader(uint8_t* buf, |
149 int num_channels, | 149 int num_channels, |
150 int sample_rate, | 150 int sample_rate, |
151 WavFormat format, | 151 WavFormat format, |
152 int bytes_per_sample, | 152 int bytes_per_sample, |
153 uint32_t num_samples) { | 153 uint32_t num_samples) { |
154 CHECK(CheckWavParameters(num_channels, sample_rate, format, | 154 RTC_CHECK(CheckWavParameters(num_channels, sample_rate, format, |
155 bytes_per_sample, num_samples)); | 155 bytes_per_sample, num_samples)); |
156 | 156 |
157 WavHeader header; | 157 WavHeader header; |
158 const uint32_t bytes_in_payload = bytes_per_sample * num_samples; | 158 const uint32_t bytes_in_payload = bytes_per_sample * num_samples; |
159 | 159 |
160 WriteFourCC(&header.riff.header.ID, 'R', 'I', 'F', 'F'); | 160 WriteFourCC(&header.riff.header.ID, 'R', 'I', 'F', 'F'); |
161 WriteLE32(&header.riff.header.Size, RiffChunkSize(bytes_in_payload)); | 161 WriteLE32(&header.riff.header.Size, RiffChunkSize(bytes_in_payload)); |
162 WriteFourCC(&header.riff.Format, 'W', 'A', 'V', 'E'); | 162 WriteFourCC(&header.riff.Format, 'W', 'A', 'V', 'E'); |
163 | 163 |
164 WriteFourCC(&header.fmt.header.ID, 'f', 'm', 't', ' '); | 164 WriteFourCC(&header.fmt.header.ID, 'f', 'm', 't', ' '); |
165 WriteLE32(&header.fmt.header.Size, kFmtSubchunkSize); | 165 WriteLE32(&header.fmt.header.Size, kFmtSubchunkSize); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 if (ReadLE16(header.fmt.BlockAlign) != | 233 if (ReadLE16(header.fmt.BlockAlign) != |
234 BlockAlign(*num_channels, *bytes_per_sample)) | 234 BlockAlign(*num_channels, *bytes_per_sample)) |
235 return false; | 235 return false; |
236 | 236 |
237 return CheckWavParameters(*num_channels, *sample_rate, *format, | 237 return CheckWavParameters(*num_channels, *sample_rate, *format, |
238 *bytes_per_sample, *num_samples); | 238 *bytes_per_sample, *num_samples); |
239 } | 239 } |
240 | 240 |
241 | 241 |
242 } // namespace webrtc | 242 } // namespace webrtc |
OLD | NEW |