2016-05-19 04:19:50 +08:00
|
|
|
import {clientConfig} from '/config';
|
2016-05-28 00:17:16 +08:00
|
|
|
import {getVoiceBridge} from '/imports/api/phone';
|
|
|
|
|
|
|
|
function createVertoUserName() {
|
|
|
|
const uid = getInStorage('userID');
|
|
|
|
const uName = Users.findOne({ userId: uid }).user.name;
|
|
|
|
const conferenceUsername = 'FreeSWITCH User - ' + encodeURIComponent(uName);
|
|
|
|
return conferenceUsername;
|
|
|
|
}
|
2016-05-13 01:43:59 +08:00
|
|
|
|
2016-05-20 02:33:27 +08:00
|
|
|
function joinVertoAudio(options) {
|
|
|
|
joinVertoCall(options);
|
2016-05-07 04:15:47 +08:00
|
|
|
}
|
|
|
|
|
2016-05-20 02:33:27 +08:00
|
|
|
function watchVertoVideo(options) {
|
|
|
|
joinVertoCall(options);
|
2016-05-07 04:15:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function joinVertoCall(options) {
|
2016-05-20 02:33:27 +08:00
|
|
|
console.log('joinVertoCall');
|
2016-05-28 00:17:16 +08:00
|
|
|
const extension = options.extension || getVoiceBridge();
|
2016-05-07 04:15:47 +08:00
|
|
|
|
|
|
|
if (!isWebRTCAvailable()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-05-19 04:19:50 +08:00
|
|
|
if (!clientConfig.useSIPAudio) {
|
2016-05-07 04:15:47 +08:00
|
|
|
const vertoServerCredentials = {
|
2016-05-20 02:33:27 +08:00
|
|
|
vertoPort: clientConfig.media.vertoPort,
|
|
|
|
hostName: clientConfig.media.vertoServerAddress,
|
2016-05-07 04:15:47 +08:00
|
|
|
login: conferenceIdNumber,
|
2016-05-20 02:33:27 +08:00
|
|
|
password: clientConfig.media.freeswitchProfilePassword,
|
2016-05-07 04:15:47 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
let wasCallSuccessful = false;
|
|
|
|
let debuggerCallback = function (message) {
|
|
|
|
console.log('CALLBACK: ' + JSON.stringify(message));
|
|
|
|
|
|
|
|
//
|
|
|
|
// Beginning of hacky method to make Firefox media calls succeed.
|
|
|
|
// Always fail the first time. Retry on failure.
|
|
|
|
//
|
|
|
|
if (!!navigator.mozGetUserMedia && message.errorcode == 1001) {
|
|
|
|
const logCallback = function (m) {
|
|
|
|
console.log('CALLBACK: ' + JSON.stringify(m));
|
|
|
|
};
|
|
|
|
|
|
|
|
callIntoConference_verto(extension, conferenceUsername, conferenceIdNumber, logCallback,
|
|
|
|
'webcam', options, vertoServerCredentials);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// End of hacky method
|
|
|
|
//
|
|
|
|
};
|
|
|
|
|
|
|
|
callIntoConference_verto(extension, conferenceUsername, conferenceIdNumber, debuggerCallback,
|
|
|
|
'webcam', options, vertoServerCredentials);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2016-05-20 02:33:27 +08:00
|
|
|
|
2016-05-27 04:01:49 +08:00
|
|
|
export {
|
2016-05-28 00:17:16 +08:00
|
|
|
createVertoUserName,
|
2016-05-20 02:33:27 +08:00
|
|
|
joinVertoAudio,
|
|
|
|
watchVertoVideo,
|
|
|
|
};
|