bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/audio/audio-controls/container.jsx

100 lines
3.3 KiB
React
Raw Normal View History

import React from 'react';
import { withTracker } from 'meteor/react-meteor-data';
2022-02-15 23:54:55 +08:00
import { withModalMounter } from '/imports/ui/components/common/modal/service';
import AudioManager from '/imports/ui/services/audio-manager';
2019-05-24 00:47:56 +08:00
import lockContextContainer from '/imports/ui/components/lock-viewers/context/container';
import { withUsersConsumer } from '/imports/ui/components/components-data/users-context/context';
import logger from '/imports/startup/client/logger';
import Auth from '/imports/ui/services/auth';
import Storage from '/imports/ui/services/storage/session';
import getFromUserSettings from '/imports/ui/services/users-settings';
import AudioControls from './component';
2017-09-29 21:38:10 +08:00
import AudioModalContainer from '../audio-modal/container';
import {
setUserSelectedMicrophone,
setUserSelectedListenOnly,
} from '../audio-modal/service';
import Service from '../service';
2021-02-11 21:23:38 +08:00
import AppService from '/imports/ui/components/app/service';
const ROLE_VIEWER = Meteor.settings.public.user.role_viewer;
const APP_CONFIG = Meteor.settings.public.app;
2021-04-20 22:36:22 +08:00
const AudioControlsContainer = (props) => {
const {
users, lockSettings, userLocks, children, ...newProps
} = props;
return <AudioControls {...newProps} />;
};
2021-02-11 21:23:38 +08:00
const handleLeaveAudio = () => {
const meetingIsBreakout = AppService.meetingIsBreakout();
if (!meetingIsBreakout) {
setUserSelectedMicrophone(false);
setUserSelectedListenOnly(false);
}
const skipOnFistJoin = getFromUserSettings('bbb_skip_check_audio_on_first_join', APP_CONFIG.skipCheckOnJoin);
if (skipOnFistJoin && !Storage.getItem('getEchoTest')) {
Storage.setItem('getEchoTest', true);
}
Service.forceExitAudio();
logger.info({
logCode: 'audiocontrols_leave_audio',
extraInfo: { logType: 'user_action' },
}, 'audio connection closed by user');
};
const {
isVoiceUser,
isConnected,
isListenOnly,
isEchoTest,
isMuted,
isConnecting,
isHangingUp,
isTalking,
toggleMuteMicrophone,
joinListenOnly,
} = Service;
2021-08-09 22:24:02 +08:00
export default withUsersConsumer(
lockContextContainer(
withModalMounter(withTracker(({ mountModal, userLocks, users }) => {
const currentUser = users[Auth.meetingID][Auth.userID];
const isViewer = currentUser.role === ROLE_VIEWER;
const isPresenter = currentUser.presenter;
const { status } = Service.getBreakoutAudioTransferStatus();
2021-08-09 22:24:02 +08:00
if (status === AudioManager.BREAKOUT_AUDIO_TRANSFER_STATES.RETURNING) {
Service.setBreakoutAudioTransferStatus({
status: AudioManager.BREAKOUT_AUDIO_TRANSFER_STATES.DISCONNECTED,
});
Service.recoverMicState();
}
2021-08-09 22:24:02 +08:00
return ({
showMute: isConnected() && !isListenOnly() && !isEchoTest() && !userLocks.userMic,
muted: isConnected() && !isListenOnly() && isMuted(),
inAudio: isConnected() && !isEchoTest(),
listenOnly: isConnected() && isListenOnly(),
disable: isConnecting() || isHangingUp() || !Meteor.status().connected,
talking: isTalking() && !isMuted(),
isVoiceUser: isVoiceUser(),
handleToggleMuteMicrophone: () => toggleMuteMicrophone(),
handleJoinAudio: () => (isConnected()
? joinListenOnly()
: mountModal(<AudioModalContainer />)
),
handleLeaveAudio,
inputStream: AudioManager.inputStream,
isViewer,
isPresenter,
});
})(AudioControlsContainer)),
),
);