Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jstabenow committed Jan 26, 2024
2 parents 813252d + 3270140 commit 77dfcbe
Show file tree
Hide file tree
Showing 18 changed files with 132 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/views/Edit/Sources/ALSA.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function SourceIcon(props) {
const id = 'alsa';
const name = <Trans>ALSA</Trans>;
const capabilities = ['audio'];
const ffversion = '^4.1.0 || ^5.0.0';
const ffversion = '^4.1.0 || ^5.0.0 || ^6.1.0';

const func = {
initSettings,
Expand Down
2 changes: 1 addition & 1 deletion src/views/Edit/Sources/AVFoundation.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ function SourceIcon(props) {
const id = 'avfoundation';
const name = <Trans>AVFoundation</Trans>;
const capabilities = ['audio', 'video'];
const ffversion = '^4.1.0 || ^5.0.0';
const ffversion = '^4.1.0 || ^5.0.0 || ^6.1.0';

const func = {
initSettings,
Expand Down
2 changes: 1 addition & 1 deletion src/views/Edit/Sources/AudioLoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ function SourceIcon(props) {
const id = 'audioloop';
const name = <Trans>Loop</Trans>;
const capabilities = ['audio'];
const ffversion = '^4.1.0 || ^5.0.0';
const ffversion = '^4.1.0 || ^5.0.0 || ^6.1.0';

const func = {
initSettings,
Expand Down
2 changes: 1 addition & 1 deletion src/views/Edit/Sources/Framebuffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function SourceIcon(props) {
const id = 'fbdev';
const name = <Trans>Framebuffer</Trans>;
const capabilities = ['video'];
const ffversion = '^4.1.0 || ^5.0.0';
const ffversion = '^4.1.0 || ^5.0.0 || ^6.1.0';

const func = {
initSettings,
Expand Down
8 changes: 5 additions & 3 deletions src/views/Edit/Sources/Network.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,15 @@ const initSkills = (initialSkills) => {
};

const createInputs = (settings, config, skills) => {
settings = initSettings(settings);
config = initConfig(config);
settings = initSettings(settings, config);
skills = initSkills(skills);

let ffmpeg_version = 4;
let ffmpeg_version = 6;
if (SemverSatisfies(skills.ffmpeg.version, '^5.0.0')) {
ffmpeg_version = 5;
} else if (SemverSatisfies(skills.ffmpeg.version, '^4.1.0')) {
ffmpeg_version = 4;
}

const input = {
Expand Down Expand Up @@ -1173,7 +1175,7 @@ function SourceIcon(props) {
const id = 'network';
const name = <Trans>Network source</Trans>;
const capabilities = ['audio', 'video'];
const ffversion = '^4.1.0 || ^5.0.0';
const ffversion = '^4.1.0 || ^5.0.0 || ^6.1.0';

const func = {
initSettings,
Expand Down
103 changes: 103 additions & 0 deletions src/views/Edit/Sources/Network.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ import '@testing-library/jest-dom';

import * as Network from './Network';

const $skills_ffmpeg6 = {
ffmpeg: {
version: '6.1.1',
},
formats: {
demuxers: ['rtsp'],
},
protocols: {
input: ['http', 'https', 'rtmp', 'rtmps', 'srt'],
},
};

const $skills_ffmpeg5 = {
ffmpeg: {
version: '5.1.2',
Expand All @@ -29,6 +41,7 @@ const $skills_ffmpeg4 = {
};

const $config = {
channelid: 'external',
rtmp: {
enabled: true,
app: '/live',
Expand Down Expand Up @@ -64,9 +77,17 @@ test('source:network pull', async () => {

expect(queryByText(`This protocol is unknown or not supported by the available FFmpeg binary.`)).toBeInTheDocument();

rerender(<Source settings={$settings} skills={$skills_ffmpeg4} onChange={handleChange} />);

expect(queryByText(`This protocol is unknown or not supported by the available FFmpeg binary.`)).toBe(null);

rerender(<Source settings={$settings} skills={$skills_ffmpeg5} onChange={handleChange} />);

expect(queryByText(`This protocol is unknown or not supported by the available FFmpeg binary.`)).toBe(null);

rerender(<Source settings={$settings} skills={$skills_ffmpeg6} onChange={handleChange} />);

expect(queryByText(`This protocol is unknown or not supported by the available FFmpeg binary.`)).toBe(null);
});

const pullmatrix = {
Expand Down Expand Up @@ -205,6 +226,56 @@ pullmatrix.tests = [
options: ['-fflags', '+genpts', '-thread_queue_size', 512],
},
},
{
name: 'RTSP',
settings: { ...pullmatrix.settings, address: 'rtsp://127.0.0.1/live/stream' },
skills: $skills_ffmpeg6,
input: {
address: 'rtsp://admin:foobar@127.0.0.1/live/stream',
options: ['-fflags', '+genpts', '-thread_queue_size', 512, '-timeout', 5000000, '-rtsp_transport', 'tcp'],
},
},
{
name: 'RTMP',
settings: { ...pullmatrix.settings, address: 'rtmp://127.0.0.1/live/stream' },
skills: $skills_ffmpeg6,
input: {
address: 'rtmp://admin:foobar@127.0.0.1/live/stream',
options: ['-fflags', '+genpts', '-thread_queue_size', 512, '-analyzeduration', 3000000],
},
},
{
name: 'HTTP',
settings: { ...pullmatrix.settings, address: 'http://127.0.0.1/live/stream.m3u8' },
skills: $skills_ffmpeg6,
input: {
address: 'http://admin:foobar@127.0.0.1/live/stream.m3u8',
options: [
'-fflags',
'+genpts',
'-thread_queue_size',
512,
'-analyzeduration',
20000000,
'-re',
'-r',
25,
'-user_agent',
'foobaz/1',
'-referer',
'http://example.com',
],
},
},
{
name: 'SRT',
settings: { ...pullmatrix.settings, address: 'srt://127.0.0.1?mode=caller&streamid=foobar' },
skills: $skills_ffmpeg6,
input: {
address: 'srt://127.0.0.1?mode=caller&streamid=foobar',
options: ['-fflags', '+genpts', '-thread_queue_size', 512],
},
},
];

test.each(pullmatrix.tests)('source:network pull $name input with ffmpeg $skills.ffmpeg.version', async (data) => {
Expand All @@ -231,6 +302,7 @@ test('source:network push', async () => {
mode: 'push',
push: {
type: 'rtmp',
name: 'external',
},
};
const handleChange = (settings) => {
Expand All @@ -244,16 +316,25 @@ test('source:network push', async () => {

expect(queryByText(`The available FFmpeg binary doesn't support any of the required protocols.`)).toBeInTheDocument();

rerender(<Source settings={$settings} skills={$skills_ffmpeg4} onChange={handleChange} />);

expect(queryByText(`The available FFmpeg binary doesn't support any of the required protocols.`)).toBe(null);

rerender(<Source settings={$settings} skills={$skills_ffmpeg5} onChange={handleChange} />);

expect(queryByText(`The available FFmpeg binary doesn't support any of the required protocols.`)).toBe(null);

rerender(<Source settings={$settings} skills={$skills_ffmpeg6} onChange={handleChange} />);

expect(queryByText(`The available FFmpeg binary doesn't support any of the required protocols.`)).toBe(null);
});

test('source:network push RTMP', async () => {
let $settings = {
mode: 'push',
push: {
type: 'rtmp',
name: 'external',
},
};
const handleChange = (settings) => {
Expand All @@ -278,6 +359,7 @@ test('source:network push SRT', async () => {
mode: 'push',
push: {
type: 'srt',
name: 'external',
},
};
const handleChange = (settings) => {
Expand All @@ -302,6 +384,7 @@ const pushmatrix = {
mode: 'push',
push: {
type: '',
name: 'external',
},
},
tests: [],
Expand Down Expand Up @@ -348,6 +431,26 @@ pushmatrix.tests = [
options: ['-fflags', '+genpts', '-thread_queue_size', 512],
},
},
{
name: 'RTMP',
settings: { ...pushmatrix.settings, push: { ...pushmatrix.push, type: 'rtmp' } },
skills: $skills_ffmpeg6,
config: $config,
input: {
address: '{rtmp,name=external.stream}',
options: ['-fflags', '+genpts', '-thread_queue_size', 512, '-analyzeduration', 3000000],
},
},
{
name: 'SRT',
settings: { ...pushmatrix.settings, push: { ...pushmatrix.push, type: 'srt' } },
skills: $skills_ffmpeg6,
config: $config,
input: {
address: '{srt,name=external.stream,mode=request}',
options: ['-fflags', '+genpts', '-thread_queue_size', 512],
},
},
];

test.each(pushmatrix.tests)('source:network push $name input with ffmpeg $skills.ffmpeg.version', async (data) => {
Expand Down
2 changes: 1 addition & 1 deletion src/views/Edit/Sources/NoAudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function SourceIcon(props) {
const id = 'noaudio';
const name = <Trans>No audio</Trans>;
const capabilities = ['audio'];
const ffversion = '^4.1.0 || ^5.0.0';
const ffversion = '^4.1.0 || ^5.0.0 || ^6.1.0';

const func = {
initSettings,
Expand Down
2 changes: 1 addition & 1 deletion src/views/Edit/Sources/Raspicam.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function SourceIcon(props) {
const id = 'raspicam';
const name = <Trans>Raspberry Pi camera</Trans>;
const capabilities = ['video'];
const ffversion = '^4.1.0 || ^5.0.0';
const ffversion = '^4.1.0 || ^5.0.0 || ^6.1.0';

const func = {
initSettings,
Expand Down
2 changes: 1 addition & 1 deletion src/views/Edit/Sources/V4L.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ function SourceIcon(props) {
const id = 'video4linux2';
const name = <Trans>Hardware device</Trans>;
const capabilities = ['video'];
const ffversion = '^4.1.0 || ^5.0.0';
const ffversion = '^4.1.0 || ^5.0.0 || ^6.1.0';

const func = {
initSettings,
Expand Down
2 changes: 1 addition & 1 deletion src/views/Edit/Sources/VideoAudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function SourceIcon(props) {
const id = 'videoaudio';
const name = <Trans>Video source</Trans>;
const capabilities = ['audio'];
const ffversion = '^4.1.0 || ^5.0.0';
const ffversion = '^4.1.0 || ^5.0.0 || ^6.1.0';

const func = {
initSettings,
Expand Down
2 changes: 1 addition & 1 deletion src/views/Edit/Sources/VideoLoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ function SourceIcon(props) {
const id = 'videoloop';
const name = <Trans>Loop</Trans>;
const capabilities = ['video'];
const ffversion = '^4.1.0 || ^5.0.0';
const ffversion = '^4.1.0 || ^5.0.0 || ^6.1.0';

const func = {
initSettings,
Expand Down
2 changes: 1 addition & 1 deletion src/views/Edit/Sources/VirtualAudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ function SourceIcon(props) {
const id = 'virtualaudio';
const name = <Trans>Virtual source</Trans>;
const capabilities = ['audio'];
const ffversion = '^4.1.0 || ^5.0.0';
const ffversion = '^4.1.0 || ^5.0.0 || ^6.1.0';

const func = {
initSettings,
Expand Down
2 changes: 1 addition & 1 deletion src/views/Edit/Sources/VirtualVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ function SourceIcon(props) {
const id = 'virtualvideo';
const name = <Trans>Virtual source</Trans>;
const capabilities = ['video'];
const ffversion = '^4.1.0 || ^5.0.0';
const ffversion = '^4.1.0 || ^5.0.0 || ^6.1.0';

const func = {
initSettings,
Expand Down
6 changes: 3 additions & 3 deletions src/views/Edit/Wizard/Sources/InternalHLS.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import * as S from '../../Sources/Network';
import BoxTextarea from '../../../../misc/BoxTextarea';
import Textarea from '../../../../misc/Textarea';

const initSettings = (initialSettings) => {
const initSettings = (initialSettings, config) => {
const settings = {
...S.func.initSettings(initialSettings),
...S.func.initSettings(initialSettings, config),
mode: 'push',
};

Expand All @@ -21,8 +21,8 @@ const initSettings = (initialSettings) => {
};

function Source(props) {
const settings = initSettings(props.settings);
const config = S.func.initConfig(props.config);
const settings = initSettings(props.settings, config);
const skills = S.func.initSkills(props.skills);

const handleChange = (newSettings) => {
Expand Down
6 changes: 3 additions & 3 deletions src/views/Edit/Wizard/Sources/InternalRTMP.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import * as S from '../../Sources/Network';
import BoxTextarea from '../../../../misc/BoxTextarea';
import Textarea from '../../../../misc/Textarea';

const initSettings = (initialSettings) => {
const initSettings = (initialSettings, config) => {
const settings = {
...S.func.initSettings(initialSettings),
...S.func.initSettings(initialSettings, config),
mode: 'push',
};

Expand All @@ -24,8 +24,8 @@ const initSettings = (initialSettings) => {

function Source(props) {
const navigate = useNavigate();
const settings = initSettings(props.settings);
const config = S.func.initConfig(props.config);
const settings = initSettings(props.settings, config);
const skills = S.func.initSkills(props.skills);

const handleChange = (newSettings) => {
Expand Down
6 changes: 3 additions & 3 deletions src/views/Edit/Wizard/Sources/InternalSRT.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import * as S from '../../Sources/Network';
import BoxTextarea from '../../../../misc/BoxTextarea';
import Textarea from '../../../../misc/Textarea';

const initSettings = (initialSettings) => {
const initSettings = (initialSettings, config) => {
const settings = {
...S.func.initSettings(initialSettings),
...S.func.initSettings(initialSettings, config),
mode: 'push',
};

Expand All @@ -24,8 +24,8 @@ const initSettings = (initialSettings) => {

function Source(props) {
const navigate = useNavigate();
const settings = initSettings(props.settings);
const config = S.func.initConfig(props.config);
const settings = initSettings(props.settings, config);
const skills = S.func.initSkills(props.skills);

const handleChange = (newSettings) => {
Expand Down
6 changes: 3 additions & 3 deletions src/views/Edit/Wizard/Sources/Network.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ import * as S from '../../Sources/Network';
import Checkbox from '../../../../misc/Checkbox';
import Password from '../../../../misc/Password';

const initSettings = (initialSettings) => {
const initSettings = (initialSettings, config) => {
const settings = {
...S.func.initSettings(initialSettings),
...S.func.initSettings(initialSettings, config),
mode: 'pull',
};

return settings;
};

function Source(props) {
const settings = initSettings(props.settings);
const config = S.func.initConfig(props.config);
const settings = initSettings(props.settings, config);
const skills = S.func.initSkills(props.skills);

const handleChange = (newSettings) => {
Expand Down
Loading

0 comments on commit 77dfcbe

Please sign in to comment.