Changes to compile service. Service args added

This commit is contained in:
devl0rd 2020-04-15 18:13:44 -06:00
parent 0e26503625
commit 32d9285081
15 changed files with 51 additions and 25 deletions

View file

@ -0,0 +1,5 @@
@echo off
Title Building...
Echo Building...
nexe main.js -o "./NxStreamingService.exe"
pause

Binary file not shown.

View file

@ -0,0 +1,4 @@
@echo off
cls
npm start main.js /ip 172.16.0.10 /q 10
pause

View file

@ -9,14 +9,15 @@ const VGen = require("vgen-xbox")
const vgen = new VGen();
const cc = require('./Devlord_modules/conColors.js');
const cs = require('./Devlord_modules/conSplash.js');
var ip = "0.0.0.0"
var quality = 5;
var screenSize = robot.getScreenSize();
var sheight = screenSize.height;
var swidth = screenSize.width;
var hidStreamClient = new net.Socket();
function connect(address) {
function connect() {
hidStreamClient.connect({
host: "172.16.0.10",
host: ip,
port: 2223
});
}
@ -31,8 +32,7 @@ hidStreamClient.on('error', function (ex) {
setTimeout(connect, 1000);
}
});
hidStreamClient.on('connect', function () {
console.log('Connected to Switch!');
function plugControllerIn() {
try {
// Try plugging in first controller
controllerId = vgen.pluginNext();
@ -40,23 +40,28 @@ hidStreamClient.on('connect', function () {
catch (e) {
// Exception most probably due to drivers not installed
vgen.installDriver(() => {
vgen.plugin(controllerId);
setTimeout(plugControllerIn, 1000);
});
}
}
hidStreamClient.on('connect', function () {
console.log('Connected to Switch!');
plugControllerIn();
ffmpegProcess = spawn(
"./ffmpeg.exe",
["-probesize", "10M", "-f", "gdigrab", "-framerate", "60", "-video_size", swidth + "x" + sheight, "-offset_x", "0", "-offset_y", "0", "-i", "desktop", "-f", "h264", "-vf", "scale=1280x720", "-preset", "ultrafast", "-tune", "zerolatency", "-pix_fmt", "yuv420p", "-profile:v", "baseline", "-x264-params", "\"nal-hrd=cbr\"", "-b:v", "5M", "-minrate", "5M", "-maxrate", "5M", "-bufsize", "2M", "tcp://172.16.0.10:2222"],
"./lib/ffmpeg.exe",
["-probesize", "10M", "-f", "gdigrab", "-framerate", "60", "-video_size", swidth + "x" + sheight, "-offset_x", "0", "-offset_y", "0", "-i", "desktop", "-f", "h264", "-vf", "scale=1280x720", "-preset", "ultrafast", "-tune", "zerolatency", "-pix_fmt", "yuv420p", "-profile:v", "baseline", "-x264-params", "\"nal-hrd=cbr\"", "-b:v", quality + "M", "-minrate", quality + "M", "-maxrate", quality + "M", "-bufsize", "2M", "tcp://" + ip + ":2222"],
{ stdio: "pipe" }
);
ffmpegProcess.stdout.on("data", chunk => {
});
ffmpegProcess.stderr.on('data', (data) => {
//console.error(`stderr: ${data}`);
});
ffmpegProcess.on('close', (code) => {
console.log(`ffmpegProcess process exited with code ${code}`);
});
@ -64,22 +69,19 @@ hidStreamClient.on('connect', function () {
ffmpegAudioProcess = spawn(
"./ffmpeg.exe",
["-y", "-f", "dshow", "-i", "audio=virtual-audio-capturer", "-f", "s16le", "-ar", "16000", "-ac", "2", "-c:a", "pcm_s16le", "udp://172.16.0.10:2224?pkt_size=640"],
"./lib/ffmpeg.exe",
["-y", "-f", "dshow", "-i", "audio=virtual-audio-capturer", "-f", "s16le", "-ar", "16000", "-ac", "2", "-c:a", "pcm_s16le", "udp://" + ip + ":2224?pkt_size=640"],
{ stdio: "pipe" }
);
ffmpegAudioProcess.stdout.on("data", chunk => {
//videoStreamClient.write(chunk);
});
ffmpegAudioProcess.stderr.on('data', (data) => {
//console.error(`stderr: ${data}`);
});
ffmpegAudioProcess.on('close', (code) => {
console.log(`ffmpegAudioProcess process exited with code ${code}`);
});
});
var switchHidBuffer = new Buffer.alloc(0);
function parseInputStruct(buff) {
@ -275,11 +277,26 @@ hidStreamClient.on('end', function () {
connect();
});
connect();
module.exports.init = connect
var args = process.argv.slice(" ");
if (args.length > 1) {
if (args.includes("/ip") && args[args.indexOf("/ip") + 1]) {
ip = args[args.indexOf("/ip") + 1];
console.log('Waiting for connection...');
if (args.includes("/q") && args[args.indexOf("/q") + 1]) {
quality = args[args.indexOf("/q") + 1];
} else {
console.log('Error: Usage NXStreamer.exe ip 0.0.0.0 q 5');
}
connect();
} else {
console.log('Error: Usage NXStreamer.exe ip 0.0.0.0 q 5');
}
} else {
}
console.log(args[args.indexOf("/ip") + 1]);

View file

@ -16,5 +16,9 @@
},
"scripts": {
"start": "node main.js"
},
"pkg": {
"scripts": "node_modules/**/*",
"assets": "lib/**/*"
}
}
}

View file

@ -1,4 +0,0 @@
@echo off
cls
npm start
pause