diff --git a/src/misc/modals/Process.js b/src/misc/modals/Process.js deleted file mode 100644 index 3eee837..0000000 --- a/src/misc/modals/Process.js +++ /dev/null @@ -1,120 +0,0 @@ -import React from 'react'; - -import { Trans } from '@lingui/macro'; -import makeStyles from '@mui/styles/makeStyles'; -import Divider from '@mui/material/Divider'; -import Grid from '@mui/material/Grid'; -import Modal from '@mui/material/Modal'; -import Typography from '@mui/material/Typography'; - -import ModalContent from '../ModalContent'; -import Progress from '../Progress'; -import Textarea from '../Textarea'; - -const useStyles = makeStyles((theme) => ({ - title: { - marginBottom: '-.3em', - marginTop: '0em', - fontWeight: 'bold', - }, - textarea: { - marginBottom: '-1em', - }, - box: { - backgroundColor: theme.palette.background.modalbox, - borderRadius: 4, - padding: '1em', - }, - banner: { - marginBottom: '-1em', - }, - logging: { - marginTop: '.15em', - }, -})); - -const initLogdata = (logdata) => { - if (!logdata) { - logdata = {}; - } - - return { - prelude: [], - log: [], - ...logdata, - }; -}; - -const formatLogline = (entry) => { - let line = '@' + entry[0] + ' '; - - const matches = entry[1].match(/^\[([0-9A-Za-z]+) @ 0x[0-9a-f]+\]/i); - if (matches !== null) { - let t = '[' + matches[1]; - for (let i = 0; i < 10 - matches[1].length; i++) { - t += ' '; - } - t += ']'; - line += entry[1].replace(matches[0], t); - } else { - line += entry[1]; - } - - return line; -}; - -const Component = function (props) { - const classes = useStyles(); - const logdata = initLogdata(props.logdata); - - return ( - - - - - - - - - - - Banner - - - - - - - - - Logging - - - - - - - - - - {props.progress !== null && } - - - - - ); -}; - -export default Component; - -Component.defaultProps = { - open: false, - title: '', - progress: {}, - logdata: { - prelude: [], - log: [], - }, - onClose: null, - onHelp: null, -}; diff --git a/src/misc/modals/Process/Progress.js b/src/misc/modals/Process/Progress.js new file mode 100644 index 0000000..ab6227a --- /dev/null +++ b/src/misc/modals/Process/Progress.js @@ -0,0 +1,269 @@ +import React from 'react'; + +import { Trans } from '@lingui/macro'; +import makeStyles from '@mui/styles/makeStyles'; +import Divider from '@mui/material/Divider'; +import Grid from '@mui/material/Grid'; +import Typography from '@mui/material/Typography'; + +import Duration from '../../Duration'; +import Number from '../../Number'; + +const useStyles = makeStyles((theme) => ({ + box: { + backgroundColor: theme.palette.background.modalbox, + borderRadius: 4, + padding: '1em', + height: '100%', + }, +})); + +function init(props) { + const initProps = { + time: 0, + fps: 0, + bitrate: 0, + q: -1, + speed: 0, + drop: 0, + dup: 0, + frames: 0, + cpu: 0, + memory: 0, + ...props, + }; + + return initProps; +} + +function IO(props) { + if (props.progress === null) { + return ( + + Not available + + ); + } + + const progress = props.progress; + + return ( + + + + {progress.type}: {progress.codec}{' '} + {progress.type === 'video' ? ( + + {progress.width}x{progress.height} {progress.pix_fmt} + + ) : ( + + {progress.layout} {progress.sampling_hz} Hz + + )} + + + + + + + + + + kbit/s + + + + + + + + + + FPS + + + + ); +} + +IO.defaultProps = { + progress: null, +}; + +export default function Progress(props) { + const classes = useStyles(); + + const progress = init(props); + + console.log(progress); + + let input_video = null; + let input_audio = null; + let output_video = null; + let output_audio = null; + + for (let i = 0; i < progress.inputs.length; i++) { + if (progress.inputs[i].type === 'video') { + input_video = progress.inputs[i]; + } else if (progress.inputs[i].type === 'audio') { + input_audio = progress.inputs[i]; + } + } + + for (let i = 0; i < progress.outputs.length; i++) { + if (progress.outputs[i].type === 'video') { + output_video = progress.outputs[i]; + } else if (progress.outputs[i].type === 'audio') { + output_audio = progress.outputs[i]; + } + } + + return ( + + + + + + + + + Uptime + + + + + + + + + + kbit/s + + + + + + + + + + Quality + + + + + + + + + + Speed + + + + + + % + + + + Frame drops + + + + + + + + + + Dup. frames + + + + + + % + + + + CPU + + + + + + MB + + + + Memory + + + {input_video || input_audio ? ( + + + + Inputs + + + {input_video && ( + + + + )} + {input_audio && ( + + + + )} + + ) : ( + + + No inputs + + + )} + {output_video || output_audio ? ( + + + + Outputs + + + {output_video && ( + + + + )} + {output_audio && ( + + + + )} + + ) : ( + + + No outputs + + + )} + + ); +} + +Progress.defaultProps = { + time: 0, + fps: 0, + bitrate: 0, + q: -1, + speed: 0, + drop: 0, + dup: 0, + frame: 0, + cpu: 0, + memory: 0, +}; diff --git a/src/misc/modals/Process/index.js b/src/misc/modals/Process/index.js new file mode 100644 index 0000000..b9c802b --- /dev/null +++ b/src/misc/modals/Process/index.js @@ -0,0 +1,148 @@ +import React from 'react'; + +import { Trans } from '@lingui/macro'; +import makeStyles from '@mui/styles/makeStyles'; +import Divider from '@mui/material/Divider'; +import Grid from '@mui/material/Grid'; +import Modal from '@mui/material/Modal'; +import Typography from '@mui/material/Typography'; +import Tab from '@mui/material/Tab'; +import Tabs from '@mui/material/Tabs'; + +import ModalContent from '../../ModalContent'; +import Progress from './Progress'; +import Textarea from '../../Textarea'; +import TabPanel from '../../TabPanel'; +import TabsVerticalGrid from '../../TabsVerticalGrid'; + +const useStyles = makeStyles((theme) => ({ + title: { + marginBottom: '-.3em', + marginTop: '0em', + fontWeight: 'bold', + }, + textarea: { + marginBottom: '-1em', + }, + box: { + backgroundColor: theme.palette.background.modalbox, + borderRadius: 4, + padding: '1em', + }, + banner: { + marginBottom: '-1em', + }, + logging: { + marginTop: '.15em', + }, +})); + +const initLogdata = (logdata) => { + if (!logdata) { + logdata = {}; + } + + return { + command: [], + prelude: [], + log: [], + ...logdata, + }; +}; + +const formatLogline = (entry) => { + let line = '@' + entry[0] + ' '; + + const matches = entry[1].match(/^\[([0-9A-Za-z]+) @ 0x[0-9a-f]+\]/i); + if (matches !== null) { + let t = '[' + matches[1]; + for (let i = 0; i < 10 - matches[1].length; i++) { + t += ' '; + } + t += ']'; + line += entry[1].replace(matches[0], t); + } else { + line += entry[1]; + } + + return line; +}; + +const Component = function (props) { + const [$tab, setTab] = React.useState('vitals'); + + const classes = useStyles(); + const logdata = initLogdata(props.logdata); + + logdata.command = props.progress.command; + + const handleChangeTab = (event, value) => { + setTab(value); + }; + + return ( + + + + + + Vitals} value="vitals" /> + Log} value="log" /> + + + + + {props.progress !== null && } + + + + + + + + + + + Command + + + + + + Banner + + + + + + + Logging + + + + + + + + + + + + + ); +}; + +export default Component; + +Component.defaultProps = { + open: false, + title: '', + progress: {}, + logdata: { + command: [], + prelude: [], + log: [], + }, + onClose: null, + onHelp: null, +}; diff --git a/src/utils/restreamer.js b/src/utils/restreamer.js index 71d31c3..60f0620 100644 --- a/src/utils/restreamer.js +++ b/src/utils/restreamer.js @@ -1,7 +1,7 @@ import { i18n } from '@lingui/core'; import { t } from '@lingui/macro'; import { v4 as uuidv4 } from 'uuid'; -import { jwtDecode } from "jwt-decode"; +import { jwtDecode } from 'jwt-decode'; import Handlebars from 'handlebars/dist/cjs/handlebars'; import SemverSatisfies from 'semver/functions/satisfies'; import SemverGt from 'semver/functions/gt'; @@ -3328,6 +3328,11 @@ class Restreamer { frames: 0, drop: 0, dup: 0, + command: [], + cpu: 0.0, + memory: 0, + inputs: [], + outputs: [], }; if (state === null) { @@ -3336,6 +3341,7 @@ class Restreamer { progress.valid = true; progress.order = state.order; + progress.command = state.command.slice(); const fps = state.progress.fps || 0; @@ -3367,6 +3373,10 @@ class Restreamer { progress.frames = state.progress.frames || 0; progress.drop = state.progress.drop || 0; progress.dup = state.progress.dup || 0; + progress.cpu = state.cpu_usage || 0; + progress.memory = state.memory_bytes || 0; + progress.inputs = state.progress.inputs.slice(); + progress.outputs = state.progress.outputs.slice(); } return progress; diff --git a/src/views/Main/index.js b/src/views/Main/index.js index ed269b2..889d46e 100644 --- a/src/views/Main/index.js +++ b/src/views/Main/index.js @@ -206,6 +206,7 @@ export default function Main(props) { const open = !$processDetails.open; let logdata = { + command: [], prelude: [], log: [], };