From dd0ab1e465c77706660212fe55bfb94ff76adfad Mon Sep 17 00:00:00 2001 From: knotteye Date: Sun, 15 Sep 2019 12:28:42 -0500 Subject: [PATCH] Remove compiled files, include source only. --- .gitignore | 1 + server.js | 99 ------------------------------------------------------ 2 files changed, 1 insertion(+), 99 deletions(-) delete mode 100644 server.js diff --git a/.gitignore b/.gitignore index 0b3efc9..8340a82 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules media +server.js diff --git a/server.js b/server.js deleted file mode 100644 index 6852af1..0000000 --- a/server.js +++ /dev/null @@ -1,99 +0,0 @@ -"use strict"; -exports.__esModule = true; -var NodeMediaServer = require("node-media-server"); -var fs = require("fs"); -var exec = require('child_process').exec; -var ircd = require("./lib/IRCDjs-six/lib/server.js").Server; -//initialize configs, eventually grab from runtime config file -var mediaconfig = { - rtmp: { - port: 1935, - chunk_size: 60000, - gop_cache: true, - ping: 30, - ping_timeout: 60 - }, - http: { - port: 8000, - allow_origin: '*', - mediaroot: './media' - }, - trans: { - ffmpeg: '/usr/bin/ffmpeg', - tasks: [ - { - app: 'live', - hls: 'true', - hlsFlags: '[hls_time=2:hls_list_size=3:hls_flags=delete_segments]' - } - ] - } -}; -function streamAuth(path) { - if (path.split("/").length > 3) { - console.log("[NodeMediaServer] Malformed URL, closing connection."); - return false; - } - var app = path.split("/")[1]; - var key = path.split("/")[2]; - console.log("[NodeMediaServer] Authenticating stream with credentials: ", "app=" + app + " key=" + key); - if (app !== "stream") { - console.log("[NodeMediaServer] Invalid app name, closing connection."); - return false; - } - console.log("[NodeMediaServer] App name ok."); - if (key !== "temp") { - console.log("[NodeMediaServer] Invalid stream key, closing connection."); - return false; - } - console.log("[NodeMediaServer] Stream key ok."); - return true; -} -var nms = new NodeMediaServer(mediaconfig); -nms.run(); -ircd.boot(); -nms.on('prePublish', function (id, StreamPath, args) { - console.log("[NodeMediaServer] Prepublish Hook for stream id=", id); - var session = nms.getSession(id); - if (StreamPath.split("/").length > 3) { - console.log("[NodeMediaServer] Malformed URL, closing connection."); - session.reject(); - return false; - } - var app = StreamPath.split("/")[1]; - var key = StreamPath.split("/")[2]; - console.log("[NodeMediaServer] Authenticating stream with credentials: ", "app=" + app + " key=" + key); - if (app !== "stream") { - console.log("[NodeMediaServer] Invalid app name, closing connection."); - session.reject(); - return false; - } - console.log("[NodeMediaServer] App name ok."); - //TODO: Hook up to DB and redirect from query - if (key !== "temp") { - console.log("[NodeMediaServer] Invalid stream key, closing connection."); - session.reject(); - return false; - } - console.log("[NodeMediaServer] Stream key ok."); - session.publishStreamPath = "/live/amy"; -}); -nms.on('postPublish', function (id, StreamPath, args) { - console.log('[NodeMediaServer] Checking record flag for ', "id=" + id + " StreamPath=" + StreamPath); - //Hook up to postgres DB. - if (true) { - console.log('[NodeMediaServer] Initiating recording for ', "id=" + id + " StreamPath=" + StreamPath); - fs.mkdir('./media' + StreamPath, { recursive: true }, function (err) { - if (err) - throw err; - }); - var subprocess = exec('ffmpeg -i rtmp://127.0.0.1' + StreamPath + ' -vcodec copy -acodec copy ./media' + StreamPath + '/$(date +%d%b%Y-%H%M).mp4', { - detached: true, - stdio: 'inherit' - }); - subprocess.unref(); - //spawn an ffmpeg process to record the stream, then detach it completely - return true; - } - console.log('[NodeMediaServer] Skipping recording for ', "id=" + id + " StreamPath=" + StreamPath); -});