bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/audio/audio-graphql/audio-controls/component.tsx

179 lines
5.7 KiB
TypeScript
Raw Normal View History

2023-09-13 22:31:20 +08:00
/* eslint-disable no-underscore-dangle */
/* eslint-disable @typescript-eslint/ban-ts-comment */
2023-07-25 02:56:40 +08:00
import React, { useCallback, useEffect, useMemo } from 'react';
import { User } from '/imports/ui/Types/user';
2023-09-14 01:57:43 +08:00
import useCurrentUser from '/imports/ui/core/hooks/useCurrentUser';
import useMeeting from '/imports/ui/core/hooks/useMeeting';
2023-07-25 02:56:40 +08:00
import { Meeting } from '/imports/ui/Types/meeting';
import { useShortcut } from '/imports/ui/core/hooks/useShortcut';
2023-07-25 02:56:40 +08:00
import { useMutation, useReactiveVar } from '@apollo/client';
import { defineMessages, useIntl } from 'react-intl';
import Button from '/imports/ui/components/common/button/component';
import AudioModalContainer from '../../audio-modal/container';
import AudioManager from '/imports/ui/services/audio-manager';
import { joinListenOnly } from './service';
import Styled from './styles';
import InputStreamLiveSelectorContainer from './input-stream-live-selector/component';
import { UPDATE_ECHO_TEST_RUNNING } from './queries';
const intlMessages = defineMessages({
joinAudio: {
id: 'app.audio.joinAudio',
description: 'Join audio button label',
},
joinAudioAndSetActive: {
id: 'app.audio.joinAudioAndSetActive',
description: 'Join audio button label when user is away',
},
2023-07-25 02:56:40 +08:00
leaveAudio: {
id: 'app.audio.leaveAudio',
description: 'Leave audio button label',
},
muteAudio: {
id: 'app.actionsBar.muteLabel',
description: 'Mute audio button label',
},
unmuteAudio: {
id: 'app.actionsBar.unmuteLabel',
description: 'Unmute audio button label',
},
});
interface AudioControlsProps {
inAudio: boolean;
isConnected: boolean;
disabled: boolean;
isEchoTest: boolean;
updateEchoTestRunning: () => void;
away: boolean;
isConnecting?: boolean;
2023-09-13 22:31:20 +08:00
}
2023-07-25 02:56:40 +08:00
const AudioControls: React.FC<AudioControlsProps> = ({
isConnected,
disabled,
inAudio,
isEchoTest,
updateEchoTestRunning,
away,
isConnecting,
2023-07-25 02:56:40 +08:00
}) => {
const intl = useIntl();
const joinAudioShortcut = useShortcut('joinAudio');
2023-09-11 21:12:37 +08:00
const echoTestIntervalRef = React.useRef<ReturnType<typeof setTimeout>>();
2023-07-25 02:56:40 +08:00
const [isAudioModalOpen, setIsAudioModalOpen] = React.useState(false);
feat(audio): rework audio join without listen only This is a rework of the audio join procedure whithout the explict listen only separation in mind. It's supposed to be used in conjunction with the transparent listen only feature so that the distinction between modes is seamless with minimal server-side impact. An abridged list of changes: - Let the user pick no input device when joining microphone while allowing them to set an input device on the fly later on - Give the user the option to join audio with no input device whenever we fail to obtain input devices, with the option to try re-enabling them on the fly later on - Add the option to open the audio settings modal (echo test et al) via the in-call device selection chevron - Rework the SFU audio bridge and its services to support adding/removing tracks on the fly without renegotiation - Rework the SFU audio bridge and its services to support a new peer role called "passive-sendrecv". That role is used by dupled peers that have no active input source on start, but might have one later on. - Remove stale PermissionsOverlay component from the audio modal - Rework how permission errors are detected using the Permissions API - Rework the local echo test so that it uses a separate media tag rather than the remote - Add new, separate dialplans that mute/hold FreeSWITCH channels on hold based on UA strings. This is orchestrated server-side via webrtc-sfu and akka-apps. The basic difference here is that channels now join in their desired state rather than waiting for client side observers to sync the state up. It also mitigates transparent listen only performance edge cases on multiple audio channels joining at the same time. The old, decoupled listen only mode is still present in code while we validate this new approach. To test this, transparentListenOnly must be enabled and listen only mode must be disable on audio join so that the user skips straight through microphone join.
2024-06-05 19:26:27 +08:00
const [audioModalContent, setAudioModalContent] = React.useState<string | null>(null);
const [audioModalProps, setAudioModalProps] = React.useState<{ unmuteOnExit?: boolean } | null>(null);
2023-07-25 02:56:40 +08:00
2023-09-11 21:12:37 +08:00
const handleJoinAudio = useCallback((connected: boolean) => {
if (connected) {
2023-07-25 02:56:40 +08:00
joinListenOnly();
} else {
setIsAudioModalOpen(true);
}
2023-09-11 21:12:37 +08:00
}, []);
2023-07-25 02:56:40 +08:00
feat(audio): rework audio join without listen only This is a rework of the audio join procedure whithout the explict listen only separation in mind. It's supposed to be used in conjunction with the transparent listen only feature so that the distinction between modes is seamless with minimal server-side impact. An abridged list of changes: - Let the user pick no input device when joining microphone while allowing them to set an input device on the fly later on - Give the user the option to join audio with no input device whenever we fail to obtain input devices, with the option to try re-enabling them on the fly later on - Add the option to open the audio settings modal (echo test et al) via the in-call device selection chevron - Rework the SFU audio bridge and its services to support adding/removing tracks on the fly without renegotiation - Rework the SFU audio bridge and its services to support a new peer role called "passive-sendrecv". That role is used by dupled peers that have no active input source on start, but might have one later on. - Remove stale PermissionsOverlay component from the audio modal - Rework how permission errors are detected using the Permissions API - Rework the local echo test so that it uses a separate media tag rather than the remote - Add new, separate dialplans that mute/hold FreeSWITCH channels on hold based on UA strings. This is orchestrated server-side via webrtc-sfu and akka-apps. The basic difference here is that channels now join in their desired state rather than waiting for client side observers to sync the state up. It also mitigates transparent listen only performance edge cases on multiple audio channels joining at the same time. The old, decoupled listen only mode is still present in code while we validate this new approach. To test this, transparentListenOnly must be enabled and listen only mode must be disable on audio join so that the user skips straight through microphone join.
2024-06-05 19:26:27 +08:00
const openAudioSettings = (props: { unmuteOnExit?: boolean } = {}) => {
setAudioModalContent('settings');
setAudioModalProps(props);
setIsAudioModalOpen(true);
};
2023-07-25 02:56:40 +08:00
const joinButton = useMemo(() => {
const joinAudioLabel = away ? intlMessages.joinAudioAndSetActive : intlMessages.joinAudio;
2023-07-25 02:56:40 +08:00
return (
2023-09-13 22:31:20 +08:00
// eslint-disable-next-line jsx-a11y/no-access-key
2023-07-25 02:56:40 +08:00
<Button
onClick={() => handleJoinAudio(isConnected)}
disabled={disabled}
hideLabel
aria-label={intl.formatMessage(joinAudioLabel)}
label={intl.formatMessage(joinAudioLabel)}
2023-07-25 02:56:40 +08:00
data-test="joinAudio"
color="default"
ghost
icon="no_audio"
size="lg"
circle
accessKey={joinAudioShortcut}
2024-08-06 01:05:04 +08:00
loading={isConnecting}
2023-07-25 02:56:40 +08:00
/>
2023-09-13 22:31:20 +08:00
);
}, [isConnected, disabled, joinAudioShortcut, away]);
2023-07-25 02:56:40 +08:00
useEffect(() => {
if (isEchoTest) {
echoTestIntervalRef.current = setInterval(() => {
updateEchoTestRunning();
}, 1000);
} else {
clearInterval(echoTestIntervalRef.current);
}
}, [isEchoTest]);
return (
<Styled.Container>
feat(audio): rework audio join without listen only This is a rework of the audio join procedure whithout the explict listen only separation in mind. It's supposed to be used in conjunction with the transparent listen only feature so that the distinction between modes is seamless with minimal server-side impact. An abridged list of changes: - Let the user pick no input device when joining microphone while allowing them to set an input device on the fly later on - Give the user the option to join audio with no input device whenever we fail to obtain input devices, with the option to try re-enabling them on the fly later on - Add the option to open the audio settings modal (echo test et al) via the in-call device selection chevron - Rework the SFU audio bridge and its services to support adding/removing tracks on the fly without renegotiation - Rework the SFU audio bridge and its services to support a new peer role called "passive-sendrecv". That role is used by dupled peers that have no active input source on start, but might have one later on. - Remove stale PermissionsOverlay component from the audio modal - Rework how permission errors are detected using the Permissions API - Rework the local echo test so that it uses a separate media tag rather than the remote - Add new, separate dialplans that mute/hold FreeSWITCH channels on hold based on UA strings. This is orchestrated server-side via webrtc-sfu and akka-apps. The basic difference here is that channels now join in their desired state rather than waiting for client side observers to sync the state up. It also mitigates transparent listen only performance edge cases on multiple audio channels joining at the same time. The old, decoupled listen only mode is still present in code while we validate this new approach. To test this, transparentListenOnly must be enabled and listen only mode must be disable on audio join so that the user skips straight through microphone join.
2024-06-05 19:26:27 +08:00
{!inAudio ? joinButton : <InputStreamLiveSelectorContainer openAudioSettings={openAudioSettings} />}
2024-08-06 01:05:04 +08:00
{isAudioModalOpen && (
<AudioModalContainer
priority="low"
feat(audio): rework audio join without listen only This is a rework of the audio join procedure whithout the explict listen only separation in mind. It's supposed to be used in conjunction with the transparent listen only feature so that the distinction between modes is seamless with minimal server-side impact. An abridged list of changes: - Let the user pick no input device when joining microphone while allowing them to set an input device on the fly later on - Give the user the option to join audio with no input device whenever we fail to obtain input devices, with the option to try re-enabling them on the fly later on - Add the option to open the audio settings modal (echo test et al) via the in-call device selection chevron - Rework the SFU audio bridge and its services to support adding/removing tracks on the fly without renegotiation - Rework the SFU audio bridge and its services to support a new peer role called "passive-sendrecv". That role is used by dupled peers that have no active input source on start, but might have one later on. - Remove stale PermissionsOverlay component from the audio modal - Rework how permission errors are detected using the Permissions API - Rework the local echo test so that it uses a separate media tag rather than the remote - Add new, separate dialplans that mute/hold FreeSWITCH channels on hold based on UA strings. This is orchestrated server-side via webrtc-sfu and akka-apps. The basic difference here is that channels now join in their desired state rather than waiting for client side observers to sync the state up. It also mitigates transparent listen only performance edge cases on multiple audio channels joining at the same time. The old, decoupled listen only mode is still present in code while we validate this new approach. To test this, transparentListenOnly must be enabled and listen only mode must be disable on audio join so that the user skips straight through microphone join.
2024-06-05 19:26:27 +08:00
setIsOpen={() => {
setIsAudioModalOpen(false);
setAudioModalContent(null);
setAudioModalProps(null);
}}
2024-08-06 01:05:04 +08:00
isOpen={isAudioModalOpen}
feat(audio): rework audio join without listen only This is a rework of the audio join procedure whithout the explict listen only separation in mind. It's supposed to be used in conjunction with the transparent listen only feature so that the distinction between modes is seamless with minimal server-side impact. An abridged list of changes: - Let the user pick no input device when joining microphone while allowing them to set an input device on the fly later on - Give the user the option to join audio with no input device whenever we fail to obtain input devices, with the option to try re-enabling them on the fly later on - Add the option to open the audio settings modal (echo test et al) via the in-call device selection chevron - Rework the SFU audio bridge and its services to support adding/removing tracks on the fly without renegotiation - Rework the SFU audio bridge and its services to support a new peer role called "passive-sendrecv". That role is used by dupled peers that have no active input source on start, but might have one later on. - Remove stale PermissionsOverlay component from the audio modal - Rework how permission errors are detected using the Permissions API - Rework the local echo test so that it uses a separate media tag rather than the remote - Add new, separate dialplans that mute/hold FreeSWITCH channels on hold based on UA strings. This is orchestrated server-side via webrtc-sfu and akka-apps. The basic difference here is that channels now join in their desired state rather than waiting for client side observers to sync the state up. It also mitigates transparent listen only performance edge cases on multiple audio channels joining at the same time. The old, decoupled listen only mode is still present in code while we validate this new approach. To test this, transparentListenOnly must be enabled and listen only mode must be disable on audio join so that the user skips straight through microphone join.
2024-06-05 19:26:27 +08:00
content={audioModalContent}
unmuteOnExit={audioModalProps?.unmuteOnExit}
2024-08-06 01:05:04 +08:00
/>
)}
2023-07-25 02:56:40 +08:00
</Styled.Container>
);
};
export const AudioControlsContainer: React.FC = () => {
const { data: currentUser } = useCurrentUser((u: Partial<User>) => ({
presenter: u.presenter,
isModerator: u.isModerator,
locked: u?.locked ?? false,
voice: u.voice,
away: u.away,
}));
const { data: currentMeeting } = useMeeting((m: Partial<Meeting>) => ({
lockSettings: m.lockSettings,
}));
2023-07-25 02:56:40 +08:00
const [updateEchoTestRunning] = useMutation(UPDATE_ECHO_TEST_RUNNING);
2023-09-13 22:31:20 +08:00
// I access the internal variable to get the makevar reference,
// so we doesn't broke the client that uses the value directly
2023-07-25 02:56:40 +08:00
// and I can use it to make my component reactive
// @ts-ignore - temporary while hybrid (meteor+GraphQl)
2023-07-25 02:56:40 +08:00
const isConnected = useReactiveVar(AudioManager._isConnected.value) as boolean;
// @ts-ignore - temporary while hybrid (meteor+GraphQl)
2023-07-25 02:56:40 +08:00
const isConnecting = useReactiveVar(AudioManager._isConnecting.value) as boolean;
// @ts-ignore - temporary while hybrid (meteor+GraphQl)
2023-07-25 02:56:40 +08:00
const isHangingUp = useReactiveVar(AudioManager._isHangingUp.value) as boolean;
// @ts-ignore - temporary while hybrid (meteor+GraphQl)
2023-07-25 02:56:40 +08:00
const isEchoTest = useReactiveVar(AudioManager._isEchoTest.value) as boolean;
if (!currentUser || !currentMeeting) return null;
2023-09-13 22:31:20 +08:00
return (
<AudioControls
inAudio={!!currentUser.voice ?? false}
2023-09-13 22:31:20 +08:00
isConnected={isConnected}
disabled={isConnecting || isHangingUp}
isEchoTest={isEchoTest}
updateEchoTestRunning={updateEchoTestRunning}
away={currentUser.away || false}
isConnecting={isConnecting}
2023-09-13 22:31:20 +08:00
/>
);
2023-07-25 02:56:40 +08:00
};
export default AudioControlsContainer;