Receiver#createStream should take options

This commit is contained in:
Amish Shah
2018-01-19 22:38:10 +00:00
parent 2c1a302eea
commit 4a1b55d145
2 changed files with 2 additions and 8 deletions

View File

@@ -10,12 +10,12 @@ class VoiceReceiver extends EventEmitter {
this.connection.sockets.udp.socket.on('message', buffer => this.packets.push(buffer));
}
createStream(user, pcm=false) {
createStream(user, { mode = 'opus' } = {}) {
user = this.connection.client.users.resolve(user);
if (!user) throw new Error('VOICE_USER_MISSING');
console.log('making stream for', user.tag);
const stream = this.packets.makeStream(user.id);
if (pcm) {
if (mode === 'pcm') {
const decoder = new prism.opus.Decoder({ channels: 2, rate: 48000, frameSize: 1920 });
stream.pipe(decoder);
return decoder;

View File

@@ -3,15 +3,9 @@ const { Readable } = require('stream');
class VoiceReadable extends Readable {
constructor() {
super();
this._packets = [];
this.open = true;
}
_read() {} // eslint-disable-line no-empty-function
_push(d) {
if (this.open) this.push(d);
}
}
module.exports = VoiceReadable;