Ingo Oppermann 28c376f5a7
Allow decoders and encoders to set global options
For more details please read the src/misc/coders/README.md
2022-06-29 21:51:10 +02:00

63 lines
1.1 KiB
JavaScript

import React from 'react';
function init(initialState) {
const state = {
...initialState,
};
return state;
}
function createMapping(settings) {
const mapping = {
global: [],
local: ['-c:v', 'mpeg2_mmal'],
};
return mapping;
}
function Coder(props) {
const settings = init(props.settings);
const handleChange = (newSettings) => {
let automatic = false;
if (!newSettings) {
newSettings = settings;
automatic = true;
}
props.onChange(newSettings, createMapping(newSettings), automatic);
};
React.useEffect(() => {
handleChange(null);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return null;
}
Coder.defaultProps = {
stream: {},
settings: {},
onChange: function (settings, mapping) {},
};
const coder = 'mpeg2_mmal';
const name = 'MPEG2 (MMAL)';
const codecs = ['mpeg2'];
const type = 'video';
const hwaccel = true;
function defaults() {
const settings = init({});
return {
settings: settings,
mapping: createMapping(settings),
};
}
export { coder, name, codecs, type, hwaccel, defaults, Coder as component };