OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 } | 93 } |
94 // Make sure that sample rate is 8,16 or 32 kHz. E.g. WAVE files may have | 94 // Make sure that sample rate is 8,16 or 32 kHz. E.g. WAVE files may have |
95 // other sampling rates. | 95 // other sampling rates. |
96 if (_codec.plfreq == 11000) { | 96 if (_codec.plfreq == 11000) { |
97 return 16000; | 97 return 16000; |
98 } else if (_codec.plfreq == 22000) { | 98 } else if (_codec.plfreq == 22000) { |
99 return 32000; | 99 return 32000; |
100 } else if (_codec.plfreq == 44000) { | 100 } else if (_codec.plfreq == 44000) { |
101 return 32000; | 101 return 32000; |
102 } else if (_codec.plfreq == 48000) { | 102 } else if (_codec.plfreq == 48000) { |
103 return 32000; | 103 return 48000; |
104 } else { | 104 } else { |
105 return _codec.plfreq; | 105 return _codec.plfreq; |
106 } | 106 } |
107 } | 107 } |
108 | 108 |
109 int32_t FilePlayerImpl::AudioCodec(CodecInst* audioCodec) const { | 109 int32_t FilePlayerImpl::AudioCodec(CodecInst* audioCodec) const { |
110 *audioCodec = _codec; | 110 *audioCodec = _codec; |
111 return 0; | 111 return 0; |
112 } | 112 } |
113 | 113 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 _fileFormat == kFileFormatPcm32kHzFile) { | 213 _fileFormat == kFileFormatPcm32kHzFile) { |
214 CodecInst codecInstL16; | 214 CodecInst codecInstL16; |
215 strncpy(codecInstL16.plname, "L16", 32); | 215 strncpy(codecInstL16.plname, "L16", 32); |
216 codecInstL16.pltype = 93; | 216 codecInstL16.pltype = 93; |
217 codecInstL16.channels = 1; | 217 codecInstL16.channels = 1; |
218 | 218 |
219 if (_fileFormat == kFileFormatPcm8kHzFile) { | 219 if (_fileFormat == kFileFormatPcm8kHzFile) { |
220 codecInstL16.rate = 128000; | 220 codecInstL16.rate = 128000; |
221 codecInstL16.plfreq = 8000; | 221 codecInstL16.plfreq = 8000; |
222 codecInstL16.pacsize = 80; | 222 codecInstL16.pacsize = 80; |
223 | |
224 } else if (_fileFormat == kFileFormatPcm16kHzFile) { | 223 } else if (_fileFormat == kFileFormatPcm16kHzFile) { |
225 codecInstL16.rate = 256000; | 224 codecInstL16.rate = 256000; |
226 codecInstL16.plfreq = 16000; | 225 codecInstL16.plfreq = 16000; |
227 codecInstL16.pacsize = 160; | 226 codecInstL16.pacsize = 160; |
228 | |
229 } else if (_fileFormat == kFileFormatPcm32kHzFile) { | 227 } else if (_fileFormat == kFileFormatPcm32kHzFile) { |
230 codecInstL16.rate = 512000; | 228 codecInstL16.rate = 512000; |
231 codecInstL16.plfreq = 32000; | 229 codecInstL16.plfreq = 32000; |
232 codecInstL16.pacsize = 160; | 230 codecInstL16.pacsize = 320; |
| 231 } else if (_fileFormat == kFileFormatPcm48kHzFile) { |
| 232 codecInstL16.rate = 768000; |
| 233 codecInstL16.plfreq = 48000; |
| 234 codecInstL16.pacsize = 480; |
233 } else { | 235 } else { |
234 LOG(LS_ERROR) << "StartPlayingFile() sample frequency not " | 236 LOG(LS_ERROR) << "StartPlayingFile() sample frequency not " |
235 << "supported for PCM format."; | 237 << "supported for PCM format."; |
236 return -1; | 238 return -1; |
237 } | 239 } |
238 | 240 |
239 if (_fileModule.StartPlayingAudioFile(fileName, notification, loop, | 241 if (_fileModule.StartPlayingAudioFile(fileName, notification, loop, |
240 _fileFormat, &codecInstL16, | 242 _fileFormat, &codecInstL16, |
241 startPosition, stopPosition) == -1) { | 243 startPosition, stopPosition) == -1) { |
242 LOG(LS_WARNING) << "StartPlayingFile() failed to initialize " | 244 LOG(LS_WARNING) << "StartPlayingFile() failed to initialize " |
(...skipping 27 matching lines...) Expand all Loading... |
270 } | 272 } |
271 | 273 |
272 int32_t FilePlayerImpl::StartPlayingFile(InStream* sourceStream, | 274 int32_t FilePlayerImpl::StartPlayingFile(InStream* sourceStream, |
273 uint32_t startPosition, | 275 uint32_t startPosition, |
274 float volumeScaling, | 276 float volumeScaling, |
275 uint32_t notification, | 277 uint32_t notification, |
276 uint32_t stopPosition, | 278 uint32_t stopPosition, |
277 const CodecInst* codecInst) { | 279 const CodecInst* codecInst) { |
278 if (_fileFormat == kFileFormatPcm16kHzFile || | 280 if (_fileFormat == kFileFormatPcm16kHzFile || |
279 _fileFormat == kFileFormatPcm32kHzFile || | 281 _fileFormat == kFileFormatPcm32kHzFile || |
280 _fileFormat == kFileFormatPcm8kHzFile) { | 282 _fileFormat == kFileFormatPcm8kHzFile || |
| 283 _fileFormat == kFileFormatPcm48kHzFile) { |
281 CodecInst codecInstL16; | 284 CodecInst codecInstL16; |
282 strncpy(codecInstL16.plname, "L16", 32); | 285 strncpy(codecInstL16.plname, "L16", 32); |
283 codecInstL16.pltype = 93; | 286 codecInstL16.pltype = 93; |
284 codecInstL16.channels = 1; | 287 codecInstL16.channels = 1; |
285 | 288 |
286 if (_fileFormat == kFileFormatPcm8kHzFile) { | 289 if (_fileFormat == kFileFormatPcm8kHzFile) { |
287 codecInstL16.rate = 128000; | 290 codecInstL16.rate = 128000; |
288 codecInstL16.plfreq = 8000; | 291 codecInstL16.plfreq = 8000; |
289 codecInstL16.pacsize = 80; | 292 codecInstL16.pacsize = 80; |
290 | |
291 } else if (_fileFormat == kFileFormatPcm16kHzFile) { | 293 } else if (_fileFormat == kFileFormatPcm16kHzFile) { |
292 codecInstL16.rate = 256000; | 294 codecInstL16.rate = 256000; |
293 codecInstL16.plfreq = 16000; | 295 codecInstL16.plfreq = 16000; |
294 codecInstL16.pacsize = 160; | 296 codecInstL16.pacsize = 160; |
295 | |
296 } else if (_fileFormat == kFileFormatPcm32kHzFile) { | 297 } else if (_fileFormat == kFileFormatPcm32kHzFile) { |
297 codecInstL16.rate = 512000; | 298 codecInstL16.rate = 512000; |
298 codecInstL16.plfreq = 32000; | 299 codecInstL16.plfreq = 32000; |
299 codecInstL16.pacsize = 160; | 300 codecInstL16.pacsize = 320; |
| 301 } else if (_fileFormat == kFileFormatPcm48kHzFile) { |
| 302 codecInstL16.rate = 768000; |
| 303 codecInstL16.plfreq = 48000; |
| 304 codecInstL16.pacsize = 480; |
300 } else { | 305 } else { |
301 LOG(LS_ERROR) << "StartPlayingFile() sample frequency not " | 306 LOG(LS_ERROR) << "StartPlayingFile() sample frequency not " |
302 << "supported for PCM format."; | 307 << "supported for PCM format."; |
303 return -1; | 308 return -1; |
304 } | 309 } |
305 if (_fileModule.StartPlayingAudioStream( | 310 if (_fileModule.StartPlayingAudioStream( |
306 *sourceStream, notification, _fileFormat, &codecInstL16, | 311 *sourceStream, notification, _fileFormat, &codecInstL16, |
307 startPosition, stopPosition) == -1) { | 312 startPosition, stopPosition) == -1) { |
308 LOG(LS_ERROR) << "StartPlayingFile() failed to initialize stream " | 313 LOG(LS_ERROR) << "StartPlayingFile() failed to initialize stream " |
309 << "playout."; | 314 << "playout."; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 std::unique_ptr<FilePlayer> FilePlayer::CreateFilePlayer( | 377 std::unique_ptr<FilePlayer> FilePlayer::CreateFilePlayer( |
373 uint32_t instanceID, | 378 uint32_t instanceID, |
374 FileFormats fileFormat) { | 379 FileFormats fileFormat) { |
375 switch (fileFormat) { | 380 switch (fileFormat) { |
376 case kFileFormatWavFile: | 381 case kFileFormatWavFile: |
377 case kFileFormatCompressedFile: | 382 case kFileFormatCompressedFile: |
378 case kFileFormatPreencodedFile: | 383 case kFileFormatPreencodedFile: |
379 case kFileFormatPcm16kHzFile: | 384 case kFileFormatPcm16kHzFile: |
380 case kFileFormatPcm8kHzFile: | 385 case kFileFormatPcm8kHzFile: |
381 case kFileFormatPcm32kHzFile: | 386 case kFileFormatPcm32kHzFile: |
| 387 case kFileFormatPcm48kHzFile: |
382 // audio formats | 388 // audio formats |
383 return std::unique_ptr<FilePlayer>( | 389 return std::unique_ptr<FilePlayer>( |
384 new FilePlayerImpl(instanceID, fileFormat)); | 390 new FilePlayerImpl(instanceID, fileFormat)); |
385 default: | 391 default: |
386 assert(false); | 392 assert(false); |
387 return nullptr; | 393 return nullptr; |
388 } | 394 } |
389 } | 395 } |
390 | 396 |
391 } // namespace webrtc | 397 } // namespace webrtc |
OLD | NEW |