-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
90 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* eslint-disable */ | ||
|
||
const fs = require('fs'); | ||
const prism = require('../'); | ||
const { promisify } = require('util'); | ||
const readFile = promisify(fs.readFile); | ||
const { roughlyEquals, streamToBuffer } = require('./util'); | ||
|
||
test('FFmpeg transcoder available', () => { | ||
expect(prism.FFmpeg).toBeTruthy(); | ||
}); | ||
|
||
test('FFmpeg transcoder to PCM is sane', async done => { | ||
expect.assertions(1); | ||
const output = fs.createReadStream('./test/audio/speech_orig.ogg') | ||
.pipe(new prism.FFmpeg({ | ||
args: [ | ||
'-analyzeduration', '0', | ||
'-loglevel', '0', | ||
'-f', 's16le', | ||
'-ar', '48000', | ||
'-ac', '2', | ||
], | ||
})); | ||
const chunks = await streamToBuffer(output); | ||
const file = await readFile('./test/audio/speech_orig.pcm'); | ||
expect(roughlyEquals(file, chunks)).toEqual(true); | ||
done(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* eslint-disable */ | ||
|
||
const fs = require('fs'); | ||
const prism = require('../'); | ||
const { promisify } = require('util'); | ||
const readFile = promisify(fs.readFile); | ||
const { roughlyEquals, streamToBuffer } = require('./util'); | ||
|
||
test('OggOpus Demuxer available', () => { | ||
expect(prism.OggOpusDemuxer).toBeTruthy(); | ||
}); | ||
|
||
test('WebmOpus Demuxer available', () => { | ||
expect(prism.WebmOpusDemuxer).toBeTruthy(); | ||
expect(prism.WebmOpusDemuxer.TOO_SHORT).toBeTruthy(); | ||
expect(prism.WebmOpusDemuxer.TAGS).toBeTruthy(); | ||
}); | ||
|
||
test('Opus encoders/decoders available', () => { | ||
expect(prism.opus).toBeTruthy(); | ||
expect(prism.opus.Encoder).toBeTruthy(); | ||
expect(prism.opus.Decoder).toBeTruthy(); | ||
}); | ||
|
||
test('OggOpus demuxer is sane', async done => { | ||
expect.assertions(1); | ||
const output = fs.createReadStream('./test/audio/speech_orig.ogg').pipe(new prism.OggOpusDemuxer()); | ||
const chunks = await streamToBuffer(output); | ||
const file = await readFile('./test/audio/speech_orig.opusdump'); | ||
expect(roughlyEquals(file, chunks)).toEqual(true); | ||
done(); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// The output is slightly different on travis because of ffmpeg version, should account for it | ||
exports.roughlyEquals = function roughlyEquals(x, y) { | ||
if (x.length !== y.length) return false; | ||
for (let i = 0; i < x.length; i++) { | ||
if (Math.abs(x[i] - y[i]) > 1) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}; | ||
|
||
exports.streamToBuffer = function streamToBuffer(stream) { | ||
return new Promise((resolve, reject) => { | ||
let chunks = []; | ||
stream.on('data', chunk => chunks.push(chunk)); | ||
stream.on('error', reject); | ||
stream.on('end', () => resolve(Buffer.concat(chunks))); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* eslint-disable */ | ||
|
||
const prism = require('../'); | ||
|
||
test('Volume Transformers available', () => { | ||
expect(prism.VolumeTransformer16LE).toBeTruthy(); | ||
expect(prism.VolumeTransformer16BE).toBeTruthy(); | ||
expect(prism.VolumeTransformer32LE).toBeTruthy(); | ||
expect(prism.VolumeTransformer32BE).toBeTruthy(); | ||
}); |