1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-12-23 16:13:18 +00:00
musix-oss/node_modules/prism-media/src/transcoders/MediaTranscoder.js
MatteZ02 5eb0264906 fix
2019-05-30 12:06:47 +03:00

32 lines
916 B
JavaScript

const Ffmpeg = require('./ffmpeg/Ffmpeg');
const transcoders = [
'ffmpeg',
];
class MediaTranscoder {
constructor(prism) {
this.prism = prism;
this.ffmpeg = new Ffmpeg(this);
}
static verifyOptions(options) {
if (!options) throw new Error('Options must be passed to MediaTranscoder.transcode()');
if (!options.type) throw new Error('Options.type must be passed to MediaTranscoder.transcode()');
if (!transcoders.includes(options.type)) throw new Error(`Options.type must be: ${transcoders.join(' ')}`);
return options;
}
/**
* Transcodes a media stream based on specified options
* @param {Object} options the options to use when transcoding
* @returns {ReadableStream} the transcodeed stream
*/
transcode(options) {
options = MediaTranscoder.verifyOptions(options);
return this[options.type].transcode(options);
}
}
module.exports = MediaTranscoder;