This commit is contained in:
Valentin Boettcher 2017-08-08 01:13:18 +02:00
parent c766f6605e
commit 5173407f84
67 changed files with 79 additions and 19781 deletions

View file

@ -1,19 +0,0 @@
///////////////////////////////////////////////////////////////////////////////
// A socket.js wrapper to abstract the communication with the server. //
///////////////////////////////////////////////////////////////////////////////
const socketio = require('socket.io-client');
///////////////////////////////////////////////////////////////////////////////
// Declarations //
///////////////////////////////////////////////////////////////////////////////
// Object oriented `this`.
let self = false;
///////////////////////////////////////////////////////////////////////////////
// Code //
///////////////////////////////////////////////////////////////////////////////
module.exports = function Communicator(){};

View file

@ -1,23 +0,0 @@
x = require('node-ipc');
//x.config.silent = true;
x.connectTo('ssh-man', function() {
x.of['ssh-man'].on('connect', function() {
let id = (new Date()).getTime();
x.of['ssh-man'].on('success' + id, (data) => {
console.log(data);)
}); x.of['ssh-man'].emit('create_tunnel', {
host: 'cams.doc.govt.nz',
id: id,
username: 'ssh',
sshPort: 54533,
localPort: 8080,
reverse: true,
privateKey: '~/.ssh/test',
serverAliveInterval: 5,
remotePort: 9999,
reverse: true
}, () => {
console.log("here")
});
});
});

4
.gitignore vendored
View file

@ -1,5 +1,9 @@
logs
out
config.js config.js
node_modules node_modules
process.log process.log
process.log.* process.log.*
ssh.pid ssh.pid
#*#
*~

View file

@ -1,18 +0,0 @@
///////////////////////////////////////////////////////////////////////////////
// A socket.js wrapper to abstract the communication with the server. //
///////////////////////////////////////////////////////////////////////////////
const socketio = require('socket.io-client');
///////////////////////////////////////////////////////////////////////////////
// Declarations //
///////////////////////////////////////////////////////////////////////////////
// Object oriented `this`.
let self = false;
///////////////////////////////////////////////////////////////////////////////
// Code //
///////////////////////////////////////////////////////////////////////////////
module.exports = function Communicator(){}

View file

@ -1,21 +0,0 @@
{
"camIP": "mpv.cdn3.bigCDN.com:554",
"camPort": 554,
"camPanelPort": 80,
"camProfile": "bigCDN/definst/mp4:bigbuckbunnyiphone_400.mp4",
"snapProfile": "video.pro1",
"key": "upjm-kz0g-c3wt-7zuj",
"name": "Uncdonfigured",
"master": "http://localhost:8080",
"sshMaster": "localhost",
"ffmpegPath": "ffmpeg",
"ssh": false,
"sshUser": "ssh",
"sshLocalUser": "alarm",
"sshPort": 22,
"customOutputOptions": "",
"customVideoOptions": "",
"customAudioOptions": "-b:a 128k -ac 1 -ar 11025 -acodec libmp3lame",
"configured": true,
"ssh": true
}

View file

@ -1,119 +0,0 @@
/**
* An SSH Manager to control the SSH tunnels to the master server.
* The manager communicates over an IPC socket with the name 'sshManager'.
*/
const ipc = require('node-ipc');
const autossh = require('autossh');
///////////////////////////////////////////////////////////////////////////////
// Declarations //
///////////////////////////////////////////////////////////////////////////////
/**
* SSH Tunnels in the format: [port] : [autossh instance].
*/
const tunnels = {};
// IPC Setup
ipc.config.id = 'sshManager';
ipc.config.retry = 1500;
ipc.config.silent = true;
ipc.serve();
const server = ipc.server;
///////////////////////////////////////////////////////////////////////////////
// Code //
///////////////////////////////////////////////////////////////////////////////
// Start the IPC Server
server.start();
/**
* The request handler to create a tunnel. Replies with an error and the remote port of the tunnel.
*/
server.on('create_tunnel', (data, socket) => {
let id = data.id;
let replySuccess = generateRelyFunction('success', socket, id);
let replyError = generateRelyFunction('error', socket, id);
let tunnel;
tunnel = tunnels[data.localPort];
// If the tunnel already runs:
if (tunnel && (tunnel.info.localHost === 'localhost' || tunnel.info.localHost === data.localHost)){
return replySuccess(tunnel.info.remotePort);
}
// Dummy for other request
tunnels[data.localPort] = {
info: {
localHost: data.localHost || 'localhost'
}
};
// Let's create a tunnel!
return createNewTunnel(data).then((tunnel) => {
tunnels[tunnel.info.localPort] = tunnel;
replySuccess(tunnel.info.remotePort);
}, (error) => {
console.log("error", error);
replyError(error);
delete tunnels[data.localPort];
});
});
/**
* The request handler to close a tunnel. The reply is {error: [message]} in case of an error, otherwise {success: true}.
*/
server.on('close_tunnel', ({port, id}, socket) => {
let replySuccess = generateRelyFunction('success', socket, id);
let replyError = generateRelyFunction('error', socket, id);
let error, tunnel;
tunnel = tunnels[port];
error = !tunnel;
if (error)
return replyError("No tunnel with this port.");
// Kill the tunnel and clean up.
tunnel.kill();
delete tunnels[port];
return replySuccess();
});
/**
* Utility
*/
function createNewTunnel(options) {
return new Promise((resolve, reject) => {
try {
let tunnel = autossh(options);
tunnel.on('connect', connection => {
// Wait for Exit // TODO: Nicer
setTimeout(() => resolve(tunnel), 1000);
});
tunnel.on('error', error => {
// If auto SSH or SSH itself issue an error. // TODO: Investigate
if(typeof error === 'string' || error.message && (error.message.indexOf("failed for listen port") > -1 || error.message.indexOf("refused") > -1)){
tunnel.kill();
reject(error.message || error);
}
return;
});
} catch (error) {
reject(error);
}
});
}
function generateRelyFunction(message, socket, id) {
return (data) => server.emit(socket, message + id, data);
}

46
grep
View file

