| | |
| | | let traceId = null |
| | | let turnId = null |
| | | const supportedAudioFormats = new Set(['pcm_s16le', 'mp3', 'mpeg', 'wav']) |
| | | const supportedPcmSampleRates = new Set([16000, 48000]) |
| | | |
| | | function fail(message) { |
| | | console.error(`turn stream fixture invalid: ${message}`) |
| | |
| | | fail(`${chunk.format} payload must be non-empty`) |
| | | } |
| | | if (chunk.format === 'pcm_s16le') { |
| | | if (chunk.sampleRate !== 48000 || chunk.channels !== 1) { |
| | | fail('pcm_s16le chunk must be 48000Hz mono') |
| | | if (!supportedPcmSampleRates.has(chunk.sampleRate) || chunk.channels !== 1) { |
| | | fail('pcm_s16le chunk must be 16000Hz or 48000Hz mono') |
| | | } |
| | | if (payload.length % 2 !== 0) { |
| | | fail('pcm_s16le payload must be 16-bit aligned') |