From 8709d377380c65573aff53e595e36e09aa0708a1 Mon Sep 17 00:00:00 2001 From: Ingo Oppermann Date: Fri, 19 Apr 2024 15:45:54 +0200 Subject: [PATCH] Add option to select different SRT stream in wizard --- src/views/Edit/Wizard/Sources/InternalSRT.js | 95 ++++++++++++++++---- 1 file changed, 77 insertions(+), 18 deletions(-) diff --git a/src/views/Edit/Wizard/Sources/InternalSRT.js b/src/views/Edit/Wizard/Sources/InternalSRT.js index c5e0bbd..0341c6c 100644 --- a/src/views/Edit/Wizard/Sources/InternalSRT.js +++ b/src/views/Edit/Wizard/Sources/InternalSRT.js @@ -1,14 +1,18 @@ import React from 'react'; import { useNavigate } from 'react-router-dom'; -import { Trans } from '@lingui/macro'; +import { Trans, t } from '@lingui/macro'; +import { useLingui } from '@lingui/react'; import Button from '@mui/material/Button'; import Grid from '@mui/material/Grid'; import Icon from '@mui/icons-material/KeyboardTab'; +import MenuItem from '@mui/material/MenuItem'; +import RefreshIcon from '@mui/icons-material/Refresh'; import Typography from '@mui/material/Typography'; import * as S from '../../Sources/Network'; import BoxTextarea from '../../../../misc/BoxTextarea'; +import Select from '../../../../misc/Select'; import Textarea from '../../../../misc/Textarea'; const initSettings = (initialSettings, config) => { @@ -23,6 +27,7 @@ const initSettings = (initialSettings, config) => { }; function Source(props) { + const { i18n } = useLingui(); const navigate = useNavigate(); const config = S.func.initConfig(props.config); const settings = initSettings(props.settings, config); @@ -37,13 +42,32 @@ function Source(props) { props.onChange(S.id, newSettings, inputs, config.srt.enabled); }; + const handleRefresh = () => { + props.onRefresh(); + }; + + const update = (what) => (event) => { + const value = event.target.value; + const newSettings = { + ...settings, + }; + + if (what in newSettings.push) { + newSettings.push[what] = value; + } + + handleChange(newSettings); + }; + React.useEffect(() => { handleChange(); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); + let form = null; + if (config.srt.enabled === false) { - return ( + form = ( @@ -57,24 +81,59 @@ function Source(props) { ); + } else { + const filteredDevices = props.knownDevices.filter((device) => device.media === 'srt'); + const options = filteredDevices.map((device) => { + return ( + + {device.name} + + ); + }); + + options.unshift( + + {i18n._(t`Choose an input stream ...`)} + , + ); + + options.push( + + {i18n._(t`Send stream to address ...`)} + , + ); + + const SRT = S.func.getSRT(config, settings.push.name); + + form = ( + + + + + + {settings.push.name === config.channelid && ( + + + + Address: + + + + +