Skip to content

Commit

Permalink
Fix wrong call to encoder defaults (datarhei/restreamer#467)
Browse files Browse the repository at this point in the history
  • Loading branch information
ioppermann committed Nov 22, 2022
1 parent d6b19e0 commit ec4edf2
Show file tree
Hide file tree
Showing 54 changed files with 1,860 additions and 615 deletions.
10 changes: 8 additions & 2 deletions src/misc/EncodingSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import H from '../utils/help';
export default function EncodingSelect(props) {
const { i18n } = useLingui();

console.log(props.streams);

const profile = props.profile;
let availableEncoders = [];
let availableDecoders = [];
Expand All @@ -28,6 +30,7 @@ export default function EncodingSelect(props) {

const handleDecoderChange = (event) => {
const decoder = profile.decoder;
const stream = props.streams[profile.stream];
decoder.coder = event.target.value;

// If the coder changes, use the coder's default settings
Expand All @@ -39,7 +42,7 @@ export default function EncodingSelect(props) {
}

if (c !== null) {
const defaults = c.defaults(props.skills);
const defaults = c.defaults(stream, props.skills);
decoder.settings = defaults.settings;
decoder.mapping = defaults.mapping;
}
Expand All @@ -58,6 +61,7 @@ export default function EncodingSelect(props) {

const handleEncoderChange = (event) => {
const encoder = profile.encoder;
const stream = props.streams[profile.stream];
encoder.coder = event.target.value;

// If the coder changes, use the coder's default settings
Expand All @@ -69,7 +73,7 @@ export default function EncodingSelect(props) {
}

if (c !== null) {
const defaults = c.defaults(props.skills);
const defaults = c.defaults(stream, props.skills);
encoder.settings = defaults.settings;
encoder.mapping = defaults.mapping;
}
Expand Down Expand Up @@ -198,6 +202,8 @@ export default function EncodingSelect(props) {
}
}

// TODO: in case there's no decoder for a codec it should be mentioned.

return (
<Grid container spacing={2}>
<Grid item xs={12}>
Expand Down
8 changes: 4 additions & 4 deletions src/misc/coders/Decoders/audio/Default.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function init(initialState) {
return state;
}

function createMapping(settings) {
function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: [],
Expand All @@ -27,7 +27,7 @@ function Coder(props) {
automatic = true;
}

props.onChange(newSettings, createMapping(newSettings), automatic);
props.onChange(newSettings, createMapping(newSettings, props.stream, props.skills), automatic);
};

React.useEffect(() => {
Expand All @@ -51,12 +51,12 @@ const codecs = [];
const type = 'audio';
const hwaccel = false;

function defaults() {
function defaults(stream, skills) {
const settings = init({});

return {
settings: settings,
mapping: createMapping(settings),
mapping: createMapping(settings, stream, skills),
};
}

Expand Down
8 changes: 4 additions & 4 deletions src/misc/coders/Decoders/video/Default.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function init(initialState) {
return state;
}

function createMapping(settings) {
function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: [],
Expand All @@ -27,7 +27,7 @@ function Coder(props) {
automatic = true;
}

props.onChange(newSettings, createMapping(newSettings), automatic);
props.onChange(newSettings, createMapping(newSettings, props.stream, props.skills), automatic);
};

React.useEffect(() => {
Expand All @@ -51,12 +51,12 @@ const codecs = [];
const type = 'video';
const hwaccel = false;

function defaults() {
function defaults(stream, skills) {
const settings = init({});

return {
settings: settings,
mapping: createMapping(settings),
mapping: createMapping(settings, stream, skills),
};
}

Expand Down
8 changes: 4 additions & 4 deletions src/misc/coders/Decoders/video/H264CUVID.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function init(initialState) {
return state;
}

function createMapping(settings) {
function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: ['-c:v', 'h264_cuvid'],
Expand All @@ -27,7 +27,7 @@ function Coder(props) {
automatic = true;
}

props.onChange(newSettings, createMapping(newSettings), automatic);
props.onChange(newSettings, createMapping(newSettings, props.stream, props.skills), automatic);
};

React.useEffect(() => {
Expand All @@ -53,12 +53,12 @@ const codecs = ['h264'];
const type = 'video';
const hwaccel = true;

function defaults() {
function defaults(stream, skills) {
const settings = init({});

return {
settings: settings,
mapping: createMapping(settings),
mapping: createMapping(settings, stream, skills),
};
}

Expand Down
8 changes: 4 additions & 4 deletions src/misc/coders/Decoders/video/H264MMAL.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function init(initialState) {
return state;
}

function createMapping(settings) {
function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: ['-c:v', 'h264_mmal'],
Expand All @@ -27,7 +27,7 @@ function Coder(props) {
automatic = true;
}

props.onChange(newSettings, createMapping(newSettings), automatic);
props.onChange(newSettings, createMapping(newSettings, props.stream, props.skills), automatic);
};

React.useEffect(() => {
Expand All @@ -51,12 +51,12 @@ const codecs = ['h264'];
const type = 'video';
const hwaccel = true;

function defaults() {
function defaults(stream, skills) {
const settings = init({});

return {
settings: settings,
mapping: createMapping(settings),
mapping: createMapping(settings, stream, skills),
};
}

Expand Down
8 changes: 4 additions & 4 deletions src/misc/coders/Decoders/video/HEVCCUVID.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function init(initialState) {
return state;
}

function createMapping(settings) {
function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: ['-c:v', 'hevc_cuvid'],
Expand All @@ -27,7 +27,7 @@ function Coder(props) {
automatic = true;
}

props.onChange(newSettings, createMapping(newSettings), automatic);
props.onChange(newSettings, createMapping(newSettings, props.stream, props.skills), automatic);
};

React.useEffect(() => {
Expand All @@ -51,12 +51,12 @@ const codecs = ['hevc'];
const type = 'video';
const hwaccel = true;

function defaults() {
function defaults(stream, skills) {
const settings = init({});

return {
settings: settings,
mapping: createMapping(settings),
mapping: createMapping(settings, stream, skills),
};
}

Expand Down
8 changes: 4 additions & 4 deletions src/misc/coders/Decoders/video/MJPEGCUVID.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function init(initialState) {
return state;
}

function createMapping(settings) {
function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: ['-c:v', 'mjpeg_cuvid'],
Expand All @@ -27,7 +27,7 @@ function Coder(props) {
automatic = true;
}

props.onChange(newSettings, createMapping(newSettings), automatic);
props.onChange(newSettings, createMapping(newSettings, props.stream, props.skills), automatic);
};

React.useEffect(() => {
Expand All @@ -51,12 +51,12 @@ const codecs = ['mjpeg'];
const type = 'video';
const hwaccel = true;

function defaults() {
function defaults(stream, skills) {
const settings = init({});

return {
settings: settings,
mapping: createMapping(settings),
mapping: createMapping(settings, stream, skills),
};
}

Expand Down
8 changes: 4 additions & 4 deletions src/misc/coders/Decoders/video/MPEG1CUVID.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function init(initialState) {
return state;
}

function createMapping(settings) {
function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: ['-c:v', 'mpeg1_cuvid'],
Expand All @@ -27,7 +27,7 @@ function Coder(props) {
automatic = true;
}

props.onChange(newSettings, createMapping(newSettings), automatic);
props.onChange(newSettings, createMapping(newSettings, props.stream, props.skills), automatic);
};

React.useEffect(() => {
Expand All @@ -51,12 +51,12 @@ const codecs = ['mpeg1'];
const type = 'video';
const hwaccel = true;

function defaults() {
function defaults(stream, skills) {
const settings = init({});

return {
settings: settings,
mapping: createMapping(settings),
mapping: createMapping(settings, stream, skills),
};
}

Expand Down
8 changes: 4 additions & 4 deletions src/misc/coders/Decoders/video/MPEG2CUVID.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function init(initialState) {
return state;
}

function createMapping(settings) {
function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: ['-c:v', 'mpeg2_cuvid'],
Expand All @@ -27,7 +27,7 @@ function Coder(props) {
automatic = true;
}

props.onChange(newSettings, createMapping(newSettings), automatic);
props.onChange(newSettings, createMapping(newSettings, props.stream, props.skills), automatic);
};

React.useEffect(() => {
Expand All @@ -51,12 +51,12 @@ const codecs = ['mpeg2'];
const type = 'video';
const hwaccel = true;

function defaults() {
function defaults(stream, skills) {
const settings = init({});

return {
settings: settings,
mapping: createMapping(settings),
mapping: createMapping(settings, stream, skills),
};
}

Expand Down
8 changes: 4 additions & 4 deletions src/misc/coders/Decoders/video/MPEG2MMAL.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function init(initialState) {
return state;
}

function createMapping(settings) {
function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: ['-c:v', 'mpeg2_mmal'],
Expand All @@ -27,7 +27,7 @@ function Coder(props) {
automatic = true;
}

props.onChange(newSettings, createMapping(newSettings), automatic);
props.onChange(newSettings, createMapping(newSettings, props.stream, props.skills), automatic);
};

React.useEffect(() => {
Expand All @@ -51,12 +51,12 @@ const codecs = ['mpeg2'];
const type = 'video';
const hwaccel = true;

function defaults() {
function defaults(stream, skills) {
const settings = init({});

return {
settings: settings,
mapping: createMapping(settings),
mapping: createMapping(settings, stream, skills),
};
}

Expand Down
8 changes: 4 additions & 4 deletions src/misc/coders/Decoders/video/MPEG4CUVID.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function init(initialState) {
return state;
}

function createMapping(settings) {
function createMapping(settings, stream, skills) {
const mapping = {
global: [],
local: ['-c:v', 'mpeg4_cuvid'],
Expand All @@ -27,7 +27,7 @@ function Coder(props) {
automatic = true;
}

props.onChange(newSettings, createMapping(newSettings), automatic);
props.onChange(newSettings, createMapping(newSettings, props.stream, props.skills), automatic);
};

React.useEffect(() => {
Expand All @@ -51,12 +51,12 @@ const codecs = ['mpeg4'];
const type = 'video';
const hwaccel = true;

function defaults() {
function defaults(stream, skills) {
const settings = init({});

return {
settings: settings,
mapping: createMapping(settings),
mapping: createMapping(settings, stream, skills),
};
}

Expand Down
Loading

0 comments on commit ec4edf2

Please sign in to comment.