From a6fc4c6cbe58010f03479a37fcb501fdbae61a5b Mon Sep 17 00:00:00 2001 From: Reaby Date: Wed, 13 May 2020 23:27:46 +0300 Subject: [PATCH] make STREAM_NAME configurable, add admin interface for mediaserver --- README.md | 5 ++++- app.js | 11 ++++++----- config-default.js | 1 + modules/admin.js | 5 ++--- views/admin/dashboard.twig | 2 +- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index ab89c0c..1cb7434 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,10 @@ set following options:
|URL:| `rtmp://localhost/live`| |Stream key:|`STREAM_NAME`| -Later it is possible to define other stream names/keys too, but for now only this one is supported. +# Mediaserver status and adminpanel +Admin interface is located at: http://localhost:8001/admin +You can use same crendetials as configured at main app + # Environment variables |ENV|default|Usage| diff --git a/app.js b/app.js index 507cdac..6b47160 100644 --- a/app.js +++ b/app.js @@ -74,11 +74,12 @@ if (config.mediaServer) { http: { port: (parseInt(config.serverListenPort) + 1), allow_origin: '*', - auth: { - api: true, - api_user: config.admins[0].username, - api_pass: config.admins[0].password - } + }, + auth: { + api: true, + api_user: config.admins[0].username, + api_pass: config.admins[0].password, + } }; diff --git a/config-default.js b/config-default.js index 44a0b67..cc55ea9 100644 --- a/config-default.js +++ b/config-default.js @@ -5,6 +5,7 @@ module.exports = { "serverHost": process.env.HOST || "127.0.0.1", "serverUrl": "http://" + (process.env.HOST || "127.0.0.1"), // used for web client "sessionKey": "generateRandomStringForSecret", + "streamKey": 'STREAM_NAME', "useLocalAssets": false, // used to load javascript libraries locally from /public/assets "mediaServer": false, // local streaming server for rtmp, see docs how to use "defaultLocale": "en", diff --git a/modules/admin.js b/modules/admin.js index 405db90..cdd31dc 100644 --- a/modules/admin.js +++ b/modules/admin.js @@ -124,17 +124,16 @@ class admin { }); - socket.on('controls.startStream', function (data) { + socket.on('controls.startStream', function () { let view = self.getView(); let serverOptions = self.getServerOptions(); if (serverOptions.isStreaming === false) { serverOptions.loop = false; - serverOptions.streamSource = "http://" + config.serverHost + ":" + (config.serverListenPort + 1) + "/live/" + data.streamName + ".flv"; + serverOptions.streamSource = "http://" + config.serverHost + ":" + (config.serverListenPort + 1) + "/live/" + config.streamKey + ".flv"; serverOptions.isStreaming = true; cli.success("start stream"); } else { - serverOptions.loop = true; serverOptions.isStreaming = false; serverOptions.streamSource = ""; diff --git a/views/admin/dashboard.twig b/views/admin/dashboard.twig index 7e3f016..03a0b3f 100644 --- a/views/admin/dashboard.twig +++ b/views/admin/dashboard.twig @@ -153,7 +153,7 @@ {% if config.mediaServer %} {% endif %}