@ -1,46 +0,0 @@
error: unknown option `ammend'
usage: git commit [<options>] [--] <pathspec>...
-q, --quiet suppress summary after successful commit
-v, --verbose show diff in commit message template
Commit message options
-F, --file <file> read message from file
--author <author> override author for commit
--date <date> override date for commit
-m, --message <message>
commit message
-c, --reedit-message <commit>
reuse and edit message from specified commit
-C, --reuse-message <commit>
reuse message from specified commit
--fixup <commit> use autosquash formatted message to fixup specified commit
--squash <commit> use autosquash formatted message to squash specified commit
--reset-author the commit is authored by me now (used with -C/-c/--amend)
-s, --signoff add Signed-off-by:
-t, --template <file>
use specified template file
-e, --edit force edit of commit
--cleanup <default> how to strip spaces and #comments from message
--status include status in commit message template
-S, --gpg-sign[=<key-id>]
GPG sign commit
Commit contents options
-a, --all commit all changed files
-i, --include add specified files to index for commit
--interactive interactively add files
-p, --patch interactively add changes
-o, --only commit only specified files
-n, --no-verify bypass pre-commit and commit-msg hooks
--dry-run show what would be committed
--short show status concisely
--branch show branch information
--porcelain machine-readable output
--long show status in long format (default)
-z, --null terminate entries with NUL
--amend amend previous commit
--no-post-rewrite bypass post-rewrite hook
-u, --untracked-files[=<mode>]
show untracked files, optional modes: all, normal, no. (Default: all)

View file

@ -1,474 +0,0 @@
{"level":"warning","message":"Trying to reconnect to: mpv.cdn3.bigCDN.com on port 5573.","timestamp":"2017-07-09T13:54:24.734Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-09T13:58:15.788Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-09T13:58:15.813Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-09T13:58:15.886Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-09T13:58:15.888Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-09T13:58:16.095Z"}
{"level":"info","message":"Setting SSH ports to [object Object]","timestamp":"2017-07-09T13:58:17.001Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-09T13:58:17.002Z"}
{"level":"danger","message":"An error has occured: Camera Disconnected\nSTDERR: ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers\n built with gcc 7.1.1 (GCC) 20170516\n configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-shared --enable-version3\n libavutil 55. 58.100 / 55. 58.100\n libavcodec 57. 89.100 / 57. 89.100\n libavformat 57. 71.100 / 57. 71.100\n libavdevice 57. 6.100 / 57. 6.100\n libavfilter 6. 82.100 / 6. 82.100\n libavresample 3. 5. 0 / 3. 5. 0\n libswscale 4. 6.100 / 4. 6.100\n libswresample 2. 7.100 / 2. 7.100\n libpostproc 54. 5.100 / 54. 5.100\n[tcp @ 0x55fe61d6a540] Connection to tcp://mpv.cdn3.bigCDN.com:5573?timeout=0 failed: Connection timed out\nrtsp://mpv.cdn3.bigCDN.com:5573/bigCDN/definst/mp4:bigbuckbunnyiphone_400.mp4: Connection timed out\n\n","timestamp":"2017-07-09T14:00:26.546Z"}
{"level":"warning","message":"Trying to reconnect to: mpv.cdn3.bigCDN.com on port 5573.","timestamp":"2017-07-09T14:00:26.549Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-09T14:02:24.737Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-09T14:02:24.788Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-09T14:02:24.851Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-09T14:02:24.852Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 42383","timestamp":"2017-07-09T14:02:24.975Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-09T14:02:24.985Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-09T14:02:25.018Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:04:58.226Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:04:58.251Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:04:58.388Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:05:35.816Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:05:35.817Z"}
{"level":"danger","message":"An (SSH) error has occured: Command failed: ssh -NR 10000:localhost:22 -o ExitOnForwardFailure=yes -o StrictHostKeyChecking=no -o ServerAliveInterval=30 -o ServerAliveCountMax=1 hiro@localhost\nstty: 'standard input': Inappropriate ioctl for device\n\u001b[91mcould not connect to remote: dial tcp [::1]:22: getsockopt: connection refused\u001b[0m\r\nssh_exchange_identification: Connection closed by remote host\r\n","timestamp":"2017-07-19T17:05:36.395Z"}
{"level":"warning","message":"Although the times are hard, we will try to reconnect the SSH tunels once the connection to the SSH-Manager is regained!","timestamp":"2017-07-19T17:05:41.709Z"}
{"level":"danger","message":"An (SSH) error has occured: Connection to SSH-Manager lost!","timestamp":"2017-07-19T17:05:41.710Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:05:51.727Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:05:53.757Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:05:53.757Z"}
{"level":"danger","message":"An error has occured: Camera Disconnected\nSTDERR: ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers\n built with gcc 7.1.1 (GCC) 20170516\n configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-shared --enable-version3\n libavutil 55. 58.100 / 55. 58.100\n libavcodec 57. 89.100 / 57. 89.100\n libavformat 57. 71.100 / 57. 71.100\n libavdevice 57. 6.100 / 57. 6.100\n libavfilter 6. 82.100 / 6. 82.100\n libavresample 3. 5. 0 / 3. 5. 0\n libswscale 4. 6.100 / 4. 6.100\n libswresample 2. 7.100 / 2. 7.100\n libpostproc 54. 5.100 / 54. 5.100\n[tcp @ 0x55f6908db540] Connection to tcp://mpv.cdn3.bigCDN.com:5573?timeout=0 failed: Connection timed out\nrtsp://mpv.cdn3.bigCDN.com:5573/bigCDN/definst/mp4:bigbuckbunnyiphone_400.mp4: Connection timed out\n\n","timestamp":"2017-07-19T17:07:13.230Z"}
{"level":"warning","message":"Trying to reconnect to: mpv.cdn3.bigCDN.com on port 5573.","timestamp":"2017-07-19T17:07:13.231Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:07:37.754Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:07:37.779Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:07:37.843Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:07:37.844Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:07:37.869Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:07:37.870Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:07:37.906Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:08:17.514Z"}
{"level":"warning","message":"Disconnected from the Master-Server.","timestamp":"2017-07-19T17:08:17.524Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:08:17.545Z"}
{"level":"warning","message":"SSH is disconnected","timestamp":"2017-07-19T17:08:28.096Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:08:53.515Z"}
{"level":"warning","message":"Disconnected from the Master-Server.","timestamp":"2017-07-19T17:08:53.520Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:08:53.537Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:08:53.537Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 45393","timestamp":"2017-07-19T17:08:55.661Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:08:55.662Z"}
{"level":"danger","message":"An error has occured: Camera Disconnected\nSTDERR: ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers\n built with gcc 7.1.1 (GCC) 20170516\n configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-shared --enable-version3\n libavutil 55. 58.100 / 55. 58.100\n libavcodec 57. 89.100 / 57. 89.100\n libavformat 57. 71.100 / 57. 71.100\n libavdevice 57. 6.100 / 57. 6.100\n libavfilter 6. 82.100 / 6. 82.100\n libavresample 3. 5. 0 / 3. 5. 0\n libswscale 4. 6.100 / 4. 6.100\n libswresample 2. 7.100 / 2. 7.100\n libpostproc 54. 5.100 / 54. 5.100\n[tcp @ 0x557b0cd37540] Connection to tcp://mpv.cdn3.bigCDN.com:5573?timeout=0 failed: Connection timed out\nrtsp://mpv.cdn3.bigCDN.com:5573/bigCDN/definst/mp4:bigbuckbunnyiphone_400.mp4: Connection timed out\n\n","timestamp":"2017-07-19T17:09:46.830Z"}
{"level":"warning","message":"Trying to reconnect to: mpv.cdn3.bigCDN.com on port 554.","timestamp":"2017-07-19T17:09:46.831Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:09:46.976Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:09:46.987Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:10:03.360Z"}
{"level":"warning","message":"Disconnected from the Master-Server.","timestamp":"2017-07-19T17:10:03.362Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:10:03.378Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:11:02.108Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:11:02.133Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:11:02.201Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:11:02.203Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:11:02.266Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 45393","timestamp":"2017-07-19T17:11:02.314Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:11:02.315Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:11:59.930Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:11:59.962Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:12:00.042Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:12:00.043Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:12:00.116Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 45393","timestamp":"2017-07-19T17:12:00.156Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:12:00.157Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:12:15.264Z"}
{"level":"warning","message":"Disconnected from the Master-Server.","timestamp":"2017-07-19T17:12:15.272Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:12:15.297Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:16:20.534Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:16:20.559Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:16:20.625Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:16:20.626Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:16:20.677Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 45393","timestamp":"2017-07-19T17:16:20.734Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:16:20.735Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:16:58.853Z"}
{"level":"warning","message":"Disconnected from the Master-Server.","timestamp":"2017-07-19T17:16:58.865Z"}
{"level":"warning","message":"SSH is disconnected","timestamp":"2017-07-19T17:16:58.884Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:16:58.885Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:16:58.900Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 43071","timestamp":"2017-07-19T17:17:01.015Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:17:01.016Z"}
{"level":"warning","message":"Although the times are hard, we will try to reconnect the SSH tunels once the connection to the SSH-Manager is regained!","timestamp":"2017-07-19T17:21:07.653Z"}
{"level":"danger","message":"An (SSH) error has occured: Connection to SSH-Manager lost!","timestamp":"2017-07-19T17:21:07.654Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:21:51.937Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:21:51.962Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:21:52.010Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:22:18.188Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:22:18.214Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:22:18.292Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:22:18.293Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:22:18.350Z"}
{"level":"warning","message":"Although the times are hard, we will try to reconnect the SSH tunels once the connection to the SSH-Manager is regained!","timestamp":"2017-07-19T17:22:18.726Z"}
{"level":"danger","message":"An (SSH) error has occured: Cannot connect to the SSH-Manager.","timestamp":"2017-07-19T17:22:18.728Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:23:23.910Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:23:23.935Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:23:23.993Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:23:23.994Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:23:24.059Z"}
{"level":"warning","message":"Although the times are hard, we will try to reconnect the SSH tunels once the connection to the SSH-Manager is regained!","timestamp":"2017-07-19T17:23:24.446Z"}
{"level":"danger","message":"An (SSH) error has occured: Cannot connect to the SSH-Manager.","timestamp":"2017-07-19T17:23:24.447Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:23:29.459Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:23:31.490Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:23:31.491Z"}
{"level":"warning","message":"SSH is disconnected","timestamp":"2017-07-19T17:23:35.290Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:23:35.291Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:23:37.304Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:23:37.304Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:25:10.279Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:25:10.303Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:25:10.366Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:25:10.367Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:25:10.434Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:25:10.476Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:25:10.477Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:25:24.369Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:25:24.393Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:25:24.480Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:25:24.481Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:25:24.495Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:25:24.495Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:25:24.526Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:25:47.835Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:25:47.865Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:25:47.937Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:25:47.938Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:25:48.007Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:25:48.049Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:25:48.049Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:26:40.872Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:26:40.896Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:26:40.957Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:26:40.958Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:26:41.019Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:26:41.065Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:26:41.065Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:27:13.233Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:27:13.266Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:27:13.343Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:27:13.344Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:27:13.417Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:27:13.452Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:27:13.452Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:27:30.030Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:27:30.054Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:27:30.130Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:27:30.131Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:27:30.160Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:27:30.238Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:27:30.239Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:29:11.389Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:29:11.413Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:29:11.474Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:29:11.475Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:29:11.544Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:29:11.587Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:29:11.587Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:30:31.537Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:30:31.568Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:30:31.635Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:30:31.637Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:30:31.700Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:30:31.743Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:30:31.744Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:30:40.591Z"}
{"level":"warning","message":"Disconnected from the Master-Server.","timestamp":"2017-07-19T17:30:40.602Z"}
{"level":"warning","message":"SSH is disconnected","timestamp":"2017-07-19T17:30:40.611Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:30:40.611Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:30:40.633Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:30:42.747Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:30:42.747Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:36:03.880Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:36:03.904Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:36:03.965Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:36:03.966Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:36:03.988Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:36:03.988Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:36:04.018Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:38:21.296Z"}
{"level":"warning","message":"Disconnected from the Master-Server.","timestamp":"2017-07-19T17:41:07.305Z"}
{"level":"warning","message":"SSH is disconnected","timestamp":"2017-07-19T17:41:07.356Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:41:07.359Z"}
{"level":"danger","message":"An error has occured: YoutTube Disconnected\nSTDERR: frame= 5474 fps= 24 q=-1.0 size= 9607kB time=00:03:48.00 bitrate= 345.2kbits/s speed=1.01x \nframe= 5486 fps= 24 q=-1.0 size= 9621kB time=00:03:48.50 bitrate= 344.9kbits/s speed=1.01x \nframe= 5498 fps= 24 q=-1.0 size= 9632kB time=00:03:49.00 bitrate= 344.6kbits/s speed=1.01x \nframe= 5510 fps= 24 q=-1.0 size= 9647kB time=00:03:49.50 bitrate= 344.4kbits/s speed=1.01x \nframe= 5523 fps= 24 q=-1.0 size= 9680kB time=00:03:50.04 bitrate= 344.7kbits/s speed=1.01x \nframe= 5534 fps= 24 q=-1.0 size= 9714kB time=00:03:50.50 bitrate= 345.2kbits/s speed=1.01x \nframe= 5545 fps= 24 q=-1.0 size= 9722kB time=00:03:50.95 bitrate= 344.8kbits/s speed=1.01x \nframe= 5558 fps= 24 q=-1.0 size= 9728kB time=00:03:51.50 bitrate= 344.2kbits/s speed=1.01x \nframe= 5570 fps= 24 q=-1.0 size= 9738kB time=00:03:52.00 bitrate= 343.9kbits/s speed=1.01x \nframe= 5582 fps= 24 q=-1.0 size= 9745kB time=00:03:52.50 bitrate= 343.4kbits/s speed=1.01x \nframe= 5582 fps= 19 q=-1.0 size= 9746kB time=00:03:52.50 bitrate= 343.4kbits/s speed=0.799x \nav_interleaved_write_frame(): Broken pipe\n[flv @ 0x5640d81ce980] Failed to update header with correct duration.\n[flv @ 0x5640d81ce980] Failed to update header with correct filesize.\nError writing trailer of rtmp://a.rtmp.youtube.com/live2/upjm-kz0g-c3wt-7zuj: Broken pipe\nframe= 5604 fps= 19 q=-1.0 Lsize= 9804kB time=00:03:53.41 bitrate= 344.1kbits/s speed=0.802x \nvideo:7808kB audio:1823kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.803781%\nConversion failed!\n\n","timestamp":"2017-07-19T17:41:07.391Z"}
{"level":"warning","message":"Trying to reconnect to: a.rtmp.youtube.com/live2/ on port 1935.","timestamp":"2017-07-19T17:41:07.392Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:41:07.406Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:41:07.516Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:41:07.530Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:41:09.429Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:41:09.429Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:41:21.546Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:41:21.571Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:41:21.632Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:41:21.633Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:41:21.661Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:41:21.662Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:41:21.698Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:42:42.965Z"}
{"level":"warning","message":"Disconnected from the Master-Server.","timestamp":"2017-07-19T17:43:55.471Z"}
{"level":"warning","message":"SSH is disconnected","timestamp":"2017-07-19T17:43:55.520Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:43:55.521Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:43:55.552Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:44:41.975Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:44:42.000Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:44:42.062Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:44:42.063Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:44:42.115Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:44:42.169Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:44:42.169Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:45:02.050Z"}
{"level":"warning","message":"Disconnected from the Master-Server.","timestamp":"2017-07-19T17:45:02.076Z"}
{"level":"warning","message":"SSH is disconnected","timestamp":"2017-07-19T17:45:02.116Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:45:02.117Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:45:02.144Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:45:04.163Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:45:04.163Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:45:59.807Z"}
{"level":"warning","message":"Disconnected from the Master-Server.","timestamp":"2017-07-19T17:47:57.395Z"}
{"level":"warning","message":"SSH is disconnected","timestamp":"2017-07-19T17:47:57.436Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:47:57.437Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:47:57.467Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:47:59.585Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:47:59.586Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:52:38.408Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:52:38.439Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:52:38.522Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:52:38.523Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:52:38.563Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:52:38.635Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:52:38.635Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:52:50.421Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:52:50.446Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:52:50.502Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:52:50.503Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:52:50.565Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:52:50.611Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:52:50.611Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:52:57.816Z"}
{"level":"warning","message":"SSH is disconnected","timestamp":"2017-07-19T17:52:57.830Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:52:57.830Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:52:59.847Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:52:59.847Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:53:47.588Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:03:02.581Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:03:02.606Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:03:02.665Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:03:02.666Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:03:02.737Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 41969","timestamp":"2017-07-19T18:03:03.782Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:03:03.783Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:03:53.770Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:04:07.117Z"}
{"level":"danger","message":"An error has occured: Camera Disconnected\nSTDERR: ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers\n built with gcc 7.1.1 (GCC) 20170516\n configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-shared --enable-version3\n libavutil 55. 58.100 / 55. 58.100\n libavcodec 57. 89.100 / 57. 89.100\n libavformat 57. 71.100 / 57. 71.100\n libavdevice 57. 6.100 / 57. 6.100\n libavfilter 6. 82.100 / 6. 82.100\n libavresample 3. 5. 0 / 3. 5. 0\n libswscale 4. 6.100 / 4. 6.100\n libswresample 2. 7.100 / 2. 7.100\n libpostproc 54. 5.100 / 54. 5.100\n[tcp @ 0x561947db3540] Connection to tcp://mpv.cdn3.bigCDN.com:5544?timeout=0 failed: Connection timed out\nrtsp://mpv.cdn3.bigCDN.com:5544/bigCDN/definst/mp4:bigbuckbunnyiphone_400.mp4: Connection timed out\n\n","timestamp":"2017-07-19T18:05:13.123Z"}
{"level":"warning","message":"Trying to reconnect to: mpv.cdn3.bigCDN.com on port 5546.","timestamp":"2017-07-19T18:05:13.125Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:08:07.186Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:09:53.358Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:09:53.382Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:09:53.459Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:09:53.460Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:09:53.495Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T18:09:53.570Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:09:53.570Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:09:58.961Z"}
{"level":"warning","message":"Disconnected from the Master-Server.","timestamp":"2017-07-19T18:09:58.968Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:09:58.994Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:11:37.267Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:11:37.291Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:11:37.354Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:11:37.355Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:11:37.423Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 41969","timestamp":"2017-07-19T18:11:37.467Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:11:37.467Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:11:43.512Z"}
{"level":"danger","message":"An error has occured: Camera Disconnected\nSTDERR: ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers\n built with gcc 7.1.1 (GCC) 20170516\n configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-shared --enable-version3\n libavutil 55. 58.100 / 55. 58.100\n libavcodec 57. 89.100 / 57. 89.100\n libavformat 57. 71.100 / 57. 71.100\n libavdevice 57. 6.100 / 57. 6.100\n libavfilter 6. 82.100 / 6. 82.100\n libavresample 3. 5. 0 / 3. 5. 0\n libswscale 4. 6.100 / 4. 6.100\n libswresample 2. 7.100 / 2. 7.100\n libpostproc 54. 5.100 / 54. 5.100\n[tcp @ 0x564d7690f540] Connection to tcp://mpv.cdn3.bigCDN.com:5544?timeout=0 failed: Connection timed out\nrtsp://mpv.cdn3.bigCDN.com:5544/bigCDN/definst/mp4:bigbuckbunnyiphone_400.mp4: Connection timed out\n\n","timestamp":"2017-07-19T18:13:46.829Z"}
{"level":"warning","message":"Trying to reconnect to: mpv.cdn3.bigCDN.com on port 554.","timestamp":"2017-07-19T18:13:46.830Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:13:46.959Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:13:46.964Z"}
{"level":"danger","message":"An error has occured: Camera Disconnected\nSTDERR: ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers\n built with gcc 7.1.1 (GCC) 20170516\n configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-shared --enable-version3\n libavutil 55. 58.100 / 55. 58.100\n libavcodec 57. 89.100 / 57. 89.100\n libavformat 57. 71.100 / 57. 71.100\n libavdevice 57. 6.100 / 57. 6.100\n libavfilter 6. 82.100 / 6. 82.100\n libavresample 3. 5. 0 / 3. 5. 0\n libswscale 4. 6.100 / 4. 6.100\n libswresample 2. 7.100 / 2. 7.100\n libpostproc 54. 5.100 / 54. 5.100\n[tcp @ 0x5589dd82b540] Connection to tcp://mpv.cdn3.bigCDN.com:5544?timeout=0 failed: Connection timed out\nrtsp://mpv.cdn3.bigCDN.com:5544/bigCDN/definst/mp4:bigbuckbunnyiphone_400.mp4: Connection timed out\n\n","timestamp":"2017-07-19T18:15:56.534Z"}
{"level":"warning","message":"Trying to reconnect to: mpv.cdn3.bigCDN.com on port 554.","timestamp":"2017-07-19T18:15:56.541Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:16:01.733Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:16:01.738Z"}
{"level":"danger","message":"An error has occured: Camera Disconnected\nSTDERR: ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers\n built with gcc 7.1.1 (GCC) 20170516\n configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-shared --enable-version3\n libavutil 55. 58.100 / 55. 58.100\n libavcodec 57. 89.100 / 57. 89.100\n libavformat 57. 71.100 / 57. 71.100\n libavdevice 57. 6.100 / 57. 6.100\n libavfilter 6. 82.100 / 6. 82.100\n libavresample 3. 5. 0 / 3. 5. 0\n libswscale 4. 6.100 / 4. 6.100\n libswresample 2. 7.100 / 2. 7.100\n libpostproc 54. 5.100 / 54. 5.100\n[tcp @ 0x558620a74540] Connection to tcp://mpv.cdn3.bigCDN.com:5544?timeout=0 failed: Connection timed out\nrtsp://mpv.cdn3.bigCDN.com:5544/bigCDN/definst/mp4:bigbuckbunnyiphone_400.mp4: Connection timed out\n\n","timestamp":"2017-07-19T18:18:11.361Z"}
{"level":"warning","message":"Trying to reconnect to: mpv.cdn3.bigCDN.com on port 554.","timestamp":"2017-07-19T18:18:11.362Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:18:11.541Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:18:11.545Z"}
{"level":"warning","message":"Disconnected from the Master-Server.","timestamp":"2017-07-19T18:19:20.521Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:19:22.990Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:19:23.015Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:19:23.125Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:19:25.936Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:19:25.937Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T18:19:26.054Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:19:26.054Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:21:13.532Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:21:13.564Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:21:13.648Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:21:13.649Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T18:21:13.676Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:21:13.677Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:21:13.713Z"}
{"level":"warning","message":"Disconnected from the Master-Server.","timestamp":"2017-07-19T18:21:21.525Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:21:22.960Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:21:34.106Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:22:12.365Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:22:12.389Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:22:12.455Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:22:12.456Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T18:22:12.479Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:22:12.480Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:22:12.521Z"}
{"level":"warning","message":"Disconnected from the Master-Server.","timestamp":"2017-07-19T18:22:40.864Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:26:30.618Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:26:30.642Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:26:30.747Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:26:33.750Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:26:33.751Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T18:26:33.867Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:26:33.868Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:26:45.741Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:26:45.766Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:26:45.834Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:26:45.835Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:26:45.891Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T18:26:45.945Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:26:45.945Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:28:07.342Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:28:07.366Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:28:07.439Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:28:07.440Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:28:07.478Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T18:28:07.550Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:28:07.550Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:28:13.009Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:30:18.057Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:30:18.082Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:30:18.144Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:30:18.145Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:30:18.220Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 37455","timestamp":"2017-07-19T18:30:19.176Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:30:19.176Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:30:25.569Z"}
{"level":"warning","message":"Disconnected from the Master-Server.","timestamp":"2017-07-19T18:30:25.584Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:30:25.609Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:31:42.833Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:31:42.860Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:31:42.924Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:31:42.925Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:31:42.993Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 37597","timestamp":"2017-07-19T18:31:44.043Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:31:44.044Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:31:50.736Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:32:07.290Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:32:07.314Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:32:07.378Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:32:07.380Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:32:07.439Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 43737","timestamp":"2017-07-19T18:32:08.412Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:32:08.412Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:32:20.897Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:32:20.923Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:32:20.986Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:32:20.988Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:32:21.056Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 43737","timestamp":"2017-07-19T18:32:21.101Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:32:21.102Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:32:31.954Z"}
{"level":"warning","message":"Although the times are hard, we will try to reconnect the SSH tunels once the connection to the SSH-Manager is regained!","timestamp":"2017-07-19T18:33:12.820Z"}
{"level":"danger","message":"An (SSH) error has occured: Connection to SSH-Manager lost!","timestamp":"2017-07-19T18:33:12.820Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:33:13.823Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T18:33:15.853Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:33:15.854Z"}
{"level":"danger","message":"An error has occured: Camera Disconnected\nSTDERR: ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers\n built with gcc 7.1.1 (GCC) 20170516\n configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-shared --enable-version3\n libavutil 55. 58.100 / 55. 58.100\n libavcodec 57. 89.100 / 57. 89.100\n libavformat 57. 71.100 / 57. 71.100\n libavdevice 57. 6.100 / 57. 6.100\n libavfilter 6. 82.100 / 6. 82.100\n libavresample 3. 5. 0 / 3. 5. 0\n libswscale 4. 6.100 / 4. 6.100\n libswresample 2. 7.100 / 2. 7.100\n libpostproc 54. 5.100 / 54. 5.100\n[tcp @ 0x562f08fb3540] Connection to tcp://mpv.cdn3.bigCDN.com:557?timeout=0 failed: Connection timed out\nrtsp://mpv.cdn3.bigCDN.com:557/bigCDN/definst/mp4:bigbuckbunnyiphone_400.mp4: Connection timed out\n\n","timestamp":"2017-07-19T18:34:30.989Z"}
{"level":"warning","message":"Trying to reconnect to: mpv.cdn3.bigCDN.com on port 558.","timestamp":"2017-07-19T18:34:30.991Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:54:14.427Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:54:14.451Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:54:14.512Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:54:14.513Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T18:54:14.539Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:54:14.539Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:54:14.570Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:54:20.445Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:54:51.852Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:54:51.876Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:54:51.944Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:54:51.945Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:54:52.005Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 39779","timestamp":"2017-07-19T18:54:52.978Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:54:52.978Z"}
{"level":"info","message":"Taking Snapshot.","timestamp":"2017-07-19T18:54:53.095Z"}
{"level":"danger","message":"Snapshot failed: TypeError: snapBuff.run is not a function","timestamp":"2017-07-19T18:54:53.097Z"}
{"level":"warning","message":"Although the times are hard, we will try to reconnect the SSH tunels once the connection to the SSH-Manager is regained!","timestamp":"2017-07-19T18:55:16.432Z"}
{"level":"danger","message":"An (SSH) error has occured: Connection to SSH-Manager lost!","timestamp":"2017-07-19T18:55:16.432Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:55:17.433Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T18:55:19.464Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:55:19.464Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:56:44.869Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:56:44.894Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:56:44.956Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:56:44.957Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T18:56:44.982Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:56:44.982Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:56:45.011Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:56:55.999Z"}
{"level":"danger","message":"An error has occured: Camera Disconnected\nSTDERR: ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers\n built with gcc 7.1.1 (GCC) 20170516\n configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-shared --enable-version3\n libavutil 55. 58.100 / 55. 58.100\n libavcodec 57. 89.100 / 57. 89.100\n libavformat 57. 71.100 / 57. 71.100\n libavdevice 57. 6.100 / 57. 6.100\n libavfilter 6. 82.100 / 6. 82.100\n libavresample 3. 5. 0 / 3. 5. 0\n libswscale 4. 6.100 / 4. 6.100\n libswresample 2. 7.100 / 2. 7.100\n libpostproc 54. 5.100 / 54. 5.100\n[tcp @ 0x557c64499540] Connection to tcp://mpv.cdn3.bigCDN.com:559?timeout=0 failed: Connection timed out\nrtsp://mpv.cdn3.bigCDN.com:559/bigCDN/definst/mp4:bigbuckbunnyiphone_400.mp4: Connection timed out\n\n","timestamp":"2017-07-19T18:58:55.309Z"}
{"level":"warning","message":"Trying to reconnect to: mpv.cdn3.bigCDN.com on port 560.","timestamp":"2017-07-19T18:58:55.311Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-08-03T10:13:34.653Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-08-03T10:13:34.680Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-08-03T10:13:34.885Z"}
{"level":"danger","message":"An error has occured: Camera Disconnected\nSTDERR: ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers\n built with gcc 7.1.1 (GCC) 20170516\n configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-shared --enable-version3\n libavutil 55. 58.100 / 55. 58.100\n libavcodec 57. 89.100 / 57. 89.100\n libavformat 57. 71.100 / 57. 71.100\n libavdevice 57. 6.100 / 57. 6.100\n libavfilter 6. 82.100 / 6. 82.100\n libavresample 3. 5. 0 / 3. 5. 0\n libswscale 4. 6.100 / 4. 6.100\n libswresample 2. 7.100 / 2. 7.100\n libpostproc 54. 5.100 / 54. 5.100\n[tcp @ 0x55fccbd43aa0] Failed to resolve hostname mpv.cdn3.bigCDN.com: Name or service not known\nrtsp://mpv.cdn3.bigCDN.com:560/bigCDN/definst/mp4:bigbuckbunnyiphone_400.mp4: Input/output error\n\n","timestamp":"2017-08-03T10:13:54.930Z"}
{"level":"warning","message":"Trying to reconnect to: mpv.cdn3.bigCDN.com on port 560.","timestamp":"2017-08-03T10:13:54.931Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-08-03T10:13:57.306Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-08-03T10:13:57.307Z"}
{"level":"warning","message":"Although the times are hard, we will try to reconnect the SSH tunels once the connection to the SSH-Manager is regained!","timestamp":"2017-08-03T10:13:57.748Z"}
{"level":"danger","message":"An (SSH) error has occured: Cannot connect to the SSH-Manager.","timestamp":"2017-08-03T10:13:57.749Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-08-03T10:14:32.834Z"}
{"level":"danger","message":"An (SSH) error has occured: Command failed: ssh -NR 10000:localhost:22 -o ExitOnForwardFailure=yes -o StrictHostKeyChecking=no -o ServerAliveInterval=30 -o ServerAliveCountMax=1 hiro@localhost\nstty: 'standard input': Inappropriate ioctl for device\n\u001b[91mcould not connect to remote: dial tcp [::1]:22: getsockopt: connection refused\u001b[0m\r\nssh_exchange_identification: Connection closed by remote host\r\n","timestamp":"2017-08-03T10:14:33.150Z"}
{"level":"warning","message":"Although the times are hard, we will try to reconnect the SSH tunels once the connection to the SSH-Manager is regained!","timestamp":"2017-08-03T10:14:35.689Z"}
{"level":"danger","message":"An (SSH) error has occured: Connection to SSH-Manager lost!","timestamp":"2017-08-03T10:14:35.690Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-08-03T10:15:46.411Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-08-03T10:15:48.448Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-08-03T10:15:48.448Z"}
{"level":"warning","message":"Disconnected from the Master-Server.","timestamp":"2017-08-03T10:17:04.551Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-08-03T10:17:07.061Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-08-03T10:31:58.486Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-08-03T10:31:58.504Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-08-03T10:31:58.556Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-08-03T10:31:58.556Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-08-03T10:31:58.666Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-08-03T10:31:58.675Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-08-03T10:31:58.675Z"}
{"level":"danger","message":"An error has occured: Camera Disconnected\nSTDERR: ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers\n built with gcc 7.1.1 (GCC) 20170516\n configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-shared --enable-version3\n libavutil 55. 58.100 / 55. 58.100\n libavcodec 57. 89.100 / 57. 89.100\n libavformat 57. 71.100 / 57. 71.100\n libavdevice 57. 6.100 / 57. 6.100\n libavfilter 6. 82.100 / 6. 82.100\n libavresample 3. 5. 0 / 3. 5. 0\n libswscale 4. 6.100 / 4. 6.100\n libswresample 2. 7.100 / 2. 7.100\n libpostproc 54. 5.100 / 54. 5.100\n[tcp @ 0x564f7c06aaa0] Failed to resolve hostname mpv.cdn3.bigCDN.com: Name or service not known\nrtsp://mpv.cdn3.bigCDN.com:560/bigCDN/definst/mp4:bigbuckbunnyiphone_400.mp4: Input/output error\n\n","timestamp":"2017-08-03T10:32:18.735Z"}
{"level":"warning","message":"Trying to reconnect to: mpv.cdn3.bigCDN.com on port 560.","timestamp":"2017-08-03T10:32:18.737Z"}
{"level":"warning","message":"SSH is disconnected","timestamp":"2017-08-03T10:32:19.019Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-08-03T10:32:19.019Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-08-03T10:32:21.031Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-08-03T10:32:21.031Z"}
{"level":"warning","message":"Although the times are hard, we will try to reconnect the SSH tunels once the connection to the SSH-Manager is regained!","timestamp":"2017-08-03T10:33:30.511Z"}
{"level":"danger","message":"An (SSH) error has occured: Connection to SSH-Manager lost!","timestamp":"2017-08-03T10:33:30.512Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-08-03T10:33:31.515Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-08-03T10:33:33.551Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-08-03T10:33:33.552Z"}
{"level":"warning","message":"Although the times are hard, we will try to reconnect the SSH tunels once the connection to the SSH-Manager is regained!","timestamp":"2017-08-03T10:33:38.340Z"}
{"level":"danger","message":"An (SSH) error has occured: Connection to SSH-Manager lost!","timestamp":"2017-08-03T10:33:38.341Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-08-03T10:33:40.845Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-08-03T10:33:42.880Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-08-03T10:33:42.881Z"}
{"level":"warning","message":"Although the times are hard, we will try to reconnect the SSH tunels once the connection to the SSH-Manager is regained!","timestamp":"2017-08-03T10:35:09.786Z"}
{"level":"danger","message":"An (SSH) error has occured: Connection to SSH-Manager lost!","timestamp":"2017-08-03T10:35:09.786Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-08-03T10:56:00.570Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-08-03T10:56:00.589Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-08-03T10:56:00.647Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-08-03T10:56:00.648Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-08-03T10:56:00.665Z"}
{"level":"warning","message":"Although the times are hard, we will try to reconnect the SSH tunels once the connection to the SSH-Manager is regained!","timestamp":"2017-08-03T10:56:01.098Z"}
{"level":"danger","message":"An (SSH) error has occured: Cannot connect to the SSH-Manager.","timestamp":"2017-08-03T10:56:01.100Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-08-03T10:56:11.731Z"}
{"level":"info","message":"Restarting Streamx","timestamp":"2017-08-03T10:56:11.732Z"}
{"level":"info","message":"Sopping Stream","timestamp":"2017-08-03T10:56:11.734Z"}
{"level":"danger","message":"Force Stop!","timestamp":"2017-08-03T10:56:14.735Z"}
{"level":"success","message":"Stopped Stream","timestamp":"2017-08-03T10:56:14.738Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-08-03T10:56:14.738Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-08-03T10:56:14.743Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-08-04T09:06:43.563Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-08-04T09:06:43.589Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-08-04T09:06:43.664Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-08-04T09:06:43.665Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-08-04T09:06:43.802Z"}
{"level":"warning","message":"Although the times are hard, we will try to reconnect the SSH tunels once the connection to the SSH-Manager is regained!","timestamp":"2017-08-04T09:06:44.110Z"}
{"level":"danger","message":"An (SSH) error has occured: Cannot connect to the SSH-Manager.","timestamp":"2017-08-04T09:06:44.112Z"}
{"level":"danger","message":"An error has occured: Camera Disconnected\nSTDERR: ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers\n built with gcc 7.1.1 (GCC) 20170516\n configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-shared --enable-version3\n libavutil 55. 58.100 / 55. 58.100\n libavcodec 57. 89.100 / 57. 89.100\n libavformat 57. 71.100 / 57. 71.100\n libavdevice 57. 6.100 / 57. 6.100\n libavfilter 6. 82.100 / 6. 82.100\n libavresample 3. 5. 0 / 3. 5. 0\n libswscale 4. 6.100 / 4. 6.100\n libswresample 2. 7.100 / 2. 7.100\n libpostproc 54. 5.100 / 54. 5.100\n[tcp @ 0x5630a5550aa0] Failed to resolve hostname mpv.cdn3.bigCDN.com1: Name or service not known\nrtsp://mpv.cdn3.bigCDN.com1:560/bigCDN/definst/mp4:bigbuckbunnyiphone_400.mp4: Input/output error\n\n","timestamp":"2017-08-04T09:06:45.503Z"}
{"level":"warning","message":"Trying to reconnect to: mpv.cdn3.bigCDN.com1 on port 560.","timestamp":"2017-08-04T09:06:45.505Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-08-04T09:07:27.111Z"}

553
main.js Executable file → Normal file
View file

@ -1,496 +1,93 @@
/////////////////////////////////////////////////////////////////////////////////// /**
// Main Module - Communicates with the Server and Orchestrates the other Moules. // * @module Main
/////////////////////////////////////////////////////////////////////////////////// * @description The main module and entry point.
*/
const sock = require('socket.io-client'); const redux = require('redux');
const ffmpeg = require('fluent-ffmpeg'); const ReduxThunk = require('redux-thunk').default;
const http = require('http'); const communicator = require('./src/communicator.js');
const path = require('path'); const commander = require('./src/commander.js');
const fs = require('fs'); const logger = require('./src/logger.js');
const WMStrm = require(__dirname + '/lib/memWrite.js'); const ssh = require('./src/ssh.js');
const exec = require('child_process').exec;
const execSync = require('child_process').execSync; ///////////////////////////////////////////////////////////////////////////////
const spawnP = require('child_process').spawn; // Redux //
///////////////////////////////////////////////////////////////////////////////
/** /**
* Custom Modules * Inital State for the app.
* Yet to be initialized. * @property { Object } stream Stream Status.
* @property { bool } stream.running Indicates wether the stream is running.
* @property { number | bool } stream.error Error code. Any number outside the range of the Error array in @see ffmpeg-command.js will be treated as non error. Most conveniently set: false.
* @property { bool | string } stream.errorHandling Indicates wether the program tries to handle an error.
* @property { bool } stream.restaring Indicades wether the stream is currently being restarted.
* @property { bool } stream.takingSnapshot Indicades wether a Snapshot is being taken.
* @property { Object } config Configuration of the camera.
* @property { Object } ssh The SSH tunnel status.
* @property { bool } ssh.enabled
* @property { bool } ssh.willReconnect Indicates if the SSH-Manager will try to reconnect as soon as the connection to the manager is regained.
* @property { string } ssh.status Status of the SSH Connection. Can either be DISABLED | DISCONNECTED |DISCONNECTING | CONNECTING | CONNECTED
* @property { number } ssh.sshForwardport SSH remote endpoint port for the ssh reverse tunnel.
* @property { number } ssh.camForwardPort SSH remote endpoint port for the reverse tunnel to the control panel of the IP Camera.
* @property { string } ssh.error The SSH Error, if there is any. You might check ssh.willReconnect as well, to see if a retry is sceduled as soon as the connection to the manager is regained.
*/ */
const logger = require('src/logger.js'); let initialState = {
stream: {
/////////////////////////////////////////////////////////////////////////////// running: 'STOPPED',
// Declarations // error: false,
/////////////////////////////////////////////////////////////////////////////// reconnecting: false,
handleError: false,
// Force a Stop. restaring: false,
let mustBe = false; snapshot: {
taking: false,
// Restart the stream after it stopped. failed: false
let restart = false;
// Central State Variable
// NOTE: Could be done with redux!
let status = {
status: 0,
error: -1
}
// Minor declarations.
let config, source, snapSource, stopTimeout;
let spawn = function() {
source = 'rtsp://' + config.camIP + ':' + config.camPort + '/' + config.camProfile;
ffmpeg.setFfmpegPath(config.ffmpegPath);
delete cmd;
cmd = ffmpeg({
source: source,
stdoutLines: 20
});
if (config.customOutputOptions !== "")
cmd.outputOptions(config.customOutputOptions.replace(/\s+\,\s+/g, ',').replace(/\s+\-/g, ',-').split(','));
if (config.customAudioOptions !== "")
cmd.outputOptions(config.customAudioOptions.replace(/\s+\,\s+/g, ',').replace(/\s+\-/g, ',-').split(','));
else
cmd.AudioCodec('copy');
if (config.customVideoOptions !== "")
cmd.outputOptions(config.customVideoOptions.replace(/\s+\,\s+/g, ',').replace(/\s+\-/g, ',-').split(','));
else
cmd.videoCodec('copy');
cmd.on('start', function(commandLine) {
status.running = 0;
logger.log(logger.importance[4], 'Spawned Ffmpeg with command: ' + commandLine);
})
.on('end', function(o, e) {
imDead('Normal Stop.', e);
})
.on('error', function(err, o, e) {
if (err.message.indexOf(source) > -1)
criticalProblem(0, e, handleDisc, config.camIP, config.camPort);
else if (err.message.indexOf(source + 'Input/output error') > -1 || err.message.indexOf('rtmp://a.rtmp.youtube.com/live2/' + config.key) > -1)
criticalProblem(1, e, handleDisc, 'a.rtmp.youtube.com/live2/', 1935);
else if (err.message.indexOf('spawn') > -1 || err.message.indexOf('niceness') > -1)
criticalProblem(2, e, function() {});
else if (err.message.indexOf('SIGINT') > -1 || err.message.indexOf('SIGKILL') > -1)
imDead('Normal Stop.', e);
else
imDead(err.message, e);
})
.outputFormat('flv')
.outputOptions(['-bufsize 50000k', '-tune film'])
.output('rtmp://a.rtmp.youtube.com/live2/' + config.key);
status.error = -1;
socket.emit('change', {
type: 'startStop',
change: {
running: 0,
error: -1
} }
}); },
cmd.run(); ssh: {
status: 'DISCONNECTED', // TODO: CD // TODO: Implement in WEBIF
cameraForwardPort: false,
sshForwardPort: false,
willReconnect: false,
error: false
},
connected: false,
config: false
}; };
let getSnap = function(cb) { // Reducer
snapSource = 'rtsp://' + config.camIP + ':' + config.camPort + '/' + config.snapProfile; const reducer = require('./src/reducers');
let picBuff = new WMStrm();
recCmd = ffmpeg(snapSource)
.on('start', function(commandLine) {
logger.log(logger.importance[4], 'Snapshot ' + commandLine);
})
.on('error', function(err, o, e) {})
.outputFormat('mjpeg')
.frames(1)
.stream(picBuff, {
end: true
});
picBuff.on('finish', function() {
try {
cb(picBuff.memStore.toString('base64'));
delete pickBuff;
} catch (e) {
cb(false);
}
});
}
function imDead(why, e = '') { // Reference to the store of the application state.
if (stopTimeout) { const store = redux.createStore(reducer, initialState, redux.applyMiddleware(ReduxThunk, logger.middleware, communicator.middleware, ssh.middleware, commander.middleware));
clearTimeout(stopTimeout);
stopTimeout = false;
}
status.running = 1; // The dispatch function for the state.
socket.emit('change', { const dispatch = store.dispatch;
type: 'startStop',
change: {
running: 1
}
});
if (restart) {
spawn();
restart = false;
}
if (!mustBe) {
logger.log(logger.importance[2], 'Crash! ' + e);
setTimeout(function() {
spawn();
}, 1000);
}
mustBe = false;
}
function criticalProblem(err, e, handler, ...args) { // The function to get the state.
if (!mustBe) { const getState = store.getState;
setTimeout(function() {
status.running = 2;
status.error = err;
logger.log(logger.importance[3], 'Critical Problem: ' + errors[err] + '\n' + e);
socket.emit('change', {
type: 'error',
change: {
running: 2,
error: err
}
});
handler(args)
}, 1000);
}
mustBe = false;
}
function handleDisc(info) { // A helper to get the config.
let [host, port] = info; const getConfig = () => store.getState().config;
isReachable(host, port, is => {
if (is) {
spawn();
} else {
setTimeout(function() {
handleDisc(info);
}, 10000);
}
});
}
function isReachable(host, port, callback) { // Simple Action creators
http.get({ const creators = require('./src/actions.js').creators;
host: host.split('/')[0],
port: port
}, function(res) {
callback(true);
}).on("error", function(e) {
if (e.message == "socket hang up") {
setTimeout(function() {
callback(true);
}, 1000);
} else
callback(false);
});
}
function stopFFMPEG() { ///////////////////////////////////////////////////////////////////////////////
cmd.kill('SIGINT'); // Load //
stopTimeout = setTimeout(() => { ///////////////////////////////////////////////////////////////////////////////
logger.log(logger.importance[3], "Force Stop!");
cmd.kill();
}, 3000);
}
var commandHandlers = function commandHandlers(command, cb) { // Code the Config
var handlers = { dispatch(creators.updateConfig());
startStop: function() {
if (restart)
return;
if (status.running !== 2) // Instanciate the Commander
if (status.running === 0) { const Commander = new commander(getState, getConfig, dispatch);
logger.log(logger.importance[1], "Stop Command!");
mustBe = true;
stopFFMPEG();
socket.emit('data', {
type: 'message',
data: {
title: 'Success',
type: 'success',
text: 'Stopped!'
}
}, command.sender);
} else {
logger.log(logger.importance[1], "Start Command!");
spawn();
socket.emit('data', {
type: 'message',
data: {
title: 'Success',
type: 'success',
text: 'Started!'
}
}, command.sender);
}
},
snap: function() {
getSnap(snap => {
socket.emit('data', {
type: 'snap',
data: snap,
}, command.sender);
});
},
config: function() {
socket.emit('data', {
type: 'config',
data: config,
}, command.sender);
},
changeSettings: function() {
for (let set in command.data) {
if (typeof config[set] !== 'undefined')
config[set] = command.data[set];
}
let oldConfigured;
if (config.configured === true)
oldConfigured = true;
config.configured = true;
fs.writeFile(__dirname + '/config.js',
JSON.stringify(config,
undefined, 2),
function(err) {
if (err) {
socket.emit('data', {
type: 'message',
data: {
title: 'Error',
type: 'error',
text: 'Can\'t save the Settings!\n' + err.message
}
}, command.sender);
} else {
restartSSH(() => {
socket.emit('data', {
type: 'message',
data: {
title: 'Success',
type: 'success',
text: 'Settings Saved!'
}
}, command.sender);
if (oldConfigured) {
socket.emit('change', {
type: 'settings',
change: {
config: command.data
}
});
stopFFMPEG();
spawn();
} else {
socket.disconnect();
init();
}
});
}
});
},
restart: function() {
if (status.running === 0) {
logger.log(logger.importance[1], "Restart Command!");
mustBe = true;
restart = true;
stopFFMPEG();
} else {
logger.log(logger.importance[1], "Start Command!");
spawn();
}
socket.emit('data', {
type: 'message',
data: {
title: 'Success',
type: 'success',
text: 'Restarted!'
}
}, command.sender);
},
restartSSH: function() {
restartSSH(() => {
socket.emit('data', {
type: 'message',
data: {
title: 'Success',
type: 'success',
text: 'Restarted SSH Tunnels!'
}
}, command.sender);
});
},
getLogs: function() {
logger.query({
limit: 100
}, function(err, data) {
data = data.file;
if (err) {
data = [];
} else
if (data.length === 0)
data = [];
socket.emit('data', {
type: 'logs',
data: data
}, command.sender);
});
}
};
//call the handler // The server Communication
var call = handlers[command.command]; const Communicator = new communicator(getState, getConfig, dispatch, Commander);
if (call)
call();
}
function restartSSH(cb) { // Start the Stream
exec('forever stop SSH-Serv', () => { dispatch(Commander.start()).then().catch(); // TODO: Better Handling
connectSSH(() => {
socket.emit('change', {
change: {
ssh: {
port: status.ssh.port,
camForwardPort: status.ssh.camForwardPort
}
}
});
cb();
});
});
}
function handleKill() { /**
process.stdin.resume(); * We're good to go from here!
logger.log(logger.importance[0], "Received Shutdown Command"); */
mustBe = true;
cmd.kill();
process.exit(0);
}
process.on('SIGTERM', function() {
handleKill();
});
//let's go
function init() {
config = readConfig();
if (config.configured) {
socket = sock(config.master + '/pi');
initSocket();
status.name = config.name;
if (!cmd)
spawn();
} else {
socket = sock(config.master + '/pi', {
query: "unconfigured=true"
});
status.running = 2;
initSocket();
}
}
function initSSH(cb) {
status.ssh = {
// that Could come from the Master server!
user: config['ssh-user'],
localUser: config['ssh-local-user'],
masterPort: config['ssh-port']
};
checkSSH((alive) => {
if (alive)
cb();
else
connectSSH(cb);
});
}
function connectSSH(cb = function() {
socket.emit('change', {
change: {
ssh: {
port: status.ssh.port,
camForwardPort: status.ssh.camForwardPort
}
}
});
}) {
socket.emit('getSSHPort', ports => {
[status.ssh.port, status.ssh.camForwardPort] = ports;
let ssh = exec(`forever start -a --killSignal=SIGINT --uid SSH-Serv sshManager.js ${status.ssh.port} ${status.ssh.camForwardPort} ${config.camPanelPort}`, {
detached: true,
shell: true,
cwd: __dirname
});
ssh.on('error', (err) => {
socket.emit('data', {
type: 'message',
data: {
title: 'Error',
type: 'error',
text: 'Could not start SSH tunnels!'
}
}, command.sender);
});
cb();
});
}
function checkSSH(cb) {
let m, pid, alive;
let re = /SSH-Serv.*?sshManager\.js\s([0-9]+)\s([0-9]+).*log.*[^STOPPED]+/g;
exec('forever list', (error, stdout, stderr) => {
if (error)
throw error;
let alive = false;
while ((m = re.exec(stdout)) !== null) {
if (m.index === re.lastIndex) {
re.lastIndex++;
}
if (alive) {
exec('forever stop SSH-Serv');
cb(false)
return;
} else {
[, status.ssh.port, status.ssh.camForwardPort] = m;
alive = true;
}
}
cb(alive);
});
}
function initSocket() {
socket.on('connect', function() {
logger.log(logger.importance[0], 'Connected to Master: ' + config.master + '.');
if (config['ssh-user'])
initSSH(err => {
if (err)
throw err;
socket.emit('meta', status);
});
else {
socket.emit('meta', status);
}
});
socket.on('disconnect', function() {
socket.disconnect();
init();
});
socket.on('command', (command, cb) => {
commandHandlers(command, cb);
});
}
function readConfig() {
return JSON.parse(fs.readFileSync(__dirname + '/config.js'));
}
init();

View file

@ -1,488 +0,0 @@
const sock = require('socket.io-client');
const ffmpeg = require('fluent-ffmpeg');
const http = require('http');
const path = require('path');
const fs = require('fs');
const WMStrm = require(__dirname + '/lib/memWrite.js');
const exec = require('child_process').exec;
const execSync = require('child_process').execSync;
const spawnP = require('child_process').spawn;
const logger = require('src/logger.js');
/**
* Global Variables
*/
// Force a Stop.
let mustBe = false;
// Restart the stream after it stopped.
let restart = false;
// Central State Variable
// NOTE: Could be done with redux!
let status = {
status: 0,
error: -1
}
// Minor declarations.
let config, source, snapSource, stopTimeout;
let spawn = function() {
source = 'rtsp://' + config.camIP + ':' + config.camPort + '/' + config.camProfile;
ffmpeg.setFfmpegPath(config.ffmpegPath);
delete cmd;
cmd = ffmpeg({
source: source,
stdoutLines: 20
});
if (config.customOutputOptions !== "")
cmd.outputOptions(config.customOutputOptions.replace(/\s+\,\s+/g, ',').replace(/\s+\-/g, ',-').split(','));
if (config.customAudioOptions !== "")
cmd.outputOptions(config.customAudioOptions.replace(/\s+\,\s+/g, ',').replace(/\s+\-/g, ',-').split(','));
else
cmd.AudioCodec('copy');
if (config.customVideoOptions !== "")
cmd.outputOptions(config.customVideoOptions.replace(/\s+\,\s+/g, ',').replace(/\s+\-/g, ',-').split(','));
else
cmd.videoCodec('copy');
cmd.on('start', function(commandLine) {
status.running = 0;
logger.log(logger.importance[4], 'Spawned Ffmpeg with command: ' + commandLine);
})
.on('end', function(o, e) {
imDead('Normal Stop.', e);
})
.on('error', function(err, o, e) {
if (err.message.indexOf(source) > -1)
criticalProblem(0, e, handleDisc, config.camIP, config.camPort);
else if (err.message.indexOf(source + 'Input/output error') > -1 || err.message.indexOf('rtmp://a.rtmp.youtube.com/live2/' + config.key) > -1)
criticalProblem(1, e, handleDisc, 'a.rtmp.youtube.com/live2/', 1935);
else if (err.message.indexOf('spawn') > -1 || err.message.indexOf('niceness') > -1)
criticalProblem(2, e, function() {});
else if (err.message.indexOf('SIGINT') > -1 || err.message.indexOf('SIGKILL') > -1)
imDead('Normal Stop.', e);
else
imDead(err.message, e);
})
.outputFormat('flv')
.outputOptions(['-bufsize 50000k', '-tune film'])
.output('rtmp://a.rtmp.youtube.com/live2/' + config.key);
status.error = -1;
socket.emit('change', {
type: 'startStop',
change: {
running: 0,
error: -1
}
});
cmd.run();
};
let getSnap = function(cb) {
snapSource = 'rtsp://' + config.camIP + ':' + config.camPort + '/' + config.snapProfile;
let picBuff = new WMStrm();
recCmd = ffmpeg(snapSource)
.on('start', function(commandLine) {
logger.log(logger.importance[4], 'Snapshot ' + commandLine);
})
.on('error', function(err, o, e) {})
.outputFormat('mjpeg')
.frames(1)
.stream(picBuff, {
end: true
});
picBuff.on('finish', function() {
try {
cb(picBuff.memStore.toString('base64'));
delete pickBuff;
} catch (e) {
cb(false);
}
});
}
function imDead(why, e = '') {
if(stopTimeout) {
clearTimeout(stopTimeout);
stopTimeout = false;
}
status.running = 1;
socket.emit('change', {
type: 'startStop',
change: {
running: 1
}
});
if (restart) {
spawn();
restart = false;
}
if (!mustBe) {
logger.log(logger.importance[2], 'Crash! ' + e);
setTimeout(function() {
spawn();
}, 1000);
}
mustBe = false;
}
function criticalProblem(err, e, handler, ...args) {
if (!mustBe) {
setTimeout(function() {
status.running = 2;
status.error = err;
logger.log(logger.importance[3], 'Critical Problem: ' + errors[err] + '\n' + e);
socket.emit('change', {
type: 'error',
change: {
running: 2,
error: err
}
});
handler(args)
}, 1000);
}
mustBe = false;
}
function handleDisc(info) {
let [host, port] = info;
isReachable(host, port, is => {
if (is) {
spawn();
} else {
setTimeout(function() {
handleDisc(info);
}, 10000);
}
});
}
function isReachable(host, port, callback) {
http.get({
host: host.split('/')[0],
port: port
}, function(res) {
callback(true);
}).on("error", function(e) {
if (e.message == "socket hang up") {
setTimeout(function() {
callback(true);
}, 1000);
} else
callback(false);
});
}
function stopFFMPEG() {
cmd.kill('SIGINT');
stopTimeout = setTimeout(() => {
logger.log(logger.importance[3], "Force Stop!");
cmd.kill();
}, 3000);
}
var commandHandlers = function commandHandlers(command, cb) {
var handlers = {
startStop: function() {
if(restart)
return;
if (status.running !== 2)
if (status.running === 0) {
logger.log(logger.importance[1], "Stop Command!");
mustBe = true;
stopFFMPEG();
socket.emit('data', {
type: 'message',
data: {
title: 'Success',
type: 'success',
text: 'Stopped!'
}
}, command.sender);
} else {
logger.log(logger.importance[1], "Start Command!");
spawn();
socket.emit('data', {
type: 'message',
data: {
title: 'Success',
type: 'success',
text: 'Started!'
}
}, command.sender);
}
},
snap: function() {
getSnap(snap => {
socket.emit('data', {
type: 'snap',
data: snap,
}, command.sender);
});
},
config: function() {
socket.emit('data', {
type: 'config',
data: config,
}, command.sender);
},
changeSettings: function() {
for (let set in command.data) {
if (typeof config[set] !== 'undefined')
config[set] = command.data[set];
}
let oldConfigured;
if (config.configured === true)
oldConfigured = true;
config.configured = true;
fs.writeFile(__dirname + '/config.js',
JSON.stringify(config,
undefined, 2),
function(err) {
if (err) {
socket.emit('data', {
type: 'message',
data: {
title: 'Error',
type: 'error',
text: 'Can\'t save the Settings!\n' + err.message
}
}, command.sender);
} else {
restartSSH(() => {
socket.emit('data', {
type: 'message',
data: {
title: 'Success',
type: 'success',
text: 'Settings Saved!'
}
}, command.sender);
if (oldConfigured) {
socket.emit('change', {
type: 'settings',
change: {
config: command.data
}
});
stopFFMPEG();
spawn();
} else {
socket.disconnect();
init();
}
});
}
});
},
restart: function() {
if (status.running === 0) {
logger.log(logger.importance[1], "Restart Command!");
mustBe = true;
restart = true;
stopFFMPEG();
} else {
logger.log(logger.importance[1], "Start Command!");
spawn();
}
socket.emit('data', {
type: 'message',
data: {
title: 'Success',
type: 'success',
text: 'Restarted!'
}
}, command.sender);
},
restartSSH: function() {
restartSSH(() => {
socket.emit('data', {
type: 'message',
data: {
title: 'Success',
type: 'success',
text: 'Restarted SSH Tunnels!'
}
}, command.sender);
});
},
getLogs: function() {
logger.query({limit: 100}, function (err, data) {
data = data.file;
if (err) {
data = [];
} else
if (data.length === 0)
data = [];
socket.emit('data', {
type: 'logs',
data: data
}, command.sender);
});
}
};
//call the handler
var call = handlers[command.command];
if (call)
call();
}
function restartSSH(cb) {
exec('forever stop SSH-Serv', () => {
connectSSH(() => {
socket.emit('change', {
change: {
ssh: {
port: status.ssh.port,
camForwardPort: status.ssh.camForwardPort
}
}
});
cb();
});
});
}
function handleKill() {
process.stdin.resume();
logger.log(logger.importance[0], "Received Shutdown Command");
mustBe = true;
cmd.kill();
process.exit(0);
}
process.on('SIGTERM', function() {
handleKill();
});
//let's go
function init() {
config = readConfig();
if (config.configured) {
socket = sock(config.master + '/pi');
initSocket();
status.name = config.name;
if (!cmd)
spawn();
} else {
socket = sock(config.master + '/pi', {
query: "unconfigured=true"
});
status.running = 2;
initSocket();
}
}
function initSSH(cb) {
status.ssh = {
// that Could come from the Master server!
user: config['ssh-user'],
localUser: config['ssh-local-user'],
masterPort: config['ssh-port']
};
checkSSH((alive) => {
if (alive)
cb();
else
connectSSH(cb);
});
}
function connectSSH(cb = function() {
socket.emit('change', {
change: {
ssh: {
port: status.ssh.port,
camForwardPort: status.ssh.camForwardPort
}
}
});
}) {
socket.emit('getSSHPort', ports => {
[status.ssh.port, status.ssh.camForwardPort] = ports;
let ssh = exec(`forever start -a --killSignal=SIGINT --uid SSH-Serv sshManager.js ${status.ssh.port} ${status.ssh.camForwardPort} ${config.camPanelPort}`, {
detached: true,
shell: true,
cwd: __dirname
});
ssh.on('error', (err) => {
socket.emit('data', {
type: 'message',
data: {
title: 'Error',
type: 'error',
text: 'Could not start SSH tunnels!'
}
}, command.sender);
});
cb();
});
}
function checkSSH(cb) {
let m, pid, alive;
let re = /SSH-Serv.*?sshManager\.js\s([0-9]+)\s([0-9]+).*log.*[^STOPPED]+/g;
exec('forever list', (error, stdout, stderr) => {
if (error)
throw error;
let alive = false;
while ((m = re.exec(stdout)) !== null) {
if (m.index === re.lastIndex) {
re.lastIndex++;
}
if (alive) {
exec('forever stop SSH-Serv');
cb(false)
return;
} else {
[, status.ssh.port, status.ssh.camForwardPort] = m;
alive = true;
}
}
cb(alive);
});
}
function initSocket() {
socket.on('connect', function() {
logger.log(logger.importance[0], 'Connected to Master: ' + config.master + '.');
if (config['ssh-user'])
initSSH(err => {
if (err)
throw err;
socket.emit('meta', status);
});
else {
socket.emit('meta', status);
}
});
socket.on('disconnect', function() {
socket.disconnect();
init();
});
socket.on('command', (command, cb) => {
commandHandlers(command, cb);
});
}
function readConfig() {
return JSON.parse(fs.readFileSync(__dirname + '/config.js'));
}
init();

View file

@ -1,93 +0,0 @@
/**
* @module Main
* @description The main module and entry point.
*/
const redux = require('redux');
const ReduxThunk = require('redux-thunk').default;
const communicator = require('./src/communicator.js');
const commander = require('./src/commander.js');
const logger = require('./src/logger.js');
const ssh = require('./src/ssh.js');
///////////////////////////////////////////////////////////////////////////////
// Redux //
///////////////////////////////////////////////////////////////////////////////
/**
* Inital State for the app.
* @property { Object } stream Stream Status.
* @property { bool } stream.running Indicates wether the stream is running.
* @property { number | bool } stream.error Error code. Any number outside the range of the Error array in @see ffmpeg-command.js will be treated as non error. Most conveniently set: false.
* @property { bool | string } stream.errorHandling Indicates wether the program tries to handle an error.
* @property { bool } stream.restaring Indicades wether the stream is currently being restarted.
* @property { bool } stream.takingSnapshot Indicades wether a Snapshot is being taken.
* @property { Object } config Configuration of the camera.
* @property { Object } ssh The SSH tunnel status.
* @property { bool } ssh.enabled
* @property { bool } ssh.willReconnect Indicates if the SSH-Manager will try to reconnect as soon as the connection to the manager is regained.
* @property { string } ssh.status Status of the SSH Connection. Can either be DISABLED | DISCONNECTED |DISCONNECTING | CONNECTING | CONNECTED
* @property { number } ssh.sshForwardport SSH remote endpoint port for the ssh reverse tunnel.
* @property { number } ssh.camForwardPort SSH remote endpoint port for the reverse tunnel to the control panel of the IP Camera.
* @property { string } ssh.error The SSH Error, if there is any. You might check ssh.willReconnect as well, to see if a retry is sceduled as soon as the connection to the manager is regained.
*/
let initialState = {
stream: {
running: 'STOPPED',
error: false,
reconnecting: false,
handleError: false,
restaring: false,
snapshot: {
taking: false,
failed: false
}
},
ssh: {
status: 'DISCONNECTED', // TODO: CD // TODO: Implement in WEBIF
cameraForwardPort: false,
sshForwardPort: false,
willReconnect: false,
error: false
},
connected: false,
config: false
};
// Reducer
const reducer = require('./src/reducers');
// Reference to the store of the application state.
const store = redux.createStore(reducer, initialState, redux.applyMiddleware(ReduxThunk, logger.middleware, communicator.middleware, ssh.middleware, commander.middleware));
// The dispatch function for the state.
const dispatch = store.dispatch;
// The function to get the state.
const getState = store.getState;
// A helper to get the config.
const getConfig = () => store.getState().config;
// Simple Action creators
const creators = require('./src/actions.js').creators;
///////////////////////////////////////////////////////////////////////////////
// Load //
///////////////////////////////////////////////////////////////////////////////
// Code the Config
dispatch(creators.updateConfig());
// Instanciate the Commander
const Commander = new commander(getState, getConfig, dispatch);
// The server Communication
const Communicator = new communicator(getState, getConfig, dispatch, Commander);
// Start the Stream
dispatch(Commander.start()).then().catch(); // TODO: Better Handling
/**
* We're good to go from here!
*/

View file

@ -1,55 +0,0 @@
/**
* @module Main
* @description The main module and entry point.
*/
const redux = require('redux');
const ReduxThunk = require('redux-thunk').default;
///////////////////////////////////////////////////////////////////////////////
// Redux //
///////////////////////////////////////////////////////////////////////////////
/**
* Inital State for the app.
* @property { Object } stream Stream Status.
* @property { bool } stream.running Indicates wether the stream is running.
* @property { number | bool } stream.error Error code. Any number outside the range of the Error array in @see ffmpeg-command.js will be treated as non error. Most conveniently set: false.
* @property { bool | string } stream.errorHandling Indicates wether the program tries to handle an error.
* @property { bool } stream.restaring Indicades wether the stream is currently being restarted.
* @property { Object } config Configuration of the camera.
*/
let initialState = {
stream: {
running: 'STOPPED',
error: false,
reconnecting: false,
handleError: false,
restaring: false
},
config: {}
};
// Reducer
const reducer = require('./src/reducers');
// Reference to the store of the application state.
const store = redux.createStore(reducer, initialState, redux.applyMiddleware(ReduxThunk));
// The dispatch function for the state.
const dispatch = store.dispatch;
// The function to get the state.
const getState = store.getState;
// Simple Action creators
const creators = require('./src/actions.js').creators;
///////////////////////////////////////////////////////////////////////////////
// Code //
///////////////////////////////////////////////////////////////////////////////
// Load the Config
store.dispatch(creators.updateConfig());
console.log(store.getState());
//const Commander = require('./src/commander.js')(getState);

Binary file not shown.

File diff suppressed because it is too large Load diff

Before

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

File diff suppressed because it is too large Load diff

Before

Width:  |  Height:  |  Size: 118 KiB

File diff suppressed because it is too large Load diff

Before

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

File diff suppressed because it is too large Load diff

Before

Width:  |  Height:  |  Size: 114 KiB

File diff suppressed because it is too large Load diff

Before

Width:  |  Height:  |  Size: 120 KiB

File diff suppressed because it is too large Load diff

Before

Width:  |  Height:  |  Size: 117 KiB

View file

@ -1,65 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Home</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Home</h1>
<h3> </h3>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Actions.html">Actions</a></li><li><a href="module-Commander.html">Commander</a></li><li><a href="module-Main.html">Main</a></li><li><a href="module-Reducers.html">Reducers</a></li><li><a href="module-Streamer.html">Streamer</a></li><li><a href="module-Utilities_Config.html">Utilities/Config</a></li></ul><h3>Classes</h3><ul><li><a href="module-Commander-Commander.html">Commander</a></li><li><a href="module-Streamer-Streamer.html">Streamer</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Mon Apr 24 2017 18:52:45 GMT+1200 (NZST)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>

View file

@ -1,100 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: main_new.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: main_new.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/**
* @module Main
* @description The main module and entry point.
*/
const redux = require('redux');
const ReduxThunk = require('redux-thunk').default;
///////////////////////////////////////////////////////////////////////////////
// Redux //
///////////////////////////////////////////////////////////////////////////////
/**
* Inital State for the app.
* @property { Object } stream Stream Status.
* @property { bool } stream.running Indicates wether the stream is running.
* @property { number | bool } stream.error Error code. Any number outside the range of the Error array in @see ffmpeg-command.js will be treated as non error. Most conveniently set: false.
* @property { bool | string } stream.errorHandling Indicates wether the program tries to handle an error.
* @property { bool } stream.restaring Indicades wether the stream is currently being restarted.
* @property { Object } config Configuration of the camera.
*/
let initialState = {
stream: {
running: 'STOPPED',
error: false,
reconnecting: false,
handleError: false,
restaring: false
},
config: {}
};
// Reducer
const reducer = require('./reducers');
// Reference to the store of the application state.
const store = redux.createStore(reducer, initialState);
// The dispatch function for the state.
const dispatch = store.dispatch;
// The function to get the state.
const getState = store.getState;
///////////////////////////////////////////////////////////////////////////////
// Code //
///////////////////////////////////////////////////////////////////////////////
const Commander = require('./src/commander.js')(getState);
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Actions.html">Actions</a></li><li><a href="module-Commander.html">Commander</a></li><li><a href="module-Main.html">Main</a></li><li><a href="module-Reducers.html">Reducers</a></li><li><a href="module-Streamer.html">Streamer</a></li><li><a href="module-Utilities_Config.html">Utilities/Config</a></li></ul><h3>Classes</h3><ul><li><a href="module-Commander-Commander.html">Commander</a></li><li><a href="module-Streamer-Streamer.html">Streamer</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Mon Apr 24 2017 18:52:45 GMT+1200 (NZST)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>

View file

@ -1,295 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Module: Actions</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Module: Actions</h1>
<section>
<header>
</header>
<article>
<div class="container-overview">
<div class="description">Outsourced definition of the actions and simple action creators for simple actions.</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_actions.js.html">src/actions.js</a>, <a href="src_actions.js.html#line1">line 1</a>
</li></ul></dd>
<dt class="tag-todo">To Do:</dt>
<dd class="tag-todo">
<ul>
<li>allowed values</li>
</ul>
</dd>
</dl>
</div>
<h3 class="subsection-title">Members</h3>
<h4 class="name" id="~actions"><span class="type-signature">(inner) </span>actions<span class="type-signature"></span></h4>
<div class="description">
Actions
The action definitions.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_actions.js.html">src/actions.js</a>, <a href="src_actions.js.html#line13">line 13</a>
</li></ul></dd>
</dl>
<h4 class="name" id="~creators"><span class="type-signature">(inner) </span>creators<span class="type-signature"></span></h4>
<div class="description">
Trivial Action Creators
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_actions.js.html">src/actions.js</a>, <a href="src_actions.js.html#line27">line 27</a>
</li></ul></dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Actions.html">Actions</a></li><li><a href="module-Commander.html">Commander</a></li><li><a href="module-Main.html">Main</a></li><li><a href="module-Reducers.html">Reducers</a></li><li><a href="module-Streamer.html">Streamer</a></li><li><a href="module-Utilities_Config.html">Utilities/Config</a></li></ul><h3>Classes</h3><ul><li><a href="module-Commander-Commander.html">Commander</a></li><li><a href="module-Streamer-Streamer.html">Streamer</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Mon Apr 24 2017 18:52:45 GMT+1200 (NZST)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>

View file

@ -1,320 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: Commander</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Class: Commander</h1>
<section>
<header>
<h2>
<span class="ancestors"><a href="module-Commander.html">Commander</a>~</span>Commander</h2>
</header>
<article>
<div class="container-overview">
<h4 class="name" id="Commander"><span class="type-signature"></span>new Commander<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Interface to the ffmpeg process. Uses fluent-ffmpeg.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_commander.js.html">src/commander.js</a>, <a href="src_commander.js.html#line46">line 46</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="~createCommand"><span class="type-signature">(inner) </span>createCommand<span class="signature">(config)</span><span class="type-signature"> &rarr; {Object}</span></h4>
<div class="description">
(Re)Create the ffmpeg command and configure it.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>config</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">The configuration for the stream.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_commander.js.html">src/commander.js</a>, <a href="src_commander.js.html#line62">line 62</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
The fluent-ffmpeg command object.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Actions.html">Actions</a></li><li><a href="module-Commander.html">Commander</a></li><li><a href="module-Main.html">Main</a></li><li><a href="module-Reducers.html">Reducers</a></li><li><a href="module-Streamer.html">Streamer</a></li><li><a href="module-Utilities_Config.html">Utilities/Config</a></li></ul><h3>Classes</h3><ul><li><a href="module-Commander-Commander.html">Commander</a></li><li><a href="module-Streamer-Streamer.html">Streamer</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Mon Apr 24 2017 18:52:46 GMT+1200 (NZST)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>

View file

@ -1,649 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Module: Commander</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Module: Commander</h1>
<section>
<header>
</header>
<article>
<div class="container-overview">
<div class="description">A Wrapper for Fluent-FFMPEG with a custom command.</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_commander.js.html">src/commander.js</a>, <a href="src_commander.js.html#line1">line 1</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Classes</h3>
<dl>
<dt><a href="module-Commander-Commander.html">Commander</a></dt>
<dd></dd>
</dl>
<h3 class="subsection-title">Members</h3>
<h4 class="name" id="~cmd"><span class="type-signature">(inner) </span>cmd<span class="type-signature"></span></h4>
<div class="description">
The FFMPEG command.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_commander.js.html">src/commander.js</a>, <a href="src_commander.js.html#line22">line 22</a>
</li></ul></dd>
</dl>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="~crashed"><span class="type-signature">(inner) </span>crashed<span class="signature">(error, stdout, stderr)</span><span class="type-signature"></span></h4>
<div class="description">
Log and handle crashes. Notify the main module.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>error</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Error object from the crash.</td>
</tr>
<tr>
<td class="name"><code>stdout</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>stderr</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_commander.js.html">src/commander.js</a>, <a href="src_commander.js.html#line174">line 174</a>
</li></ul></dd>
</dl>
<h4 class="name" id="~stopped"><span class="type-signature">(inner) </span>stopped<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Utilities
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_commander.js.html">src/commander.js</a>, <a href="src_commander.js.html#line138">line 138</a>
</li></ul></dd>
</dl>
<h4 class="name" id="~tryReconnect"><span class="type-signature">(inner) </span>tryReconnect<span class="signature">(host, port)</span><span class="type-signature"></span></h4>
<div class="description">
Probe the connection to the host on the port and restart the stream afterwards.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>host</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>port</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_commander.js.html">src/commander.js</a>, <a href="src_commander.js.html#line211">line 211</a>
</li></ul></dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Actions.html">Actions</a></li><li><a href="module-Commander.html">Commander</a></li><li><a href="module-Main.html">Main</a></li><li><a href="module-Reducers.html">Reducers</a></li><li><a href="module-Streamer.html">Streamer</a></li><li><a href="module-Utilities_Config.html">Utilities/Config</a></li></ul><h3>Classes</h3><ul><li><a href="module-Commander-Commander.html">Commander</a></li><li><a href="module-Streamer-Streamer.html">Streamer</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Mon Apr 24 2017 18:52:45 GMT+1200 (NZST)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>

View file

@ -1,423 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Module: Main</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Module: Main</h1>
<section>
<header>
</header>
<article>
<div class="container-overview">
<div class="description">The main module and entry point.</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="main_new.js.html">main_new.js</a>, <a href="main_new.js.html#line1">line 1</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Members</h3>
<h4 class="name" id="~initialState"><span class="type-signature">(inner) </span>initialState<span class="type-signature"></span></h4>
<div class="description">
Inital State for the app.
</div>
<h5 class="subsection-title">Properties:</h5>
<table class="props">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>stream</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Stream Status.
<h6>Properties</h6>
<table class="props">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>running</code></td>
<td class="type">
<span class="param-type">bool</span>
</td>
<td class="description last">Indicates wether the stream is running.</td>
</tr>
<tr>
<td class="name"><code>error</code></td>
<td class="type">
<span class="param-type">number</span>
|
<span class="param-type">bool</span>
</td>
<td class="description last">Error code. Any number outside the range of the Error array in @see ffmpeg-command.js will be treated as non error. Most conveniently set: false.</td>
</tr>
<tr>
<td class="name"><code>errorHandling</code></td>
<td class="type">
<span class="param-type">bool</span>
|
<span class="param-type">string</span>
</td>
<td class="description last">Indicates wether the program tries to handle an error.</td>
</tr>
<tr>
<td class="name"><code>restaring</code></td>
<td class="type">
<span class="param-type">bool</span>
</td>
<td class="description last">Indicades wether the stream is currently being restarted.</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="name"><code>config</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Configuration of the camera.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="main_new.js.html">main_new.js</a>, <a href="main_new.js.html#line22">line 22</a>
</li></ul></dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Actions.html">Actions</a></li><li><a href="module-Commander.html">Commander</a></li><li><a href="module-Main.html">Main</a></li><li><a href="module-Reducers.html">Reducers</a></li><li><a href="module-Streamer.html">Streamer</a></li><li><a href="module-Utilities_Config.html">Utilities/Config</a></li></ul><h3>Classes</h3><ul><li><a href="module-Commander-Commander.html">Commander</a></li><li><a href="module-Streamer-Streamer.html">Streamer</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Mon Apr 24 2017 18:52:46 GMT+1200 (NZST)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>

View file

@ -1,581 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Module: Reducers</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Module: Reducers</h1>
<section>
<header>
</header>
<article>
<div class="container-overview">
<div class="description">Outsourced definition of the Reducers for redux.</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_reducers.js.html">src/reducers.js</a>, <a href="src_reducers.js.html#line1">line 1</a>
</li></ul></dd>
<dt class="tag-see">See:</dt>
<dd class="tag-see">
<ul>
<li><a href="http://redux.js.org/docs/basics/Reducers.html">http://redux.js.org/docs/basics/Reducers.html</a></li>
</ul>
</dd>
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="~config"><span class="type-signature">(inner) </span>config<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Updates the config state.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_reducers.js.html">src/reducers.js</a>, <a href="src_reducers.js.html#line81">line 81</a>
</li></ul></dd>
</dl>
<h4 class="name" id="~error"><span class="type-signature">(inner) </span>error<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Set the error code. @see ffmpegCommand.js for the error code descriptions.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_reducers.js.html">src/reducers.js</a>, <a href="src_reducers.js.html#line21">line 21</a>
</li></ul></dd>
</dl>
<h4 class="name" id="~handleError"><span class="type-signature">(inner) </span>handleError<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Set the error handling procedure.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_reducers.js.html">src/reducers.js</a>, <a href="src_reducers.js.html#line36">line 36</a>
</li></ul></dd>
</dl>
<h4 class="name" id="~running"><span class="type-signature">(inner) </span>running<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Set the running flag.
It can either be RUNNING, STARTING, STOPPING or STOPPED
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_reducers.js.html">src/reducers.js</a>, <a href="src_reducers.js.html#line53">line 53</a>
</li></ul></dd>
</dl>
<h4 class="name" id="~stream"><span class="type-signature">(inner) </span>stream<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Stream Root Reducer.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_reducers.js.html">src/reducers.js</a>, <a href="src_reducers.js.html#line68">line 68</a>
</li></ul></dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Actions.html">Actions</a></li><li><a href="module-Commander.html">Commander</a></li><li><a href="module-Main.html">Main</a></li><li><a href="module-Reducers.html">Reducers</a></li><li><a href="module-Streamer.html">Streamer</a></li><li><a href="module-Utilities_Config.html">Utilities/Config</a></li></ul><h3>Classes</h3><ul><li><a href="module-Commander-Commander.html">Commander</a></li><li><a href="module-Streamer-Streamer.html">Streamer</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Mon Apr 24 2017 18:52:46 GMT+1200 (NZST)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>

View file

@ -1,460 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: Streamer</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Class: Streamer</h1>
<section>
<header>
<h2>
<span class="ancestors"><a href="module-Streamer.html">Streamer</a>~</span>Streamer</h2>
<div class="class-description">Streamer
The central control Object (singleton for now) which has the permission to change state.</div>
</header>
<article>
<div class="container-overview">
<h2>Constructor</h2>
<h4 class="name" id="Streamer"><span class="type-signature"></span>new Streamer<span class="signature">(communicator)</span><span class="type-signature"></span></h4>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>communicator</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="default">
false
</td>
<td class="description last">A communicator object. @see communicator.js - Optional //TODO: Find proper tag.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_streamer.js.html">src/streamer.js</a>, <a href="src_streamer.js.html#line59">line 59</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="getConfig"><span class="type-signature"></span>getConfig<span class="signature">()</span><span class="type-signature"> &rarr; {*}</span></h4>
<div class="description">
Get the current config.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_streamer.js.html">src/streamer.js</a>, <a href="src_streamer.js.html#line91">line 91</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
The current config.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">*</span>
</dd>
</dl>
<h4 class="name" id="setCommunicator"><span class="type-signature"></span>setCommunicator<span class="signature">(communicator)</span><span class="type-signature"></span></h4>
<div class="description">
Set the communicator object and enable the state sync with the server.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>communicator</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">A communicator object. @see communicator.js</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_streamer.js.html">src/streamer.js</a>, <a href="src_streamer.js.html#line80">line 80</a>
</li></ul></dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Actions.html">Actions</a></li><li><a href="module-Commander.html">Commander</a></li><li><a href="module-Main.html">Main</a></li><li><a href="module-Reducers.html">Reducers</a></li><li><a href="module-Streamer.html">Streamer</a></li><li><a href="module-Utilities_Config.html">Utilities/Config</a></li></ul><h3>Classes</h3><ul><li><a href="module-Commander-Commander.html">Commander</a></li><li><a href="module-Streamer-Streamer.html">Streamer</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Mon Apr 24 2017 18:52:46 GMT+1200 (NZST)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>

View file

@ -1,525 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Module: Streamer</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Module: Streamer</h1>
<section>
<header>
</header>
<article>
<div class="container-overview">
<div class="description">The central interface to the streaming process.</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_streamer.js.html">src/streamer.js</a>, <a href="src_streamer.js.html#line1">line 1</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Classes</h3>
<dl>
<dt><a href="module-Streamer-Streamer.html">Streamer</a></dt>
<dd></dd>
</dl>
<h3 class="subsection-title">Members</h3>
<h4 class="name" id="~_communicator"><span class="type-signature">(inner) </span>_communicator<span class="type-signature"></span></h4>
<div class="description">
The socket.io connection from the main-module.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_streamer.js.html">src/streamer.js</a>, <a href="src_streamer.js.html#line35">line 35</a>
</li></ul></dd>
</dl>
<h4 class="name" id="~initialState"><span class="type-signature">(inner) </span>initialState<span class="type-signature"></span></h4>
<div class="description">
Inital State for the app.
</div>
<h5 class="subsection-title">Properties:</h5>
<table class="props">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>stream</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Stream Status.
<h6>Properties</h6>
<table class="props">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>running</code></td>
<td class="type">
<span class="param-type">bool</span>
</td>
<td class="description last">Indicates wether the stream is running.</td>
</tr>
<tr>
<td class="name"><code>error</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last">Error code. Any number outside the range of the Error array in @see ffmpeg-command.js will be treated as non error. Most conveniently set: -1.</td>
</tr>
<tr>
<td class="name"><code>reconnecting</code></td>
<td class="type">
<span class="param-type">bool</span>
</td>
<td class="description last">Indicates wether the program tries to reconnect to the camera or the internet.</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="name"><code>config</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Configuration of the camera.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_streamer.js.html">src/streamer.js</a>, <a href="src_streamer.js.html#line22">line 22</a>
</li></ul></dd>
</dl>
<h4 class="name" id="~reducer"><span class="type-signature">(inner, constant) </span>reducer<span class="type-signature"></span></h4>
<div class="description">
Redux Actions
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_streamer.js.html">src/streamer.js</a>, <a href="src_streamer.js.html#line41">line 41</a>
</li></ul></dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Actions.html">Actions</a></li><li><a href="module-Commander.html">Commander</a></li><li><a href="module-Main.html">Main</a></li><li><a href="module-Reducers.html">Reducers</a></li><li><a href="module-Streamer.html">Streamer</a></li><li><a href="module-Utilities_Config.html">Utilities/Config</a></li></ul><h3>Classes</h3><ul><li><a href="module-Commander-Commander.html">Commander</a></li><li><a href="module-Streamer-Streamer.html">Streamer</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Mon Apr 24 2017 18:52:46 GMT+1200 (NZST)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>

View file

@ -1,423 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Module: Utilities/Config</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Module: Utilities/Config</h1>
<section>
<header>
</header>
<article>
<div class="container-overview">
<div class="description">Config read/write utilities.</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_utility_config.js.html">src/utility/config.js</a>, <a href="src_utility_config.js.html#line1">line 1</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id=".read"><span class="type-signature">(static) </span>read<span class="signature">()</span><span class="type-signature"> &rarr; {Object|bool}</span></h4>
<div class="description">
Read the JSON config file.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_utility_config.js.html">src/utility/config.js</a>, <a href="src_utility_config.js.html#line18">line 18</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Returns the parsed config or false in case of an error.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
|
<span class="param-type">bool</span>
</dd>
</dl>
<h4 class="name" id=".write"><span class="type-signature">(static) </span>write<span class="signature">(state)</span><span class="type-signature"> &rarr; {Promise}</span></h4>
<div class="description">
Writes the config to disk.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>state</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">A function to retrieve the current state. This makes it harder to accidentially write arbitrary code.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="src_utility_config.js.html">src/utility/config.js</a>, <a href="src_utility_config.js.html#line32">line 32</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
A promise for writing the configuration.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Actions.html">Actions</a></li><li><a href="module-Commander.html">Commander</a></li><li><a href="module-Main.html">Main</a></li><li><a href="module-Reducers.html">Reducers</a></li><li><a href="module-Streamer.html">Streamer</a></li><li><a href="module-Utilities_Config.html">Utilities/Config</a></li></ul><h3>Classes</h3><ul><li><a href="module-Commander-Commander.html">Commander</a></li><li><a href="module-Streamer-Streamer.html">Streamer</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Mon Apr 24 2017 18:52:46 GMT+1200 (NZST)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>

View file

@ -1,25 +0,0 @@
/*global document */
(function() {
var source = document.getElementsByClassName('prettyprint source linenums');
var i = 0;
var lineNumber = 0;
var lineId;
var lines;
var totalLines;
var anchorHash;
if (source && source[0]) {
anchorHash = document.location.hash.substring(1);
lines = source[0].getElementsByTagName('li');
totalLines = lines.length;
for (; i < totalLines; i++) {
lineNumber++;
lineId = 'line' + lineNumber;
lines[i].id = lineId;
if (lineId === anchorHash) {
lines[i].className += ' selected';
}
}
}
})();

View file

@ -1,202 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View file

@ -1,2 +0,0 @@
PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\f\r ]+/,null," \t\r\n "]],[["str",/^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/,null],["str",/^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/,null],["lang-css-str",/^url\(([^"')]*)\)/i],["kwd",/^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],["com",
/^(?:<\!--|--\>)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#[\da-f]{3,6}/i],["pln",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],["pun",/^[^\s\w"']+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^"')]+/]]),["css-str"]);

View file

@ -1,28 +0,0 @@
var q=null;window.PR_SHOULD_USE_CONTINUATION=!0;
(function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a=
[],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c<i;++c){var j=f[c];if(/\\[bdsw]/i.test(j))a.push(j);else{var j=m(j),d;c+2<i&&"-"===f[c+1]?(d=m(f[c+2]),c+=2):d=j;b.push([j,d]);d<65||j>122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;c<b.length;++c)i=b[c],i[0]<=j[1]+1?j[1]=Math.max(j[1],i[1]):f.push(j=i);b=["["];o&&b.push("^");b.push.apply(b,a);for(c=0;c<
f.length;++c)i=f[c],b.push(e(i[0])),i[1]>i[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c<b;++c){var j=f[c];j==="("?++i:"\\"===j.charAt(0)&&(j=+j.substring(1))&&j<=i&&(d[j]=-1)}for(c=1;c<d.length;++c)-1===d[c]&&(d[c]=++t);for(i=c=0;c<b;++c)j=f[c],j==="("?(++i,d[i]===void 0&&(f[c]="(?:")):"\\"===j.charAt(0)&&
(j=+j.substring(1))&&j<=i&&(f[c]="\\"+d[i]);for(i=c=0;c<b;++c)"^"===f[c]&&"^"!==f[c+1]&&(f[c]="");if(a.ignoreCase&&s)for(c=0;c<b;++c)j=f[c],a=j.charAt(0),j.length>=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p<d;++p){var g=a[p];if(g.ignoreCase)l=!0;else if(/[a-z]/i.test(g.source.replace(/\\u[\da-f]{4}|\\x[\da-f]{2}|\\[^UXux]/gi,""))){s=!0;l=!1;break}}for(var r=
{b:8,t:9,n:10,v:11,f:12,r:13},n=[],p=0,d=a.length;p<d;++p){g=a[p];if(g.global||g.multiline)throw Error(""+g);n.push("(?:"+y(g)+")")}return RegExp(n.join("|"),l?"gi":"g")}function M(a){function m(a){switch(a.nodeType){case 1:if(e.test(a.className))break;for(var g=a.firstChild;g;g=g.nextSibling)m(g);g=a.nodeName;if("BR"===g||"LI"===g)h[s]="\n",t[s<<1]=y++,t[s++<<1|1]=a;break;case 3:case 4:g=a.nodeValue,g.length&&(g=p?g.replace(/\r\n?/g,"\n"):g.replace(/[\t\n\r ]+/g," "),h[s]=g,t[s<<1]=y,y+=g.length,
t[s++<<1|1]=a)}}var e=/(?:^|\s)nocode(?:\s|$)/,h=[],y=0,t=[],s=0,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=document.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);m(a);return{a:h.join("").replace(/\n$/,""),c:t}}function B(a,m,e,h){m&&(a={a:m,d:a},e(a),h.push.apply(h,a.e))}function x(a,m){function e(a){for(var l=a.d,p=[l,"pln"],d=0,g=a.a.match(y)||[],r={},n=0,z=g.length;n<z;++n){var f=g[n],b=r[f],o=void 0,c;if(typeof b===
"string")c=!1;else{var i=h[f.charAt(0)];if(i)o=f.match(i[1]),b=i[0];else{for(c=0;c<t;++c)if(i=m[c],o=f.match(i[1])){b=i[0];break}o||(b="pln")}if((c=b.length>=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m),
l=[],p={},d=0,g=e.length;d<g;++d){var r=e[d],n=r[3];if(n)for(var k=n.length;--k>=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/,
q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/,
q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g,
"");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a),
a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e}
for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g<d.length;++g)e(d[g]);m===(m|0)&&d[0].setAttribute("value",
m);var r=s.createElement("OL");r.className="linenums";for(var n=Math.max(0,m-1|0)||0,g=0,z=d.length;g<z;++g)l=d[g],l.className="L"+(g+n)%10,l.firstChild||l.appendChild(s.createTextNode("\xa0")),r.appendChild(l);a.appendChild(r)}function k(a,m){for(var e=m.length;--e>=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*</.test(m)?"default-markup":"default-code";return A[a]}function E(a){var m=
a.g;try{var e=M(a.h),h=e.a;a.a=h;a.c=e.c;a.d=0;C(m,h)(a);var k=/\bMSIE\b/.test(navigator.userAgent),m=/\n/g,t=a.a,s=t.length,e=0,l=a.c,p=l.length,h=0,d=a.e,g=d.length,a=0;d[g]=s;var r,n;for(n=r=0;n<g;)d[n]!==d[n+2]?(d[r++]=d[n++],d[r++]=d[n++]):n+=2;g=r;for(n=r=0;n<g;){for(var z=d[n],f=d[n+1],b=n+2;b+2<=g&&d[b+1]===f;)b+=2;d[r++]=z;d[r++]=f;n=b}for(d.length=r;h<p;){var o=l[h+2]||s,c=d[a+2]||s,b=Math.min(o,c),i=l[h+1],j;if(i.nodeType!==1&&(j=t.substring(e,b))){k&&(j=j.replace(m,"\r"));i.nodeValue=
j;var u=i.ownerDocument,v=u.createElement("SPAN");v.className=d[a+1];var x=i.parentNode;x.replaceChild(v,i);v.appendChild(i);e<o&&(l[h+1]=i=u.createTextNode(t.substring(b,o)),x.insertBefore(i,v.nextSibling))}e=b;e>=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],
"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"],
H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],
J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+
I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^<?]+/],["dec",/^<!\w[^>]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),
["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css",
/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),
["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes",
hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p<h.length&&l.now()<e;p++){var n=h[p],k=n.className;if(k.indexOf("prettyprint")>=0){var k=k.match(g),f,b;if(b=
!k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p<h.length?setTimeout(m,
250):a&&a()}for(var e=[document.getElementsByTagName("pre"),document.getElementsByTagName("code"),document.getElementsByTagName("xmp")],h=[],k=0;k<e.length;++k)for(var t=0,s=e[k].length;t<s;++t)h.push(e[k][t]);var e=q,l=Date;l.now||(l={now:function(){return+new Date}});var p=0,d,g=/\blang(?:uage)?-([\w.]+)(?!\S)/;m()};window.PR={createSimpleLexer:x,registerLangHandler:k,sourceDecorator:u,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",
PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ"}})();

View file

@ -1,137 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: src/actions.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: src/actions.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/** Outsourced definition of the actions and simple action creators for simple actions.
* @module Actions
* @todo allowed values
*/
const Promise = require('promise');
const writeConfig = require('./utility/config.js').write;
/**
* Actions
* The action definitions.
*/
let actions = {
UPDATE_CONFIG: 'UPDATE_CONFIG',
REQUEST_START: 'REQUEST_START',
SET_STARTED: 'SET_STATED',
REQUEST_STOP: 'REQUEST_STOP',
SET_STOPPED: 'SET_STOPPED',
REQUEST_RESTART: 'REQUEST_RESTART',
SET_ERROR: 'SET_ERROR',
TRY_RECONECT: 'TRY_RECONNECT'
};
/**
* Trivial Action Creators
*/
let creators = {};
creators.updateConfig = function(update) {
return function(dispatch, getState) {
dispatch({
type: actions.UPDATE_CONFIG,
data: update
});
return writeConfig(getState());
};
};
creators.requestStart = function() {
return {
type: actions.REQUEST_START
};
};
creators.requestStop = function() {
return {
type: actions.REQUEST_STOP
};
};
creators.setStarted = function() {
return {
type: actions.SET_STARTED
};
};
creators.setStopped = function() {
return {
type: actions.SET_STOPPED
};
};
creators.requestRestart = function() {
return {
type: actions.REQUEST_RESTART
};
};
creators.setError = function(error) {
return {
type: actions.SET_ERROR,
data: error
};
};
creators.tryReconnect = function() {
return {
type: actions.TRY_RECONECT
};
};
module.exports = {
actions,
creators
};
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Actions.html">Actions</a></li><li><a href="module-Commander.html">Commander</a></li><li><a href="module-Main.html">Main</a></li><li><a href="module-Reducers.html">Reducers</a></li><li><a href="module-Streamer.html">Streamer</a></li><li><a href="module-Utilities_Config.html">Utilities/Config</a></li></ul><h3>Classes</h3><ul><li><a href="module-Commander-Commander.html">Commander</a></li><li><a href="module-Streamer-Streamer.html">Streamer</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Mon Apr 24 2017 18:52:45 GMT+1200 (NZST)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>

View file

@ -1,294 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: src/commander.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: src/commander.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/**
* @module Commander
* @description A Wrapper for Fluent-FFMPEG with a custom command.
*/
const ffmpeg = require('fluent-ffmpeg');
const http = require('http');
const logger = require('./logger');
///////////////////////////////////////////////////////////////////////////////
// Declarations //
///////////////////////////////////////////////////////////////////////////////
// Reference to itself. (Object oriented this. Only used to call public methods.)
let self = false;
/**
* The FFMPEG command.
* @member
*/
let cmd = ffmpeg({
stdoutLines: 20
});
// The Config, Logger and a handle for the kill timeout.
let _config, _stopHandle = false, _connectHandle = false;
// Error Texts //TODO put them into separate module
let errorDescriptions = ['Camera Disconnected',
'YoutTube Disconnected',
'Wrong ffmpeg executable.',
'Unknown Error - Restarting'];
// The stream source url. Yet to be set.
let source = "";
///////////////////////////////////////////////////////////////////////////////
// Code //
///////////////////////////////////////////////////////////////////////////////
/**
* Interface to the ffmpeg process. Uses fluent-ffmpeg.
* @constructor
*/
let Commander = function(){
// singleton
if(self)
return self;
// Make `new` optional.
if(!(this instanceof Commander))
return new Commander();
self = this;
/**
* (Re)Create the ffmpeg command and configure it.
* @param { Object } config The configuration for the stream.
* @returns { Object } The fluent-ffmpeg command object.
*/
let createCommand = function(config) {
// Clear inputs
cmd._inputs = [];
// TODO: Multi Protocol
source = 'rtsp://' + config.camIP + ':' + config.camPort + '/' + config.camProfile;
cmd.input(source);
// Custom config if any.
if (config.customOutputOptions !== "")
cmd.outputOptions(config.customOutputOptions.replace(/\s+\,\s+/g, ',').replace(/\s+\-/g, ',-').split(','));
if (config.customAudioOptions !== "")
cmd.outputOptions(config.customAudioOptions.replace(/\s+\,\s+/g, ',').replace(/\s+\-/g, ',-').split(','));
else
cmd.AudioCodec('copy');
if (config.customVideoOptions !== "")
cmd.outputOptions(config.customVideoOptions.replace(/\s+\,\s+/g, ',').replace(/\s+\-/g, ',-').split(','));
else
cmd.videoCodec('copy');
// Output Options.
cmd.outputFormat('flv')
.outputOptions(['-bufsize 50000k', '-tune film'])
.output('rtmp://a.rtmp.youtube.com/live2/' + config.key);
// Register events.
cmd.on('start', started);
cmd.on('end', stopped);
cmd.on('error', crashed);
return cmd;
};
let ffmpegCommand = function() {
return cmd;
};
// NOTE: Maybe better error resolving strategy.
// Start streaming.
let start = function() {
// Ignore if we try to reconnect.
if(_connectHandle)
return;
cmd.run();
};
// Restart the stream;
let restart = function() {
if(status.streaming) {
restart = true; // NOTE: not very nice
this.stop();
} else
this.start();
};
// Stop streaming.
let stop = function() {
cmd.kill('SIGINT');
_stopHandle = setTimeout(() => {
logger.log(logger.importance[3], "Force Stop!");
cmd.kill();
}, 3000);
};
};
/**
* Utilities
*/
// Handle Stop and Restart
function stopped() {
status.streaming = false;
// Clear force kill Timeout
if(stopTimeout) {
clearTimeout(stopTimeout);
stopTimeout = false;
}
// Restart the stream;
if (restart) {
self.start();
}
cmd.emit('stopped');
}
// TODO: Restart = false in stopped?
// Hande Stat
function started() {
cmd.emit(restart ? 'restarted' : 'started');
restart = false;
status.error = false;
status.streaming = true;
}
/**
* Error Handling
*/
/**
* Log and handle crashes. Notify the main module.
* @param { Object } error - Error object from the crash.
* @param { String } stdout
* @param { String } stderr
*/
function crashed(error, stdout, stderr){
// Can't connect to the
if (err.message.indexOf(source) > -1)
status.error = 0;
// Can't connect to the Internet / YouTube
else if (err.message.indexOf(source + 'Input/output error') > -1 || err.message.indexOf('rtmp://a.rtmp.youtube.com/live2/' + _config.key) > -1)
status.error = 1;
// Wrong FFMPEG Executable
else if (err.message.indexOf('spawn') > -1 || err.message.indexOf('niceness') > -1)
status.error = 2;
// Stopped by us - SIGINT Shouldn't lead to a crash.
else if (err.message.indexOf('SIGINT') > -1 || err.message.indexOf('SIGKILL') > -1){
stopped();
return;
}
// Some unknown Problem, just try to restart.
else {
status.error = 3;
// Just restart in a Second
setTimeout(function(){
self.start();
}, 1000);
}
logger.log(logger.importance[2], `Crashed: ${erro}\nSTDERR: ${stderr}`);
}
/**
* Probe the connection to the host on the port and restart the stream afterwards.
* @param { string } host
* @param { number } port
*/
function tryReconnect( host, port ){
if (!host || !port)
return;
http.get({
host: host.split('/')[0],
port: port
}, function(res) {
// We have a response! Connection works.
setTimeout(function() {
// NOTE: Ugly!
// We have a response! Connection works.
_connectHandle = false;
self.start();
}, 1000);
}).on("error", function(e) {
if (e.message == "socket hang up") {
setTimeout(function() {
// NOTE: Ugly!
// We have a response! Connection works.
_connectHandle = false;
self.start();
}, 1000);
} else {
// try again
_connectHandle = setTimeout(function(){
tryReconnect(host, port);
}, 1000);
}
});
}
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Actions.html">Actions</a></li><li><a href="module-Commander.html">Commander</a></li><li><a href="module-Main.html">Main</a></li><li><a href="module-Reducers.html">Reducers</a></li><li><a href="module-Streamer.html">Streamer</a></li><li><a href="module-Utilities_Config.html">Utilities/Config</a></li></ul><h3>Classes</h3><ul><li><a href="module-Commander-Commander.html">Commander</a></li><li><a href="module-Streamer-Streamer.html">Streamer</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Mon Apr 24 2017 18:52:45 GMT+1200 (NZST)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>

View file

@ -1,130 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: src/logger.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: src/logger.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>///////////////////////////////////////////////////////////////////////////////
// Winston Logger Wrapper with Custom Colors and Transports //
///////////////////////////////////////////////////////////////////////////////
let winston = require('winston');
///////////////////////////////////////////////////////////////////////////////
// Declarations //
///////////////////////////////////////////////////////////////////////////////
// Object oriented `this`.
let self = false;
// Custom log levels.
const customLevels = {
levels: {
normal: 0,
info: 1,
warning: 2,
danger: 3,
success: 4
},
colors: {
normal: 'white',
info: 'blue',
warning: 'orange',
danger: 'red',
success: 'green'
}
};
///////////////////////////////////////////////////////////////////////////////
// Code //
///////////////////////////////////////////////////////////////////////////////
/**
* Monkey Patching.
*/
/**
* Calls the logging function with arguments, if the node enviroment isn't in production mode.
*/
winston.Logger.prototype.dbgmsg = function() {
if (process.env.NODE_ENV !== 'production')
this.log.apply(undefined, arguments);
};
// Set the Colors
winston.addColors(customLevels.colors);
let logger = (function() {
if(!self)
self = new(winston.Logger)({
levels: customLevels.levels,
transports: [
new(winston.transports.Console)({
level: 'success'
}),
new(winston.transports.File)({
filename: __dirname + '/process.log',
colorize: true,
timestamp: true,
level: 'success',
json: true,
maxsize: 500000,
maxFiles: 10
})
]
});
return self;
})();
logger.importance = ['normal', 'info', 'warning', 'danger', 'success'];
// Export the Logger
module.exports = logger;
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Actions.html">Actions</a></li><li><a href="module-Commander.html">Commander</a></li><li><a href="module-Main.html">Main</a></li><li><a href="module-Reducers.html">Reducers</a></li><li><a href="module-Streamer.html">Streamer</a></li><li><a href="module-Utilities_Config.html">Utilities/Config</a></li></ul><h3>Classes</h3><ul><li><a href="module-Commander-Commander.html">Commander</a></li><li><a href="module-Streamer-Streamer.html">Streamer</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Mon Apr 24 2017 18:52:45 GMT+1200 (NZST)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>

View file

@ -1,146 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: src/reducers.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: src/reducers.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/** Outsourced definition of the Reducers for redux.
* @see {@link http://redux.js.org/docs/basics/Reducers.html}
* @module Reducers
*/
const redux = srequire('redux');
const { UPDATE_CONFIG,
REQUEST_START,
SET_STARTED,
REQUEST_STOP,
SET_STOPPED,
REQUEST_RESTART,
SET_ERROR,
TRY_RECONECT}= require('./actions');
let reducers = {};
/**
* Set the error code. @see ffmpegCommand.js for the error code descriptions.
*/
function error(state = false, action) {
switch (action.type) {
case SET_ERROR:
return action.data;
case SET_STARTED:
return false;
default:
return state;
}
};
// TODO: Add central definition
/**
* Set the error handling procedure.
*/
function handleError(state = false, action) {
switch (action.type) {
case SET_STARTED:
return false;
case TRY_RECONECT:
return 'RECONNECTING';
default:
return state;
}
}
/**
* Set the running flag.
* It can either be RUNNING, STARTING, STOPPING or STOPPED
*/
function running(state = 'STOPPED', action) {
switch (action.type) {
case REQUEST_START:
return 'STARTING';
case SET_STARTED:
return 'RUNNING';
case REQUEST_STOP:
return 'STOPPING';
case SET_STOPPED:
return 'STOPPED';
default:
return state;
}
}
/**
* @function stream
* @description Stream Root Reducer.
*/
reducers.stream = function(state = {}, action){
return {
running: running(state, action),
error: error(state, action),
handleError: handleError(state, action),
restarting: restarting(state, action)
};
};
/**
* @function config
* @description Updates the config state.
*/
reducers.config = function(state = {}, action) {
switch (action.type) {
case UPDATE_CONFIG:
return Object.assign({}, state, action.data);
break;
default:
return state;
}
};
module.exports = redux.combineReducers(reducers);
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Actions.html">Actions</a></li><li><a href="module-Commander.html">Commander</a></li><li><a href="module-Main.html">Main</a></li><li><a href="module-Reducers.html">Reducers</a></li><li><a href="module-Streamer.html">Streamer</a></li><li><a href="module-Utilities_Config.html">Utilities/Config</a></li></ul><h3>Classes</h3><ul><li><a href="module-Commander-Commander.html">Commander</a></li><li><a href="module-Streamer-Streamer.html">Streamer</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Mon Apr 24 2017 18:52:45 GMT+1200 (NZST)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>

View file

@ -1,151 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: src/streamer.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: src/streamer.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/** The central interface to the streaming process.
* @module Streamer
*/
const logger = require('./logger');
///////////////////////////////////////////////////////////////////////////////
// Declarations //
///////////////////////////////////////////////////////////////////////////////
// Object oriented `this`.
let self = false;
/**
* Inital State for the app.
* @property { Object } stream Stream Status.
* @property { bool } stream.running Indicates wether the stream is running.
* @property { number } stream.error Error code. Any number outside the range of the Error array in @see ffmpeg-command.js will be treated as non error. Most conveniently set: -1.
* @property { bool } stream.reconnecting Indicates wether the program tries to reconnect to the camera or the internet.
* @property { Object } config Configuration of the camera.
*/
let initialState = {
stream: {
running: 'STOPPED',
error: -1,
reconnecting: false,
restarting: false
},
config: {}
}; // NOTE: Maybe in main.js
/**
* The socket.io connection from the main-module.
*/
let _communicator;
/**
* Redux Actions
*/
// Reducer
const reducer = require('./reducers');
// Reference to the store of the application state.
const store = redux.createStore(reducer, initialState);
///////////////////////////////////////////////////////////////////////////////
// Code //
///////////////////////////////////////////////////////////////////////////////
// TODO: Log state changes.
/**
* @class Streamer
* The central control Object (singleton for now) which has the permission to change state.
*
* @constructor
* @param { Object } communicator A communicator object. @see communicator.js - Optional //TODO: Find proper tag.
*/
function Streamer(communicator = false) {
// singleton
if (self)
return self;
// Make `new` optional.
if (!(this instanceof Streamer))
return new Streamer(_communicator);
_communicator = communicator;
self = this;
return this;
};
module.exports = Streamer;
/**
* Set the communicator object and enable the state sync with the server.
* @param {Object} communicator A communicator object. @see communicator.js
*/
Streamer.prototype.setCommunicator = function(communicator) {
if (_communicator)
_communicator = communicator;
else
logger.dbgmsdg("Invalid Communicator");
};
/**
* Get the current config.
* @returns { * } The current config.
*/
Streamer.prototype.getConfig = function(){
return store.getStreamer().config;
};
/**
* Utilities
*/
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Actions.html">Actions</a></li><li><a href="module-Commander.html">Commander</a></li><li><a href="module-Main.html">Main</a></li><li><a href="module-Reducers.html">Reducers</a></li><li><a href="module-Streamer.html">Streamer</a></li><li><a href="module-Utilities_Config.html">Utilities/Config</a></li></ul><h3>Classes</h3><ul><li><a href="module-Commander-Commander.html">Commander</a></li><li><a href="module-Streamer-Streamer.html">Streamer</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Mon Apr 24 2017 18:52:45 GMT+1200 (NZST)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>

View file

@ -1,94 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: src/utility/config.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: src/utility/config.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/** Config read/write utilities.
* @module Utilities/Config
*/
const Promise = require('promise');
const fs = require('fs');
const logger = require('./logger.js');
// TODO: Config path in defs
module.exports = {};
// TODO Default CFG
/**
* Read the JSON config file.
* @returns { Object | bool } Returns the parsed config or false in case of an error.
*/
module.exports.read = function() {
try {
return JSON.parse(fs.readFileSync(__dirname + '/config.js'));
} catch (e) {
logger.dbgmsg(e);
return false;
}
};
/**
* Writes the config to disk.
* @param {Object} state A function to retrieve the current state. This makes it harder to accidentially write arbitrary code.
* @returns { Promise } A promise for writing the configuration.
*/
module.exports.write = function( getState ){
return new Promise((resolve, reject) => {
fs.writeFile(__dirname + '/config.js',
JSON.stringify(getState().config, undefined, 2),
err => {
if(err)
reject(err);
else
resolve();
});
});
};
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-Actions.html">Actions</a></li><li><a href="module-Commander.html">Commander</a></li><li><a href="module-Main.html">Main</a></li><li><a href="module-Reducers.html">Reducers</a></li><li><a href="module-Streamer.html">Streamer</a></li><li><a href="module-Utilities_Config.html">Utilities/Config</a></li></ul><h3>Classes</h3><ul><li><a href="module-Commander-Commander.html">Commander</a></li><li><a href="module-Streamer-Streamer.html">Streamer</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Mon Apr 24 2017 18:52:45 GMT+1200 (NZST)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>

View file

@ -1,354 +0,0 @@
@font-face {
font-family: 'Open Sans';
font-weight: normal;
font-style: normal;
src: url('../fonts/OpenSans-Regular-webfont.eot');
src:
local('Open Sans'),
local('OpenSans'),
url('../fonts/OpenSans-Regular-webfont.eot?#iefix') format('embedded-opentype'),
url('../fonts/OpenSans-Regular-webfont.woff') format('woff'),
url('../fonts/OpenSans-Regular-webfont.svg#open_sansregular') format('svg');
}
@font-face {
font-family: 'Open Sans Light';
font-weight: normal;
font-style: normal;
src: url('../fonts/OpenSans-Light-webfont.eot');
src:
local('Open Sans Light'),
local('OpenSans Light'),
url('../fonts/OpenSans-Light-webfont.eot?#iefix') format('embedded-opentype'),
url('../fonts/OpenSans-Light-webfont.woff') format('woff'),
url('../fonts/OpenSans-Light-webfont.svg#open_sanslight') format('svg');
}
html
{
overflow: auto;
background-color: #fff;
font-size: 14px;
}
body
{
font-family: 'Open Sans', sans-serif;
line-height: 1.5;
color: #4d4e53;
background-color: white;
}
a, a:visited, a:active {
color: #0095dd;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
header
{
display: block;
padding: 0px 4px;
}
tt, code, kbd, samp {
font-family: Consolas, Monaco, 'Andale Mono', monospace;
}
.class-description {
font-size: 130%;
line-height: 140%;
margin-bottom: 1em;
margin-top: 1em;
}
.class-description:empty {
margin: 0;
}
#main {
float: left;
width: 70%;
}
article dl {
margin-bottom: 40px;
}
section
{
display: block;
background-color: #fff;
padding: 12px 24px;
border-bottom: 1px solid #ccc;
margin-right: 30px;
}
.variation {
display: none;
}
.signature-attributes {
font-size: 60%;
color: #aaa;
font-style: italic;
font-weight: lighter;
}
nav
{
display: block;
float: right;
margin-top: 28px;
width: 30%;
box-sizing: border-box;
border-left: 1px solid #ccc;
padding-left: 16px;
}
nav ul {
font-family: 'Lucida Grande', 'Lucida Sans Unicode', arial, sans-serif;
font-size: 100%;
line-height: 17px;
padding: 0;
margin: 0;
list-style-type: none;
}
nav ul a, nav ul a:visited, nav ul a:active {
font-family: Consolas, Monaco, 'Andale Mono', monospace;
line-height: 18px;
color: #4D4E53;
}
nav h3 {
margin-top: 12px;
}
nav li {
margin-top: 6px;
}
footer {
display: block;
padding: 6px;
margin-top: 12px;
font-style: italic;
font-size: 90%;
}
h1, h2, h3, h4 {
font-weight: 200;
margin: 0;
}
h1
{
font-family: 'Open Sans Light', sans-serif;
font-size: 48px;
letter-spacing: -2px;
margin: 12px 24px 20px;
}
h2, h3.subsection-title
{
font-size: 30px;
font-weight: 700;
letter-spacing: -1px;
margin-bottom: 12px;
}
h3
{
font-size: 24px;
letter-spacing: -0.5px;
margin-bottom: 12px;
}
h4
{
font-size: 18px;
letter-spacing: -0.33px;
margin-bottom: 12px;
color: #4d4e53;
}
h5, .container-overview .subsection-title
{
font-size: 120%;
font-weight: bold;
letter-spacing: -0.01em;
margin: 8px 0 3px 0;
}
h6
{
font-size: 100%;
letter-spacing: -0.01em;
margin: 6px 0 3px 0;
font-style: italic;
}
table
{
border-spacing: 0;
border: 0;
border-collapse: collapse;
}
td, th
{
border: 1px solid #ddd;
margin: 0px;
text-align: left;
vertical-align: top;
padding: 4px 6px;
display: table-cell;
}
thead tr
{
background-color: #ddd;
font-weight: bold;
}
th { border-right: 1px solid #aaa; }
tr > th:last-child { border-right: 1px solid #ddd; }
.ancestors { color: #999; }
.ancestors a
{
color: #999 !important;
text-decoration: none;
}
.clear
{
clear: both;
}
.important
{
font-weight: bold;
color: #950B02;
}
.yes-def {
text-indent: -1000px;
}
.type-signature {
color: #aaa;
}
.name, .signature {
font-family: Consolas, Monaco, 'Andale Mono', monospace;
}
.details { margin-top: 14px; border-left: 2px solid #DDD; }
.details dt { width: 120px; float: left; padding-left: 10px; padding-top: 6px; }
.details dd { margin-left: 70px; }
.details ul { margin: 0; }
.details ul { list-style-type: none; }
.details li { margin-left: 30px; padding-top: 6px; }
.details pre.prettyprint { margin: 0 }
.details .object-value { padding-top: 0; }
.description {
margin-bottom: 1em;
margin-top: 1em;
}
.code-caption
{
font-style: italic;
font-size: 107%;
margin: 0;
}
.prettyprint
{
border: 1px solid #ddd;
width: 80%;
overflow: auto;
}
.prettyprint.source {
width: inherit;
}
.prettyprint code
{
font-size: 100%;
line-height: 18px;
display: block;
padding: 4px 12px;
margin: 0;
background-color: #fff;
color: #4D4E53;
}
.prettyprint code span.line
{
display: inline-block;
}
.prettyprint.linenums
{
padding-left: 70px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.prettyprint.linenums ol
{
padding-left: 0;
}
.prettyprint.linenums li
{
border-left: 3px #ddd solid;
}
.prettyprint.linenums li.selected,
.prettyprint.linenums li.selected *
{
background-color: lightyellow;
}
.prettyprint.linenums li *
{
-webkit-user-select: text;
-moz-user-select: text;
-ms-user-select: text;
user-select: text;
}
.params .name, .props .name, .name code {
color: #4D4E53;
font-family: Consolas, Monaco, 'Andale Mono', monospace;
font-size: 100%;
}
.params td.description > p:first-child,
.props td.description > p:first-child
{
margin-top: 0;
padding-top: 0;
}
.params td.description > p:last-child,
.props td.description > p:last-child
{
margin-bottom: 0;
padding-bottom: 0;
}
.disabled {
color: #454545;
}

View file

@ -1,111 +0,0 @@
/* JSDoc prettify.js theme */
/* plain text */
.pln {
color: #000000;
font-weight: normal;
font-style: normal;
}
/* string content */
.str {
color: #006400;
font-weight: normal;
font-style: normal;
}
/* a keyword */
.kwd {
color: #000000;
font-weight: bold;
font-style: normal;
}
/* a comment */
.com {
font-weight: normal;
font-style: italic;
}
/* a type name */
.typ {
color: #000000;
font-weight: normal;
font-style: normal;
}
/* a literal value */
.lit {
color: #006400;
font-weight: normal;
font-style: normal;
}
/* punctuation */
.pun {
color: #000000;
font-weight: bold;
font-style: normal;
}
/* lisp open bracket */
.opn {
color: #000000;
font-weight: bold;
font-style: normal;
}
/* lisp close bracket */
.clo {
color: #000000;
font-weight: bold;
font-style: normal;
}
/* a markup tag name */
.tag {
color: #006400;
font-weight: normal;
font-style: normal;
}
/* a markup attribute name */
.atn {
color: #006400;
font-weight: normal;
font-style: normal;
}
/* a markup attribute value */
.atv {
color: #006400;
font-weight: normal;
font-style: normal;
}
/* a declaration */
.dec {
color: #000000;
font-weight: bold;
font-style: normal;
}
/* a variable name */
.var {
color: #000000;
font-weight: normal;
font-style: normal;
}
/* a function name */
.fun {
color: #000000;
font-weight: bold;
font-style: normal;
}
/* Specify class=linenums on a pre to get line numbering */
ol.linenums {
margin-top: 0;
margin-bottom: 0;
}

View file

@ -1,132 +0,0 @@
/* Tomorrow Theme */
/* Original theme - https://github.com/chriskempson/tomorrow-theme */
/* Pretty printing styles. Used with prettify.js. */
/* SPAN elements with the classes below are added by prettyprint. */
/* plain text */
.pln {
color: #4d4d4c; }
@media screen {
/* string content */
.str {
color: #718c00; }
/* a keyword */
.kwd {
color: #8959a8; }
/* a comment */
.com {
color: #8e908c; }
/* a type name */
.typ {
color: #4271ae; }
/* a literal value */
.lit {
color: #f5871f; }
/* punctuation */
.pun {
color: #4d4d4c; }
/* lisp open bracket */
.opn {
color: #4d4d4c; }
/* lisp close bracket */
.clo {
color: #4d4d4c; }
/* a markup tag name */
.tag {
color: #c82829; }
/* a markup attribute name */
.atn {
color: #f5871f; }
/* a markup attribute value */
.atv {
color: #3e999f; }
/* a declaration */
.dec {
color: #f5871f; }
/* a variable name */
.var {
color: #c82829; }
/* a function name */
.fun {
color: #4271ae; } }
/* Use higher contrast and text-weight for printable form. */
@media print, projection {
.str {
color: #060; }
.kwd {
color: #006;
font-weight: bold; }
.com {
color: #600;
font-style: italic; }
.typ {
color: #404;
font-weight: bold; }
.lit {
color: #044; }
.pun, .opn, .clo {
color: #440; }
.tag {
color: #006;
font-weight: bold; }
.atn {
color: #404; }
.atv {
color: #060; } }
/* Style */
/*
pre.prettyprint {
background: white;
font-family: Consolas, Monaco, 'Andale Mono', monospace;
font-size: 12px;
line-height: 1.5;
border: 1px solid #ccc;
padding: 10px; }
*/
/* Specify class=linenums on a pre to get line numbering */
ol.linenums {
margin-top: 0;
margin-bottom: 0; }
/* IE indents via margin-left */
li.L0,
li.L1,
li.L2,
li.L3,
li.L4,
li.L5,
li.L6,
li.L7,
li.L8,
li.L9 {
/* */ }
/* Alternate shading for lines */
li.L1,
li.L3,
li.L5,
li.L7,
li.L9 {
/* */ }

View file

@ -1,71 +0,0 @@
/** The central interface to the streaming process.
* @module Streamer
*/
const logger = require('./logger');
///////////////////////////////////////////////////////////////////////////////
// Declarations //
///////////////////////////////////////////////////////////////////////////////
// Object oriented `this`.
let self = false;
///////////////////////////////////////////////////////////////////////////////
// Code //
///////////////////////////////////////////////////////////////////////////////
// TODO: Log state changes.
/**
* @class Streamer
* The central control Object (singleton for now) which has the permission to change state.
*
* @constructor
* @param { Object } communicator A communicator object. @see communicator.js - Optional //TODO: Find proper tag.
*/
function Streamer(communicator = false) {
// singleton
if (self)
return self;
// Make `new` optional.
if (!(this instanceof Streamer))
return new Streamer(_communicator);
_communicator = communicator;
self = this;
return this;
};
module.exports = Streamer;
/**
* Set the communicator object and enable the state sync with the server.
* @param {Object} communicator A communicator object. @see communicator.js
*/
Streamer.prototype.setCommunicator = function(communicator) {
if (_communicator)
_communicator = communicator;
else
logger.dbgmsdg("Invalid Communicator");
};
/**
* Get the current config.
* @returns { * } The current config.
*/
Streamer.prototype.getConfig = function(){
return store.getStreamer().config;
};
/**
* Utilities
*/

View file

@ -1,11 +0,0 @@
///////////////////////////////////////////////////////////////////////////////
// The Actions to change the State //
///////////////////////////////////////////////////////////////////////////////
let actions = module.exports = {
UPDATE_CONFIG : 'UPDATE_CONFIG',
START : 'START',
STOP : 'STOP',
SET_ERROR : 'SET_ERROR',
RESTART: 'RESTART'
}

View file

@ -1,259 +0,0 @@
/**
* @module Commander
* @description A Wrapper for Fluent-FFMPEG with a custom command.
*/
const ffmpeg = require('fluent-ffmpeg');
const http = require('http');
const logger = require('./logger');
///////////////////////////////////////////////////////////////////////////////
// Declarations //
///////////////////////////////////////////////////////////////////////////////
// Reference to itself. (Object oriented this. Only used to call public methods.)
let self = false;
/**
* The FFMPEG command.
* @member
*/
let cmd = ffmpeg({
stdoutLines: 20
});
// The Config, Logger and a handle for the kill timeout.
let _config, _stopHandle = false, _connectHandle = false;
// Error Texts //TODO put them into separate module
let errorDescriptions = ['Camera Disconnected',
'YoutTube Disconnected',
'Wrong ffmpeg executable.',
'Unknown Error - Restarting'];
// The stream source url. Yet to be set.
let source = "";
// The function to get the State.
let getState;
///////////////////////////////////////////////////////////////////////////////
// Code //
///////////////////////////////////////////////////////////////////////////////
/**
* Interface to the ffmpeg process. Uses fluent-ffmpeg.
* @constructor
*/
let Commander = function(_getState){
// singleton
if(self)
return self;
// Make `new` optional.
if(!(this instanceof Commander))
return new Commander();
if (!_getState) {
throw new Error('Invalid getState() function.');
}
getState = _getState;
self = this;
/**
* (Re)Create the ffmpeg command and configure it.
* @param { Object } config The configuration for the stream.
* @returns { Object } The fluent-ffmpeg command object.
*/
let createCommand = function() {
// Clear inputs
cmd._inputs = [];
// TODO: Multi Protocol
source = 'rtsp://' + config.camIP + ':' + config.camPort + '/' + config.camProfile;
cmd.input(source);
// Custom config if any.
if (config.customOutputOptions !== "")
cmd.outputOptions(config.customOutputOptions.replace(/\s+\,\s+/g, ',').replace(/\s+\-/g, ',-').split(','));
if (config.customAudioOptions !== "")
cmd.outputOptions(config.customAudioOptions.replace(/\s+\,\s+/g, ',').replace(/\s+\-/g, ',-').split(','));
else
cmd.AudioCodec('copy');
if (config.customVideoOptions !== "")
cmd.outputOptions(config.customVideoOptions.replace(/\s+\,\s+/g, ',').replace(/\s+\-/g, ',-').split(','));
else
cmd.videoCodec('copy');
// Output Options.
cmd.outputFormat('flv')
.outputOptions(['-bufsize 50000k', '-tune film'])
.output('rtmp://a.rtmp.youtube.com/live2/' + config.key);
// Register events.
cmd.on('start', started);
cmd.on('end', stopped);
cmd.on('error', crashed);
return cmd;
};
let ffmpegCommand = function() {
return cmd;
};
// NOTE: Maybe better error resolving strategy.
// Start streaming.
let start = function() {
// Ignore if we try to reconnect.
if(_connectHandle)
return;
cmd.run();
};
// Restart the stream;
let restart = function() {
if(status.streaming) {
restart = true; // NOTE: not very nice
this.stop();
} else
this.start();
};
// Stop streaming.
let stop = function() {
cmd.kill('SIGINT');
_stopHandle = setTimeout(() => {
logger.log(logger.importance[3], "Force Stop!");
cmd.kill();
}, 3000);
};
}
/**
* Utilities
*/
/**
* Get the current config.
* @returns {}
*/
function config() {
return getState().config;
}
// Handle Stop and Restart
function stopped() {
status.streaming = false;
// Clear force kill Timeout
if(stopTimeout) {
clearTimeout(stopTimeout);
stopTimeout = false;
}
// Restart the stream;
if (restart) {
self.start();
}
cmd.emit('stopped');
}
// TODO: Restart = false in stopped?
// Hande Stat
function started() {
cmd.emit(restart ? 'restarted' : 'started');
restart = false;
status.error = false;
status.streaming = true;
}
/**
* Error Handling
*/
/**
* Log and handle crashes. Notify the main module.
* @param { Object } error - Error object from the crash.
* @param { String } stdout
* @param { String } stderr
*/
function crashed(error, stdout, stderr){
// Can't connect to the
if (err.message.indexOf(source) > -1)
status.error = 0;
// Can't connect to the Internet / YouTube
else if (err.message.indexOf(source + 'Input/output error') > -1 || err.message.indexOf('rtmp://a.rtmp.youtube.com/live2/' + _config.key) > -1)
status.error = 1;
// Wrong FFMPEG Executable
else if (err.message.indexOf('spawn') > -1 || err.message.indexOf('niceness') > -1)
status.error = 2;
// Stopped by us - SIGINT Shouldn't lead to a crash.
else if (err.message.indexOf('SIGINT') > -1 || err.message.indexOf('SIGKILL') > -1){
stopped();
return;
}
// Some unknown Problem, just try to restart.
else {
status.error = 3;
// Just restart in a Second
setTimeout(function(){
self.start();
}, 1000);
}
logger.log(logger.importance[2], `Crashed: ${erro}\nSTDERR: ${stderr}`);
}
/**
* Probe the connection to the host on the port and restart the stream afterwards.
* @param { string } host
* @param { number } port
*/
function tryReconnect( host, port ){
if (!host || !port)
return;
http.get({
host: host.split('/')[0],
port: port
}, function(res) {
// We have a response! Connection works.
setTimeout(function() {
// NOTE: Ugly!
// We have a response! Connection works.
_connectHandle = false;
self.start();
}, 1000);
}).on("error", function(e) {
if (e.message == "socket hang up") {
setTimeout(function() {
// NOTE: Ugly!
// We have a response! Connection works.
_connectHandle = false;
self.start();
}, 1000);
} else {
// try again
_connectHandle = setTimeout(function(){
tryReconnect(host, port);
}, 1000);
}
});
}

View file

@ -1,46 +0,0 @@
///////////////////////////////////////////////////////////////////////////////
// A socket.js wrapper to abstract the communication with the server. //
///////////////////////////////////////////////////////////////////////////////
const socketio = require('socket.io-client');
///////////////////////////////////////////////////////////////////////////////
// Declarations //
///////////////////////////////////////////////////////////////////////////////
// Object oriented `this`.
let self = false;
// Get the current application state.
let getState;
///////////////////////////////////////////////////////////////////////////////
// Code //
///////////////////////////////////////////////////////////////////////////////
module.exports = function Communicator(_getState){
// singleton
if(self)
return self;
// Make `new` optional.
if(!(this instanceof Communicator))
return new Communicator();
if (!_getState) {
throw new Error('Invalid getState() function.');
}
// define the locals
getState = _getState;
init();
self = this;
return this;
};
/**
* Utilities
*/

View file

@ -1,131 +0,0 @@
/**
* @module Error-Handler
* @description Provides error Handlers
*/
const http = require('http');
const {
TRY_RECONNECT,
STOP_ERROR_HANDLING
} = require('./actions.js').actions;
const {
setTryReconnect,
stopErrorHandling
} = require('./actions.js').creators;
///////////////////////////////////////////////////////////////////////////////
// Declarations //
///////////////////////////////////////////////////////////////////////////////
module.exports = {};
/**
* Error Handler Map. Each handler function returns an object, which has a handle function of it's own name and a (empty) stop function.
*/
const handlers = {
tryReconnect: tryReconnect().handle // TODO: Nicer
};
///////////////////////////////////////////////////////////////////////////////
// Code //
///////////////////////////////////////////////////////////////////////////////
module.exports.handlers = handlers;
/**
* Utilities
*/
/**
* Stops the error handler.
* @returns {function} An action-creating thunk. (That returns a promise.)
*/
handlers.stopHandling = function() {
return (dispatch, getState) => {
let stopper,
handler = handlers[getState().stream.handleError];
if (!getState().stream.handleError)
return Promise.resolve();
if (!handler)
return Promise.resolve();
dispatch(stopErrorHandling());
stopper = handler.stop();
if (!stopper.then)
return Promise.resolve();
// If it is a promise.
return stopper;
};
};
/**
* Error Handlers
*/
/**
* Reconnection handler.
* @returns {Object} A handler object. @see handlers
*/
function tryReconnect() {
let connectHandle;
/**
* Try to reconnect to the host.
* @param {string} host
* @param {number} port
* @param {function} after A function to be executed upon resolution of the error.
* @returns {function} An action-creating thunk.
*/
this.handle = function(host, port, after) {
return (dispatch, getState) => {
if (!host || !port)
throw new Error("Invalid Host or Port!");
dispatch(setTryReconnect([host, port]));
connectHandle = false;
reconnect();
function reconnect() {
// Somebody has stopped it.
if(!getState().stream.handleError)
return;
http.get({
host: host.split('/')[0],
port: port
}, function() {
success();
}).on("error", function(error) {
if (error.message == "socket hang up") {
// Even if he doesn't like to talk to us, he's there.
success();
} else {
// try again
connectHandle = setTimeout(function() {
reconnect();
}, 1000);
}
});
}
function success() {
setTimeout(() => {
dispatch(stopErrorHandling());
after();
});
};
};
};
this.stop = function() {
clearTimeout(connectHandle);
};
return this;
}

View file

@ -1,246 +0,0 @@
///////////////////////////////////////////////////////////////////////////////
// A Wrapper for Fluent-FFMPEG with a custom command. //
///////////////////////////////////////////////////////////////////////////////
const ffmpeg = require('fluent-ffmpeg');
const http = require('http');
///////////////////////////////////////////////////////////////////////////////
// Declarations //
///////////////////////////////////////////////////////////////////////////////
// This
let self;
// The Variable for the FFMpeg command.
let cmd = ffmpeg({
stdoutLines: 20
});
// The Config, Logger and a handle for the kill timeout.
let config, logger, stopHandle = false, connectHandle = false;
// True if stream should be restarted.
let restart = false;
// Error Texts
let errorDescriptions = ['Camera Disconnected',
'YoutTube Disconnected',
'Wrong ffmpeg executable.',
'Unknown Error - Restarting'];
// Internal Status
let status = {
streaming: false,
error: false
};
// The stream source url. Yet to be set.
let source = "";
///////////////////////////////////////////////////////////////////////////////
// Code //
///////////////////////////////////////////////////////////////////////////////
/**
* Interface to the ffmpeg process. Uses fluent-ffmpeg.
* @param {Object} _config Configuration for the stream. @see config.js.example
* @param {Object} _logger Logger Instance from main module.
*/
let command = function(_config, _logger){
// TODO: Better Error Checking
if(!_config)
throw new Error("Invalid Config");
if(!_logger)
throw new Error("Invalid Logger");
config = _config;
self = this;
// (Re)Create the ffmpeg command and configure it.
let createCommand = function() {
// Clear inputs
cmd._inputs = [];
// TODO: Multi Protocol
source = 'rtsp://' + config.camIP + ':' + config.camPort + '/' + config.camProfile;
cmd.input(source);
// Custom config if any.
if (config.customOutputOptions !== "")
cmd.outputOptions(config.customOutputOptions.replace(/\s+\,\s+/g, ',').replace(/\s+\-/g, ',-').split(','));
if (config.customAudioOptions !== "")
cmd.outputOptions(config.customAudioOptions.replace(/\s+\,\s+/g, ',').replace(/\s+\-/g, ',-').split(','));
else
cmd.AudioCodec('copy');
if (config.customVideoOptions !== "")
cmd.outputOptions(config.customVideoOptions.replace(/\s+\,\s+/g, ',').replace(/\s+\-/g, ',-').split(','));
else
cmd.videoCodec('copy');
// Output Options.
cmd.outputFormat('flv')
.outputOptions(['-bufsize 50000k', '-tune film'])
.output('rtmp://a.rtmp.youtube.com/live2/' + config.key);
// Register events.
cmd.on('start', started);
cmd.on('end', stopped);
cmd.on('error', crashed);
};
let ffmpegCommand = function() {
return cmd;
};
// NOTE: Maybe better error resolving strategy.
// Start streaming.
let start = function() {
// Ignore if we try to reconnect.
if(connectHandle)
return;
cmd.run();
};
// Restart the stream;
let restart = function() {
if(status.streaming) {
restart = true; // NOTE: not very nice
this.stop();
} else
this.start();
};
// Stop streaming.
let stop = function() {
cmd.kill('SIGINT');
stopHandle = setTimeout(() => {
logger.log(logger.importance[3], "Force Stop!");
cmd.kill();
}, 3000);
};
let setConfig = function(_conf) {
config = _conf;
};
};
/**
* Utilities
*/
// Handle Stop and Restart
function stopped() {
status.streaming = false;
// Clear force kill Timeout
if(stopTimeout) {
clearTimeout(stopTimeout);
stopTimeout = false;
}
// Restart the stream;
if (restart) {
self.start();
}
cmd.emit('stopped');
}
// TODO: Restart = false in stopped?
// Hande Stat
function started() {
cmd.emit(restart ? 'restarted' : 'started');
restart = false;
status.error = false;
status.streaming = true;
}
/**
* Error Handling
*/
/**
* Log and handle crashes. Notify the main module.
* @param { Object } error - Error object from the crash.
* @param { String } stdout
* @param { String } stderr
*/
function crashed(error, stdout, stderr){
// Can't connect to the
if (err.message.indexOf(source) > -1)
status.error = 0;
// Can't connect to the Internet / YouTube
else if (err.message.indexOf(source + 'Input/output error') > -1 || err.message.indexOf('rtmp://a.rtmp.youtube.com/live2/' + config.key) > -1)
status.error = 1;
// Wrong FFMPEG Executable
else if (err.message.indexOf('spawn') > -1 || err.message.indexOf('niceness') > -1)
status.error = 2;
// Stopped by us - SIGINT Shouldn't lead to a crash.
else if (err.message.indexOf('SIGINT') > -1 || err.message.indexOf('SIGKILL') > -1){
stopped();
return;
}
// Some unknown Problem, just try to restart.
else {
status.error = 3;
// Just restart in a Second
setTimeout(function(){
self.start();
}, 1000);
}
logger.log(logger.importance[2], `Crashed: ${erro}\nSTDERR: ${stderr}`);
}
/**
* Probe the connection to the host on the port and restart the stream afterwards.
* @param { string } host
* @param { number } port
*/
function tryReconnect( host, port ){
if (!host || !port)
return;
http.get({
host: host.split('/')[0],
port: port
}, function(res) {
// We have a response! Connection works.
setTimeout(function() {
// NOTE: Ugly!
// We have a response! Connection works.
connectHandle = false;
self.start();
}, 1000);
}).on("error", function(e) {
if (e.message == "socket hang up") {
setTimeout(function() {
// NOTE: Ugly!
// We have a response! Connection works.
connectHandle = false;
self.start();
}, 1000);
} else {
// try again
connectHandle = setTimeout(function(){
tryReconnect(host, port);
}, 1000);
}
});
}

View file

@ -1,2 +0,0 @@

View file

@ -1,71 +0,0 @@
///////////////////////////////////////////////////////////////////////////////
// Reducers //
///////////////////////////////////////////////////////////////////////////////
const redux = require('redux');
const actions = require('./actions');
let reducers = {};
/**
* Set the streaming/error state.
*/
reducers.error = function(state = -1, action) {
switch (action.type) {
case actions.SET_ERROR:
if((typeof action.data) == 'undefined') {
return action.data;
break;
}
default:
return state;
}
};
/**
* Set the streaming state.
*/
reducers.streaming = function(state = false, action) {
switch (action.type) {
case actions.START:
case actions.STOP:
return action.type == actions.START;
break;
default:
return state;
}
};
/**
* Set the restart flag.
*
* The restart flag get's automaticly unset, as soon as the start action gets reduced.
*/
reducers.restart = function(state = false, action) {
switch (action.type) {
case actions.RESTART:
return true;
case actions.START:
return false;
default:
return state;
}
};
/**
* Update the config.
*/
reducers.config = function(state = {}, action) {
switch (action.type) {
case actions.UPDATE_CONFIG:
return Object.assign({}, state, action.data);
break;
default:
return state;
}
};
module.exports = redux.combineReducers(reducers);

View file

@ -1,300 +0,0 @@
/**
* @module ssh
* @description Manages the SSH Tunnels to the master-server. (Even works with muliple instances.)
* @description The SSH Manager is commandet by the Communicator.
*/
// TODO: Disconnect event from SSH-Manager itself!
const ipc = require('node-ipc');
const {
setSSHError,
setSSHConnecting,
setSSHConnected,
setSSHDisconnecting,
setSSHDisconnected,
setSSHWillReconnect,
setSSHRemotePorts
} = require('./actions').actions;
///////////////////////////////////////////////////////////////////////////////
// Declarations //
///////////////////////////////////////////////////////////////////////////////
// Object oriented `this`.
let self;
// Get state for the SSH State.
let getState, getConfig;
// The redux dispatch function to alter the state.
let dispatch;
// PIDs of the ssh-tunnel and the camera tunnel.
let sshPID, camPID;
// IPC Setup
ipc.config.silent = true;
// Connected to the ipc // TODO: May be redundand (see socket.destroyed...) // FIXME: RENAME!
let connected = false;
/**
* @function getPorts
* A function to get the Ports for the SSH-Tunnel. Given as parameter for the @see SSHMan.
* This module doesn't care where it comes from, as long as it WORKS!
* @returns {Promise} Resolves to ports {camForwardPort: integer, sshForwardport: integer}.
*/
let getPorts;
///////////////////////////////////////////////////////////////////////////////
// Code //
///////////////////////////////////////////////////////////////////////////////
// TODO: Check if autossh installed
class SSHMan {
constructor(_getState, _getConfig, _dispatch, _getPorts) {
// Signleton
if (self)
return;
if ((typeof _getState) !== 'function') {
throw new Error('Invalid getState() function.');
}
if ((typeof _getConfig) !== 'function' || !_getConfig()) {
throw new Error('Please load a valid config.');
}
if ((typeof _dispatch) !== 'function') {
throw new Error('Invalid dispatch function.');
}
if ((typeof _getPorts) !== 'function') {
throw new Error('Invalid getPorts function.');
}
getState = _getState;
getConfig = _getConfig;
getPorts = _getPorts;
dispatch = _dispatch;
connectIpc();
}
};
/**
* Action Creators.
*/
/**
* Action Creator to connect the SSH Tunnels via the SSH-Manager.
* @returns {Promise}
*/
SSHMan.prototype.connect = function() {
return (dispatch, getState) => {
if (getState().ssh.status == 'DISABLED' || getState().ssh.status == 'CONNECTED')
return Promise.resolve(); // Nothing todo
if (getState().ssh.status == 'CONNECTING')
return Promise.reject('A command which is currently being executed is in conflict with the current one.');
// Let's go ahead.
dispatch(setSSHConnecting());
let config = getState().config();
let newPorts, ports = {};
return getPorts().then((_ports) => {
if (typeof _ports.sshForwardPort !== 'number' || typeof _ports.camForwardPort !== 'number') {
return Promise.reject("Invalid Ports!");
} else {
ports = _ports;
return isIpcConnected();
}
})
.then(() => createTunnel(config.sshPort, ports.sshForwardPort))
.then(port => newPorts.sshForwardPort = port)
.then(() => createTunnel(ports.camPort, ports.camForwardPort))
.then(port => newPorts.camForwardPort = port)
.then(() => {
if (connected) {
dispatch(setSSHRemotePorts(newPorts));
dispatch(setSSHConnected());
return Promise.resolve();
} else
return Promise.reject("No connection to the ssh-manager.");
})
.catch((error) => {
dispatch(setSSHError(error));
return Promise.reject(error);
});
};
};
/**
* An action creator for disconnecting the SSH Tunnels.
* Resolves on successfull disconnect. Rejects if the request couldn't be made. In both cases the tunnel is disconnected.
* It also sets the willReconnect flag to false.
* @returns { Promise }
*/
SSHMan.prototype.disconnect = function() {
return (dispatch, getState) => {
// Nothing todo
if (getState().ssh.status !== 'CONNECTED') {
return Promise.reject("Can't disconnect the SSH-Tunnels right now, please try later."); // TODO: CD
}
// Let's go ahead.
dispatch(setSSHDisconnecting());
let config = getState().config();
return isIpcConnected
.then(() => closeTunnel(config.sshPort))
.then(() => closeTunnel(config.camPort))
.then(() => {
dispatch(setSSHDisconnected());
return Promise.resolve();
})
.catch((error) => {
// This means that the tunnel is not connected anymore.
dispatch(setSSHDisconnected());
return Promise.reject(error);
});
};
};
// TODO: Maybe both tunnels handled completely different.
/**
* An action creator that restarts the SSH Tunnels.
* @returns { Promise }
*/
SSHMan.prototype.restartTunnels = function() {
return (dispatch, getState) => {
let connect = () => dispatch(self.connect);
dispatch(self.disconnect())
.then(connect, connect)
.then(() => Promise.resolve("SSH Tunnels successfully restarted."))
.catch(error => Promise.reject(error)); //Todo CD
};
};
/**
* Private Utility
*/
function connectIpc(ports) {
ipc.connectTo('sshMan'); // TODO: CD
// Register Events
ipc.of.sshMan.on('connect', ipcConnected);
ipc.of.sshMan.on('disconnect', ipcDisconnected);
}
/**
* Handler for the IPC Connection Event.
* Currently just sets connected = true.
*/
function ipcConnected() {
connected = true;
if (getState().ssh.willReconnect) {
dispatch(self.connect());
}
}
/**
* Handler for the IPC Disconnect Event.
*/
function ipcDisconnected() {
connected = false;
// Automatically attempt to reconnect once connection is made.
dispatch(setSSHWillReconnect());
dispatch(setSSHDisconnected());
}
/**
* Creates a tunnel by reqesting it from the manager.
* @param { number } localPort
* @param { number } remotePort
* @returns { Promise }
*/
function createTunnel(localPort, remotePort) {
return new Promise((resolve, reject) => {
let id = (new Date()).getTime();
let config = getConfig();
let connectTimeout = setTimeout(() => reject("IPC Timeout. Can't reach SSH-Manager."), 2000); // TODO: CD
ipc.of.sshMan.once('success' + id, (port) => {
resolve(port); // TODO: That's ok for now, but should be auto-determined by the SSH-Manager further down the road...
});
ipc.of.sshMan.once('error' + id, (error) => {
reject(error);
});
// In case of an Error in the IPC Connection.
ipc.of.sshMan.prependOnceListener('error', error => {
clearTimeout(connectTimeout);
reject(error);
});
ipc.of.sshMan.emit('create_tunnel', {
id: id,
host: config.sshMaster,
username: config.sshUser,
sshPort: config.sshPort,
localPort: localPort,
remotePort: remotePort,
serverAliveInterval: 30,
reverse: true
});
});
}
function closeTunnel(port) {
return new Promise((resolve, reject) => {
let id = (new Date()).getTime();
let connectTimeout = setTimeout(() => reject("IPC Timeout. Can't reach SSH-Manager."), 2000); // TODO: CD
ipc.of.sshMan.once('success' + id, (port) => {
resolve(); // TODO: That's ok for now, but should be auto-determined by the SSH-Manager further down the road...
});
ipc.of.sshMan.once('error' + id, (error) => {
reject();
});
// In case of an Error in the IPC Connection.
ipc.of.sshMan.prependOnceListener('error', error => {
clearTimeout(connectTimeout);
reject();
});
ipc.of.sshMan.emit('close_tunnel', {
id: id,
port
});
});
}
/**
* Helper to tell if the IPC connection works.
* @returns {Promise}
*/
function isIpcConnected() {
if (connected)
return Promise.resolve();
// Wait a bit and try again.
return new Promise((resolve, reject) => {
ipc.of.sshMan.once('connect', () => resolve());
ipc.of.sshMan.once('error', () => reject('Cannot connect to the SSH-Manager.'));
});
}

View file

@ -1,128 +0,0 @@
/** Redux Wrapper to hold the state and communicate with the Server
* @module State
*/
const redux = require('redux');
const ReduxThunk = require('redux-thunk').default;
const logger = require('./logger');
///////////////////////////////////////////////////////////////////////////////
// Declarations //
///////////////////////////////////////////////////////////////////////////////
// Object oriented `this`.
let self = false;
/**
* Inital State for the app.
* @property { Object } stream Stream Status.
* @property { bool } stream.running Indicates wether the stream is running.
* @property { number } stream.error Error code. Any number outside the range of the Error array in @see ffmpeg-command.js will be treated as non error. Most conveniently set: -1.
* @property { bool } stream.reconnecting Indicates wether the program tries to reconnect to the camera or the internet.
* @property { Object } config Configuration of the camera.
*/
let initialState = {
stream: {
running: 'STOPPED',
error: -1,
reconnecting: false,
restarting: false
},
config: {}
}; // NOTE: Maybe in main.js
// The socket.io connection from the main-module.
let _communicator;
/**
* Redux Actions
*/
// Reducer
const reducer = require('./reducers');
// Reference to the store of the application state.
const store = redux.createStore(reducer, initialState);
///////////////////////////////////////////////////////////////////////////////
// Code //
///////////////////////////////////////////////////////////////////////////////
// TODO: Log state changes.
/**
* @class Streamer
* The central control Object (singleton for now) which has the permission to change state.
*
* @constructor
* @param { Object } communicator A communicator object. @see communicator.js - Optional //TODO: Find proper tag.
*/
function Streamer(communicator = false) {
// singleton
if (self)
return self;
// Make `new` optional.
if (!(this instanceof Streamer))
return new Streamer(_communicator);
_communicator = communicator;
self = this;
return this;
};
applyDispatchers(creators);
/**
* Set the communicator object and enable the state sync with the server.
* @param {Object} communicator A communicator object. @see communicator.js
*/
Streamer.prototype.setCommunicator = function(communicator) {
if (_communicator)
_communicator = communicator;
else
logger.dbgmsdg("Invalid Communicator");
};
/**
* Wrapper for redux.
* @returns { Object } The current state.
*/
Streamer.prototype.getStreamer = function(){
return store.getStreamer();
};
/**
* Get the current config.
* @returns { * } The current config.
*/
Streamer.prototype.getConfig = function(){
return store.getStreamer().config;
};
/**
* Utilities
*/
/**
* Adds prototypes for the action dispatchers to the Streamer.
* @param { Object } creators
* @throws { Error } If a method with the creators name already exists. @see actionCreators.js
*/
function applyDispatchers( creators ){
for(let creator in creators){
if(Streamer.prototype[creator])
throw new Error(`Streamer has already a meber '${creator}'.`);
Streamer.prototype[creator] = function(){
store.dispatch(creators[creator].apply(undefined, arguments));
};
}
}
module.exports = Streamer;

View file

@ -1,23 +0,0 @@
const spawn = require('child_process').spawn;
const exec = require('child_process').exec;
const fs = require('fs');
let pid;
let config = JSON.parse(fs.readFileSync('./config.js'));
let p = spawn(`ssh -oStrictHostKeyChecking=no -o ServerAliveInterval=30 -o ServerAliveCountMax=3 -p ${config['ssh-port']} -f -N -R ${process.argv[2]}:localhost:22 -f -N -R 0.0.0.0:${process.argv[3]}:${config.camIP}:${process.argv[4]} ${config['ssh-user']}@${config.master.replace(/((http|https)\:\/{2}|\:[0-9]+)/g, '')} && pidof ssh`, {
shell: true,
detached: false
})
p.stdout.on('data', (p) => {
pid = p.toString().split(' ')[0];
});
p.on('close', () => {
process.exit(1);
});
process.once("SIGINT", function() {
console.log('kill ');
exec(`kill ${pid}`, () => {
process.exit(0);
});
});

5
test
View file

@ -1,5 +0,0 @@
debug> < Debugger listening on port 5858.
< Warning: This is an experimental feature and could change at any time.
< To start debugging, open the following URL in Chrome:
< chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:5858/e75b2ceb-14cb-4339-93a4-aac1427611d8
debug> connecting to 127.0.0.1:5858 ...

20
test.js
View file

@ -1,20 +0,0 @@
x = require('node-ipc');
//x.config.silent = true;
x.connectTo('sshManager', function(){
x.of['sshManager'].on('connect',function(){
let id = (new Date()).getTime();
x.of['sshManager'].on('success'+id, (data) => {console.log(data);});
x.of['sshManager'].emit('create_tunnel', {
host: 'cams.doc.govt.nz',
id: id,
username: 'ssh',
sshPort: 54533,
localPort: 8080,
reverse: true,
privateKey: '~/.ssh/test',
serverAliveInterval: 5,
remotePort: 9999,
reverse: true
}, () => {console.log("here")});
});
});

0
todo~
View file