import React from 'react';
import { Trans } from '@lingui/macro';
import Button from '@mui/material/Button';
import Grid from '@mui/material/Grid';
import Stack from '@mui/material/Stack';
import MenuItem from '@mui/material/MenuItem';
import Typography from '@mui/material/Typography';
import Dialog from './Dialog';
import Select from '../Select';
import Video from '../coders/settings/Video';
import Audio from '../coders/settings/Audio';
const Stream = function (props) {
const handleChange = (what) => (event) => {
const value = event.target.value;
let stream = {
...props.stream,
};
if (what === 'type') {
if (value === 'audio') {
stream.codec = 'aac';
if (stream.sampling_hz === 0) {
stream.sampling_hz = 44100;
}
if (stream.layout === '') {
stream.layout = 'stereo';
stream.channels = 2;
}
} else {
stream.codec = 'h264';
if (stream.width === 0) {
stream.width = 1920;
stream.height = 1080;
}
if (stream.pix_fmt === '') {
stream.pix_fmt = 'yuv240p';
}
}
stream.type = value;
} else if (what === 'size') {
const [width, height] = value.split('x');
stream.width = width;
stream.height = height;
} else {
stream[what] = value;
}
props.onChange(stream);
};
return (
{props.stream.type === 'audio' ? (
) : (
)}
);
};
Stream.defaultProps = {
stream: {},
onChange: () => {},
};
const Streams = function (props) {
const handleChange = (index) => (stream) => {
const streams = props.streams.slice();
streams[index] = stream;
props.onChange(streams);
};
const handleAddStream = () => {
const streams = props.streams.slice();
streams.push({
index: props.type === 'video' ? 0 : 1,
stream: streams.length,
type: 'audio',
codec: 'aac',
width: 0,
height: 0,
sampling_hz: 44100,
layout: 'stereo',
channels: 2,
});
props.onChange(streams);
};
const handleRemoveStream = (index) => () => {
const streams = props.streams.toSpliced(index, 1);
props.onChange(streams);
};
return (
{props.streams.map((stream, index) => (
Stream {stream.stream}
{index > 0 && (
)}
))}
);
};
Streams.defaultProps = {
streams: [],
type: '',
onChange: () => {},
};
const Component = function (props) {
return (
);
};
export default Component;
Component.defaultProps = {
open: false,
title: '',
streams: [],
type: '',
onClose: null,
onDone: () => {},
onHelp: null,
};