|
|
@ -21,16 +21,6 @@ const TrackErrors = JitsiMeetJS.errors.track; |
|
|
|
|
|
|
|
|
|
|
|
let room, connection, localAudio, localVideo, roomLocker; |
|
|
|
let room, connection, localAudio, localVideo, roomLocker; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Known custom conference commands. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
const Commands = { |
|
|
|
|
|
|
|
CONNECTION_QUALITY: "stats", |
|
|
|
|
|
|
|
EMAIL: "email", |
|
|
|
|
|
|
|
ETHERPAD: "etherpad", |
|
|
|
|
|
|
|
SHARED_VIDEO: "shared-video" |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import {VIDEO_CONTAINER_TYPE} from "./modules/UI/videolayout/LargeVideo"; |
|
|
|
import {VIDEO_CONTAINER_TYPE} from "./modules/UI/videolayout/LargeVideo"; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -52,10 +42,11 @@ function connect(roomName) { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Share email with other users. |
|
|
|
* Share email with other users. |
|
|
|
|
|
|
|
* @param emailCommand the email command |
|
|
|
* @param {string} email new email |
|
|
|
* @param {string} email new email |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function sendEmail (email) { |
|
|
|
function sendEmail (emailCommand, email) { |
|
|
|
room.sendCommand(Commands.EMAIL, { |
|
|
|
room.sendCommand(emailCommand, { |
|
|
|
value: email, |
|
|
|
value: email, |
|
|
|
attributes: { |
|
|
|
attributes: { |
|
|
|
id: room.myUserId() |
|
|
|
id: room.myUserId() |
|
|
@ -494,32 +485,6 @@ export default { |
|
|
|
getLogs () { |
|
|
|
getLogs () { |
|
|
|
return room.getLogs(); |
|
|
|
return room.getLogs(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
_createRoom (localTracks) { |
|
|
|
|
|
|
|
room = connection.initJitsiConference(APP.conference.roomName, |
|
|
|
|
|
|
|
this._getConferenceOptions()); |
|
|
|
|
|
|
|
this.localId = room.myUserId(); |
|
|
|
|
|
|
|
localTracks.forEach((track) => { |
|
|
|
|
|
|
|
if (track.isAudioTrack()) { |
|
|
|
|
|
|
|
this.useAudioStream(track); |
|
|
|
|
|
|
|
} else if (track.isVideoTrack()) { |
|
|
|
|
|
|
|
this.useVideoStream(track); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
roomLocker = createRoomLocker(room); |
|
|
|
|
|
|
|
this._room = room; // FIXME do not use this
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let email = APP.settings.getEmail(); |
|
|
|
|
|
|
|
email && sendEmail(email); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let nick = APP.settings.getDisplayName(); |
|
|
|
|
|
|
|
if (config.useNicks && !nick) { |
|
|
|
|
|
|
|
nick = APP.UI.askForNickname(); |
|
|
|
|
|
|
|
APP.settings.setDisplayName(nick); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
nick && room.setDisplayName(nick); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this._setupListeners(); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Exposes a Command(s) API on this instance. It is necessitated by (1) the |
|
|
|
* Exposes a Command(s) API on this instance. It is necessitated by (1) the |
|
|
@ -531,20 +496,30 @@ export default { |
|
|
|
* API of this instance. |
|
|
|
* API of this instance. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
commands: { |
|
|
|
commands: { |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Known custom conference commands. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
defaults: { |
|
|
|
|
|
|
|
CONNECTION_QUALITY: "stats", |
|
|
|
|
|
|
|
EMAIL: "email", |
|
|
|
|
|
|
|
ETHERPAD: "etherpad", |
|
|
|
|
|
|
|
SHARED_VIDEO: "shared-video", |
|
|
|
|
|
|
|
CUSTOM_ROLE: "custom-role" |
|
|
|
|
|
|
|
}, |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Receives notifications from other participants about commands aka |
|
|
|
* Receives notifications from other participants about commands aka |
|
|
|
* custom events (sent by sendCommand or sendCommandOnce methods). |
|
|
|
* custom events (sent by sendCommand or sendCommandOnce methods). |
|
|
|
* @param command {String} the name of the command |
|
|
|
* @param command {String} the name of the command |
|
|
|
* @param handler {Function} handler for the command |
|
|
|
* @param handler {Function} handler for the command |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
addCommandListener () { |
|
|
|
addCommandListener () { |
|
|
|
room.addCommandListener.apply(room, arguments); |
|
|
|
room.addCommandListener.apply(room, arguments); |
|
|
|
}, |
|
|
|
}, |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Removes command. |
|
|
|
* Removes command. |
|
|
|
* @param name {String} the name of the command. |
|
|
|
* @param name {String} the name of the command. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
removeCommand () { |
|
|
|
removeCommand () { |
|
|
|
room.removeCommand.apply(room, arguments); |
|
|
|
room.removeCommand.apply(room, arguments); |
|
|
|
}, |
|
|
|
}, |
|
|
|
/** |
|
|
|
/** |
|
|
@ -552,7 +527,7 @@ export default { |
|
|
|
* @param name {String} the name of the command. |
|
|
|
* @param name {String} the name of the command. |
|
|
|
* @param values {Object} with keys and values that will be sent. |
|
|
|
* @param values {Object} with keys and values that will be sent. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
sendCommand () { |
|
|
|
sendCommand () { |
|
|
|
room.sendCommand.apply(room, arguments); |
|
|
|
room.sendCommand.apply(room, arguments); |
|
|
|
}, |
|
|
|
}, |
|
|
|
/** |
|
|
|
/** |
|
|
@ -560,9 +535,36 @@ export default { |
|
|
|
* @param name {String} the name of the command. |
|
|
|
* @param name {String} the name of the command. |
|
|
|
* @param values {Object} with keys and values that will be sent. |
|
|
|
* @param values {Object} with keys and values that will be sent. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
sendCommandOnce () { |
|
|
|
sendCommandOnce () { |
|
|
|
room.sendCommandOnce.apply(room, arguments); |
|
|
|
room.sendCommandOnce.apply(room, arguments); |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_createRoom (localTracks) { |
|
|
|
|
|
|
|
room = connection.initJitsiConference(APP.conference.roomName, |
|
|
|
|
|
|
|
this._getConferenceOptions()); |
|
|
|
|
|
|
|
this.localId = room.myUserId(); |
|
|
|
|
|
|
|
localTracks.forEach((track) => { |
|
|
|
|
|
|
|
if (track.isAudioTrack()) { |
|
|
|
|
|
|
|
this.useAudioStream(track); |
|
|
|
|
|
|
|
} else if (track.isVideoTrack()) { |
|
|
|
|
|
|
|
this.useVideoStream(track); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
roomLocker = createRoomLocker(room); |
|
|
|
|
|
|
|
this._room = room; // FIXME do not use this
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let email = APP.settings.getEmail(); |
|
|
|
|
|
|
|
email && sendEmail(this.commands.defaults.EMAIL, email); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let nick = APP.settings.getDisplayName(); |
|
|
|
|
|
|
|
if (config.useNicks && !nick) { |
|
|
|
|
|
|
|
nick = APP.UI.askForNickname(); |
|
|
|
|
|
|
|
APP.settings.setDisplayName(nick); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
nick && room.setDisplayName(nick); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this._setupListeners(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
_getConferenceOptions() { |
|
|
|
_getConferenceOptions() { |
|
|
@ -721,6 +723,8 @@ export default { |
|
|
|
* Setup interaction between conference and UI. |
|
|
|
* Setup interaction between conference and UI. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
_setupListeners () { |
|
|
|
_setupListeners () { |
|
|
|
|
|
|
|
var self = this; |
|
|
|
|
|
|
|
|
|
|
|
// add local streams when joined to the conference
|
|
|
|
// add local streams when joined to the conference
|
|
|
|
room.on(ConferenceEvents.CONFERENCE_JOINED, () => { |
|
|
|
room.on(ConferenceEvents.CONFERENCE_JOINED, () => { |
|
|
|
APP.UI.mucJoined(); |
|
|
|
APP.UI.mucJoined(); |
|
|
@ -903,7 +907,8 @@ export default { |
|
|
|
APP.UI.updateLocalStats(percent, stats); |
|
|
|
APP.UI.updateLocalStats(percent, stats); |
|
|
|
|
|
|
|
|
|
|
|
// send local stats to other users
|
|
|
|
// send local stats to other users
|
|
|
|
room.sendCommandOnce(Commands.CONNECTION_QUALITY, { |
|
|
|
room.sendCommandOnce(self.commands.defaults.CONNECTION_QUALITY, |
|
|
|
|
|
|
|
{ |
|
|
|
children: ConnectionQuality.convertToMUCStats(stats), |
|
|
|
children: ConnectionQuality.convertToMUCStats(stats), |
|
|
|
attributes: { |
|
|
|
attributes: { |
|
|
|
xmlns: 'http://jitsi.org/jitmeet/stats' |
|
|
|
xmlns: 'http://jitsi.org/jitmeet/stats' |
|
|
@ -913,8 +918,9 @@ export default { |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
// listen to remote stats
|
|
|
|
// listen to remote stats
|
|
|
|
room.addCommandListener(Commands.CONNECTION_QUALITY,(values, from) => { |
|
|
|
room.addCommandListener(self.commands.defaults.CONNECTION_QUALITY, |
|
|
|
ConnectionQuality.updateRemoteStats(from, values); |
|
|
|
(values, from) => { |
|
|
|
|
|
|
|
ConnectionQuality.updateRemoteStats(from, values); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
ConnectionQuality.addListener(CQEvents.REMOTESTATS_UPDATED, |
|
|
|
ConnectionQuality.addListener(CQEvents.REMOTESTATS_UPDATED, |
|
|
@ -922,7 +928,7 @@ export default { |
|
|
|
APP.UI.updateRemoteStats(id, percent, stats); |
|
|
|
APP.UI.updateRemoteStats(id, percent, stats); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
room.addCommandListener(Commands.ETHERPAD, ({value}) => { |
|
|
|
room.addCommandListener(self.commands.defaults.ETHERPAD, ({value}) => { |
|
|
|
APP.UI.initEtherpad(value); |
|
|
|
APP.UI.initEtherpad(value); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -935,9 +941,9 @@ export default { |
|
|
|
|
|
|
|
|
|
|
|
APP.settings.setEmail(email); |
|
|
|
APP.settings.setEmail(email); |
|
|
|
APP.UI.setUserAvatar(room.myUserId(), email); |
|
|
|
APP.UI.setUserAvatar(room.myUserId(), email); |
|
|
|
sendEmail(email); |
|
|
|
sendEmail(self.commands.defaults.EMAIL, email); |
|
|
|
}); |
|
|
|
}); |
|
|
|
room.addCommandListener(Commands.EMAIL, (data) => { |
|
|
|
room.addCommandListener(self.commands.defaults.EMAIL, (data) => { |
|
|
|
APP.UI.setUserAvatar(data.attributes.id, data.value); |
|
|
|
APP.UI.setUserAvatar(data.attributes.id, data.value); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -1082,8 +1088,8 @@ export default { |
|
|
|
// send start and stop commands once, and remove any updates
|
|
|
|
// send start and stop commands once, and remove any updates
|
|
|
|
// that had left
|
|
|
|
// that had left
|
|
|
|
if (state === 'stop' || state === 'start' || state === 'playing') { |
|
|
|
if (state === 'stop' || state === 'start' || state === 'playing') { |
|
|
|
room.removeCommand(Commands.SHARED_VIDEO); |
|
|
|
room.removeCommand(self.commands.defaults.SHARED_VIDEO); |
|
|
|
room.sendCommandOnce(Commands.SHARED_VIDEO, { |
|
|
|
room.sendCommandOnce(self.commands.defaults.SHARED_VIDEO, { |
|
|
|
value: url, |
|
|
|
value: url, |
|
|
|
attributes: { |
|
|
|
attributes: { |
|
|
|
state: state, |
|
|
|
state: state, |
|
|
@ -1095,8 +1101,8 @@ export default { |
|
|
|
else { |
|
|
|
else { |
|
|
|
// in case of paused, in order to allow late users to join
|
|
|
|
// in case of paused, in order to allow late users to join
|
|
|
|
// paused
|
|
|
|
// paused
|
|
|
|
room.removeCommand(Commands.SHARED_VIDEO); |
|
|
|
room.removeCommand(self.commands.defaults.SHARED_VIDEO); |
|
|
|
room.sendCommand(Commands.SHARED_VIDEO, { |
|
|
|
room.sendCommand(self.commands.defaults.SHARED_VIDEO, { |
|
|
|
value: url, |
|
|
|
value: url, |
|
|
|
attributes: { |
|
|
|
attributes: { |
|
|
|
state: state, |
|
|
|
state: state, |
|
|
@ -1107,7 +1113,7 @@ export default { |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
room.addCommandListener( |
|
|
|
room.addCommandListener( |
|
|
|
Commands.SHARED_VIDEO, ({value, attributes}, id) => { |
|
|
|
self.commands.defaults.SHARED_VIDEO, ({value, attributes}, id) => { |
|
|
|
|
|
|
|
|
|
|
|
if (attributes.state === 'stop') { |
|
|
|
if (attributes.state === 'stop') { |
|
|
|
APP.UI.stopSharedVideo(id, attributes); |
|
|
|
APP.UI.stopSharedVideo(id, attributes); |
|
|
|