mirror of
https://github.com/discordjs/discord.js.git
synced 2024-08-21 08:24:42 +12:00
Add opusscript as a possible opus encoder (#558)
* Add opusscript as a possible opus encoder * Make weird eslint rule happy
This commit is contained in:
parent
a959cd339c
commit
ac7e1a052c
4 changed files with 32 additions and 2 deletions
|
@ -35,7 +35,8 @@
|
|||
"fs-extra": "^0.30.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"node-opus": "^0.1.13"
|
||||
"node-opus": "^0.1.13",
|
||||
"opusscript": "^0.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.12.7"
|
||||
|
|
|
@ -20,7 +20,7 @@ class NodeOpusEngine extends OpusEngine {
|
|||
}
|
||||
|
||||
decode(buffer) {
|
||||
super.encode(buffer);
|
||||
super.decode(buffer);
|
||||
return this.encoder.decode(buffer, 1920);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
const list = [
|
||||
require('./NodeOpusEngine'),
|
||||
require('./OpusScriptEngine'),
|
||||
];
|
||||
|
||||
exports.add = encoder => {
|
||||
|
|
28
src/client/voice/opus/OpusScriptEngine.js
Normal file
28
src/client/voice/opus/OpusScriptEngine.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
const OpusEngine = require('./BaseOpusEngine');
|
||||
|
||||
let Opusscript;
|
||||
|
||||
class NodeOpusEngine extends OpusEngine {
|
||||
constructor(player) {
|
||||
super(player);
|
||||
try {
|
||||
// eslint-disable-next-line import/no-unresolved
|
||||
Opusscript = require('opusscript');
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
this.encoder = new Opusscript(48000, 2);
|
||||
}
|
||||
|
||||
encode(buffer) {
|
||||
super.encode(buffer);
|
||||
return this.encoder.encode(buffer, 960);
|
||||
}
|
||||
|
||||
decode(buffer) {
|
||||
super.decode(buffer);
|
||||
return this.encoder.decode(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = NodeOpusEngine;
|
Loading…
Reference in a new issue