feat: implement transcoding profile

This commit is contained in:
Tim 2024-03-21 22:11:05 +01:00
parent 1c57dd3a65
commit 38365339f0
2 changed files with 48 additions and 2 deletions

View file

@ -49,7 +49,8 @@ const Settings = () => {
streamingServerRemoteUrlInput,
remoteEndpointSelect,
cacheSizeSelect,
torrentProfileSelect
torrentProfileSelect,
transcodingProfileSelect,
} = useStreamingServerSettingsInputs(streamingServer);
const [configureServerUrlModalOpen, openConfigureServerUrlModal, closeConfigureServerUrlModal] = useBinaryState(false);
const configureServerUrlInputRef = React.useRef(null);
@ -612,6 +613,20 @@ const Settings = () => {
:
null
}
{
transcodingProfileSelect !== null ?
<div className={styles['option-container']}>
<div className={styles['option-name-container']}>
<div className={styles['label']}>{ t('SETTINGS_TRANSCODE_PROFILE') }</div>
</div>
<Multiselect
className={classnames(styles['option-input-container'], styles['multiselect-container'])}
{...transcodingProfileSelect}
/>
</div>
:
null
}
</div>
<div ref={shortcutsSectionRef} className={styles['section-container']}>
<div className={styles['section-title']}>{ t('SETTINGS_NAV_SHORTCUTS') }</div>

View file

@ -167,7 +167,38 @@ const useStreamingServerSettingsInputs = (streamingServer) => {
}
};
}, [streamingServer.settings]);
return { streamingServerRemoteUrlInput, remoteEndpointSelect, cacheSizeSelect, torrentProfileSelect };
const transcodingProfileSelect = React.useMemo(() => {
if (streamingServer.settings?.type !== 'Ready' || streamingServer.deviceInfo?.type !== 'Ready') {
return null;
}
return {
options: [
{
label: t('SETTINGS_DISABLED'),
value: null,
},
...streamingServer.deviceInfo.content.availableHardwareAccelerations.map((name) => ({
label: name,
value: name,
}))
],
selected: [streamingServer.settings.content.transcodeProfile],
onSelect: (event) => {
core.transport.dispatch({
action: 'StreamingServer',
args: {
action: 'UpdateSettings',
args: {
...streamingServer.settings.content,
transcodeProfile: event.value,
}
}
});
}
};
}, [streamingServer.settings, streamingServer.deviceInfo]);
return { streamingServerRemoteUrlInput, remoteEndpointSelect, cacheSizeSelect, torrentProfileSelect, transcodingProfileSelect };
};
module.exports = useStreamingServerSettingsInputs;