2017-09-20 01:47:57 +08:00
|
|
|
import React from 'react';
|
2018-01-08 12:44:42 +08:00
|
|
|
import { withTracker } from 'meteor/react-meteor-data';
|
2017-09-26 04:28:36 +08:00
|
|
|
import { withModalMounter } from '/imports/ui/components/modal/service';
|
2018-11-01 23:03:16 +08:00
|
|
|
import AudioManager from '/imports/ui/services/audio-manager';
|
|
|
|
import { makeCall } from '/imports/ui/services/api';
|
2019-05-24 00:47:56 +08:00
|
|
|
import lockContextContainer from '/imports/ui/components/lock-viewers/context/container';
|
2021-04-07 03:58:11 +08:00
|
|
|
import { withUsersConsumer } from '/imports/ui/components/components-data/users-context/context';
|
2019-07-26 02:41:24 +08:00
|
|
|
import logger from '/imports/startup/client/logger';
|
2020-06-23 21:38:59 +08:00
|
|
|
import Auth from '/imports/ui/services/auth';
|
2021-02-05 02:42:31 +08:00
|
|
|
import Storage from '/imports/ui/services/storage/session';
|
|
|
|
import getFromUserSettings from '/imports/ui/services/users-settings';
|
2017-09-20 01:47:57 +08:00
|
|
|
import AudioControls from './component';
|
2017-09-29 21:38:10 +08:00
|
|
|
import AudioModalContainer from '../audio-modal/container';
|
fix: breakout autojoin audio with wrong behavior
When joining/returning breakouts, audio would always connect
with full audio. This can lead to a performance problem, once
all listenonly users would join full audio, increasing the
number of streams in FreeSWITCH.
We now have a consistent behavior, which is:
1 - The choice made by the user in the main room is predominant:
if mic is active in main room, user will automatically
join mic in breakout room. When returning from breakout
room, user will also join with mic again.
2 - Changes made in breakout room won't have effect when
returning to the main room. This means if user, for example,
change from listenonly to mic in breakout room, the returning
will consider the option choosen previously (listenonly) and
listenonly will be active again in the main room.
3 - If user didn't join audio in the main room, the audio modal
will be prompted when joining the breakout room (this is
a special case of (1))
The following is some technicall information:
InputStreamLiveSelector (component.jsx) now calls
'handleLeaveAudio' function, which is the default
function when user leaves audio (also used when
dynamic devices are inactive).
We now store information about user's choice (mic or listenonly)
using local storage, instead of the previous cookie method (this
was triggering some warnings in browser's console).
Also did a small refactoring to match eslint rules.
Fixes #11662.
2021-04-21 01:38:11 +08:00
|
|
|
import {
|
|
|
|
setUserSelectedMicrophone,
|
|
|
|
setUserSelectedListenOnly,
|
|
|
|
} from '../audio-modal/service';
|
|
|
|
|
2017-09-20 01:47:57 +08:00
|
|
|
import Service from '../service';
|
2021-02-11 21:23:38 +08:00
|
|
|
import AppService from '/imports/ui/components/app/service';
|
2017-09-20 01:47:57 +08:00
|
|
|
|
2020-06-23 21:38:59 +08:00
|
|
|
const ROLE_VIEWER = Meteor.settings.public.user.role_viewer;
|
2021-02-05 02:42:31 +08:00
|
|
|
const APP_CONFIG = Meteor.settings.public.app;
|
2020-06-23 21:38:59 +08:00
|
|
|
|
2021-04-20 22:36:22 +08:00
|
|
|
const AudioControlsContainer = (props) => {
|
|
|
|
const {
|
|
|
|
users, lockSettings, userLocks, children, ...newProps
|
|
|
|
} = props;
|
|
|
|
return <AudioControls {...newProps} />;
|
|
|
|
};
|
2017-09-20 01:47:57 +08:00
|
|
|
|
2018-11-01 23:03:16 +08:00
|
|
|
const processToggleMuteFromOutside = (e) => {
|
2018-11-14 01:14:30 +08:00
|
|
|
switch (e.data) {
|
|
|
|
case 'c_mute': {
|
2020-02-14 03:19:29 +08:00
|
|
|
makeCall('toggleVoice');
|
2018-11-14 01:14:30 +08:00
|
|
|
break;
|
|
|
|
}
|
2018-11-21 21:46:13 +08:00
|
|
|
case 'get_audio_joined_status': {
|
|
|
|
const audioJoinedState = AudioManager.isConnected ? 'joinedAudio' : 'notInAudio';
|
|
|
|
this.window.parent.postMessage({ response: audioJoinedState }, '*');
|
|
|
|
break;
|
|
|
|
}
|
2018-11-14 01:14:30 +08:00
|
|
|
case 'c_mute_status': {
|
|
|
|
const muteState = AudioManager.isMuted ? 'selfMuted' : 'selfUnmuted';
|
|
|
|
this.window.parent.postMessage({ response: muteState }, '*');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
// console.log(e.data);
|
|
|
|
}
|
2018-11-01 23:03:16 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-02-11 21:23:38 +08:00
|
|
|
const handleLeaveAudio = () => {
|
|
|
|
const meetingIsBreakout = AppService.meetingIsBreakout();
|
|
|
|
|
2020-03-03 04:49:15 +08:00
|
|
|
if (!meetingIsBreakout) {
|
fix: breakout autojoin audio with wrong behavior
When joining/returning breakouts, audio would always connect
with full audio. This can lead to a performance problem, once
all listenonly users would join full audio, increasing the
number of streams in FreeSWITCH.
We now have a consistent behavior, which is:
1 - The choice made by the user in the main room is predominant:
if mic is active in main room, user will automatically
join mic in breakout room. When returning from breakout
room, user will also join with mic again.
2 - Changes made in breakout room won't have effect when
returning to the main room. This means if user, for example,
change from listenonly to mic in breakout room, the returning
will consider the option choosen previously (listenonly) and
listenonly will be active again in the main room.
3 - If user didn't join audio in the main room, the audio modal
will be prompted when joining the breakout room (this is
a special case of (1))
The following is some technicall information:
InputStreamLiveSelector (component.jsx) now calls
'handleLeaveAudio' function, which is the default
function when user leaves audio (also used when
dynamic devices are inactive).
We now store information about user's choice (mic or listenonly)
using local storage, instead of the previous cookie method (this
was triggering some warnings in browser's console).
Also did a small refactoring to match eslint rules.
Fixes #11662.
2021-04-21 01:38:11 +08:00
|
|
|
setUserSelectedMicrophone(false);
|
|
|
|
setUserSelectedListenOnly(false);
|
2020-03-03 04:49:15 +08:00
|
|
|
}
|
|
|
|
|
2021-02-05 02:42:31 +08:00
|
|
|
const skipOnFistJoin = getFromUserSettings('bbb_skip_check_audio_on_first_join', APP_CONFIG.skipCheckOnJoin);
|
|
|
|
if (skipOnFistJoin && !Storage.getItem('getEchoTest')) {
|
|
|
|
Storage.setItem('getEchoTest', true);
|
|
|
|
}
|
|
|
|
|
2019-07-26 02:41:24 +08:00
|
|
|
Service.exitAudio();
|
|
|
|
logger.info({
|
|
|
|
logCode: 'audiocontrols_leave_audio',
|
|
|
|
extraInfo: { logType: 'user_action' },
|
|
|
|
}, 'audio connection closed by user');
|
|
|
|
};
|
|
|
|
|
|
|
|
const {
|
2019-08-22 20:05:06 +08:00
|
|
|
isVoiceUser,
|
2019-07-26 02:41:24 +08:00
|
|
|
isConnected,
|
|
|
|
isListenOnly,
|
|
|
|
isEchoTest,
|
|
|
|
isMuted,
|
|
|
|
isConnecting,
|
|
|
|
isHangingUp,
|
|
|
|
isTalking,
|
|
|
|
toggleMuteMicrophone,
|
|
|
|
joinListenOnly,
|
|
|
|
} = Service;
|
|
|
|
|
2021-04-07 03:58:11 +08:00
|
|
|
export default withUsersConsumer(lockContextContainer(withModalMounter(withTracker(({ mountModal, userLocks, users }) => {
|
2021-04-15 20:12:21 +08:00
|
|
|
const currentUser = users[Auth.meetingID][Auth.userID];
|
2020-06-23 21:38:59 +08:00
|
|
|
const isViewer = currentUser.role === ROLE_VIEWER;
|
|
|
|
const isPresenter = currentUser.presenter;
|
2021-03-07 09:09:43 +08:00
|
|
|
const { status } = Service.getBreakoutAudioTransferStatus();
|
2020-06-23 21:38:59 +08:00
|
|
|
|
2021-03-07 09:09:43 +08:00
|
|
|
if (status === AudioManager.BREAKOUT_AUDIO_TRANSFER_STATES.RETURNING) {
|
2021-03-08 02:01:12 +08:00
|
|
|
Service.setBreakoutAudioTransferStatus({
|
|
|
|
status: AudioManager.BREAKOUT_AUDIO_TRANSFER_STATES.DISCONNECTED,
|
|
|
|
});
|
2021-02-26 02:36:11 +08:00
|
|
|
Service.recoverMicState();
|
|
|
|
}
|
|
|
|
|
2020-06-23 21:38:59 +08:00
|
|
|
return ({
|
fix: breakout autojoin audio with wrong behavior
When joining/returning breakouts, audio would always connect
with full audio. This can lead to a performance problem, once
all listenonly users would join full audio, increasing the
number of streams in FreeSWITCH.
We now have a consistent behavior, which is:
1 - The choice made by the user in the main room is predominant:
if mic is active in main room, user will automatically
join mic in breakout room. When returning from breakout
room, user will also join with mic again.
2 - Changes made in breakout room won't have effect when
returning to the main room. This means if user, for example,
change from listenonly to mic in breakout room, the returning
will consider the option choosen previously (listenonly) and
listenonly will be active again in the main room.
3 - If user didn't join audio in the main room, the audio modal
will be prompted when joining the breakout room (this is
a special case of (1))
The following is some technicall information:
InputStreamLiveSelector (component.jsx) now calls
'handleLeaveAudio' function, which is the default
function when user leaves audio (also used when
dynamic devices are inactive).
We now store information about user's choice (mic or listenonly)
using local storage, instead of the previous cookie method (this
was triggering some warnings in browser's console).
Also did a small refactoring to match eslint rules.
Fixes #11662.
2021-04-21 01:38:11 +08:00
|
|
|
processToggleMuteFromOutside: (arg) => processToggleMuteFromOutside(arg),
|
2020-06-23 21:38:59 +08:00
|
|
|
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,
|
|
|
|
});
|
2021-04-07 03:58:11 +08:00
|
|
|
})(AudioControlsContainer))));
|