// This content populates the video variant modal, which is spawned from the variants table. import React from 'react'; import { Slider, Select, Switch, Divider, Collapse } from 'antd'; import { FieldUpdaterFunc, CpuUsageLevel, VideoVariant } from '../../../types/config-section'; import { DEFAULT_VARIANT_STATE } from './constants'; import InfoTip from '../info-tip'; import CPUUsageSelector from './cpu-usage'; const { Option } = Select; const { Panel } = Collapse; const VIDEO_VARIANT_DEFAULTS = { framerate: { min: 10, max: 80, defaultValue: 24, unit: 'fps', incrementBy: 1, tip: 'You prob wont need to touch this unless youre a hardcore gamer and need all the bitties', }, videoBitrate: { min: 600, max: 1200, defaultValue: 800, unit: 'kbps', incrementBy: 100, tip: 'This is importatnt yo', }, audioBitrate: { min: 600, max: 1200, defaultValue: 800, unit: 'kbps', incrementBy: 100, tip: 'nothing to see here', }, videoPassthrough: { tip: 'If No is selected, then you should set your desired Video Bitrate.', }, audioPassthrough: { tip: 'If No is selected, then you should set your desired Audio Bitrate.', }, }; interface VideoVariantFormProps { dataState: VideoVariant; onUpdateField: FieldUpdaterFunc; } export default function VideoVariantForm({ dataState = DEFAULT_VARIANT_STATE, onUpdateField, }: VideoVariantFormProps) { const handleFramerateChange = (value: number) => { onUpdateField({ fieldName: 'framerate', value }); }; const handleVideoBitrateChange = (value: number) => { onUpdateField({ fieldName: 'videoBitrate', value }); }; const handleAudioBitrateChange = (value: number) => { onUpdateField({ fieldName: 'audioBitrate', value }); }; const handleAudioPassChange = (value: boolean) => { onUpdateField({ fieldName: 'audioPassthrough', value }); }; const handleVideoPassChange = (value: boolean) => { onUpdateField({ fieldName: 'videoPassthrough', value }); }; const handleVideoCpuUsageLevelChange = (value: number) => { onUpdateField({ fieldName: 'cpuUsageLevel', value }); }; const framerateDefaults = VIDEO_VARIANT_DEFAULTS.framerate; const framerateMin = framerateDefaults.min; const framerateMax = framerateDefaults.max; const framerateUnit = framerateDefaults.unit; const videoBitrateDefaults = VIDEO_VARIANT_DEFAULTS.videoBitrate; const videoBRMin = videoBitrateDefaults.min; const videoBRMax = videoBitrateDefaults.max; const videoBRUnit = videoBitrateDefaults.unit; const audioBitrateDefaults = VIDEO_VARIANT_DEFAULTS.audioBitrate; const audioBRMin = audioBitrateDefaults.min; const audioBRMax = audioBitrateDefaults.max; const audioBRUnit = audioBitrateDefaults.unit; const selectedVideoBRnote = `Selected: ${dataState.videoBitrate}${videoBRUnit} - it sucks`; const selectedAudioBRnote = `Selected: ${dataState.audioBitrate}${audioBRUnit} - too slow`; const selectedFramerateNote = `Selected: ${dataState.framerate}${framerateUnit} - whoa there`; const selectedPresetNote = ''; return (
Say a thing here about how this all works. Read more{' '} here.

{/* ENCODER PRESET FIELD */}
{selectedPresetNote ? ( {selectedPresetNote} ) : null}
{/* VIDEO PASSTHROUGH FIELD */}

Use Video Passthrough?

{/* VIDEO BITRATE FIELD */}

Video Bitrate:

`${value} ${videoBRUnit}`} disabled={dataState.videoPassthrough === true} defaultValue={dataState.videoBitrate} value={dataState.videoBitrate} onChange={handleVideoBitrateChange} step={videoBitrateDefaults.incrementBy} min={videoBRMin} max={videoBRMax} marks={{ [videoBRMin]: `${videoBRMin} ${videoBRUnit}`, [videoBRMax]: `${videoBRMax} ${videoBRUnit}`, }} /> {selectedVideoBRnote ? ( {selectedVideoBRnote} ) : null}




Touch if you dare.
{/* FRAME RATE FIELD */}

Frame rate:

`${value} ${framerateUnit}`} defaultValue={dataState.framerate} value={dataState.framerate} onChange={handleFramerateChange} step={framerateDefaults.incrementBy} min={framerateMin} max={framerateMax} marks={{ [framerateMin]: `${framerateMin} ${framerateUnit}`, [framerateMax]: `${framerateMax} ${framerateUnit}`, }} /> {selectedFramerateNote ? ( {selectedFramerateNote} ) : null}
{/* AUDIO PASSTHROUGH FIELD */}

Use Audio Passthrough?

{dataState.audioPassthrough ? Same as source : null}
{/* AUDIO BITRATE FIELD */}

Audio Bitrate:

`${value} ${audioBRUnit}`} disabled={dataState.audioPassthrough === true} defaultValue={dataState.audioBitrate} value={dataState.audioBitrate} onChange={handleAudioBitrateChange} step={audioBitrateDefaults.incrementBy} min={audioBRMin} max={audioBRMax} marks={{ [audioBRMin]: `${audioBRMin} ${audioBRUnit}`, [audioBRMax]: `${audioBRMax} ${audioBRUnit}`, }} /> {selectedAudioBRnote ? ( {selectedAudioBRnote} ) : null}
); }