Fix reset of previous audio settings when editing profile (datarhei/restreamer#730)
This commit is contained in:
parent
1e86878d75
commit
f53be95e70
@ -804,12 +804,6 @@ const initSource = (type, initialSource) => {
|
||||
streams: [],
|
||||
};
|
||||
|
||||
// Default pre-selection for custom audio
|
||||
if (type === 'audio') {
|
||||
source.type = 'virtualaudio';
|
||||
source.settings.source = 'silence';
|
||||
}
|
||||
|
||||
source = {
|
||||
...source,
|
||||
...initialSource,
|
||||
@ -1026,9 +1020,10 @@ const analyzeStreams = (type, streams) => {
|
||||
* @param {*} streams Array of streams
|
||||
* @param {*} profile A profile
|
||||
* @param {*} encoders Array of supported (by ffmpeg) encoders
|
||||
* @param {*} preselectAudio Whether to preselect an audio profile if type == video
|
||||
* @returns A profile
|
||||
*/
|
||||
const preselectProfile = (type, streams, profile, encoders) => {
|
||||
const preselectProfile = (type, streams, profile, encoders, preselectAudio = true) => {
|
||||
const preselectAudioProfile = (streams, audio) => {
|
||||
audio.stream = -1;
|
||||
audio.encoder.coder = 'none';
|
||||
@ -1110,7 +1105,7 @@ const preselectProfile = (type, streams, profile, encoders) => {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (streams[audio.stream].codec !== 'aac' || streams[audio.stream].codec !== 'mp3') {
|
||||
if (streams[audio.stream].codec !== 'aac' && streams[audio.stream].codec !== 'mp3') {
|
||||
if (audio.encoder.coder === 'copy') {
|
||||
return false;
|
||||
}
|
||||
@ -1164,7 +1159,10 @@ const preselectProfile = (type, streams, profile, encoders) => {
|
||||
profile.video = video;
|
||||
}
|
||||
|
||||
// Only select audio stream if explicitely asked to.
|
||||
if (preselectAudio === true) {
|
||||
if (isAudioPlausible(streams, profile.audio) === false) {
|
||||
console.log('audio is not plausible');
|
||||
profile.audio = preselectAudioProfile(streams, profile.audio);
|
||||
|
||||
if (profile.audio.stream >= 0) {
|
||||
@ -1173,8 +1171,9 @@ const preselectProfile = (type, streams, profile, encoders) => {
|
||||
profile.custom.selected = false;
|
||||
profile.custom.stream = profile.audio.stream;
|
||||
} else {
|
||||
profile.custom.selected = true;
|
||||
profile.custom.stream = -2;
|
||||
profile.custom.selected = false;
|
||||
profile.custom.stream = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (type === 'audio') {
|
||||
|
||||
@ -59,14 +59,6 @@ export default function Profile(props) {
|
||||
|
||||
let audio = $sources.audio;
|
||||
|
||||
if ($profile.custom.selected === false) {
|
||||
if ($profile.custom.stream === -1) {
|
||||
audio.type = 'noaudio';
|
||||
} else {
|
||||
audio.type = 'videoaudio';
|
||||
}
|
||||
}
|
||||
|
||||
let hasAudio = false;
|
||||
for (let i = 0; i < $sources.video.streams.length; i++) {
|
||||
if ($sources.video.streams[i].type === 'audio') {
|
||||
@ -117,7 +109,9 @@ export default function Profile(props) {
|
||||
let status = M.analyzeStreams(type, res.streams);
|
||||
|
||||
if (type === 'video') {
|
||||
const profile = M.preselectProfile('video', res.streams, $profile, props.skills.encoders);
|
||||
let audio = $sources.audio;
|
||||
|
||||
const profile = M.preselectProfile('video', res.streams, $profile, props.skills.encoders, audio.type === '');
|
||||
|
||||
// Add pseudo sources
|
||||
props.skills.sources.noaudio = [];
|
||||
@ -130,15 +124,23 @@ export default function Profile(props) {
|
||||
}
|
||||
}
|
||||
|
||||
let audio = $sources.audio;
|
||||
|
||||
if (hasAudio === true) {
|
||||
props.skills.sources.videoaudio = [];
|
||||
if (audio.type === '') {
|
||||
audio.type = 'videoaudio';
|
||||
}
|
||||
} else {
|
||||
delete props.skills.sources.videoaudio;
|
||||
audio = M.initSource('audio', {});
|
||||
if (audio.type === '' || audio.type === 'videoaudio') {
|
||||
audio.type = 'noaudio';
|
||||
profile.audio.source = -1;
|
||||
profile.audio.stream = -1;
|
||||
profile.custom.selected = false;
|
||||
profile.custom.stream = -1;
|
||||
}
|
||||
}
|
||||
|
||||
audio = M.initSource('audio', audio);
|
||||
|
||||
setProfile({
|
||||
...$profile,
|
||||
@ -154,7 +156,7 @@ export default function Profile(props) {
|
||||
|
||||
setAudioProbe({
|
||||
...$audioProbe,
|
||||
status: 'none',
|
||||
status: audio.type === 'noaudio' ? 'success' : 'none',
|
||||
});
|
||||
|
||||
setSources({
|
||||
@ -272,9 +274,11 @@ export default function Profile(props) {
|
||||
if (source === 'noaudio') {
|
||||
custom.selected = false;
|
||||
custom.stream = -1;
|
||||
profile.source = -1;
|
||||
profile.stream = -1;
|
||||
} else if (source === 'videoaudio') {
|
||||
custom.selected = false;
|
||||
profile.source = 0;
|
||||
|
||||
for (let i = 0; i < $sources.video.streams.length; i++) {
|
||||
if ($sources.video.streams[i].type === 'audio') {
|
||||
@ -287,8 +291,25 @@ export default function Profile(props) {
|
||||
custom.selected = true;
|
||||
custom.stream = -2;
|
||||
|
||||
profile.source = 1;
|
||||
profile.stream = -1;
|
||||
}
|
||||
|
||||
let audio = $sources.audio;
|
||||
audio.type = source;
|
||||
|
||||
setSources({
|
||||
...$sources,
|
||||
audio: audio,
|
||||
});
|
||||
} else {
|
||||
let video = $sources.video;
|
||||
video.type = source;
|
||||
|
||||
setSources({
|
||||
...$sources,
|
||||
video: video,
|
||||
});
|
||||
}
|
||||
|
||||
setProfile({
|
||||
@ -485,7 +506,7 @@ export default function Profile(props) {
|
||||
onChange={handleEncoding('audio')}
|
||||
/>
|
||||
</Grid>
|
||||
{$profile.audio.encoder.coder !== 'none' && $profile.audio.encoder.coder !== 'copy' && (
|
||||
{$profile.audio.encoder.coder !== 'none' && $profile.audio.encoder.coder !== 'copy' && $profile.audio.source !== -1 && (
|
||||
<Grid item xs={12}>
|
||||
<FilterSelect
|
||||
type="audio"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user