bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/audio/service.js

56 lines
1.9 KiB
JavaScript
Raw Normal View History

import Users from '/imports/api/users';
2017-04-19 23:01:28 +08:00
import Auth from '/imports/ui/services/auth';
2017-10-13 03:22:10 +08:00
import AudioManager from '/imports/ui/services/audio-manager';
import Meetings from '/imports/api/meetings';
2017-03-28 22:02:23 +08:00
const init = (messages) => {
AudioManager.setAudioMessages(messages);
if (AudioManager.initialized) return;
const meetingId = Auth.meetingID;
2017-04-19 23:01:28 +08:00
const userId = Auth.userID;
2018-03-06 04:00:52 +08:00
const { sessionToken } = Auth;
2017-04-19 23:01:28 +08:00
const User = Users.findOne({ userId });
2017-07-26 22:31:35 +08:00
const username = User.name;
2017-07-18 22:59:05 +08:00
const Meeting = Meetings.findOne({ meetingId: User.meetingId });
const voiceBridge = Meeting.voiceProp.voiceConf;
2017-04-19 23:01:28 +08:00
// FIX ME
2017-07-18 22:59:05 +08:00
const microphoneLockEnforced = false;
2017-04-19 22:59:57 +08:00
2017-04-19 23:01:28 +08:00
const userData = {
meetingId,
2017-04-19 23:01:28 +08:00
userId,
2017-09-29 21:38:10 +08:00
sessionToken,
2017-04-19 23:01:28 +08:00
username,
voiceBridge,
microphoneLockEnforced,
2017-04-19 23:01:28 +08:00
};
AudioManager.init(userData);
2017-04-19 23:01:28 +08:00
};
2017-04-19 22:59:57 +08:00
export default {
2017-04-19 22:59:57 +08:00
init,
exitAudio: () => AudioManager.exitAudio(),
transferCall: () => AudioManager.transferCall(),
joinListenOnly: () => AudioManager.joinListenOnly(),
joinMicrophone: () => AudioManager.joinMicrophone(),
joinEchoTest: () => AudioManager.joinEchoTest(),
toggleMuteMicrophone: () => AudioManager.toggleMuteMicrophone(),
changeInputDevice: inputDeviceId => AudioManager.changeInputDevice(inputDeviceId),
changeOutputDevice: outputDeviceId => AudioManager.changeOutputDevice(outputDeviceId),
isConnected: () => AudioManager.isConnected,
isTalking: () => AudioManager.isTalking,
2017-10-27 01:14:56 +08:00
isHangingUp: () => AudioManager.isHangingUp,
isUsingAudio: () => AudioManager.isUsingAudio(),
2017-11-09 02:41:15 +08:00
isWaitingPermissions: () => AudioManager.isWaitingPermissions,
isMuted: () => AudioManager.isMuted,
isConnecting: () => AudioManager.isConnecting,
isListenOnly: () => AudioManager.isListenOnly,
inputDeviceId: () => AudioManager.inputDeviceId,
outputDeviceId: () => AudioManager.outputDeviceId,
2017-09-29 21:38:10 +08:00
isEchoTest: () => AudioManager.isEchoTest,
error: () => AudioManager.error,
2018-03-06 04:00:52 +08:00
isUserModerator: () => Users.findOne({ userId: Auth.userID }).moderator,
2017-09-29 21:42:08 +08:00
};