Fix output path generation

This commit is contained in:
Ingo Oppermann 2022-07-07 17:10:30 +02:00
parent 154e126716
commit 27eb93e465
No known key found for this signature in database
GPG Key ID: 2AB32426E9DD229E
3 changed files with 31 additions and 36 deletions

View File

@ -1,10 +1,5 @@
class API {
constructor(address) {
// Removes the / at the end
if (address.slice(-1) === '/') {
address = address.slice(0, -1);
}
this.base = '/api';
this.address = address;
this.token = '';

View File

@ -20,6 +20,11 @@ class Restreamer {
address = window.location.protocol + '//' + window.location.host;
}
// Remove the / at the end
if (address.slice(-1) === '/') {
address = address.slice(0, -1);
}
this.address = address;
this.api = new API(this.address);
@ -759,6 +764,8 @@ class Restreamer {
hostname = val.config.host.name[0];
}
config.hostname = hostname;
// If we're connecting to the API with TLS or if the API is TLS-enabled
// we upgrade to TLS.
let protocol = 'http:';
@ -774,8 +781,6 @@ class Restreamer {
port = config.http.secure ? '443' : '80';
}
config.hostname = hostname;
// Set the HTTP host and only add the port if it is not the default one.
config.http.host = config.hostname;
if ((config.http.secure && port !== '443') || (!config.http.secure && port !== '80')) {
@ -925,7 +930,7 @@ class Restreamer {
// Get all RTMP/SRT/SNAPSHOT+MEMFS/HLS+MEMFS addresses
GetAddresses(what, channelId) {
const config = this.ConfigActive();
const host = new URL(this.Address()).hostname;
const host = config.hostname;
let address = '';
@ -941,44 +946,39 @@ class Restreamer {
}
}
// rtmp/s
if (what && what === 'rtmp') {
const port = getPort(config.source.network.rtmp.host);
// rtmp/s
const cfg = config.source.network.rtmp;
const port = getPort(cfg.host);
if (config.source.network.rtmp.secure) {
address =
`rtmps://${host}${port}/` +
(config.source.network.rtmp.app.length !== 0 ? config.source.network.rtmp.app : '') +
channelId +
'.stream' +
(config.source.network.rtmp.token.length !== 0 ? `?token=${config.source.network.rtmp.token}` : '');
} else {
address =
`rtmp://${host}${port}/` +
(config.source.network.rtmp.app.length !== 0 ? config.source.network.rtmp.app : '') +
channelId +
'.stream' +
(config.source.network.rtmp.token.length !== 0 ? `?token=${config.source.network.rtmp.token}` : '');
address = 'rtmp';
if (cfg.secure) {
address += 's';
}
// srt
address +=
`://${host}${port}` +
(cfg.app.length !== 0 ? cfg.app : '') +
'/' +
channelId +
'.stream' +
(cfg.token.length !== 0 ? `?token=${cfg.token}` : '');
} else if (what && what === 'srt') {
const port = getPort(config.source.network.srt.host);
// srt
const cfg = config.source.network.srt;
const port = getPort(cfg.host);
address =
`srt://${host}${port}/?mode=caller&streamid=#!:m=request,r=${channelId}` +
(config.source.network.srt.token.length !== 0 ? `,token=${config.source.network.srt.token}` : '') +
'&transtype=live' +
(config.source.network.srt.passphrase.length !== 0 ? `&passphrase=${config.source.network.srt.passphrase}` : '');
`srt://${host}${port}/?mode=caller&transtype=live&streamid=#!:m=request,r=${channelId}` +
(cfg.token.length !== 0 ? `,token=${cfg.srt.token}` : '') +
(cfg.passphrase.length !== 0 ? `&passphrase=${cfg.passphrase}` : '');
} else if (what && what === 'snapshot+memfs') {
// snapshot+memfs
} else if (what && what === 'snapshotMemFs') {
const port = getPort(config.source.network.hls.host);
address = (config.http.secure === true ? 'https://' : 'http://') + `${host}${port}/memfs/${channelId}.jpg`;
// hls+memfs
} else {
// hls+memfs
const port = getPort(config.source.network.hls.host);
address = (config.http.secure === true ? 'https://' : 'http://') + `${host}${port}/memfs/${channelId}.m3u8`;

View File

@ -384,7 +384,7 @@ export default function Main(props) {
variant="outlined"
color="default"
size="small"
value={props.restreamer.GetAddresses('hlsMemFs', _channelid)}
value={props.restreamer.GetAddresses('hls+memfs', _channelid)}
>
<Trans>HLS</Trans>
</CopyButton>
@ -412,7 +412,7 @@ export default function Main(props) {
variant="outlined"
color="default"
size="small"
value={props.restreamer.GetAddresses('snapshotMemFs', _channelid)}
value={props.restreamer.GetAddresses('snapshot+memfs', _channelid)}
>
<Trans>Snapshot</Trans>
</CopyButton>