From 98b827b9f3e783a36a4dee253d0cc9a3ce91f769 Mon Sep 17 00:00:00 2001 From: Ingo Oppermann Date: Fri, 18 Nov 2022 10:35:06 +0100 Subject: [PATCH] Refine network source test --- src/views/Edit/Sources/Network.js | 288 +++++++++++++------------ src/views/Edit/Sources/Network.test.js | 6 +- 2 files changed, 155 insertions(+), 139 deletions(-) diff --git a/src/views/Edit/Sources/Network.js b/src/views/Edit/Sources/Network.js index 993fbd9..b11ef06 100644 --- a/src/views/Edit/Sources/Network.js +++ b/src/views/Edit/Sources/Network.js @@ -152,7 +152,9 @@ const initSkills = (initialSkills) => { }; if (skills.formats.demuxers.includes('rtsp')) { - skills.protocols.input.push('rtsp'); + if (!skills.protocols.input.includes('rtsp')) { + skills.protocols.input.push('rtsp'); + } } return skills; @@ -408,6 +410,7 @@ function Pull(props) { const settings = props.settings; const protocolClass = getProtocolClass(settings.address); const authProtocol = isAuthProtocol(settings.address); + const validURL = isValidURL(settings.address); const supportedProtocol = isSupportedProtocol(settings.address, props.skills.protocols.input); return ( @@ -430,68 +433,133 @@ function Pull(props) { Supports HTTP (HLS, DASH), RTP, RTSP, RTMP, SRT and more. - {!supportedProtocol ? ( - - - - - This protocol is unknown or not supported by the available FFmpeg binary. - - - - ) : ( + {validURL === true && ( - {authProtocol && ( - - - Username} - value={settings.username} - onChange={props.onChange('', 'username')} - /> - - Username for the device. - - - - Password} - value={settings.password} - onChange={props.onChange('', 'password')} - /> - - Password for the device. - - - - )} - - - }> + {!supportedProtocol ? ( + + + - Advanced settings + This protocol is unknown or not supported by the available FFmpeg binary. - - - - {protocolClass === 'rtsp' && ( - + + + ) : ( + + {authProtocol && ( + + + Username} + value={settings.username} + onChange={props.onChange('', 'username')} + /> + + Username for the device. + + + + Password} + value={settings.password} + onChange={props.onChange('', 'password')} + /> + + Password for the device. + + + + )} + + + }> + + Advanced settings + + + + + {protocolClass === 'rtsp' && ( + + + + RTSP + + + + UDP transport} + checked={settings.rtsp.udp} + onChange={props.onChange('rtsp', 'udp')} + /> + + + Socket timeout (microseconds)} + value={settings.rtsp.stimeout} + onChange={props.onChange('rtsp', 'stimeout')} + /> + + + )} + {protocolClass === 'http' && ( + + + + HTTP and HTTPS + + + + Read input at native speed} + checked={settings.http.readNative} + onChange={props.onChange('http', 'readNative')} + /> + Force input framerate} + checked={settings.http.forceFramerate} + onChange={props.onChange('http', 'forceFramerate')} + /> + + {settings.http.forceFramerate === true && ( + + Framerate} + value={settings.http.framerate} + onChange={props.onChange('http', 'framerate')} + /> + + )} + + + + + )} - RTSP + General - - UDP transport} - checked={settings.rtsp.udp} - onChange={props.onChange('rtsp', 'udp')} - /> - Socket timeout (microseconds)} - value={settings.rtsp.stimeout} - onChange={props.onChange('rtsp', 'stimeout')} + label="thread_queue_size" + value={settings.general.thread_queue_size} + onChange={props.onChange('general', 'thread_queue_size')} /> - - )} - {protocolClass === 'http' && ( - - - - HTTP and HTTPS - - - Read input at native speed} - checked={settings.http.readNative} - onChange={props.onChange('http', 'readNative')} - /> - Force input framerate} - checked={settings.http.forceFramerate} - onChange={props.onChange('http', 'forceFramerate')} - /> + + + + + + + + + + + - {settings.http.forceFramerate === true && ( - - Framerate} - value={settings.http.framerate} - onChange={props.onChange('http', 'framerate')} - /> - - )} - - - - - )} - - - General - - - - - - - - - - - - - - - - - - - - - - + + + + + + )} )} - + Probe diff --git a/src/views/Edit/Sources/Network.test.js b/src/views/Edit/Sources/Network.test.js index d357cc9..8beedd0 100644 --- a/src/views/Edit/Sources/Network.test.js +++ b/src/views/Edit/Sources/Network.test.js @@ -52,17 +52,21 @@ test('source:network pull', async () => { const Source = Network.component; let { getByLabelText, queryByText, rerender } = render(); + expect(queryByText(`This protocol is unknown or not supported by the available FFmpeg binary.`)).toBe(null); + const input = getByLabelText('Address'); fireEvent.change(input, { target: { value: 'rtsp://127.0.0.1/live/stream' } }); expect($settings.mode).toBe('pull'); expect($settings.address).toBe('rtsp://127.0.0.1/live/stream'); + rerender(); + expect(queryByText(`This protocol is unknown or not supported by the available FFmpeg binary.`)).toBeInTheDocument(); rerender(); - expect(queryByText(`The available FFmpeg binary doesn't support any of the required protocols.`)).toBe(null); + expect(queryByText(`This protocol is unknown or not supported by the available FFmpeg binary.`)).toBe(null); }); const pullmatrix = {