import { useState } from 'react' import fetch from 'isomorphic-unfetch' import {useSocket} from '../hooks/useSocket' import Layout from '../components/Layout' const mixerLabels = { mock: "Built-In Mock for testing", atem: "ATEM by Blackmagic Design", vmix: "vMix", "null": "Off", } const Config = props => { const allowedMixers = props.allowedMixers const [currentMixerId, setCurrentMixerId] = useState(props.currentMixerId) const [atemIp, setAtemIp] = useState(props.atem.ip) const [atemPort, setAtemPort] = useState(props.atem.port) const [vmixIp, setVmixIp] = useState(props.vmix.ip) const [vmixPort, setVmixPort] = useState(props.vmix.port) const [mockTickTime, setMockTickTime] = useState(props.mock.tickTime) const [mockChannelCount, setMockChannelCount] = useState(props.mock.channelCount) const [mockChannelNames, setMockChannelNames] = useState(props.mock.channelNames) const socket = useSocket('config', config => { setCurrentMixerId(config.currentMixerId) setAtemIp(config.atem.ip) setAtemPort(config.atem.port) setVmixIp(config.vmix.ip) setVmixPort(config.vmix.port) setMockTickTime(config.mock.tickTime) setMockChannelCount(config.mock.channelCount) setMockChannelNames(config.mock.channelNames) }) const handleSubmit = e => { socket.emit('config.changeRequest', currentMixerId, atemIp, atemPort, vmixIp, vmixPort, mockTickTime, mockChannelCount, mockChannelNames) e.preventDefault() } const addMixerOption = function(id) { const label = mixerLabels[id] return ( ) } return (

Video Mixer

Select a Video Mixer to use.

{currentMixerId === "mock" ? (
Mock Configuration

This simulates a Video Mixer by changing the channels randomly at a fixed time interval. It is intended for development, when you do not have a video mixer at hand, but serves no purpose in productive environments.

setMockTickTime(e.target.value)} />
setMockChannelCount(e.target.value)} />
setMockChannelNames(e.target.value)} />
): ""} {currentMixerId === "atem" ? (
ATEM Configuration

Connects to any ATEM device over network.

setAtemIp(e.target.value)} />
setAtemPort(e.target.value)} />
) : ""} {currentMixerId === "vmix" ? (
vMix Configuration

Connects to any vMix over network.

setVmixIp(e.target.value)} />
setVmixPort(e.target.value)} />
) : ""} {currentMixerId === "null" ? (

This cuts the connection to any video mixer.

) : ""}
) } Config.getInitialProps = async (context) => { const baseUrl = context && context.req ? `${context.req.protocol}://${context.req.get('Host')}` : ''; const response = await fetch(baseUrl + '/atem') const info = await response.json() return info } export default Config;