From 73d2f79876426ac74e8b1a62eb343d9dbb9b076a Mon Sep 17 00:00:00 2001 From: Ingo Oppermann Date: Mon, 4 Jul 2022 20:26:06 +0200 Subject: [PATCH] Add SRT settings --- src/utils/restreamer.js | 18 ++++++ src/views/Settings.js | 118 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 134 insertions(+), 2 deletions(-) diff --git a/src/utils/restreamer.js b/src/utils/restreamer.js index 2bad11b..75488aa 100644 --- a/src/utils/restreamer.js +++ b/src/utils/restreamer.js @@ -679,6 +679,13 @@ class Restreamer { token: '', name: '', }, + srt: { + enabled: false, + host: '', + local: 'localhost', + token: '', + passphrase: '', + }, hls: { secure: false, host: '', @@ -824,6 +831,17 @@ class Restreamer { config.source.network.rtmp.local += ':' + rtmp_port; } + // SRT + + config.source.network.srt.enabled = val.config.srt.enable; + config.source.network.srt.passphrase = val.config.srt.passphrase; + config.source.network.srt.token = val.config.srt.token; + + let [srt_host, srt_port] = splitHostPort(val.config.srt.address); + config.source.network.srt.local = srt_host.length !== 0 ? srt_host : 'localhost'; + config.source.network.srt.host += ':' + srt_port; + config.source.network.srt.local += ':' + srt_port; + // Memfs config.memfs.auth.enable = val.config.storage.memory.auth.enable; diff --git a/src/views/Settings.js b/src/views/Settings.js index fe5dff3..223961d 100644 --- a/src/views/Settings.js +++ b/src/views/Settings.js @@ -295,6 +295,54 @@ const configValues = { return null; }, }, + 'srt.enable': { + tab: 'srt', + set: (config, value) => { + config.srt.enable = !config.srt.enable; + }, + unset: (config) => { + delete config.srt.enable; + }, + validate: (config) => { + return null; + }, + }, + 'srt.address': { + tab: 'srt', + set: (config, value) => { + config.srt.address = value; + }, + unset: (config) => { + delete config.srt.address; + }, + validate: (config) => { + return null; + }, + }, + 'srt.passphrase': { + tab: 'srt', + set: (config, value) => { + config.srt.token = value; + }, + unset: (config) => { + delete config.srt.token; + }, + validate: (config) => { + return null; + }, + }, + 'srt.token': { + tab: 'srt', + set: (config, value) => { + config.srt.token = value; + }, + unset: (config) => { + delete config.srt.token; + }, + validate: (config) => { + return null; + }, + }, 'storage.cors.allow_all': { tab: 'storage', set: (config, value) => { @@ -638,6 +686,7 @@ export default function Settings(props) { playback: { errors: false, messages: [] }, storage: { errors: false, messages: [] }, rtmp: { errors: false, messages: [] }, + srt: { errors: false, messages: [] }, logging: { errors: false, messages: [] }, service: { errors: false, messages: [] }, }); @@ -703,9 +752,10 @@ export default function Settings(props) { config.tls.auto = false; } - config.tls.address = config.tls.address.split(':').join(''); config.address = config.address.split(':').join(''); + config.tls.address = config.tls.address.split(':').join(''); config.rtmp.address = config.rtmp.address.split(':').join(''); + config.srt.address = config.srt.address.split(':').join(''); if (config.tls.auto === true) { config.tls.enable = true; @@ -856,9 +906,11 @@ export default function Settings(props) { config.sessions.session_timeout_sec = toInt(config.sessions.session_timeout_sec); config.sessions.max_bitrate_mbit = toInt(config.sessions.max_bitrate_mbit); config.sessions.max_sessions = toInt(config.sessions.max_sessions); - config.tls.address = ':' + config.tls.address; + config.address = ':' + config.address; + config.tls.address = ':' + config.tls.address; config.rtmp.address = ':' + config.rtmp.address; + config.srt.address = ':' + config.srt.address; if (config.tls.auto === true) { config.tls.enable = true; @@ -1144,6 +1196,7 @@ export default function Settings(props) { {$expert === true && Playback} value="playback" errors={$tabs.playback.errors} />} {$expert === true && Storage} value="storage" errors={$tabs.storage.errors} />} RTMP/S} value="rtmp" errors={$tabs.rtmp.errors} /> + SRT} value="srt" errors={$tabs.srt.errors} /> {$expert === true && Logging} value="logging" errors={$tabs.logging.errors} />} @@ -1839,6 +1892,67 @@ export default function Settings(props) { + + + + + SRT + + + + SRT server} + checked={config.srt.enable} + disabled={env('srt.enable')} + onChange={handleChange('srt.enable')} + />{' '} + {env('srt.enable') && } + + + + + + + Port} + env={env('srt.address')} + disabled={env('srt.address') || !config.srt.enable} + value={config.srt.address} + onChange={handleChange('srt.address')} + /> + + + SRT server listen address. + + + + Token} + env={env('srt.token')} + disabled={env('srt.token') || !config.srt.enable} + value={config.srt.token} + onChange={handleChange('srt.token')} + /> + + + SRT token for publishing and playing. The token is the value of the streamid parameter 'token.' + + + + Passphrase} + env={env('srt.passphrase')} + disabled={env('srt.passphrase') || !config.srt.enable} + value={config.srt.passphrase} + onChange={handleChange('srt.passphrase')} + /> + + + Passphrase for SRT encryption. + + + +