2017-06-28 06:14:53 +08:00
|
|
|
import Users from '/imports/api/2.0/users';
|
2017-04-19 23:01:28 +08:00
|
|
|
import Auth from '/imports/ui/services/auth';
|
2017-09-20 01:47:57 +08:00
|
|
|
import AudioManager from '/imports/ui/services/audio-manager';
|
2017-07-18 22:59:05 +08:00
|
|
|
import Meetings from '/imports/api/2.0/meetings';
|
2017-03-28 22:02:23 +08:00
|
|
|
|
2017-04-19 22:59:57 +08:00
|
|
|
const init = () => {
|
2017-09-20 01:47:57 +08:00
|
|
|
console.log('Running audio service init.');
|
2017-04-19 23:01:28 +08:00
|
|
|
const userId = Auth.userID;
|
2017-09-29 21:38:10 +08:00
|
|
|
const sessionToken = Auth.sessionToken;
|
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
|
|
|
|
2017-07-13 02:51:29 +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 = {
|
|
|
|
userId,
|
2017-09-29 21:38:10 +08:00
|
|
|
sessionToken,
|
2017-04-19 23:01:28 +08:00
|
|
|
username,
|
|
|
|
voiceBridge,
|
2017-05-04 04:12:47 +08:00
|
|
|
microphoneLockEnforced,
|
2017-04-19 23:01:28 +08:00
|
|
|
};
|
|
|
|
|
2017-09-20 01:47:57 +08:00
|
|
|
AudioManager.userData = userData;
|
2017-04-19 23:01:28 +08:00
|
|
|
};
|
2017-04-19 22:59:57 +08:00
|
|
|
|
2017-05-03 01:18:01 +08:00
|
|
|
export default {
|
2017-04-19 22:59:57 +08:00
|
|
|
init,
|
2017-09-20 01:47:57 +08:00
|
|
|
exitAudio: () => AudioManager.exitAudio(),
|
2017-09-29 21:38:10 +08:00
|
|
|
joinListenOnly: () => AudioManager.joinAudio({ isListenOnly: true }),
|
2017-09-20 01:47:57 +08:00
|
|
|
joinMicrophone: () => AudioManager.joinAudio(),
|
2017-09-29 21:38:10 +08:00
|
|
|
joinEchoTest: () => AudioManager.joinAudio({ isEchoTest: true }),
|
2017-09-20 01:47:57 +08:00
|
|
|
toggleMuteMicrophone: () => AudioManager.toggleMuteMicrophone(),
|
2017-09-30 04:42:34 +08:00
|
|
|
changeInputDevice: (inputDeviceId) => AudioManager.changeInputDevice(inputDeviceId),
|
2017-10-10 04:48:10 +08:00
|
|
|
changeOutputDevice: (outputDeviceId) => AudioManager.changeOutputDevice(outputDeviceId),
|
2017-09-20 01:47:57 +08:00
|
|
|
isConnected: () => AudioManager.isConnected,
|
|
|
|
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,
|
2017-09-29 21:42:08 +08:00
|
|
|
};
|