rebuilt files

This commit is contained in:
Amish Shah
2015-11-22 15:01:42 +00:00
parent cf33df18cf
commit 68b60c5464
27 changed files with 1023 additions and 1746 deletions

View File

@@ -1,7 +1,5 @@
"use strict";
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var cpoc = require("child_process");
var opus;
@@ -12,41 +10,26 @@ try {
}
var VoicePacket = require("./VoicePacket.js");
var AudioEncoder = (function () {
function AudioEncoder() {
_classCallCheck(this, AudioEncoder);
class AudioEncoder {
constructor() {
if (opus) {
this.opus = new opus.OpusEncoder(48000, 1);
}
this.choice = false;
}
AudioEncoder.prototype.opusBuffer = function opusBuffer(buffer) {
opusBuffer(buffer) {
return this.opus.encode(buffer, 1920);
};
}
AudioEncoder.prototype.getCommand = function getCommand(force) {
getCommand(force) {
if (this.choice && force) return choice;
var choices = ["avconv", "ffmpeg"];
for (var _iterator = choices, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
var choice = _ref;
for (var choice of choices) {
var p = cpoc.spawnSync(choice);
if (!p.error) {
this.choice = choice;
@@ -55,13 +38,11 @@ var AudioEncoder = (function () {
}
return "help";
};
AudioEncoder.prototype.encodeStream = function encodeStream(stream) {
var callback = arguments.length <= 1 || arguments[1] === undefined ? function (err, buffer) {} : arguments[1];
}
encodeStream(stream, callback = function (err, buffer) {}) {
var self = this;
return new Promise(function (resolve, reject) {
return new Promise((resolve, reject) => {
var enc = cpoc.spawn(self.getCommand(), ["-f", "s16le", "-ar", "48000", "-ac", "1", // this can be 2 but there's no point, discord makes it mono on playback, wasted bandwidth.
"-af", "volume=1", "pipe:1", "-i", "-"]);
@@ -90,13 +71,11 @@ var AudioEncoder = (function () {
reject("close");
});
});
};
AudioEncoder.prototype.encodeFile = function encodeFile(file) {
var callback = arguments.length <= 1 || arguments[1] === undefined ? function (err, buffer) {} : arguments[1];
}
encodeFile(file, callback = function (err, buffer) {}) {
var self = this;
return new Promise(function (resolve, reject) {
return new Promise((resolve, reject) => {
var enc = cpoc.spawn(self.getCommand(), ["-f", "s16le", "-ar", "48000", "-ac", "1", // this can be 2 but there's no point, discord makes it mono on playback, wasted bandwidth.
"-af", "volume=1", "pipe:1", "-i", file]);
@@ -121,9 +100,7 @@ var AudioEncoder = (function () {
reject("close");
});
});
};
return AudioEncoder;
})();
}
}
module.exports = AudioEncoder;