From ff79efca02d969a2c961d4d549b3dd8a36a6effd Mon Sep 17 00:00:00 2001 From: Ingo Oppermann Date: Fri, 26 Jan 2024 12:53:32 +0100 Subject: [PATCH] Set channelid as default push stream name --- src/utils/restreamer.js | 4 +--- src/views/Edit/Sources/Network.js | 34 +++++++++++++++---------------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/utils/restreamer.js b/src/utils/restreamer.js index 6558402..cfc52ba 100644 --- a/src/utils/restreamer.js +++ b/src/utils/restreamer.js @@ -922,9 +922,7 @@ class Restreamer { ConfigActive() { const config = JSON.parse(JSON.stringify(this.config)); - config.source.network.rtmp.name = this.channel.channelid; - config.source.network.hls.name = this.channel.channelid; - config.source.network.srt.name = this.channel.channelid; + config.source.network.channelid = this.channel.channelid; return config; } diff --git a/src/views/Edit/Sources/Network.js b/src/views/Edit/Sources/Network.js index 21f9d7d..eab6091 100644 --- a/src/views/Edit/Sources/Network.js +++ b/src/views/Edit/Sources/Network.js @@ -35,7 +35,7 @@ const useStyles = makeStyles((theme) => ({ }, })); -const initSettings = (initialSettings) => { +const initSettings = (initialSettings, config) => { if (!initialSettings) { initialSettings = {}; } @@ -54,7 +54,7 @@ const initSettings = (initialSettings) => { settings.push = { type: 'rtmp', - name: 'none', + name: config.channelid, ...settings.push, }; @@ -101,6 +101,7 @@ const initConfig = (initialConfig) => { rtmp: {}, srt: {}, hls: {}, + channelid: 'external', ...initialConfig, }; @@ -111,7 +112,6 @@ const initConfig = (initialConfig) => { local: 'localhost', app: '', token: '', - name: 'external', ...config.rtmp, }; @@ -121,7 +121,6 @@ const initConfig = (initialConfig) => { local: 'localhost', token: '', passphrase: '', - name: 'external', ...config.srt, }; @@ -130,7 +129,6 @@ const initConfig = (initialConfig) => { host: 'localhost', local: 'localhost', credentials: '', - name: 'external', ...config.hls, }; @@ -198,16 +196,16 @@ const createInputs = (settings, config, skills) => { let name = settings.push.name; if (settings.push.type === 'hls') { if (name === 'none') { - name = config.hls.name; + name = config.channelid; } input.address = getLocalHLS(name); } else if (settings.push.type === 'rtmp') { - if (name === config.rtmp.name) { + if (name === config.channelid) { name += '.stream'; } input.address = getLocalRTMP(name); } else if (settings.push.type === 'srt') { - if (name === config.srt.name) { + if (name === config.channelid) { name += '.stream'; } input.address = getLocalSRT(name); @@ -452,25 +450,25 @@ const getSRTAddress = (host, name, token, passphrase, publish) => { }; const getHLS = (config, name) => { - const url = getHLSAddress(config.hls.host, config.hls.credentials, config.hls.name, config.hls.secure); + const url = getHLSAddress(config.hls.host, config.hls.credentials, config.channelid, config.hls.secure); return url; }; const getRTMP = (config) => { - const url = getRTMPAddress(config.rtmp.host, config.rtmp.app, config.rtmp.name, config.rtmp.token, config.rtmp.secure); + const url = getRTMPAddress(config.rtmp.host, config.rtmp.app, config.channelid, config.rtmp.token, config.rtmp.secure); return url; }; const getSRT = (config) => { - const url = getSRTAddress(config.srt.host, config.srt.name, config.srt.token, config.srt.passphrase, true); + const url = getSRTAddress(config.srt.host, config.channelid, config.srt.token, config.srt.passphrase, true); return url; }; const getLocalHLS = (config, name) => { - let url = getHLSAddress(config.hls.local, '', config.hls.name, false); + let url = getHLSAddress(config.hls.local, '', config.channelid, false); return url; }; @@ -936,7 +934,7 @@ function PushRTMP(props) { ); options.push( - + {i18n._(t`Send stream to address ...`)} , ); @@ -951,7 +949,7 @@ function PushRTMP(props) { Refresh - {props.settings.push.name === config.rtmp.name && ( + {props.settings.push.name === config.channelid && ( @@ -1030,7 +1028,7 @@ function PushSRT(props) { ); options.push( - + {i18n._(t`Send stream to address ...`)} , ); @@ -1045,7 +1043,7 @@ function PushSRT(props) { Refresh - {props.settings.push.name === config.srt.name && ( + {props.settings.push.name === config.channelid && ( @@ -1086,7 +1084,7 @@ function Source(props) { const classes = useStyles(); const { i18n } = useLingui(); const config = initConfig(props.config); - const settings = initSettings(props.settings); + const settings = initSettings(props.settings, config); const skills = initSkills(props.skills); const handleChange = (section, what) => (event) => { @@ -1113,7 +1111,7 @@ function Source(props) { } else if (section === 'push') { settings.push[what] = value; if (what === 'type') { - settings.push.name = 'none'; + settings.push.name = config.channelid; } } else { settings[what] = value;