2016-11-16 05:00:28 +08:00
|
|
|
import React from 'react';
|
2017-10-11 02:03:29 +08:00
|
|
|
import PropTypes from 'prop-types';
|
2020-05-26 04:00:13 +08:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
2022-02-15 04:20:50 +08:00
|
|
|
import Button from '/imports/ui/components/common/button/component';
|
2017-03-23 21:19:44 +08:00
|
|
|
import AudioTestContainer from '/imports/ui/components/audio/audio-test/container';
|
2021-11-09 22:33:40 +08:00
|
|
|
import Styled from './styles';
|
2022-04-05 05:09:35 +08:00
|
|
|
import logger from '/imports/startup/client/logger';
|
|
|
|
import AudioStreamVolume from '/imports/ui/components/audio/audio-stream-volume/component';
|
2022-04-12 04:18:43 +08:00
|
|
|
import LocalEchoContainer from '/imports/ui/components/audio/local-echo/container';
|
2022-05-03 23:07:16 +08:00
|
|
|
import DeviceSelector from '/imports/ui/components/audio/device-selector/component';
|
2022-04-05 05:09:35 +08:00
|
|
|
import MediaStreamUtils from '/imports/utils/media-stream-utils';
|
2024-06-05 19:26:27 +08:00
|
|
|
import AudioManager from '/imports/ui/services/audio-manager';
|
2024-06-06 21:50:03 +08:00
|
|
|
import Session from '/imports/ui/services/storage/in-memory';
|
2024-08-09 07:52:50 +08:00
|
|
|
import AudioCaptionsSelectContainer from '../audio-graphql/audio-captions/captions/component';
|
2017-09-26 04:28:36 +08:00
|
|
|
|
2017-10-11 02:03:29 +08:00
|
|
|
const propTypes = {
|
2021-08-09 22:24:02 +08:00
|
|
|
intl: PropTypes.shape({
|
|
|
|
formatMessage: PropTypes.func.isRequired,
|
|
|
|
}).isRequired,
|
2024-06-05 19:26:27 +08:00
|
|
|
animations: PropTypes.bool,
|
2017-10-11 02:03:29 +08:00
|
|
|
changeInputDevice: PropTypes.func.isRequired,
|
2024-06-05 19:26:27 +08:00
|
|
|
liveChangeInputDevice: PropTypes.func.isRequired,
|
2017-10-11 02:03:29 +08:00
|
|
|
changeOutputDevice: PropTypes.func.isRequired,
|
|
|
|
handleBack: PropTypes.func.isRequired,
|
2022-04-05 05:09:35 +08:00
|
|
|
handleConfirmation: PropTypes.func.isRequired,
|
|
|
|
handleGUMFailure: PropTypes.func.isRequired,
|
2017-10-11 02:03:29 +08:00
|
|
|
isConnecting: PropTypes.bool.isRequired,
|
2024-06-05 19:26:27 +08:00
|
|
|
isConnected: PropTypes.bool.isRequired,
|
|
|
|
isMuted: PropTypes.bool.isRequired,
|
|
|
|
toggleMuteMicrophoneSystem: PropTypes.func.isRequired,
|
2017-10-11 02:03:29 +08:00
|
|
|
inputDeviceId: PropTypes.string.isRequired,
|
|
|
|
outputDeviceId: PropTypes.string.isRequired,
|
2022-04-13 05:32:06 +08:00
|
|
|
produceStreams: PropTypes.bool,
|
|
|
|
withEcho: PropTypes.bool,
|
2022-08-20 01:22:42 +08:00
|
|
|
notify: PropTypes.func.isRequired,
|
2024-06-05 19:26:27 +08:00
|
|
|
unmuteOnExit: PropTypes.bool,
|
|
|
|
doGUM: PropTypes.func.isRequired,
|
|
|
|
getAudioConstraints: PropTypes.func.isRequired,
|
|
|
|
checkMicrophonePermission: PropTypes.func.isRequired,
|
|
|
|
supportsTransparentListenOnly: PropTypes.bool.isRequired,
|
|
|
|
toggleVoice: PropTypes.func.isRequired,
|
|
|
|
permissionStatus: PropTypes.string,
|
2024-08-09 07:52:50 +08:00
|
|
|
isTranscriptionEnabled: PropTypes.bool.isRequired,
|
2024-08-16 23:48:47 +08:00
|
|
|
skipAudioOptions: PropTypes.func.isRequired,
|
2017-10-11 02:03:29 +08:00
|
|
|
};
|
|
|
|
|
2022-04-13 05:32:06 +08:00
|
|
|
const defaultProps = {
|
2024-06-05 19:26:27 +08:00
|
|
|
animations: true,
|
2022-04-13 05:32:06 +08:00
|
|
|
produceStreams: false,
|
|
|
|
withEcho: false,
|
2024-06-05 19:26:27 +08:00
|
|
|
unmuteOnExit: false,
|
|
|
|
permissionStatus: null,
|
2022-04-19 04:05:26 +08:00
|
|
|
};
|
2022-04-13 05:32:06 +08:00
|
|
|
|
2017-09-26 04:28:36 +08:00
|
|
|
const intlMessages = defineMessages({
|
2024-08-09 07:52:50 +08:00
|
|
|
testSpeakerLabel: {
|
|
|
|
id: 'app.audio.audioSettings.testSpeakerLabel',
|
|
|
|
description: 'Test speaker label',
|
|
|
|
},
|
|
|
|
captionsSelectorLabel: {
|
|
|
|
id: 'app.audio.captions.speech.title',
|
|
|
|
description: 'Audio speech recognition title',
|
|
|
|
},
|
2017-09-26 04:28:36 +08:00
|
|
|
backLabel: {
|
|
|
|
id: 'app.audio.backLabel',
|
|
|
|
description: 'audio settings back button label',
|
|
|
|
},
|
|
|
|
micSourceLabel: {
|
|
|
|
id: 'app.audio.audioSettings.microphoneSourceLabel',
|
|
|
|
description: 'Label for mic source',
|
|
|
|
},
|
|
|
|
speakerSourceLabel: {
|
|
|
|
id: 'app.audio.audioSettings.speakerSourceLabel',
|
|
|
|
description: 'Label for speaker source',
|
|
|
|
},
|
|
|
|
streamVolumeLabel: {
|
|
|
|
id: 'app.audio.audioSettings.microphoneStreamLabel',
|
|
|
|
description: 'Label for stream volume',
|
|
|
|
},
|
2017-10-05 04:49:11 +08:00
|
|
|
retryLabel: {
|
2022-04-05 05:09:35 +08:00
|
|
|
id: 'app.audio.joinAudio',
|
|
|
|
description: 'Confirmation button label',
|
2017-09-29 21:38:10 +08:00
|
|
|
},
|
2022-08-20 01:22:42 +08:00
|
|
|
deviceChangeFailed: {
|
|
|
|
id: 'app.audioNotification.deviceChangeFailed',
|
|
|
|
description: 'Device change failed',
|
|
|
|
},
|
2024-06-05 19:26:27 +08:00
|
|
|
confirmLabel: {
|
|
|
|
id: 'app.audio.audioSettings.confirmLabel',
|
|
|
|
description: 'Audio settings confirmation button label',
|
|
|
|
},
|
|
|
|
cancelLabel: {
|
|
|
|
id: 'app.audio.audioSettings.cancelLabel',
|
|
|
|
description: 'Audio settings cancel button label',
|
|
|
|
},
|
|
|
|
findingDevicesTitle: {
|
|
|
|
id: 'app.audio.audioSettings.findingDevicesTitle',
|
|
|
|
description: 'Message for finding audio devices',
|
|
|
|
},
|
2024-08-15 11:30:18 +08:00
|
|
|
noMicSelectedWarning: {
|
|
|
|
id: 'app.audio.audioSettings.noMicSelectedWarning',
|
|
|
|
description: 'Warning when no mic is selected',
|
|
|
|
},
|
|
|
|
baseSubtitle: {
|
|
|
|
id: 'app.audio.audioSettings.baseSubtitle',
|
|
|
|
description: 'Base subtitle for audio settings',
|
|
|
|
},
|
2017-09-26 04:28:36 +08:00
|
|
|
});
|
2016-12-01 11:37:52 +08:00
|
|
|
|
2017-02-17 04:57:57 +08:00
|
|
|
class AudioSettings extends React.Component {
|
2016-11-16 05:00:28 +08:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
2024-06-05 19:26:27 +08:00
|
|
|
const {
|
|
|
|
inputDeviceId,
|
|
|
|
outputDeviceId,
|
|
|
|
unmuteOnExit,
|
2024-08-09 07:52:50 +08:00
|
|
|
permissionStatus,
|
2024-06-05 19:26:27 +08:00
|
|
|
} = props;
|
2017-10-11 02:03:29 +08:00
|
|
|
|
2016-12-09 02:17:08 +08:00
|
|
|
this.handleInputChange = this.handleInputChange.bind(this);
|
|
|
|
this.handleOutputChange = this.handleOutputChange.bind(this);
|
2022-04-12 06:18:40 +08:00
|
|
|
this.handleConfirmationClick = this.handleConfirmationClick.bind(this);
|
2024-06-05 19:26:27 +08:00
|
|
|
this.handleCancelClick = this.handleCancelClick.bind(this);
|
|
|
|
this.unmuteOnExit = this.unmuteOnExit.bind(this);
|
|
|
|
this.updateDeviceList = this.updateDeviceList.bind(this);
|
2017-10-04 04:42:10 +08:00
|
|
|
|
2016-12-09 02:17:08 +08:00
|
|
|
this.state = {
|
2017-10-27 21:19:24 +08:00
|
|
|
inputDeviceId,
|
|
|
|
outputDeviceId,
|
2022-07-13 22:32:48 +08:00
|
|
|
// If streams need to be produced, device selectors and audio join are
|
|
|
|
// blocked until at least one stream is generated
|
|
|
|
producingStreams: props.produceStreams,
|
2022-04-05 05:09:35 +08:00
|
|
|
stream: null,
|
2024-06-05 19:26:27 +08:00
|
|
|
unmuteOnExit,
|
|
|
|
audioInputDevices: [],
|
|
|
|
audioOutputDevices: [],
|
2024-08-09 07:52:50 +08:00
|
|
|
findingDevices: permissionStatus === 'prompt' || permissionStatus === 'denied',
|
2017-03-23 04:10:49 +08:00
|
|
|
};
|
2022-04-05 05:09:35 +08:00
|
|
|
|
|
|
|
this._isMounted = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount() {
|
2024-06-05 19:26:27 +08:00
|
|
|
const {
|
|
|
|
inputDeviceId,
|
|
|
|
outputDeviceId,
|
|
|
|
} = this.state;
|
|
|
|
const {
|
|
|
|
isConnected,
|
|
|
|
isMuted,
|
|
|
|
toggleMuteMicrophoneSystem,
|
|
|
|
checkMicrophonePermission,
|
|
|
|
toggleVoice,
|
|
|
|
permissionStatus,
|
|
|
|
} = this.props;
|
2022-04-29 00:36:22 +08:00
|
|
|
|
2024-06-06 21:50:03 +08:00
|
|
|
Session.setItem('inEchoTest', true);
|
2022-04-05 05:09:35 +08:00
|
|
|
this._isMounted = true;
|
2022-04-29 00:36:22 +08:00
|
|
|
// Guarantee initial in/out devices are initialized on all ends
|
2024-06-05 19:26:27 +08:00
|
|
|
AudioManager.isEchoTest = true;
|
|
|
|
checkMicrophonePermission({ gumOnPrompt: true, permissionStatus })
|
|
|
|
.then(this.updateDeviceList)
|
|
|
|
.then(() => {
|
|
|
|
if (!this._isMounted) return;
|
|
|
|
|
|
|
|
navigator.mediaDevices.addEventListener(
|
|
|
|
'devicechange',
|
|
|
|
this.updateDeviceList,
|
|
|
|
);
|
|
|
|
this.setState({ findingDevices: false });
|
|
|
|
this.setInputDevice(inputDeviceId);
|
|
|
|
this.setOutputDevice(outputDeviceId);
|
|
|
|
});
|
|
|
|
|
|
|
|
// If connected and unmuted, we need to mute the audio and revert it
|
|
|
|
// back to the original state on exit.
|
|
|
|
if (isConnected && !isMuted) {
|
|
|
|
toggleMuteMicrophoneSystem(isMuted, toggleVoice);
|
|
|
|
// We only need to revert the mute state if the user is not listen-only
|
|
|
|
if (inputDeviceId !== 'listen-only') this.setState({ unmuteOnExit: true });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidUpdate(prevProps) {
|
|
|
|
const { permissionStatus } = this.props;
|
|
|
|
|
|
|
|
if (prevProps.permissionStatus !== permissionStatus) {
|
|
|
|
this.updateDeviceList();
|
|
|
|
}
|
2022-04-05 05:09:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
const { stream } = this.state;
|
|
|
|
|
2024-06-06 21:50:03 +08:00
|
|
|
Session.setItem('inEchoTest', false);
|
2024-06-05 19:26:27 +08:00
|
|
|
this._isMounted = false;
|
2022-04-05 05:09:35 +08:00
|
|
|
|
|
|
|
if (stream) {
|
|
|
|
MediaStreamUtils.stopMediaStreamTracks(stream);
|
|
|
|
}
|
2024-06-05 19:26:27 +08:00
|
|
|
|
|
|
|
AudioManager.isEchoTest = false;
|
|
|
|
navigator.mediaDevices.removeEventListener(
|
|
|
|
'devicechange', this.updateDeviceList,
|
|
|
|
);
|
|
|
|
|
|
|
|
this.unmuteOnExit();
|
2022-04-05 05:09:35 +08:00
|
|
|
}
|
|
|
|
|
2017-10-23 20:41:09 +08:00
|
|
|
handleInputChange(deviceId) {
|
2022-04-29 00:36:22 +08:00
|
|
|
this.setInputDevice(deviceId);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleOutputChange(deviceId) {
|
|
|
|
this.setOutputDevice(deviceId);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleConfirmationClick() {
|
2024-08-15 11:30:18 +08:00
|
|
|
const { stream, inputDeviceId: selectedInputDeviceId } = this.state;
|
2024-06-05 19:26:27 +08:00
|
|
|
const {
|
|
|
|
isConnected,
|
|
|
|
produceStreams,
|
|
|
|
handleConfirmation,
|
|
|
|
liveChangeInputDevice,
|
|
|
|
} = this.props;
|
|
|
|
|
2024-08-15 11:30:18 +08:00
|
|
|
const confirm = () => {
|
|
|
|
// Stream generation disabled or there isn't any stream: just run the provided callback
|
|
|
|
if (!produceStreams || !stream) return handleConfirmation();
|
|
|
|
|
|
|
|
// Stream generation enabled and there is a valid input stream => call
|
|
|
|
// the confirmation callback with the input stream as arg so it can be used
|
|
|
|
// in upstream components. The rationale is no surplus gUM calls.
|
|
|
|
// We're cloning it because the original will be cleaned up on unmount here.
|
|
|
|
const clonedStream = stream.clone();
|
2022-04-29 00:36:22 +08:00
|
|
|
|
2024-08-15 11:30:18 +08:00
|
|
|
return handleConfirmation(clonedStream);
|
|
|
|
};
|
2022-04-29 00:36:22 +08:00
|
|
|
|
2024-08-15 11:30:18 +08:00
|
|
|
if (isConnected) {
|
|
|
|
// If connected, we need to use the in-call device change method so that all
|
|
|
|
// components pick up the change and the peer is properly updated.
|
|
|
|
liveChangeInputDevice(selectedInputDeviceId).catch((error) => {
|
|
|
|
logger.warn({
|
|
|
|
logCode: 'audiosettings_live_change_device_failed',
|
|
|
|
extraInfo: {
|
|
|
|
errorMessage: error?.message,
|
|
|
|
errorStack: error?.stack,
|
|
|
|
errorName: error?.name,
|
|
|
|
},
|
|
|
|
}, `Audio settings live change device failed: ${error.name}`);
|
|
|
|
}).finally(() => {
|
|
|
|
confirm();
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
confirm();
|
|
|
|
}
|
2022-04-29 00:36:22 +08:00
|
|
|
}
|
|
|
|
|
2024-06-05 19:26:27 +08:00
|
|
|
handleCancelClick() {
|
|
|
|
const { handleBack } = this.props;
|
|
|
|
|
|
|
|
handleBack();
|
|
|
|
}
|
|
|
|
|
2022-04-29 00:36:22 +08:00
|
|
|
setInputDevice(deviceId) {
|
2024-06-05 19:26:27 +08:00
|
|
|
const {
|
|
|
|
isConnected,
|
|
|
|
handleGUMFailure,
|
|
|
|
changeInputDevice,
|
|
|
|
produceStreams,
|
|
|
|
intl,
|
|
|
|
notify,
|
|
|
|
} = this.props;
|
2022-08-20 01:22:42 +08:00
|
|
|
const { inputDeviceId: currentInputDeviceId } = this.state;
|
|
|
|
try {
|
2024-06-05 19:26:27 +08:00
|
|
|
if (!isConnected) changeInputDevice(deviceId);
|
|
|
|
|
2022-08-20 01:22:42 +08:00
|
|
|
// Only generate input streams if they're going to be used with something
|
|
|
|
// In this case, the volume meter or local echo test.
|
|
|
|
if (produceStreams) {
|
2024-08-20 08:30:34 +08:00
|
|
|
this.setState({
|
|
|
|
producingStreams: true,
|
|
|
|
});
|
2024-06-05 19:26:27 +08:00
|
|
|
this.generateInputStream(deviceId).then((stream) => {
|
|
|
|
// Extract the deviceId again from the stream to guarantee consistency
|
|
|
|
// between stream DID vs chosen DID. That's necessary in scenarios where,
|
|
|
|
// eg, there's no default/pre-set deviceId ('') and the browser's
|
|
|
|
// default device has been altered by the user (browser default != system's
|
|
|
|
// default).
|
|
|
|
let extractedDeviceId = deviceId;
|
|
|
|
|
|
|
|
if (stream) {
|
|
|
|
extractedDeviceId = MediaStreamUtils.extractDeviceIdFromStream(stream, 'audio');
|
|
|
|
|
|
|
|
if (extractedDeviceId !== deviceId && !isConnected) {
|
2023-07-25 02:56:40 +08:00
|
|
|
changeInputDevice(extractedDeviceId);
|
2024-06-05 19:26:27 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Component unmounted after gUM resolution -> skip echo rendering
|
|
|
|
if (!this._isMounted) return;
|
2023-07-25 02:56:40 +08:00
|
|
|
|
2024-06-05 19:26:27 +08:00
|
|
|
this.setState({
|
|
|
|
inputDeviceId: extractedDeviceId,
|
|
|
|
stream,
|
2022-08-20 01:22:42 +08:00
|
|
|
});
|
2024-08-20 08:30:34 +08:00
|
|
|
|
|
|
|
// Update the device list after the stream has been generated.
|
|
|
|
// This is necessary to guarantee the device list is up-to-date, mainly
|
|
|
|
// in Firefox as it omit labels if no active stream is present (even if
|
|
|
|
// gUM permission is flagged as granted).
|
|
|
|
this.updateDeviceList();
|
2024-06-05 19:26:27 +08:00
|
|
|
}).catch((error) => {
|
|
|
|
logger.warn({
|
|
|
|
logCode: 'audiosettings_gum_failed',
|
|
|
|
extraInfo: {
|
|
|
|
deviceId,
|
|
|
|
errorMessage: error.message,
|
|
|
|
errorName: error.name,
|
|
|
|
},
|
|
|
|
}, `Audio settings gUM failed: ${error.name}`);
|
|
|
|
handleGUMFailure(error);
|
2024-08-20 08:30:34 +08:00
|
|
|
}).finally(() => {
|
|
|
|
// Component unmounted after gUM resolution -> skip echo rendering
|
|
|
|
if (!this._isMounted) return;
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
producingStreams: false,
|
|
|
|
});
|
2024-06-05 19:26:27 +08:00
|
|
|
});
|
2022-08-20 01:22:42 +08:00
|
|
|
} else {
|
2022-04-05 05:09:35 +08:00
|
|
|
this.setState({
|
2022-08-20 01:22:42 +08:00
|
|
|
inputDeviceId: deviceId,
|
2022-04-05 05:09:35 +08:00
|
|
|
});
|
2022-08-20 01:22:42 +08:00
|
|
|
}
|
|
|
|
} catch (error) {
|
2023-07-25 02:56:40 +08:00
|
|
|
logger.debug(
|
|
|
|
{
|
|
|
|
logCode: 'audiosettings_input_device_change_failure',
|
|
|
|
extraInfo: {
|
|
|
|
errorName: error.name,
|
|
|
|
errorMessage: error.message,
|
|
|
|
deviceId: currentInputDeviceId,
|
|
|
|
newDeviceId: deviceId,
|
|
|
|
},
|
2022-08-20 01:22:42 +08:00
|
|
|
},
|
2024-06-05 19:26:27 +08:00
|
|
|
`Audio settings: error changing input device - {${error.name}: ${error.message}}`,
|
2023-07-25 02:56:40 +08:00
|
|
|
);
|
2022-08-20 01:22:42 +08:00
|
|
|
notify(intl.formatMessage(intlMessages.deviceChangeFailed), true);
|
2022-04-05 05:09:35 +08:00
|
|
|
}
|
2016-12-09 02:17:08 +08:00
|
|
|
}
|
|
|
|
|
2022-04-29 00:36:22 +08:00
|
|
|
setOutputDevice(deviceId) {
|
2022-08-20 01:22:42 +08:00
|
|
|
const { outputDeviceId: currentOutputDeviceId } = this.state;
|
2024-08-09 07:52:50 +08:00
|
|
|
const {
|
|
|
|
changeOutputDevice,
|
|
|
|
withEcho,
|
|
|
|
intl,
|
|
|
|
notify,
|
|
|
|
} = this.props;
|
2017-10-27 21:19:24 +08:00
|
|
|
|
2022-04-13 05:32:06 +08:00
|
|
|
// withEcho usage (isLive arg): if local echo is enabled we need the device
|
2024-03-18 21:58:53 +08:00
|
|
|
// change to be performed seamlessly (which is what the isLive parameter guarantees)
|
2023-07-25 02:56:40 +08:00
|
|
|
changeOutputDevice(deviceId, withEcho)
|
|
|
|
.then(() => {
|
|
|
|
this.setState({
|
|
|
|
outputDeviceId: deviceId,
|
|
|
|
});
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
2024-08-09 07:52:50 +08:00
|
|
|
logger.debug({
|
|
|
|
logCode: 'audiosettings_output_device_change_failure',
|
|
|
|
extraInfo: {
|
|
|
|
errorName: error.name,
|
|
|
|
errorMessage: error.message,
|
|
|
|
deviceId: currentOutputDeviceId,
|
|
|
|
newDeviceId: deviceId,
|
2023-07-25 02:56:40 +08:00
|
|
|
},
|
2024-08-09 07:52:50 +08:00
|
|
|
}, `Audio settings: error changing output device - {${error.name}: ${error.message}}`);
|
2023-07-25 02:56:40 +08:00
|
|
|
notify(intl.formatMessage(intlMessages.deviceChangeFailed), true);
|
2022-08-20 01:22:42 +08:00
|
|
|
});
|
2016-12-09 02:17:08 +08:00
|
|
|
}
|
|
|
|
|
2024-06-05 19:26:27 +08:00
|
|
|
updateDeviceList() {
|
|
|
|
return navigator.mediaDevices.enumerateDevices()
|
|
|
|
.then((devices) => {
|
|
|
|
const audioInputDevices = devices.filter((i) => i.kind === 'audioinput');
|
|
|
|
const audioOutputDevices = devices.filter((i) => i.kind === 'audiooutput');
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
audioInputDevices,
|
|
|
|
audioOutputDevices,
|
|
|
|
});
|
2024-08-20 08:30:34 +08:00
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
logger.warn({
|
|
|
|
logCode: 'audiosettings_enumerate_devices_error',
|
|
|
|
extraInfo: {
|
|
|
|
errorName: error.name,
|
|
|
|
errorMessage: error.message,
|
|
|
|
},
|
|
|
|
}, `Audio settings: error enumerating devices - {${error.name}: ${error.message}}`);
|
2024-06-05 19:26:27 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
unmuteOnExit() {
|
|
|
|
const { toggleMuteMicrophoneSystem, toggleVoice } = this.props;
|
|
|
|
const { unmuteOnExit } = this.state;
|
|
|
|
|
|
|
|
// Unmutes microphone if flagged to do so
|
|
|
|
if (unmuteOnExit) toggleMuteMicrophoneSystem(true, toggleVoice);
|
|
|
|
}
|
|
|
|
|
2022-04-19 04:05:26 +08:00
|
|
|
generateInputStream(inputDeviceId) {
|
2024-06-05 19:26:27 +08:00
|
|
|
const { doGUM, getAudioConstraints } = this.props;
|
2022-04-19 04:05:26 +08:00
|
|
|
const { stream } = this.state;
|
|
|
|
|
|
|
|
if (inputDeviceId && stream) {
|
|
|
|
const currentDeviceId = MediaStreamUtils.extractDeviceIdFromStream(stream, 'audio');
|
|
|
|
|
|
|
|
if (currentDeviceId === inputDeviceId) return Promise.resolve(stream);
|
|
|
|
|
|
|
|
MediaStreamUtils.stopMediaStreamTracks(stream);
|
|
|
|
}
|
|
|
|
|
2024-06-05 19:26:27 +08:00
|
|
|
if (inputDeviceId === 'listen-only') return Promise.resolve(null);
|
|
|
|
|
2022-04-19 04:05:26 +08:00
|
|
|
const constraints = {
|
|
|
|
audio: getAudioConstraints({ deviceId: inputDeviceId }),
|
|
|
|
};
|
|
|
|
|
2022-09-16 01:48:26 +08:00
|
|
|
return doGUM(constraints, true);
|
2022-04-19 04:05:26 +08:00
|
|
|
}
|
|
|
|
|
2024-08-09 07:52:50 +08:00
|
|
|
renderAudioCaptionsSelector() {
|
|
|
|
const { intl, isTranscriptionEnabled } = this.props;
|
|
|
|
|
|
|
|
if (!isTranscriptionEnabled) return null;
|
2022-04-05 05:09:35 +08:00
|
|
|
|
|
|
|
return (
|
2024-08-09 07:52:50 +08:00
|
|
|
<Styled.FormElement>
|
|
|
|
<Styled.LabelSmall htmlFor="audioSettingsCaptionsSelector">
|
|
|
|
{intl.formatMessage(intlMessages.captionsSelectorLabel)}
|
|
|
|
<AudioCaptionsSelectContainer showTitleLabel={false} />
|
|
|
|
</Styled.LabelSmall>
|
|
|
|
</Styled.FormElement>
|
2022-04-05 05:09:35 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-04-13 05:32:06 +08:00
|
|
|
renderDeviceSelectors() {
|
2024-06-05 19:26:27 +08:00
|
|
|
const {
|
|
|
|
inputDeviceId,
|
|
|
|
outputDeviceId,
|
|
|
|
producingStreams,
|
|
|
|
audioInputDevices,
|
|
|
|
audioOutputDevices,
|
|
|
|
findingDevices,
|
|
|
|
} = this.state;
|
2024-08-09 07:52:50 +08:00
|
|
|
const {
|
|
|
|
intl,
|
|
|
|
isConnecting,
|
|
|
|
supportsTransparentListenOnly,
|
|
|
|
withEcho,
|
|
|
|
} = this.props;
|
|
|
|
const { stream } = this.state;
|
2024-06-05 19:26:27 +08:00
|
|
|
const blocked = producingStreams || isConnecting || findingDevices;
|
2022-04-12 06:18:40 +08:00
|
|
|
|
2022-04-13 05:32:06 +08:00
|
|
|
return (
|
2024-08-09 07:52:50 +08:00
|
|
|
<>
|
|
|
|
<Styled.FormElement>
|
|
|
|
<Styled.LabelSmall htmlFor="inputDeviceSelector">
|
|
|
|
{intl.formatMessage(intlMessages.micSourceLabel)}
|
|
|
|
<DeviceSelector
|
|
|
|
id="inputDeviceSelector"
|
|
|
|
deviceId={inputDeviceId}
|
|
|
|
devices={audioInputDevices}
|
|
|
|
kind="audioinput"
|
|
|
|
blocked={blocked}
|
|
|
|
onChange={this.handleInputChange}
|
|
|
|
intl={intl}
|
|
|
|
supportsTransparentListenOnly={supportsTransparentListenOnly}
|
|
|
|
/>
|
|
|
|
</Styled.LabelSmall>
|
|
|
|
</Styled.FormElement>
|
|
|
|
<Styled.LabelSmallFullWidth htmlFor="audioStreamVolume">
|
|
|
|
{intl.formatMessage(intlMessages.streamVolumeLabel)}
|
|
|
|
<AudioStreamVolume stream={stream} />
|
|
|
|
</Styled.LabelSmallFullWidth>
|
|
|
|
<Styled.FormElement>
|
|
|
|
<Styled.LabelSmall htmlFor="outputDeviceSelector">
|
|
|
|
{intl.formatMessage(intlMessages.speakerSourceLabel)}
|
|
|
|
<DeviceSelector
|
|
|
|
id="outputDeviceSelector"
|
|
|
|
deviceId={outputDeviceId}
|
|
|
|
devices={audioOutputDevices}
|
|
|
|
kind="audiooutput"
|
|
|
|
blocked={blocked}
|
|
|
|
onChange={this.handleOutputChange}
|
|
|
|
intl={intl}
|
|
|
|
supportsTransparentListenOnly={supportsTransparentListenOnly}
|
|
|
|
/>
|
|
|
|
</Styled.LabelSmall>
|
|
|
|
</Styled.FormElement>
|
|
|
|
<Styled.LabelSmall htmlFor="audioTest">
|
|
|
|
{intl.formatMessage(intlMessages.testSpeakerLabel)}
|
|
|
|
{!withEcho ? (
|
|
|
|
<AudioTestContainer id="audioTest" />
|
|
|
|
) : (
|
|
|
|
<LocalEchoContainer intl={intl} stream={stream} />
|
|
|
|
)}
|
|
|
|
</Styled.LabelSmall>
|
|
|
|
{this.renderAudioCaptionsSelector()}
|
|
|
|
</>
|
2022-04-13 05:32:06 +08:00
|
|
|
);
|
2022-04-12 06:18:40 +08:00
|
|
|
}
|
|
|
|
|
2024-08-15 11:30:18 +08:00
|
|
|
renderAudioNote() {
|
|
|
|
const {
|
|
|
|
animations,
|
|
|
|
intl,
|
|
|
|
} = this.props;
|
|
|
|
const { findingDevices, inputDeviceId: selectedInputDeviceId } = this.state;
|
|
|
|
let subtitle = intl.formatMessage(intlMessages.baseSubtitle);
|
|
|
|
|
|
|
|
if (findingDevices) {
|
|
|
|
subtitle = intl.formatMessage(intlMessages.findingDevicesTitle);
|
|
|
|
} else if (selectedInputDeviceId === 'listen-only') {
|
|
|
|
subtitle = intl.formatMessage(intlMessages.noMicSelectedWarning);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Styled.AudioNote>
|
|
|
|
<span>{subtitle}</span>
|
|
|
|
{findingDevices && <Styled.FetchingAnimation animations={animations} />}
|
|
|
|
</Styled.AudioNote>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-11-16 05:00:28 +08:00
|
|
|
render() {
|
2024-06-05 19:26:27 +08:00
|
|
|
const {
|
|
|
|
producingStreams,
|
|
|
|
} = this.state;
|
|
|
|
const {
|
|
|
|
isConnecting,
|
|
|
|
isConnected,
|
2024-08-16 23:48:47 +08:00
|
|
|
skipAudioOptions,
|
2024-06-05 19:26:27 +08:00
|
|
|
intl,
|
|
|
|
} = this.props;
|
2017-02-17 04:57:57 +08:00
|
|
|
|
2016-11-16 05:00:28 +08:00
|
|
|
return (
|
2022-07-02 04:55:32 +08:00
|
|
|
<Styled.FormWrapper data-test="audioSettingsModal">
|
2024-08-15 11:30:18 +08:00
|
|
|
{this.renderAudioNote()}
|
2024-08-09 07:52:50 +08:00
|
|
|
<Styled.Form>
|
|
|
|
{this.renderDeviceSelectors()}
|
|
|
|
</Styled.Form>
|
|
|
|
<Styled.BottomSeparator />
|
2021-11-09 22:33:40 +08:00
|
|
|
<Styled.EnterAudio>
|
|
|
|
<Styled.BackButton
|
2024-08-16 23:48:47 +08:00
|
|
|
label={(isConnected || skipAudioOptions())
|
2024-06-05 19:26:27 +08:00
|
|
|
? intl.formatMessage(intlMessages.cancelLabel)
|
|
|
|
: intl.formatMessage(intlMessages.backLabel)}
|
2022-06-23 03:47:12 +08:00
|
|
|
color="secondary"
|
2024-06-05 19:26:27 +08:00
|
|
|
onClick={this.handleCancelClick}
|
2017-09-29 21:38:10 +08:00
|
|
|
disabled={isConnecting}
|
2017-09-26 04:28:36 +08:00
|
|
|
/>
|
2017-09-29 21:38:10 +08:00
|
|
|
<Button
|
2022-07-02 04:55:32 +08:00
|
|
|
data-test="joinEchoTestButton"
|
2019-03-12 12:14:31 +08:00
|
|
|
size="md"
|
|
|
|
color="primary"
|
2024-06-05 19:26:27 +08:00
|
|
|
label={isConnected
|
|
|
|
? intl.formatMessage(intlMessages.confirmLabel)
|
|
|
|
: intl.formatMessage(intlMessages.retryLabel)}
|
2022-04-12 06:18:40 +08:00
|
|
|
onClick={this.handleConfirmationClick}
|
2022-07-13 22:32:48 +08:00
|
|
|
disabled={isConnecting || producingStreams}
|
2017-10-05 04:49:11 +08:00
|
|
|
/>
|
2021-11-09 22:33:40 +08:00
|
|
|
</Styled.EnterAudio>
|
|
|
|
</Styled.FormWrapper>
|
2017-09-29 21:42:08 +08:00
|
|
|
);
|
2016-11-16 05:00:28 +08:00
|
|
|
}
|
2017-06-03 03:25:02 +08:00
|
|
|
}
|
2017-02-17 04:57:57 +08:00
|
|
|
|
2017-10-11 02:03:29 +08:00
|
|
|
AudioSettings.propTypes = propTypes;
|
2022-04-19 04:05:26 +08:00
|
|
|
AudioSettings.defaultProps = defaultProps;
|
2017-10-11 02:03:29 +08:00
|
|
|
|
2023-03-27 23:36:25 +08:00
|
|
|
export default injectIntl(AudioSettings);
|