Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
do not use RTC/xmpp in UI module
isymchych6ded050b516d
diff --git a/app.js b/app.jsindex c4961b4b8f..161f92b591 100644--- a/app.js+++ b/app.js@@ -13,6 +13,7 @@ import "jQuery-Impromptu";import "autosize";window.toastr = require("toastr");+import URLProcessor from "./modules/config/URLProcessor";import RoomnameGenerator from './modules/util/RoomnameGenerator';import CQEvents from './service/connectionquality/CQEvents';import UIEvents from './service/UI/UIEvents';@@ -101,23 +102,23 @@ const APP = {};-var ConnectionEvents = JitsiMeetJS.events.connection;-var ConnectionErrors = JitsiMeetJS.errors.connection;+const ConnectionEvents = JitsiMeetJS.events.connection;+const ConnectionErrors = JitsiMeetJS.errors.connection;function connect() {- var connection = new JitsiMeetJS.JitsiConnection(null, null, {+ let connection = new JitsiMeetJS.JitsiConnection(null, null, {hosts: config.hosts,bosh: config.bosh,clientNode: config.clientNode});return new Promise(function (resolve, reject) {- var handlers = {};+ let handlers = {};- var unsubscribe = function () {+ function unsubscribe () {Object.keys(handlers).forEach(function (event) {connection.removeEventListener(event, handlers[event]);});- };+ }handlers[ConnectionEvents.CONNECTION_ESTABLISHED] = function () {console.log('CONNECTED');@@ -125,14 +126,14 @@ function connect() {resolve(connection);};- var listenForFailure = function (event) {+ function listenForFailure (event) {handlers[event] = function (...args) {console.error(`CONNECTION FAILED: ${event}`, ...args);unsubscribe();reject([event, ...args]);};- };+ }listenForFailure(ConnectionEvents.CONNECTION_FAILED);listenForFailure(ConnectionErrors.PASSWORD_REQUIRED);@@ -172,6 +173,13 @@ function initConference(localTracks, connection) {}});+ APP.conference.listMembers = function () {+ return room.getParticipants();+ };+ APP.conference.listMembersIds = function () {+ return room.getParticipants().map(p => p.getId());+ };+function getDisplayName(id) {if (APP.conference.isLocalId(id)) {return APP.settings.getDisplayName();@@ -187,17 +195,22 @@ function initConference(localTracks, connection) {room.on(ConferenceEvents.CONFERENCE_JOINED, function () {localTracks.forEach(function (track) {room.addTrack(track);- //APP.UI.addLocalStream(track);+ APP.UI.addLocalStream(track);});});- room.on(ConferenceEvents.USER_JOINED, function (id) {+ room.on(ConferenceEvents.USER_JOINED, function (id, user) {+ if (APP.conference.isLocalId(id)) {+ return;+ }+ console.error('USER %s connnected', id);// FIXME email???- //APP.UI.addUser(id);+ APP.UI.addUser(id, user.getDisplayName());});- room.on(ConferenceEvents.USER_LEFT, function (id) {- APP.UI.removeUser(id);+ room.on(ConferenceEvents.USER_LEFT, function (id, user) {+ console.error('USER LEFT', id);+ APP.UI.removeUser(id, user.getDisplayName());});@@ -230,6 +243,26 @@ function initConference(localTracks, connection) {});+ room.on(ConferenceEvents.TRACK_ADDED, function (track) {+ if (!track.getParticipantId) { // skip local tracks+ return;+ }+ console.error(+ 'REMOTE %s TRACK', track.getType(), track.getParticipantId()+ );+ APP.UI.addRemoteStream(track);+ });+ room.on(ConferenceEvents.TRACK_REMOVED, function (track) {+ if (!track.getParticipantId) { // skip local tracks+ return;+ }++ console.error(+ 'REMOTE %s TRACK REMOVED', track.getType(), track.getParticipantId()+ );++ // FIXME handle+ });room.on(ConferenceEvents.TRACK_MUTE_CHANGED, function (track) {// FIXME handle mute});@@ -421,10 +454,23 @@ function initConference(localTracks, connection) {// on SUBJECT_CHANGED UI.setSubject(topic);});+ APP.UI.addListener(UIEvents.USER_KICKED, function (id) {+ // FIXME handle+ // APP.xmpp.eject(self.id);+ });++ APP.UI.addListener(UIEvents.SELECTED_ENDPOINT, function (id) {+ room.selectParticipant(id);+ });+room.on(ConferenceEvents.DTMF_SUPPORT_CHANGED, function (isDTMFSupported) {APP.UI.updateDTMFSupport(isDTMFSupported);});+ $(window).bind('beforeunload', function () {+ room.leave();+ });+return new Promise(function (resolve, reject) {room.on(ConferenceEvents.CONFERENCE_JOINED, resolve);@@ -456,6 +502,7 @@ function createLocalTracks () {}function init() {+ APP.UI.start();JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.TRACE);JitsiMeetJS.init().then(function () {return Promise.all([createLocalTracks(), connect()]);@@ -463,8 +510,6 @@ function init() {console.log('initialized with %s local tracks', tracks.length);return initConference(tracks, connection);}).then(function () {- APP.UI.start();-APP.UI.initConference();APP.UI.addListener(UIEvents.LANG_CHANGED, function (language) {@@ -518,7 +563,6 @@ function obtainConfigAndInit() {$(document).ready(function () {console.log("(TIME) document ready:\t", window.performance.now());- var URLProcessor = require("./modules/config/URLProcessor");URLProcessor.setConfigParametersFromUrl();APP.init();@@ -537,4 +581,4 @@ $(window).bind('beforeunload', function () {}});-export default APP;+module.exports = APP;diff --git a/lib-jitsi-meet.js b/lib-jitsi-meet.jsindex e2b9eb8545..19badfd090 100644--- a/lib-jitsi-meet.js+++ b/lib-jitsi-meet.js@@ -8,6 +8,7 @@ var XMPPEvents = require("./service/xmpp/XMPPEvents");var RTCEvents = require("./service/RTC/RTCEvents");var EventEmitter = require("events");var JitsiConferenceEvents = require("./JitsiConferenceEvents");+var JitsiConferenceErrors = require("./JitsiConferenceErrors");var JitsiParticipant = require("./JitsiParticipant");var Statistics = require("./modules/statistics/statistics");var JitsiDTMFManager = require('./modules/DTMF/JitsiDTMFManager');@@ -246,6 +247,36 @@ JitsiConference.prototype.isModerator = function () {return this.room.isModerator();};+/**+ * Set password for the room.+ * @param {string} password new password for the room.+ * @returns {Promise}+ */+JitsiConference.prototype.lock = function (password) {+ if (!this.isModerator()) {+ return Promise.reject();+ }++ var conference = this;+ return new Promise(function (resolve, reject) {+ conference.xmpp.lockRoom(password, function () {+ resolve();+ }, function (err) {+ reject(err);+ }, function () {+ reject(JitsiConferenceErrors.PASSWORD_REQUIRED);+ });+ });+};++/**+ * Remove password from the room.+ * @returns {Promise}+ */+JitsiConference.prototype.unlock = function () {+ return this.lock(undefined);+};+/*** Elects the participant with the given id to be the selected participant or the speaker.* @param id the identifier of the participant@@ -287,10 +318,13 @@ JitsiConference.prototype.getParticipantById = function(id) {JitsiConference.prototype.onMemberJoined = function (jid, email, nick) {var id = Strophe.getResourceFromJid(jid);+ if (id === 'focus') {+ return;+ }var participant = new JitsiParticipant(id, this, nick);- this.eventEmitter.emit(JitsiConferenceEvents.USER_JOINED, id);this.participants[id] = participant;- this.connection.xmpp.connection.disco.info(+ this.eventEmitter.emit(JitsiConferenceEvents.USER_JOINED, id, participant);+ this.xmpp.connection.disco.info(jid, "node", function(iq) {participant._supportsDTMF = $(iq).find('>query>feature[var="urn:xmpp:jingle:dtmf:0"]').length > 0;@@ -301,8 +335,9 @@ JitsiConference.prototype.onMemberJoined = function (jid, email, nick) {JitsiConference.prototype.onMemberLeft = function (jid) {var id = Strophe.getResourceFromJid(jid);+ var participant = this.participants[id];delete this.participants[id];- this.eventEmitter.emit(JitsiConferenceEvents.USER_LEFT, id);+ this.eventEmitter.emit(JitsiConferenceEvents.USER_LEFT, id, participant);};JitsiConference.prototype.onUserRoleChanged = function (jid, role) {@@ -398,7 +433,7 @@ JitsiConference.prototype.myUserId = function () {JitsiConference.prototype.sendTones = function (tones, duration, pause) {if (!this.dtmfManager) {- var connection = this.connection.xmpp.connection.jingle.activecall.peerconnection;+ var connection = this.xmpp.connection.jingle.activecall.peerconnection;if (!connection) {logger.warn("cannot sendTones: no conneciton");return;@@ -482,6 +517,9 @@ function setupListeners(conference) {conference.eventEmitter.emit(JitsiConferenceEvents.LAST_N_ENDPOINTS_CHANGED,lastNEndpoints, endpointsEnteringLastN);});+ conference.xmpp.addListener(XMPPEvents.PASSWORD_REQUIRED, function () {+ conference.eventEmitter.emit(JitsiConferenceErrors.PASSWORD_REQUIRED);+ });if(conference.statistics) {//FIXME: Maybe remove event should not be associated with the conference.@@ -508,7 +546,7 @@ function setupListeners(conference) {module.exports = JitsiConference;}).call(this,"/JitsiConference.js")-},{"./JitsiConferenceEvents":3,"./JitsiParticipant":8,"./JitsiTrackEvents":10,"./modules/DTMF/JitsiDTMFManager":11,"./modules/RTC/RTC":16,"./modules/statistics/statistics":24,"./service/RTC/RTCEvents":83,"./service/xmpp/XMPPEvents":89,"events":43,"jitsi-meet-logger":47}],2:[function(require,module,exports){+},{"./JitsiConferenceErrors":2,"./JitsiConferenceEvents":3,"./JitsiParticipant":8,"./JitsiTrackEvents":10,"./modules/DTMF/JitsiDTMFManager":11,"./modules/RTC/RTC":16,"./modules/statistics/statistics":24,"./service/RTC/RTCEvents":79,"./service/xmpp/XMPPEvents":85,"events":43,"jitsi-meet-logger":47}],2:[function(require,module,exports){/*** Enumeration with the errors for the conference.* @type {{string: string}}@@ -518,6 +556,10 @@ var JitsiConferenceErrors = {* Indicates that a password is required in order to join the conference.*/PASSWORD_REQUIRED: "conference.passwordRequired",+ /**+ * Indicates that password cannot be set for this conference.+ */+ PASSWORD_NOT_SUPPORTED: "conference.passwordNotSupported",/*** Indicates that a connection error occurred when trying to join a* conference.@@ -1282,7 +1324,7 @@ module.exports = DataChannels;}).call(this,"/modules/RTC/DataChannels.js")-},{"../../service/RTC/RTCEvents":83,"jitsi-meet-logger":47}],13:[function(require,module,exports){+},{"../../service/RTC/RTCEvents":79,"jitsi-meet-logger":47}],13:[function(require,module,exports){var JitsiTrack = require("./JitsiTrack");var RTCBrowserType = require("./RTCBrowserType");var JitsiTrackEvents = require('../../JitsiTrackEvents');@@ -1342,7 +1384,7 @@ JitsiLocalTrack.prototype._setMute = function (mute) {} else {if (mute) {this.dontFireRemoveEvent = true;- this.rtc.room.removeStream(this.stream);+ this.rtc.room.removeStream(this.stream, function () {});RTC.stopMediaStream(this.stream);if(isAudio)this.rtc.room.setAudioMute(mute);@@ -1982,7 +2024,7 @@ RTC.prototype.setAudioLevel = function (jid, audioLevel) {}module.exports = RTC;-},{"../../service/RTC/MediaStreamTypes":82,"../../service/RTC/RTCEvents.js":83,"../../service/desktopsharing/DesktopSharingEventTypes":86,"./DataChannels":12,"./JitsiLocalTrack.js":13,"./JitsiRemoteTrack.js":14,"./JitsiTrack":15,"./RTCBrowserType":17,"./RTCUtils.js":18,"events":43}],17:[function(require,module,exports){+},{"../../service/RTC/MediaStreamTypes":78,"../../service/RTC/RTCEvents.js":79,"../../service/desktopsharing/DesktopSharingEventTypes":82,"./DataChannels":12,"./JitsiLocalTrack.js":13,"./JitsiRemoteTrack.js":14,"./JitsiTrack":15,"./RTCBrowserType":17,"./RTCUtils.js":18,"events":43}],17:[function(require,module,exports){var currentBrowser;@@ -2918,7 +2960,7 @@ var RTCUtils = {module.exports = RTCUtils;}).call(this,"/modules/RTC/RTCUtils.js")-},{"../../JitsiTrackErrors":9,"../../service/RTC/RTCEvents":83,"../../service/RTC/Resolutions":84,"../xmpp/SDPUtil":32,"./RTCBrowserType":17,"./ScreenObtainer":19,"./adapter.screenshare":20,"events":43,"jitsi-meet-logger":47}],19:[function(require,module,exports){+},{"../../JitsiTrackErrors":9,"../../service/RTC/RTCEvents":79,"../../service/RTC/Resolutions":80,"../xmpp/SDPUtil":32,"./RTCBrowserType":17,"./ScreenObtainer":19,"./adapter.screenshare":20,"events":43,"jitsi-meet-logger":47}],19:[function(require,module,exports){(function (__filename){/* global chrome, $, alert *//* jshint -W003 */@@ -3340,7 +3382,7 @@ function initFirefoxExtensionDetection(options) {module.exports = ScreenObtainer;}).call(this,"/modules/RTC/ScreenObtainer.js")-},{"../../service/desktopsharing/DesktopSharingEventTypes":86,"./RTCBrowserType":17,"./adapter.screenshare":20,"jitsi-meet-logger":47}],20:[function(require,module,exports){+},{"../../service/desktopsharing/DesktopSharingEventTypes":82,"./RTCBrowserType":17,"./adapter.screenshare":20,"jitsi-meet-logger":47}],20:[function(require,module,exports){(function (__filename){/*! adapterjs - v0.12.0 - 2015-09-04 */var console = require("jitsi-meet-logger").getLogger(__filename);@@ -5451,7 +5493,7 @@ StatsCollector.prototype.processAudioLevelReport = function () {};}).call(this,"/modules/statistics/RTPStatsCollector.js")-},{"../../service/statistics/Events":87,"../RTC/RTCBrowserType":17,"jitsi-meet-logger":47}],24:[function(require,module,exports){+},{"../../service/statistics/Events":83,"../RTC/RTCBrowserType":17,"jitsi-meet-logger":47}],24:[function(require,module,exports){/* global require, APP */var LocalStats = require("./LocalStatsCollector.js");var RTPStats = require("./RTPStatsCollector.js");@@ -5626,7 +5668,7 @@ Statistics.LOCAL_JID = require("../../service/statistics/constants").LOCAL_JID;module.exports = Statistics;-},{"../../service/statistics/Events":87,"../../service/statistics/constants":88,"./LocalStatsCollector.js":22,"./RTPStatsCollector.js":23,"events":43}],25:[function(require,module,exports){+},{"../../service/statistics/Events":83,"../../service/statistics/constants":84,"./LocalStatsCollector.js":22,"./RTPStatsCollector.js":23,"events":43}],25:[function(require,module,exports){/**/*** @const@@ -6347,7 +6389,7 @@ ChatRoom.prototype.getJidBySSRC = function (ssrc) {module.exports = ChatRoom;}).call(this,"/modules/xmpp/ChatRoom.js")-},{"../../service/xmpp/XMPPEvents":89,"./moderator":34,"events":43,"jitsi-meet-logger":47}],27:[function(require,module,exports){+},{"../../service/xmpp/XMPPEvents":85,"./moderator":34,"events":43,"jitsi-meet-logger":47}],27:[function(require,module,exports){(function (__filename){/** JingleSession provides an API to manage a single Jingle session. We will@@ -8116,7 +8158,7 @@ JingleSessionPC.prototype.remoteStreamAdded = function (data, times) {module.exports = JingleSessionPC;}).call(this,"/modules/xmpp/JingleSessionPC.js")-},{"../../service/xmpp/XMPPEvents":89,"../RTC/RTC":16,"../RTC/RTCBrowserType":17,"./JingleSession":27,"./LocalSSRCReplacement":29,"./SDP":30,"./SDPDiffer":31,"./SDPUtil":32,"./TraceablePeerConnection":33,"async":42,"jitsi-meet-logger":47,"sdp-transform":79}],29:[function(require,module,exports){+},{"../../service/xmpp/XMPPEvents":85,"../RTC/RTC":16,"../RTC/RTCBrowserType":17,"./JingleSession":27,"./LocalSSRCReplacement":29,"./SDP":30,"./SDPDiffer":31,"./SDPUtil":32,"./TraceablePeerConnection":33,"async":42,"jitsi-meet-logger":47,"sdp-transform":75}],29:[function(require,module,exports){(function (__filename){/* global $ */var logger = require("jitsi-meet-logger").getLogger(__filename);@@ -8171,11 +8213,11 @@ var isEnabled = !RTCBrowserType.isFirefox();var localVideoSSRC;/**- * SSRC, msid, mslabel, label used for recvonly video stream when we have no local camera.+ * SSRC used for recvonly video stream when we have no local camera.* This is in order to tell Chrome what SSRC should be used in RTCP requests* instead of 1.*/-var localRecvOnlySSRC, localRecvOnlyMSID, localRecvOnlyMSLabel, localRecvOnlyLabel;+var localRecvOnlySSRC;/*** cname for <tt>localRecvOnlySSRC</tt>@@ -8248,30 +8290,19 @@ var storeLocalVideoSSRC = function (jingleIq) {};/**- * Generates new label/mslabel attribute- * @returns {string} label/mslabel attribute- */-function generateLabel() {- return RandomUtil.randomHexString(8) + "-" + RandomUtil.randomHexString(4) +- "-" + RandomUtil.randomHexString(4) + "-" +- RandomUtil.randomHexString(4) + "-" + RandomUtil.randomHexString(12);-}--/**- * Generates new SSRC, CNAME, mslabel, label and msid for local video recvonly stream.+ * Generates new SSRC for local video recvonly stream.* FIXME what about eventual SSRC collision ?*/function generateRecvonlySSRC() {+localRecvOnlySSRC =- Math.random().toString(10).substring(2, 11);+ localVideoSSRC ?+ localVideoSSRC : Math.random().toString(10).substring(2, 11);+localRecvOnlyCName =Math.random().toString(36).substring(2);- localRecvOnlyMSLabel = generateLabel();- localRecvOnlyLabel = generateLabel();- localRecvOnlyMSID = localRecvOnlyMSLabel + " " + localRecvOnlyLabel;-- logger.info(+ logger.info("Generated local recvonly SSRC: " + localRecvOnlySSRC +", cname: " + localRecvOnlyCName);}@@ -8313,51 +8344,41 @@ var LocalSSRCReplacement = {// IF we have local video SSRC stored make sure it is replaced// with old SSRC- if (localVideoSSRC) {- var newSdp = new SDP(localDescription.sdp);- if (newSdp.media[1].indexOf("a=ssrc:") !== -1 &&- !newSdp.containsSSRC(localVideoSSRC)) {- // Get new video SSRC- var map = newSdp.getMediaSsrcMap();- var videoPart = map[1];- var videoSSRCs = videoPart.ssrcs;- var newSSRC = Object.keys(videoSSRCs)[0];-- logger.info(- "Replacing new video SSRC: " + newSSRC +- " with " + localVideoSSRC);+ var sdp = new SDP(localDescription.sdp);+ if (sdp.media.length < 2)+ return;- localDescription.sdp =- newSdp.raw.replace(- new RegExp('a=ssrc:' + newSSRC, 'g'),- 'a=ssrc:' + localVideoSSRC);- }- } else {+ if (localVideoSSRC && sdp.media[1].indexOf("a=ssrc:") !== -1 &&+ !sdp.containsSSRC(localVideoSSRC)) {+ // Get new video SSRC+ var map = sdp.getMediaSsrcMap();+ var videoPart = map[1];+ var videoSSRCs = videoPart.ssrcs;+ var newSSRC = Object.keys(videoSSRCs)[0];++ logger.info(+ "Replacing new video SSRC: " + newSSRC ++ " with " + localVideoSSRC);++ localDescription.sdp =+ sdp.raw.replace(+ new RegExp('a=ssrc:' + newSSRC, 'g'),+ 'a=ssrc:' + localVideoSSRC);+ }+ else if (sdp.media[1].indexOf('a=ssrc:') === -1 &&+ sdp.media[1].indexOf('a=recvonly') !== -1) {// Make sure we have any SSRC for recvonly video stream- var sdp = new SDP(localDescription.sdp);-- if (sdp.media[1] && sdp.media[1].indexOf('a=ssrc:') === -1 &&- sdp.media[1].indexOf('a=recvonly') !== -1) {-- if (!localRecvOnlySSRC) {- generateRecvonlySSRC();- }- localVideoSSRC = localRecvOnlySSRC;+ if (!localRecvOnlySSRC) {+ generateRecvonlySSRC();+ }- logger.info('No SSRC in video recvonly stream' +- ' - adding SSRC: ' + localRecvOnlySSRC);+ logger.info('No SSRC in video recvonly stream' ++ ' - adding SSRC: ' + localRecvOnlySSRC);- sdp.media[1] += 'a=ssrc:' + localRecvOnlySSRC +- ' cname:' + localRecvOnlyCName + '\r\n' +- 'a=ssrc:' + localRecvOnlySSRC +- ' msid:' + localRecvOnlyMSID + '\r\n' +- 'a=ssrc:' + localRecvOnlySSRC +- ' mslabel:' + localRecvOnlyMSLabel + '\r\n' +- 'a=ssrc:' + localRecvOnlySSRC +- ' label:' + localRecvOnlyLabel + '\r\n';+ sdp.media[1] += 'a=ssrc:' + localRecvOnlySSRC ++ ' cname:' + localRecvOnlyCName + '\r\n';- localDescription.sdp = sdp.session + sdp.media.join('');- }+ localDescription.sdp = sdp.session + sdp.media.join('');}return localDescription;},@@ -8493,16 +8514,18 @@ SDP.prototype.getMediaSsrcMap = function() {* @param ssrc the ssrc to check.* @returns {boolean} <tt>true</tt> if this SDP contains given SSRC.*/-SDP.prototype.containsSSRC = function(ssrc) {+SDP.prototype.containsSSRC = function (ssrc) {+ // FIXME this code is really strange - improve it if you canvar medias = this.getMediaSsrcMap();- Object.keys(medias).forEach(function(mediaindex){- var media = medias[mediaindex];- //logger.log("Check", channel, ssrc);- if(Object.keys(media.ssrcs).indexOf(ssrc) != -1){- return true;+ var result = false;+ Object.keys(medias).forEach(function (mediaindex) {+ if (result)+ return;+ if (medias[mediaindex].ssrcs[ssrc]) {+ result = true;}});- return false;+ return result;};// remove iSAC and CN from SDP@@ -10053,7 +10076,7 @@ TraceablePeerConnection.prototype.getStats = function(callback, errback) {module.exports = TraceablePeerConnection;}).call(this,"/modules/xmpp/TraceablePeerConnection.js")-},{"../../service/xmpp/XMPPEvents":89,"../RTC/RTC":16,"../RTC/RTCBrowserType.js":17,"./LocalSSRCReplacement":29,"jitsi-meet-logger":47,"sdp-interop":65,"sdp-simulcast":72,"sdp-transform":79}],34:[function(require,module,exports){+},{"../../service/xmpp/XMPPEvents":85,"../RTC/RTC":16,"../RTC/RTCBrowserType.js":17,"./LocalSSRCReplacement":29,"jitsi-meet-logger":47,"sdp-interop":65,"sdp-simulcast":68,"sdp-transform":75}],34:[function(require,module,exports){(function (__filename){/* global $, $iq, APP, config, messageHandler,roomName, sessionTerminated, Strophe, Util */@@ -10497,7 +10520,7 @@ module.exports = Moderator;}).call(this,"/modules/xmpp/moderator.js")-},{"../../service/authentication/AuthenticationEvents":85,"../../service/xmpp/XMPPEvents":89,"../settings/Settings":21,"jitsi-meet-logger":47}],35:[function(require,module,exports){+},{"../../service/authentication/AuthenticationEvents":81,"../../service/xmpp/XMPPEvents":85,"../settings/Settings":21,"jitsi-meet-logger":47}],35:[function(require,module,exports){(function (__filename){/* jshint -W117 *//* a simple MUC connection plugin@@ -10891,7 +10914,7 @@ module.exports = function(XMPP, eventEmitter) {}).call(this,"/modules/xmpp/strophe.jingle.js")-},{"../../service/xmpp/XMPPEvents":89,"../RTC/RTCBrowserType":17,"./JingleSessionPC":28,"jitsi-meet-logger":47}],37:[function(require,module,exports){+},{"../../service/xmpp/XMPPEvents":85,"../RTC/RTCBrowserType":17,"./JingleSessionPC":28,"jitsi-meet-logger":47}],37:[function(require,module,exports){/* global Strophe */module.exports = function () {@@ -11039,7 +11062,7 @@ module.exports = function (XMPP, eventEmitter) {};}).call(this,"/modules/xmpp/strophe.ping.js")-},{"../../service/xmpp/XMPPEvents":89,"jitsi-meet-logger":47}],39:[function(require,module,exports){+},{"../../service/xmpp/XMPPEvents":85,"jitsi-meet-logger":47}],39:[function(require,module,exports){(function (__filename){/* jshint -W117 */var logger = require("jitsi-meet-logger").getLogger(__filename);@@ -11512,7 +11535,7 @@ XMPP.prototype.getLocalSSRC = function (mediaType) {module.exports = XMPP;}).call(this,"/modules/xmpp/xmpp.js")-},{"../../JitsiConnectionErrors":5,"../../JitsiConnectionEvents":6,"../../service/RTC/RTCEvents":83,"../../service/xmpp/XMPPEvents":89,"../RTC/RTC":16,"./strophe.emuc":35,"./strophe.jingle":36,"./strophe.logger":37,"./strophe.ping":38,"./strophe.rayo":39,"./strophe.util":40,"events":43,"jitsi-meet-logger":47,"pako":48}],42:[function(require,module,exports){+},{"../../JitsiConnectionErrors":5,"../../JitsiConnectionEvents":6,"../../service/RTC/RTCEvents":79,"../../service/xmpp/XMPPEvents":85,"../RTC/RTC":16,"./strophe.emuc":35,"./strophe.jingle":36,"./strophe.logger":37,"./strophe.ping":38,"./strophe.rayo":39,"./strophe.util":40,"events":43,"jitsi-meet-logger":47,"pako":48}],42:[function(require,module,exports){(function (process){/*!* async@@ -21562,625 +21585,145 @@ exports.parse = function(sdp) {};-},{"sdp-transform":69}],68:[function(require,module,exports){-var grammar = module.exports = {- v: [{- name: 'version',- reg: /^(\d*)$/- }],- o: [{ //o=- 20518 0 IN IP4 203.0.113.1- // NB: sessionId will be a String in most cases because it is huge- name: 'origin',- reg: /^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,- names: ['username', 'sessionId', 'sessionVersion', 'netType', 'ipVer', 'address'],- format: "%s %s %d %s IP%d %s"- }],- // default parsing of these only (though some of these feel outdated)- s: [{ name: 'name' }],- i: [{ name: 'description' }],- u: [{ name: 'uri' }],- e: [{ name: 'email' }],- p: [{ name: 'phone' }],- z: [{ name: 'timezones' }], // TODO: this one can actually be parsed properly..- r: [{ name: 'repeats' }], // TODO: this one can also be parsed properly- //k: [{}], // outdated thing ignored- t: [{ //t=0 0- name: 'timing',- reg: /^(\d*) (\d*)/,- names: ['start', 'stop'],- format: "%d %d"- }],- c: [{ //c=IN IP4 10.47.197.26- name: 'connection',- reg: /^IN IP(\d) (\S*)/,- names: ['version', 'ip'],- format: "IN IP%d %s"- }],- b: [{ //b=AS:4000- push: 'bandwidth',- reg: /^(TIAS|AS|CT|RR|RS):(\d*)/,- names: ['type', 'limit'],- format: "%s:%s"- }],- m: [{ //m=video 51744 RTP/AVP 126 97 98 34 31- // NB: special - pushes to session- // TODO: rtp/fmtp should be filtered by the payloads found here?- reg: /^(\w*) (\d*) ([\w\/]*)(?: (.*))?/,- names: ['type', 'port', 'protocol', 'payloads'],- format: "%s %d %s %s"- }],- a: [- { //a=rtpmap:110 opus/48000/2- push: 'rtp',- reg: /^rtpmap:(\d*) ([\w\-]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,- names: ['payload', 'codec', 'rate', 'encoding'],- format: function (o) {- return (o.encoding) ?- "rtpmap:%d %s/%s/%s":- o.rate ?- "rtpmap:%d %s/%s":- "rtpmap:%d %s";- }- },- {- //a=fmtp:108 profile-level-id=24;object=23;bitrate=64000- //a=fmtp:111 minptime=10; useinbandfec=1- push: 'fmtp',- reg: /^fmtp:(\d*) ([\S| ]*)/,- names: ['payload', 'config'],- format: "fmtp:%d %s"- },- { //a=control:streamid=0- name: 'control',- reg: /^control:(.*)/,- format: "control:%s"- },- { //a=rtcp:65179 IN IP4 193.84.77.194- name: 'rtcp',- reg: /^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,- names: ['port', 'netType', 'ipVer', 'address'],- format: function (o) {- return (o.address != null) ?- "rtcp:%d %s IP%d %s":- "rtcp:%d";- }- },- { //a=rtcp-fb:98 trr-int 100- push: 'rtcpFbTrrInt',- reg: /^rtcp-fb:(\*|\d*) trr-int (\d*)/,- names: ['payload', 'value'],- format: "rtcp-fb:%d trr-int %d"- },- { //a=rtcp-fb:98 nack rpsi- push: 'rtcpFb',- reg: /^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,- names: ['payload', 'type', 'subtype'],- format: function (o) {- return (o.subtype != null) ?- "rtcp-fb:%s %s %s":- "rtcp-fb:%s %s";- }- },- { //a=extmap:2 urn:ietf:params:rtp-hdrext:toffset- //a=extmap:1/recvonly URI-gps-string- push: 'ext',- reg: /^extmap:([\w_\/]*) (\S*)(?: (\S*))?/,- names: ['value', 'uri', 'config'], // value may include "/direction" suffix- format: function (o) {- return (o.config != null) ?- "extmap:%s %s %s":- "extmap:%s %s";- }- },- {- //a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:PS1uQCVeeCFCanVmcjkpPywjNWhcYD0mXXtxaVBR|2^20|1:32- push: 'crypto',- reg: /^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,- names: ['id', 'suite', 'config', 'sessionConfig'],- format: function (o) {- return (o.sessionConfig != null) ?- "crypto:%d %s %s %s":- "crypto:%d %s %s";- }- },- { //a=setup:actpass- name: 'setup',- reg: /^setup:(\w*)/,- format: "setup:%s"- },- { //a=mid:1- name: 'mid',- reg: /^mid:([^\s]*)/,- format: "mid:%s"- },- { //a=msid:0c8b064d-d807-43b4-b434-f92a889d8587 98178685-d409-46e0-8e16-7ef0db0db64a- name: 'msid',- reg: /^msid:(.*)/,- format: "msid:%s"- },- { //a=ptime:20- name: 'ptime',- reg: /^ptime:(\d*)/,- format: "ptime:%d"- },- { //a=maxptime:60- name: 'maxptime',- reg: /^maxptime:(\d*)/,- format: "maxptime:%d"- },- { //a=sendrecv- name: 'direction',- reg: /^(sendrecv|recvonly|sendonly|inactive)/- },- { //a=ice-lite- name: 'icelite',- reg: /^(ice-lite)/- },- { //a=ice-ufrag:F7gI- name: 'iceUfrag',- reg: /^ice-ufrag:(\S*)/,- format: "ice-ufrag:%s"- },- { //a=ice-pwd:x9cml/YzichV2+XlhiMu8g- name: 'icePwd',- reg: /^ice-pwd:(\S*)/,- format: "ice-pwd:%s"- },- { //a=fingerprint:SHA-1 00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF:00:11:22:33- name: 'fingerprint',- reg: /^fingerprint:(\S*) (\S*)/,- names: ['type', 'hash'],- format: "fingerprint:%s %s"- },- {- //a=candidate:0 1 UDP 2113667327 203.0.113.1 54400 typ host- //a=candidate:1162875081 1 udp 2113937151 192.168.34.75 60017 typ host generation 0- //a=candidate:3289912957 2 udp 1845501695 193.84.77.194 60017 typ srflx raddr 192.168.34.75 rport 60017 generation 0- //a=candidate:229815620 1 tcp 1518280447 192.168.150.19 60017 typ host tcptype active generation 0- //a=candidate:3289912957 2 tcp 1845501695 193.84.77.194 60017 typ srflx raddr 192.168.34.75 rport 60017 tcptype passive generation 0- push:'candidates',- reg: /^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?/,- names: ['foundation', 'component', 'transport', 'priority', 'ip', 'port', 'type', 'raddr', 'rport', 'tcptype', 'generation'],- format: function (o) {- var str = "candidate:%s %d %s %d %s %d typ %s";+},{"sdp-transform":75}],68:[function(require,module,exports){+/* Copyright @ 2015 Atlassian Pty Ltd+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */- str += (o.raddr != null) ? " raddr %s rport %d" : "%v%v";+var transform = require('sdp-transform');+var transformUtils = require('./transform-utils');+var parseSsrcs = transformUtils.parseSsrcs;+var writeSsrcs = transformUtils.writeSsrcs;- // NB: candidate has three optional chunks, so %void middles one if it's missing- str += (o.tcptype != null) ? " tcptype %s" : "%v";+//region Constants- if (o.generation != null) {- str += " generation %d";- }- return str;- }- },- { //a=end-of-candidates (keep after the candidates line for readability)- name: 'endOfCandidates',- reg: /^(end-of-candidates)/- },- { //a=remote-candidates:1 203.0.113.1 54400 2 203.0.113.1 54401 ...- name: 'remoteCandidates',- reg: /^remote-candidates:(.*)/,- format: "remote-candidates:%s"- },- { //a=ice-options:google-ice- name: 'iceOptions',- reg: /^ice-options:(\S*)/,- format: "ice-options:%s"- },- { //a=ssrc:2566107569 cname:t9YU8M1UxTF8Y1A1- push: "ssrcs",- reg: /^ssrc:(\d*) ([\w_]*):(.*)/,- names: ['id', 'attribute', 'value'],- format: "ssrc:%d %s:%s"- },- { //a=ssrc-group:FEC 1 2- push: "ssrcGroups",- reg: /^ssrc-group:(\w*) (.*)/,- names: ['semantics', 'ssrcs'],- format: "ssrc-group:%s %s"- },- { //a=msid-semantic: WMS Jvlam5X3SX1OP6pn20zWogvaKJz5Hjf9OnlV- name: "msidSemantic",- reg: /^msid-semantic:\s?(\w*) (\S*)/,- names: ['semantic', 'token'],- format: "msid-semantic: %s %s" // space after ":" is not accidental- },- { //a=group:BUNDLE audio video- push: 'groups',- reg: /^group:(\w*) (.*)/,- names: ['type', 'mids'],- format: "group:%s %s"- },- { //a=rtcp-mux- name: 'rtcpMux',- reg: /^(rtcp-mux)/- },- { //a=rtcp-rsize- name: 'rtcpRsize',- reg: /^(rtcp-rsize)/- },- { // any a= that we don't understand is kepts verbatim on media.invalid- push: 'invalid',- names: ["value"]+var DEFAULT_NUM_OF_LAYERS = 3;++//endregion++//region Ctor++function Simulcast(options) {++ this.options = options ? options : {};++ if (!this.options.numOfLayers) {+ this.options.numOfLayers = DEFAULT_NUM_OF_LAYERS;}- ]++ this.layers = [];+}++//endregion++//region Stateless private utility functions++/**+ * Returns a random integer between min (included) and max (excluded)+ * Using Math.round() gives a non-uniform distribution!+ * @returns {number}+ */+function generateSSRC() {+ var min = 0, max = 0xffffffff;+ return Math.floor(Math.random() * (max - min)) + min;};-// set sensible defaults to avoid polluting the grammar with boring details-Object.keys(grammar).forEach(function (key) {- var objs = grammar[key];- objs.forEach(function (obj) {- if (!obj.reg) {- obj.reg = /(.*)/;- }- if (!obj.format) {- obj.format = "%s";+function processVideo(session, action) {+ if (session == null || !Array.isArray(session.media)) {+ return;}- });-});-},{}],69:[function(require,module,exports){-var parser = require('./parser');-var writer = require('./writer');+ session.media.forEach(function (mLine) {+ if (mLine.type === 'video') {+ action(mLine);+ }+ });+}-exports.write = writer;-exports.parse = parser.parse;-exports.parseFmtpConfig = parser.parseFmtpConfig;-exports.parsePayloads = parser.parsePayloads;-exports.parseRemoteCandidates = parser.parseRemoteCandidates;+function validateDescription(desc)+{+ return desc && desc != null+ && desc.type && desc.type != ''+ && desc.sdp && desc.sdp != '';+}-},{"./parser":70,"./writer":71}],70:[function(require,module,exports){-var toIntIfInt = function (v) {- return String(Number(v)) === v ? Number(v) : v;-};+function explodeRemoteSimulcast(mLine) {-var attachProperties = function (match, location, names, rawName) {- if (rawName && !names) {- location[rawName] = toIntIfInt(match[1]);- }- else {- for (var i = 0; i < names.length; i += 1) {- if (match[i+1] != null) {- location[names[i]] = toIntIfInt(match[i+1]);- }+ if (!mLine || !Array.isArray(mLine.ssrcGroups)) {+ return;}- }-};-var parseReg = function (obj, location, content) {- var needsBlank = obj.name && obj.names;- if (obj.push && !location[obj.push]) {- location[obj.push] = [];- }- else if (needsBlank && !location[obj.name]) {- location[obj.name] = {};- }- var keyLocation = obj.push ?- {} : // blank object that will be pushed- needsBlank ? location[obj.name] : location; // otherwise, named location or root+ var sources = parseSsrcs(mLine);+ var order = [];- attachProperties(content.match(obj.reg), keyLocation, obj.names, obj.name);+ // Find the SIM group and explode its sources.+ var j = mLine.ssrcGroups.length;+ while (j--) {- if (obj.push) {- location[obj.push].push(keyLocation);- }-};+ if (mLine.ssrcGroups[j].semantics !== 'SIM') {+ continue;+ }-var grammar = require('./grammar');-var validLine = RegExp.prototype.test.bind(/^([a-z])=(.*)/);+ var simulcastSsrcs = mLine.ssrcGroups[j].ssrcs.split(' ');-exports.parse = function (sdp) {- var session = {}- , media = []- , location = session; // points at where properties go under (one of the above)+ for (var i = 0; i < simulcastSsrcs.length; i++) {- // parse lines we understand- sdp.split(/(\r\n|\r|\n)/).filter(validLine).forEach(function (l) {- var type = l[0];- var content = l.slice(2);- if (type === 'm') {- media.push({rtp: [], fmtp: []});- location = media[media.length-1]; // point at latest media line- }+ var ssrc = simulcastSsrcs[i];+ order.push(ssrc);- for (var j = 0; j < (grammar[type] || []).length; j += 1) {- var obj = grammar[type][j];- if (obj.reg.test(content)) {- return parseReg(obj, location, content);- }- }- });+ var parts = sources[ssrc].msid.split(' ');+ sources[ssrc].msid = [parts[0], '/', i, ' ', parts[1], '/', i].join('');+ sources[ssrc].cname = [sources[ssrc].cname, '/', i].join('');- session.media = media; // link it up- return session;-};+ // Remove all the groups that this SSRC participates in.+ mLine.ssrcGroups.forEach(function (relatedGroup) {+ if (relatedGroup.semantics === 'SIM') {+ return;+ }-var fmtpReducer = function (acc, expr) {- var s = expr.split('=');- if (s.length === 2) {- acc[s[0]] = toIntIfInt(s[1]);- }- return acc;-};+ var relatedSsrcs = relatedGroup.ssrcs.split(' ');+ if (relatedSsrcs.indexOf(ssrc) === -1) {+ return;+ }-exports.parseFmtpConfig = function (str) {- return str.split(/\;\s?/).reduce(fmtpReducer, {});-};+ // Nuke all the related SSRCs.+ relatedSsrcs.forEach(function (relatedSSRC) {+ sources[relatedSSRC].msid = sources[ssrc].msid;+ sources[relatedSSRC].cname = sources[ssrc].cname;+ if (relatedSSRC !== ssrc) {+ order.push(relatedSSRC);+ }+ });-exports.parsePayloads = function (str) {- return str.split(' ').map(Number);-};+ // Schedule the related group for nuking.+ })+ }-exports.parseRemoteCandidates = function (str) {- var candidates = [];- var parts = str.split(' ').map(toIntIfInt);- for (var i = 0; i < parts.length; i += 3) {- candidates.push({- component: parts[i],- ip: parts[i + 1],- port: parts[i + 2]- });- }- return candidates;-};+ mLine.ssrcs = writeSsrcs(sources, order);+ mLine.ssrcGroups.splice(j, 1);+ };+}-},{"./grammar":68}],71:[function(require,module,exports){-var grammar = require('./grammar');+function implodeRemoteSimulcast(mLine) {-// customized util.format - discards excess arguments and can void middle ones-var formatRegExp = /%[sdv%]/g;-var format = function (formatStr) {- var i = 1;- var args = arguments;- var len = args.length;- return formatStr.replace(formatRegExp, function (x) {- if (i >= len) {- return x; // missing argument- }- var arg = args[i];- i += 1;- switch (x) {- case '%%':- return '%';- case '%s':- return String(arg);- case '%d':- return Number(arg);- case '%v':- return '';+ if (!mLine || !Array.isArray(mLine.ssrcGroups)) {+ console.debug('Halt: There are no SSRC groups in the remote ' ++ 'description.');+ return;}- });- // NB: we discard excess arguments - they are typically undefined from makeLine-};-var makeLine = function (type, obj, location) {- var str = obj.format instanceof Function ?- (obj.format(obj.push ? location : location[obj.name])) :- obj.format;-- var args = [type + '=' + str];- if (obj.names) {- for (var i = 0; i < obj.names.length; i += 1) {- var n = obj.names[i];- if (obj.name) {- args.push(location[obj.name][n]);- }- else { // for mLine and push attributes- args.push(location[obj.names[i]]);- }- }- }- else {- args.push(location[obj.name]);- }- return format.apply(null, args);-};--// RFC specified order-// TODO: extend this with all the rest-var defaultOuterOrder = [- 'v', 'o', 's', 'i',- 'u', 'e', 'p', 'c',- 'b', 't', 'r', 'z', 'a'-];-var defaultInnerOrder = ['i', 'c', 'b', 'a'];---module.exports = function (session, opts) {- opts = opts || {};- // ensure certain properties exist- if (session.version == null) {- session.version = 0; // "v=0" must be there (only defined version atm)- }- if (session.name == null) {- session.name = " "; // "s= " must be there if no meaningful name set- }- session.media.forEach(function (mLine) {- if (mLine.payloads == null) {- mLine.payloads = "";- }- });-- var outerOrder = opts.outerOrder || defaultOuterOrder;- var innerOrder = opts.innerOrder || defaultInnerOrder;- var sdp = [];-- // loop through outerOrder for matching properties on session- outerOrder.forEach(function (type) {- grammar[type].forEach(function (obj) {- if (obj.name in session && session[obj.name] != null) {- sdp.push(makeLine(type, obj, session));- }- else if (obj.push in session && session[obj.push] != null) {- session[obj.push].forEach(function (el) {- sdp.push(makeLine(type, obj, el));- });- }- });- });-- // then for each media line, follow the innerOrder- session.media.forEach(function (mLine) {- sdp.push(makeLine('m', grammar.m[0], mLine));-- innerOrder.forEach(function (type) {- grammar[type].forEach(function (obj) {- if (obj.name in mLine && mLine[obj.name] != null) {- sdp.push(makeLine(type, obj, mLine));- }- else if (obj.push in mLine && mLine[obj.push] != null) {- mLine[obj.push].forEach(function (el) {- sdp.push(makeLine(type, obj, el));- });- }- });- });- });-- return sdp.join('\r\n') + '\r\n';-};--},{"./grammar":68}],72:[function(require,module,exports){-/* Copyright @ 2015 Atlassian Pty Ltd- *- * Licensed under the Apache License, Version 2.0 (the "License");- * you may not use this file except in compliance with the License.- * You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */--var transform = require('sdp-transform');-var transformUtils = require('./transform-utils');-var parseSsrcs = transformUtils.parseSsrcs;-var writeSsrcs = transformUtils.writeSsrcs;--//region Constants--var DEFAULT_NUM_OF_LAYERS = 3;--//endregion--//region Ctor--function Simulcast(options) {-- this.options = options ? options : {};-- if (!this.options.numOfLayers) {- this.options.numOfLayers = DEFAULT_NUM_OF_LAYERS;- }-- this.layers = [];-}--//endregion--//region Stateless private utility functions--/**- * Returns a random integer between min (included) and max (excluded)- * Using Math.round() gives a non-uniform distribution!- * @returns {number}- */-function generateSSRC() {- var min = 0, max = 0xffffffff;- return Math.floor(Math.random() * (max - min)) + min;-};--function processVideo(session, action) {- if (session == null || !Array.isArray(session.media)) {- return;- }-- session.media.forEach(function (mLine) {- if (mLine.type === 'video') {- action(mLine);- }- });-}--function validateDescription(desc)-{- return desc && desc != null- && desc.type && desc.type != ''- && desc.sdp && desc.sdp != '';-}--function explodeRemoteSimulcast(mLine) {-- if (!mLine || !Array.isArray(mLine.ssrcGroups)) {- return;- }-- var sources = parseSsrcs(mLine);- var order = [];-- // Find the SIM group and explode its sources.- var j = mLine.ssrcGroups.length;- while (j--) {-- if (mLine.ssrcGroups[j].semantics !== 'SIM') {- continue;- }-- var simulcastSsrcs = mLine.ssrcGroups[j].ssrcs.split(' ');-- for (var i = 0; i < simulcastSsrcs.length; i++) {-- var ssrc = simulcastSsrcs[i];- order.push(ssrc);-- var parts = sources[ssrc].msid.split(' ');- sources[ssrc].msid = [parts[0], '/', i, ' ', parts[1], '/', i].join('');- sources[ssrc].cname = [sources[ssrc].cname, '/', i].join('');-- // Remove all the groups that this SSRC participates in.- mLine.ssrcGroups.forEach(function (relatedGroup) {- if (relatedGroup.semantics === 'SIM') {- return;- }-- var relatedSsrcs = relatedGroup.ssrcs.split(' ');- if (relatedSsrcs.indexOf(ssrc) === -1) {- return;- }-- // Nuke all the related SSRCs.- relatedSsrcs.forEach(function (relatedSSRC) {- sources[relatedSSRC].msid = sources[ssrc].msid;- sources[relatedSSRC].cname = sources[ssrc].cname;- if (relatedSSRC !== ssrc) {- order.push(relatedSSRC);- }- });-- // Schedule the related group for nuking.- })- }-- mLine.ssrcs = writeSsrcs(sources, order);- mLine.ssrcGroups.splice(j, 1);- };-}--function implodeRemoteSimulcast(mLine) {-- if (!mLine || !Array.isArray(mLine.ssrcGroups)) {- console.debug('Halt: There are no SSRC groups in the remote ' +- 'description.');- return;- }-- var sources = parseSsrcs(mLine);+ var sources = parseSsrcs(mLine);// Find the SIM group and nuke it.mLine.ssrcGroups.forEach(function (simulcastGroup) {@@ -22378,180 +21921,984 @@ Simulcast.prototype._restoreSimulcastView = function(mLine) {mLine.ssrcGroups = ssrcGroups;mLine.ssrcs = writeSsrcs(sources);}-}--//endregion--//region "Public" functions--Simulcast.prototype.isSupported = function () {- return window.chrome;-- // TODO this needs improvements. For example I doubt that Chrome in Android- // has simulcast support. Also, only recent versions of Chromium have native- // simulcast support.-}--/**- *- * @param desc- * @returns {RTCSessionDescription}- */-Simulcast.prototype.mungeRemoteDescription = function (desc) {+}++//endregion++//region "Public" functions++Simulcast.prototype.isSupported = function () {+ return window.chrome;++ // TODO this needs improvements. For example I doubt that Chrome in Android+ // has simulcast support. Also, only recent versions of Chromium have native+ // simulcast support.+}++/**+ *+ * @param desc+ * @returns {RTCSessionDescription}+ */+Simulcast.prototype.mungeRemoteDescription = function (desc) {++ if (!validateDescription(desc)) {+ return desc;+ }++ var session = transform.parse(desc.sdp);++ var self = this;+ processVideo(session, function (mLine) {++ // Handle simulcast reception.+ if (self.options.explodeRemoteSimulcast) {+ explodeRemoteSimulcast(mLine);+ } else {+ implodeRemoteSimulcast(mLine);+ }++ // If native simulcast is enabled, we must append the x-goog-conference+ // attribute to the SDP.+ if (self.layers.length < 1) {+ removeGoogConference(mLine);+ } else {+ assertGoogConference(mLine);+ }+ });++ return new RTCSessionDescription({+ type: desc.type,+ sdp: transform.write(session)+ });+};++/**+ *+ * @param desc+ * @returns {RTCSessionDescription}+ */+Simulcast.prototype.mungeLocalDescription = function (desc) {++ if (!validateDescription(desc) || !this.isSupported()) {+ return desc;+ }++ var session = transform.parse(desc.sdp);++ var self = this;+ processVideo(session, function (mLine) {+ // Initialize native simulcast layers, if not already done.+ self._maybeInitializeLayers(mLine);++ // Update the SDP with the simulcast layers.+ self._restoreSimulcastView(mLine);+ });++ return new RTCSessionDescription({+ type: desc.type,+ sdp: transform.write(session)+ });+};++//endregion++module.exports = Simulcast;++},{"./transform-utils":69,"sdp-transform":71}],69:[function(require,module,exports){+/* Copyright @ 2015 Atlassian Pty Ltd+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++exports.writeSsrcs = function(sources, order) {+ var ssrcs = [];++ // expand sources to ssrcs+ if (typeof sources !== 'undefined' &&+ Object.keys(sources).length !== 0) {++ if (Array.isArray(order)) {+ for (var i = 0; i < order.length; i++) {+ var ssrc = order[i];+ var source = sources[ssrc];+ Object.keys(source).forEach(function (attribute) {+ ssrcs.push({+ id: ssrc,+ attribute: attribute,+ value: source[attribute]+ });+ });+ }+ } else {+ Object.keys(sources).forEach(function (ssrc) {+ var source = sources[ssrc];+ Object.keys(source).forEach(function (attribute) {+ ssrcs.push({+ id: ssrc,+ attribute: attribute,+ value: source[attribute]+ });+ });+ });+ }+ }++ return ssrcs;+};++exports.parseSsrcs = function (mLine) {+ var sources = {};+ // group sources attributes by ssrc.+ if (typeof mLine.ssrcs !== 'undefined' && Array.isArray(mLine.ssrcs)) {+ mLine.ssrcs.forEach(function (ssrc) {+ if (!sources[ssrc.id])+ sources[ssrc.id] = {};+ sources[ssrc.id][ssrc.attribute] = ssrc.value;+ });+ }+ return sources;+};+++},{}],70:[function(require,module,exports){+var grammar = module.exports = {+ v: [{+ name: 'version',+ reg: /^(\d*)$/+ }],+ o: [{ //o=- 20518 0 IN IP4 203.0.113.1+ // NB: sessionId will be a String in most cases because it is huge+ name: 'origin',+ reg: /^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,+ names: ['username', 'sessionId', 'sessionVersion', 'netType', 'ipVer', 'address'],+ format: "%s %s %d %s IP%d %s"+ }],+ // default parsing of these only (though some of these feel outdated)+ s: [{ name: 'name' }],+ i: [{ name: 'description' }],+ u: [{ name: 'uri' }],+ e: [{ name: 'email' }],+ p: [{ name: 'phone' }],+ z: [{ name: 'timezones' }], // TODO: this one can actually be parsed properly..+ r: [{ name: 'repeats' }], // TODO: this one can also be parsed properly+ //k: [{}], // outdated thing ignored+ t: [{ //t=0 0+ name: 'timing',+ reg: /^(\d*) (\d*)/,+ names: ['start', 'stop'],+ format: "%d %d"+ }],+ c: [{ //c=IN IP4 10.47.197.26+ name: 'connection',+ reg: /^IN IP(\d) (\S*)/,+ names: ['version', 'ip'],+ format: "IN IP%d %s"+ }],+ b: [{ //b=AS:4000+ push: 'bandwidth',+ reg: /^(TIAS|AS|CT|RR|RS):(\d*)/,+ names: ['type', 'limit'],+ format: "%s:%s"+ }],+ m: [{ //m=video 51744 RTP/AVP 126 97 98 34 31+ // NB: special - pushes to session+ // TODO: rtp/fmtp should be filtered by the payloads found here?+ reg: /^(\w*) (\d*) ([\w\/]*)(?: (.*))?/,+ names: ['type', 'port', 'protocol', 'payloads'],+ format: "%s %d %s %s"+ }],+ a: [+ { //a=rtpmap:110 opus/48000/2+ push: 'rtp',+ reg: /^rtpmap:(\d*) ([\w\-]*)\/(\d*)(?:\s*\/(\S*))?/,+ names: ['payload', 'codec', 'rate', 'encoding'],+ format: function (o) {+ return (o.encoding) ?+ "rtpmap:%d %s/%s/%s":+ "rtpmap:%d %s/%s";+ }+ },+ { //a=fmtp:108 profile-level-id=24;object=23;bitrate=64000+ push: 'fmtp',+ reg: /^fmtp:(\d*) (\S*)/,+ names: ['payload', 'config'],+ format: "fmtp:%d %s"+ },+ { //a=control:streamid=0+ name: 'control',+ reg: /^control:(.*)/,+ format: "control:%s"+ },+ { //a=rtcp:65179 IN IP4 193.84.77.194+ name: 'rtcp',+ reg: /^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,+ names: ['port', 'netType', 'ipVer', 'address'],+ format: function (o) {+ return (o.address != null) ?+ "rtcp:%d %s IP%d %s":+ "rtcp:%d";+ }+ },+ { //a=rtcp-fb:98 trr-int 100+ push: 'rtcpFbTrrInt',+ reg: /^rtcp-fb:(\*|\d*) trr-int (\d*)/,+ names: ['payload', 'value'],+ format: "rtcp-fb:%d trr-int %d"+ },+ { //a=rtcp-fb:98 nack rpsi+ push: 'rtcpFb',+ reg: /^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,+ names: ['payload', 'type', 'subtype'],+ format: function (o) {+ return (o.subtype != null) ?+ "rtcp-fb:%s %s %s":+ "rtcp-fb:%s %s";+ }+ },+ { //a=extmap:2 urn:ietf:params:rtp-hdrext:toffset+ //a=extmap:1/recvonly URI-gps-string+ push: 'ext',+ reg: /^extmap:([\w_\/]*) (\S*)(?: (\S*))?/,+ names: ['value', 'uri', 'config'], // value may include "/direction" suffix+ format: function (o) {+ return (o.config != null) ?+ "extmap:%s %s %s":+ "extmap:%s %s";+ }+ },+ {+ //a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:PS1uQCVeeCFCanVmcjkpPywjNWhcYD0mXXtxaVBR|2^20|1:32+ push: 'crypto',+ reg: /^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,+ names: ['id', 'suite', 'config', 'sessionConfig'],+ format: function (o) {+ return (o.sessionConfig != null) ?+ "crypto:%d %s %s %s":+ "crypto:%d %s %s";+ }+ },+ { //a=setup:actpass+ name: 'setup',+ reg: /^setup:(\w*)/,+ format: "setup:%s"+ },+ { //a=mid:1+ name: 'mid',+ reg: /^mid:([^\s]*)/,+ format: "mid:%s"+ },+ { //a=msid:0c8b064d-d807-43b4-b434-f92a889d8587 98178685-d409-46e0-8e16-7ef0db0db64a+ name: 'msid',+ reg: /^msid:(.*)/,+ format: "msid:%s"+ },+ { //a=ptime:20+ name: 'ptime',+ reg: /^ptime:(\d*)/,+ format: "ptime:%d"+ },+ { //a=maxptime:60+ name: 'maxptime',+ reg: /^maxptime:(\d*)/,+ format: "maxptime:%d"+ },+ { //a=sendrecv+ name: 'direction',+ reg: /^(sendrecv|recvonly|sendonly|inactive)/+ },+ { //a=ice-lite+ name: 'icelite',+ reg: /^(ice-lite)/+ },+ { //a=ice-ufrag:F7gI+ name: 'iceUfrag',+ reg: /^ice-ufrag:(\S*)/,+ format: "ice-ufrag:%s"+ },+ { //a=ice-pwd:x9cml/YzichV2+XlhiMu8g+ name: 'icePwd',+ reg: /^ice-pwd:(\S*)/,+ format: "ice-pwd:%s"+ },+ { //a=fingerprint:SHA-1 00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF:00:11:22:33+ name: 'fingerprint',+ reg: /^fingerprint:(\S*) (\S*)/,+ names: ['type', 'hash'],+ format: "fingerprint:%s %s"+ },+ {+ //a=candidate:0 1 UDP 2113667327 203.0.113.1 54400 typ host+ //a=candidate:1162875081 1 udp 2113937151 192.168.34.75 60017 typ host generation 0+ //a=candidate:3289912957 2 udp 1845501695 193.84.77.194 60017 typ srflx raddr 192.168.34.75 rport 60017 generation 0+ push:'candidates',+ reg: /^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: generation (\d*))?/,+ names: ['foundation', 'component', 'transport', 'priority', 'ip', 'port', 'type', 'raddr', 'rport', 'generation'],+ format: function (o) {+ var str = "candidate:%s %d %s %d %s %d typ %s";+ // NB: candidate has two optional chunks, so %void middle one if it's missing+ str += (o.raddr != null) ? " raddr %s rport %d" : "%v%v";+ if (o.generation != null) {+ str += " generation %d";+ }+ return str;+ }+ },+ { //a=end-of-candidates (keep after the candidates line for readability)+ name: 'endOfCandidates',+ reg: /^(end-of-candidates)/+ },+ { //a=remote-candidates:1 203.0.113.1 54400 2 203.0.113.1 54401 ...+ name: 'remoteCandidates',+ reg: /^remote-candidates:(.*)/,+ format: "remote-candidates:%s"+ },+ { //a=ice-options:google-ice+ name: 'iceOptions',+ reg: /^ice-options:(\S*)/,+ format: "ice-options:%s"+ },+ { //a=ssrc:2566107569 cname:t9YU8M1UxTF8Y1A1+ push: "ssrcs",+ reg: /^ssrc:(\d*) ([\w_]*):(.*)/,+ names: ['id', 'attribute', 'value'],+ format: "ssrc:%d %s:%s"+ },+ { //a=ssrc-group:FEC 1 2+ push: "ssrcGroups",+ reg: /^ssrc-group:(\w*) (.*)/,+ names: ['semantics', 'ssrcs'],+ format: "ssrc-group:%s %s"+ },+ { //a=msid-semantic: WMS Jvlam5X3SX1OP6pn20zWogvaKJz5Hjf9OnlV+ name: "msidSemantic",+ reg: /^msid-semantic:\s?(\w*) (\S*)/,+ names: ['semantic', 'token'],+ format: "msid-semantic: %s %s" // space after ":" is not accidental+ },+ { //a=group:BUNDLE audio video+ push: 'groups',+ reg: /^group:(\w*) (.*)/,+ names: ['type', 'mids'],+ format: "group:%s %s"+ },+ { //a=rtcp-mux+ name: 'rtcpMux',+ reg: /^(rtcp-mux)/+ },+ { //a=rtcp-rsize+ name: 'rtcpRsize',+ reg: /^(rtcp-rsize)/+ },+ { // any a= that we don't understand is kepts verbatim on media.invalid+ push: 'invalid',+ names: ["value"]+ }+ ]+};++// set sensible defaults to avoid polluting the grammar with boring details+Object.keys(grammar).forEach(function (key) {+ var objs = grammar[key];+ objs.forEach(function (obj) {+ if (!obj.reg) {+ obj.reg = /(.*)/;+ }+ if (!obj.format) {+ obj.format = "%s";+ }+ });+});++},{}],71:[function(require,module,exports){+var parser = require('./parser');+var writer = require('./writer');++exports.write = writer;+exports.parse = parser.parse;+exports.parseFmtpConfig = parser.parseFmtpConfig;+exports.parsePayloads = parser.parsePayloads;+exports.parseRemoteCandidates = parser.parseRemoteCandidates;++},{"./parser":72,"./writer":73}],72:[function(require,module,exports){+var toIntIfInt = function (v) {+ return String(Number(v)) === v ? Number(v) : v;+};++var attachProperties = function (match, location, names, rawName) {+ if (rawName && !names) {+ location[rawName] = toIntIfInt(match[1]);+ }+ else {+ for (var i = 0; i < names.length; i += 1) {+ if (match[i+1] != null) {+ location[names[i]] = toIntIfInt(match[i+1]);+ }+ }+ }+};++var parseReg = function (obj, location, content) {+ var needsBlank = obj.name && obj.names;+ if (obj.push && !location[obj.push]) {+ location[obj.push] = [];+ }+ else if (needsBlank && !location[obj.name]) {+ location[obj.name] = {};+ }+ var keyLocation = obj.push ?+ {} : // blank object that will be pushed+ needsBlank ? location[obj.name] : location; // otherwise, named location or root++ attachProperties(content.match(obj.reg), keyLocation, obj.names, obj.name);++ if (obj.push) {+ location[obj.push].push(keyLocation);+ }+};++var grammar = require('./grammar');+var validLine = RegExp.prototype.test.bind(/^([a-z])=(.*)/);++exports.parse = function (sdp) {+ var session = {}+ , media = []+ , location = session; // points at where properties go under (one of the above)++ // parse lines we understand+ sdp.split(/(\r\n|\r|\n)/).filter(validLine).forEach(function (l) {+ var type = l[0];+ var content = l.slice(2);+ if (type === 'm') {+ media.push({rtp: [], fmtp: []});+ location = media[media.length-1]; // point at latest media line+ }++ for (var j = 0; j < (grammar[type] || []).length; j += 1) {+ var obj = grammar[type][j];+ if (obj.reg.test(content)) {+ return parseReg(obj, location, content);+ }+ }+ });++ session.media = media; // link it up+ return session;+};++var fmtpReducer = function (acc, expr) {+ var s = expr.split('=');+ if (s.length === 2) {+ acc[s[0]] = toIntIfInt(s[1]);+ }+ return acc;+};++exports.parseFmtpConfig = function (str) {+ return str.split(';').reduce(fmtpReducer, {});+};++exports.parsePayloads = function (str) {+ return str.split(' ').map(Number);+};++exports.parseRemoteCandidates = function (str) {+ var candidates = [];+ var parts = str.split(' ').map(toIntIfInt);+ for (var i = 0; i < parts.length; i += 3) {+ candidates.push({+ component: parts[i],+ ip: parts[i + 1],+ port: parts[i + 2]+ });+ }+ return candidates;+};++},{"./grammar":70}],73:[function(require,module,exports){+var grammar = require('./grammar');++// customized util.format - discards excess arguments and can void middle ones+var formatRegExp = /%[sdv%]/g;+var format = function (formatStr) {+ var i = 1;+ var args = arguments;+ var len = args.length;+ return formatStr.replace(formatRegExp, function (x) {+ if (i >= len) {+ return x; // missing argument+ }+ var arg = args[i];+ i += 1;+ switch (x) {+ case '%%':+ return '%';+ case '%s':+ return String(arg);+ case '%d':+ return Number(arg);+ case '%v':+ return '';+ }+ });+ // NB: we discard excess arguments - they are typically undefined from makeLine+};++var makeLine = function (type, obj, location) {+ var str = obj.format instanceof Function ?+ (obj.format(obj.push ? location : location[obj.name])) :+ obj.format;++ var args = [type + '=' + str];+ if (obj.names) {+ for (var i = 0; i < obj.names.length; i += 1) {+ var n = obj.names[i];+ if (obj.name) {+ args.push(location[obj.name][n]);+ }+ else { // for mLine and push attributes+ args.push(location[obj.names[i]]);+ }+ }+ }+ else {+ args.push(location[obj.name]);+ }+ return format.apply(null, args);+};++// RFC specified order+// TODO: extend this with all the rest+var defaultOuterOrder = [+ 'v', 'o', 's', 'i',+ 'u', 'e', 'p', 'c',+ 'b', 't', 'r', 'z', 'a'+];+var defaultInnerOrder = ['i', 'c', 'b', 'a'];+++module.exports = function (session, opts) {+ opts = opts || {};+ // ensure certain properties exist+ if (session.version == null) {+ session.version = 0; // "v=0" must be there (only defined version atm)+ }+ if (session.name == null) {+ session.name = " "; // "s= " must be there if no meaningful name set+ }+ session.media.forEach(function (mLine) {+ if (mLine.payloads == null) {+ mLine.payloads = "";+ }+ });++ var outerOrder = opts.outerOrder || defaultOuterOrder;+ var innerOrder = opts.innerOrder || defaultInnerOrder;+ var sdp = [];++ // loop through outerOrder for matching properties on session+ outerOrder.forEach(function (type) {+ grammar[type].forEach(function (obj) {+ if (obj.name in session && session[obj.name] != null) {+ sdp.push(makeLine(type, obj, session));+ }+ else if (obj.push in session && session[obj.push] != null) {+ session[obj.push].forEach(function (el) {+ sdp.push(makeLine(type, obj, el));+ });+ }+ });+ });++ // then for each media line, follow the innerOrder+ session.media.forEach(function (mLine) {+ sdp.push(makeLine('m', grammar.m[0], mLine));++ innerOrder.forEach(function (type) {+ grammar[type].forEach(function (obj) {+ if (obj.name in mLine && mLine[obj.name] != null) {+ sdp.push(makeLine(type, obj, mLine));+ }+ else if (obj.push in mLine && mLine[obj.push] != null) {+ mLine[obj.push].forEach(function (el) {+ sdp.push(makeLine(type, obj, el));+ });+ }+ });+ });+ });++ return sdp.join('\r\n') + '\r\n';+};++},{"./grammar":70}],74:[function(require,module,exports){+var grammar = module.exports = {+ v: [{+ name: 'version',+ reg: /^(\d*)$/+ }],+ o: [{ //o=- 20518 0 IN IP4 203.0.113.1+ // NB: sessionId will be a String in most cases because it is huge+ name: 'origin',+ reg: /^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,+ names: ['username', 'sessionId', 'sessionVersion', 'netType', 'ipVer', 'address'],+ format: "%s %s %d %s IP%d %s"+ }],+ // default parsing of these only (though some of these feel outdated)+ s: [{ name: 'name' }],+ i: [{ name: 'description' }],+ u: [{ name: 'uri' }],+ e: [{ name: 'email' }],+ p: [{ name: 'phone' }],+ z: [{ name: 'timezones' }], // TODO: this one can actually be parsed properly..+ r: [{ name: 'repeats' }], // TODO: this one can also be parsed properly+ //k: [{}], // outdated thing ignored+ t: [{ //t=0 0+ name: 'timing',+ reg: /^(\d*) (\d*)/,+ names: ['start', 'stop'],+ format: "%d %d"+ }],+ c: [{ //c=IN IP4 10.47.197.26+ name: 'connection',+ reg: /^IN IP(\d) (\S*)/,+ names: ['version', 'ip'],+ format: "IN IP%d %s"+ }],+ b: [{ //b=AS:4000+ push: 'bandwidth',+ reg: /^(TIAS|AS|CT|RR|RS):(\d*)/,+ names: ['type', 'limit'],+ format: "%s:%s"+ }],+ m: [{ //m=video 51744 RTP/AVP 126 97 98 34 31+ // NB: special - pushes to session+ // TODO: rtp/fmtp should be filtered by the payloads found here?+ reg: /^(\w*) (\d*) ([\w\/]*)(?: (.*))?/,+ names: ['type', 'port', 'protocol', 'payloads'],+ format: "%s %d %s %s"+ }],+ a: [+ { //a=rtpmap:110 opus/48000/2+ push: 'rtp',+ reg: /^rtpmap:(\d*) ([\w\-]*)\/(\d*)(?:\s*\/(\S*))?/,+ names: ['payload', 'codec', 'rate', 'encoding'],+ format: function (o) {+ return (o.encoding) ?+ "rtpmap:%d %s/%s/%s":+ "rtpmap:%d %s/%s";+ }+ },+ {+ //a=fmtp:108 profile-level-id=24;object=23;bitrate=64000+ //a=fmtp:111 minptime=10; useinbandfec=1+ push: 'fmtp',+ reg: /^fmtp:(\d*) ([\S| ]*)/,+ names: ['payload', 'config'],+ format: "fmtp:%d %s"+ },+ { //a=control:streamid=0+ name: 'control',+ reg: /^control:(.*)/,+ format: "control:%s"+ },+ { //a=rtcp:65179 IN IP4 193.84.77.194+ name: 'rtcp',+ reg: /^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,+ names: ['port', 'netType', 'ipVer', 'address'],+ format: function (o) {+ return (o.address != null) ?+ "rtcp:%d %s IP%d %s":+ "rtcp:%d";+ }+ },+ { //a=rtcp-fb:98 trr-int 100+ push: 'rtcpFbTrrInt',+ reg: /^rtcp-fb:(\*|\d*) trr-int (\d*)/,+ names: ['payload', 'value'],+ format: "rtcp-fb:%d trr-int %d"+ },+ { //a=rtcp-fb:98 nack rpsi+ push: 'rtcpFb',+ reg: /^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,+ names: ['payload', 'type', 'subtype'],+ format: function (o) {+ return (o.subtype != null) ?+ "rtcp-fb:%s %s %s":+ "rtcp-fb:%s %s";+ }+ },+ { //a=extmap:2 urn:ietf:params:rtp-hdrext:toffset+ //a=extmap:1/recvonly URI-gps-string+ push: 'ext',+ reg: /^extmap:([\w_\/]*) (\S*)(?: (\S*))?/,+ names: ['value', 'uri', 'config'], // value may include "/direction" suffix+ format: function (o) {+ return (o.config != null) ?+ "extmap:%s %s %s":+ "extmap:%s %s";+ }+ },+ {+ //a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:PS1uQCVeeCFCanVmcjkpPywjNWhcYD0mXXtxaVBR|2^20|1:32+ push: 'crypto',+ reg: /^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,+ names: ['id', 'suite', 'config', 'sessionConfig'],+ format: function (o) {+ return (o.sessionConfig != null) ?+ "crypto:%d %s %s %s":+ "crypto:%d %s %s";+ }+ },+ { //a=setup:actpass+ name: 'setup',+ reg: /^setup:(\w*)/,+ format: "setup:%s"+ },+ { //a=mid:1+ name: 'mid',+ reg: /^mid:([^\s]*)/,+ format: "mid:%s"+ },+ { //a=msid:0c8b064d-d807-43b4-b434-f92a889d8587 98178685-d409-46e0-8e16-7ef0db0db64a+ name: 'msid',+ reg: /^msid:(.*)/,+ format: "msid:%s"+ },+ { //a=ptime:20+ name: 'ptime',+ reg: /^ptime:(\d*)/,+ format: "ptime:%d"+ },+ { //a=maxptime:60+ name: 'maxptime',+ reg: /^maxptime:(\d*)/,+ format: "maxptime:%d"+ },+ { //a=sendrecv+ name: 'direction',+ reg: /^(sendrecv|recvonly|sendonly|inactive)/+ },+ { //a=ice-lite+ name: 'icelite',+ reg: /^(ice-lite)/+ },+ { //a=ice-ufrag:F7gI+ name: 'iceUfrag',+ reg: /^ice-ufrag:(\S*)/,+ format: "ice-ufrag:%s"+ },+ { //a=ice-pwd:x9cml/YzichV2+XlhiMu8g+ name: 'icePwd',+ reg: /^ice-pwd:(\S*)/,+ format: "ice-pwd:%s"+ },+ { //a=fingerprint:SHA-1 00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF:00:11:22:33+ name: 'fingerprint',+ reg: /^fingerprint:(\S*) (\S*)/,+ names: ['type', 'hash'],+ format: "fingerprint:%s %s"+ },+ {+ //a=candidate:0 1 UDP 2113667327 203.0.113.1 54400 typ host+ //a=candidate:1162875081 1 udp 2113937151 192.168.34.75 60017 typ host generation 0+ //a=candidate:3289912957 2 udp 1845501695 193.84.77.194 60017 typ srflx raddr 192.168.34.75 rport 60017 generation 0+ push:'candidates',+ reg: /^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: generation (\d*))?/,+ names: ['foundation', 'component', 'transport', 'priority', 'ip', 'port', 'type', 'raddr', 'rport', 'generation'],+ format: function (o) {+ var str = "candidate:%s %d %s %d %s %d typ %s";+ // NB: candidate has two optional chunks, so %void middle one if it's missing+ str += (o.raddr != null) ? " raddr %s rport %d" : "%v%v";+ if (o.generation != null) {+ str += " generation %d";+ }+ return str;+ }+ },+ { //a=end-of-candidates (keep after the candidates line for readability)+ name: 'endOfCandidates',+ reg: /^(end-of-candidates)/+ },+ { //a=remote-candidates:1 203.0.113.1 54400 2 203.0.113.1 54401 ...+ name: 'remoteCandidates',+ reg: /^remote-candidates:(.*)/,+ format: "remote-candidates:%s"+ },+ { //a=ice-options:google-ice+ name: 'iceOptions',+ reg: /^ice-options:(\S*)/,+ format: "ice-options:%s"+ },+ { //a=ssrc:2566107569 cname:t9YU8M1UxTF8Y1A1+ push: "ssrcs",+ reg: /^ssrc:(\d*) ([\w_]*):(.*)/,+ names: ['id', 'attribute', 'value'],+ format: "ssrc:%d %s:%s"+ },+ { //a=ssrc-group:FEC 1 2+ push: "ssrcGroups",+ reg: /^ssrc-group:(\w*) (.*)/,+ names: ['semantics', 'ssrcs'],+ format: "ssrc-group:%s %s"+ },+ { //a=msid-semantic: WMS Jvlam5X3SX1OP6pn20zWogvaKJz5Hjf9OnlV+ name: "msidSemantic",+ reg: /^msid-semantic:\s?(\w*) (\S*)/,+ names: ['semantic', 'token'],+ format: "msid-semantic: %s %s" // space after ":" is not accidental+ },+ { //a=group:BUNDLE audio video+ push: 'groups',+ reg: /^group:(\w*) (.*)/,+ names: ['type', 'mids'],+ format: "group:%s %s"+ },+ { //a=rtcp-mux+ name: 'rtcpMux',+ reg: /^(rtcp-mux)/+ },+ { //a=rtcp-rsize+ name: 'rtcpRsize',+ reg: /^(rtcp-rsize)/+ },+ { // any a= that we don't understand is kepts verbatim on media.invalid+ push: 'invalid',+ names: ["value"]+ }+ ]+};- if (!validateDescription(desc)) {- return desc;+// set sensible defaults to avoid polluting the grammar with boring details+Object.keys(grammar).forEach(function (key) {+ var objs = grammar[key];+ objs.forEach(function (obj) {+ if (!obj.reg) {+ obj.reg = /(.*)/;}+ if (!obj.format) {+ obj.format = "%s";+ }+ });+});- var session = transform.parse(desc.sdp);-- var self = this;- processVideo(session, function (mLine) {-- // Handle simulcast reception.- if (self.options.explodeRemoteSimulcast) {- explodeRemoteSimulcast(mLine);- } else {- implodeRemoteSimulcast(mLine);- }-- // If native simulcast is enabled, we must append the x-goog-conference- // attribute to the SDP.- if (self.layers.length < 1) {- removeGoogConference(mLine);- } else {- assertGoogConference(mLine);- }- });-- return new RTCSessionDescription({- type: desc.type,- sdp: transform.write(session)- });+},{}],75:[function(require,module,exports){+arguments[4][71][0].apply(exports,arguments)+},{"./parser":76,"./writer":77,"dup":71}],76:[function(require,module,exports){+var toIntIfInt = function (v) {+ return String(Number(v)) === v ? Number(v) : v;};-/**- *- * @param desc- * @returns {RTCSessionDescription}- */-Simulcast.prototype.mungeLocalDescription = function (desc) {-- if (!validateDescription(desc) || !this.isSupported()) {- return desc;+var attachProperties = function (match, location, names, rawName) {+ if (rawName && !names) {+ location[rawName] = toIntIfInt(match[1]);+ }+ else {+ for (var i = 0; i < names.length; i += 1) {+ if (match[i+1] != null) {+ location[names[i]] = toIntIfInt(match[i+1]);+ }}+ }+};- var session = transform.parse(desc.sdp);-- var self = this;- processVideo(session, function (mLine) {- // Initialize native simulcast layers, if not already done.- self._maybeInitializeLayers(mLine);+var parseReg = function (obj, location, content) {+ var needsBlank = obj.name && obj.names;+ if (obj.push && !location[obj.push]) {+ location[obj.push] = [];+ }+ else if (needsBlank && !location[obj.name]) {+ location[obj.name] = {};+ }+ var keyLocation = obj.push ?+ {} : // blank object that will be pushed+ needsBlank ? location[obj.name] : location; // otherwise, named location or root- // Update the SDP with the simulcast layers.- self._restoreSimulcastView(mLine);- });+ attachProperties(content.match(obj.reg), keyLocation, obj.names, obj.name);- return new RTCSessionDescription({- type: desc.type,- sdp: transform.write(session)- });+ if (obj.push) {+ location[obj.push].push(keyLocation);+ }};-//endregion--module.exports = Simulcast;--},{"./transform-utils":73,"sdp-transform":75}],73:[function(require,module,exports){-/* Copyright @ 2015 Atlassian Pty Ltd- *- * Licensed under the Apache License, Version 2.0 (the "License");- * you may not use this file except in compliance with the License.- * You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */+var grammar = require('./grammar');+var validLine = RegExp.prototype.test.bind(/^([a-z])=(.*)/);-exports.writeSsrcs = function(sources, order) {- var ssrcs = [];+exports.parse = function (sdp) {+ var session = {}+ , media = []+ , location = session; // points at where properties go under (one of the above)- // expand sources to ssrcs- if (typeof sources !== 'undefined' &&- Object.keys(sources).length !== 0) {+ // parse lines we understand+ sdp.split(/(\r\n|\r|\n)/).filter(validLine).forEach(function (l) {+ var type = l[0];+ var content = l.slice(2);+ if (type === 'm') {+ media.push({rtp: [], fmtp: []});+ location = media[media.length-1]; // point at latest media line+ }- if (Array.isArray(order)) {- for (var i = 0; i < order.length; i++) {- var ssrc = order[i];- var source = sources[ssrc];- Object.keys(source).forEach(function (attribute) {- ssrcs.push({- id: ssrc,- attribute: attribute,- value: source[attribute]- });- });+ for (var j = 0; j < (grammar[type] || []).length; j += 1) {+ var obj = grammar[type][j];+ if (obj.reg.test(content)) {+ return parseReg(obj, location, content);}- } else {- Object.keys(sources).forEach(function (ssrc) {- var source = sources[ssrc];- Object.keys(source).forEach(function (attribute) {- ssrcs.push({- id: ssrc,- attribute: attribute,- value: source[attribute]- });- });- });}+ });++ session.media = media; // link it up+ return session;+};++var fmtpReducer = function (acc, expr) {+ var s = expr.split('=');+ if (s.length === 2) {+ acc[s[0]] = toIntIfInt(s[1]);}+ return acc;+};- return ssrcs;+exports.parseFmtpConfig = function (str) {+ return str.split(/\;\s?/).reduce(fmtpReducer, {});};-exports.parseSsrcs = function (mLine) {- var sources = {};- // group sources attributes by ssrc.- if (typeof mLine.ssrcs !== 'undefined' && Array.isArray(mLine.ssrcs)) {- mLine.ssrcs.forEach(function (ssrc) {- if (!sources[ssrc.id])- sources[ssrc.id] = {};- sources[ssrc.id][ssrc.attribute] = ssrc.value;+exports.parsePayloads = function (str) {+ return str.split(' ').map(Number);+};++exports.parseRemoteCandidates = function (str) {+ var candidates = [];+ var parts = str.split(' ').map(toIntIfInt);+ for (var i = 0; i < parts.length; i += 3) {+ candidates.push({+ component: parts[i],+ ip: parts[i + 1],+ port: parts[i + 2]});}- return sources;+ return candidates;};--},{}],74:[function(require,module,exports){-arguments[4][68][0].apply(exports,arguments)-},{"dup":68}],75:[function(require,module,exports){-arguments[4][69][0].apply(exports,arguments)-},{"./parser":76,"./writer":77,"dup":69}],76:[function(require,module,exports){-arguments[4][70][0].apply(exports,arguments)-},{"./grammar":74,"dup":70}],77:[function(require,module,exports){-arguments[4][71][0].apply(exports,arguments)-},{"./grammar":74,"dup":71}],78:[function(require,module,exports){-arguments[4][68][0].apply(exports,arguments)-},{"dup":68}],79:[function(require,module,exports){-arguments[4][69][0].apply(exports,arguments)-},{"./parser":80,"./writer":81,"dup":69}],80:[function(require,module,exports){-arguments[4][70][0].apply(exports,arguments)-},{"./grammar":78,"dup":70}],81:[function(require,module,exports){-arguments[4][71][0].apply(exports,arguments)-},{"./grammar":78,"dup":71}],82:[function(require,module,exports){+},{"./grammar":74}],77:[function(require,module,exports){+arguments[4][73][0].apply(exports,arguments)+},{"./grammar":74,"dup":73}],78:[function(require,module,exports){var MediaStreamType = {VIDEO_TYPE: "Video",AUDIO_TYPE: "Audio"};module.exports = MediaStreamType;-},{}],83:[function(require,module,exports){+},{}],79:[function(require,module,exports){var RTCEvents = {RTC_READY: "rtc.ready",DATA_CHANNEL_OPEN: "rtc.data_channel_open",@@ -22562,7 +22909,7 @@ var RTCEvents = {};module.exports = RTCEvents;-},{}],84:[function(require,module,exports){+},{}],80:[function(require,module,exports){var Resolutions = {"1080": {width: 1920,@@ -22616,7 +22963,7 @@ var Resolutions = {}};module.exports = Resolutions;-},{}],85:[function(require,module,exports){+},{}],81:[function(require,module,exports){var AuthenticationEvents = {/*** Event callback arguments:@@ -22630,7 +22977,7 @@ var AuthenticationEvents = {};module.exports = AuthenticationEvents;-},{}],86:[function(require,module,exports){+},{}],82:[function(require,module,exports){var DesktopSharingEventTypes = {INIT: "ds.init",@@ -22646,7 +22993,7 @@ var DesktopSharingEventTypes = {module.exports = DesktopSharingEventTypes;-},{}],87:[function(require,module,exports){+},{}],83:[function(require,module,exports){module.exports = {/*** An event carrying connection statistics.@@ -22662,12 +23009,12 @@ module.exports = {STOP: "statistics.stop"};-},{}],88:[function(require,module,exports){+},{}],84:[function(require,module,exports){var Constants = {LOCAL_JID: 'local'};module.exports = Constants;-},{}],89:[function(require,module,exports){+},{}],85:[function(require,module,exports){var XMPPEvents = {// Designates an event indicating that the connection to the XMPP server// failed.diff --git a/modules/UI/UI.js b/modules/UI/UI.jsindex 96e3b96b76..f2936a1adf 100644--- a/modules/UI/UI.js+++ b/modules/UI/UI.js@@ -1,31 +1,33 @@-/* global Strophe, APP, $, config, interfaceConfig, toastr */+/* global APP, $, config, interfaceConfig, toastr *//* jshint -W101 */var UI = {};-var VideoLayout = require("./videolayout/VideoLayout");-var AudioLevels = require("./audio_levels/AudioLevels");+import AudioLevels from './audio_levels/AudioLevels';+import Chat from "./side_pannels/chat/Chat";+import Toolbar from "./toolbars/Toolbar";+import ToolbarToggler from "./toolbars/ToolbarToggler";+import BottomToolbar from "./toolbars/BottomToolbar";+import ContactList from "./side_pannels/contactlist/ContactList";+import Avatar from "./avatar/Avatar";+import PanelToggler from "./side_pannels/SidePanelToggler";+import UIUtil from "./util/UIUtil";+import UIEvents from "../../service/UI/UIEvents";++import VideoLayout from "./videolayout/VideoLayout";+var Prezi = require("./prezi/Prezi");var Etherpad = require("./etherpad/Etherpad");-var Chat = require("./side_pannels/chat/Chat");-var Toolbar = require("./toolbars/Toolbar");-var ToolbarToggler = require("./toolbars/ToolbarToggler");-var BottomToolbar = require("./toolbars/BottomToolbar");-var ContactList = require("./side_pannels/contactlist/ContactList");-var Avatar = require("./avatar/Avatar");var EventEmitter = require("events");var SettingsMenu = require("./side_pannels/settings/SettingsMenu");var Settings = require("./../settings/Settings");-var PanelToggler = require("./side_pannels/SidePanelToggler");UI.messageHandler = require("./util/MessageHandler");var messageHandler = UI.messageHandler;var Authentication = require("./authentication/Authentication");-var UIUtil = require("./util/UIUtil");var JitsiPopover = require("./util/JitsiPopover");var CQEvents = require("../../service/connectionquality/CQEvents");var DesktopSharingEventTypes= require("../../service/desktopsharing/DesktopSharingEventTypes");var StatisticsEvents = require("../../service/statistics/Events");-var UIEvents = require("../../service/UI/UIEvents");var Feedback = require("./Feedback");var eventEmitter = new EventEmitter();@@ -352,7 +354,7 @@ function initEtherpad(name) {Etherpad.init(name);}-UI.addUser = function (jid, id, displayName) {+UI.addUser = function (id, displayName) {messageHandler.notify(displayName,'notify.somebody', 'connected', 'notify.connected');@@ -362,16 +364,14 @@ UI.addUser = function (jid, id, displayName) {UIUtil.playSoundNotification('userJoined');// Configure avatar- UI.setUserAvatar(jid, id);+ UI.setUserAvatar(id, displayName);// Add Peer's container- VideoLayout.ensurePeerContainerExists(jid);+ VideoLayout.ensurePeerContainerExists(id);};-UI.removeUser = function (jid) {- console.log('left.muc', jid);- var displayName = $('#participant_' + Strophe.getResourceFromJid(jid) +- '>.displayname').html();+UI.removeUser = function (id, displayName) {+ console.log('left.muc', id);messageHandler.notify(displayName,'notify.somebody','disconnected','notify.disconnected');@@ -380,9 +380,9 @@ UI.removeUser = function (jid) {UIUtil.playSoundNotification('userLeft');}- ContactList.removeContact(jid);+ ContactList.removeContact(id);- VideoLayout.participantLeft(jid);+ VideoLayout.participantLeft(id);};function onMucPresenceStatus(jid, info) {@@ -601,7 +601,7 @@ UI.handleLastNEndpoints = function (ids) {UI.setAudioLevel = function (id, lvl) {AudioLevels.updateAudioLevel(- id, lvl, VideoLayout.getLargeVideoResource()+ id, lvl, VideoLayout.getLargeVideoId());};diff --git a/modules/UI/audio_levels/AudioLevels.js b/modules/UI/audio_levels/AudioLevels.jsindex a158cd79a8..2e99fe94d3 100644--- a/modules/UI/audio_levels/AudioLevels.js+++ b/modules/UI/audio_levels/AudioLevels.js@@ -248,8 +248,7 @@ const AudioLevels = {// Fill the shape.ASDrawContext.fill();- },-+ }};export default AudioLevels;diff --git a/modules/UI/prezi/Prezi.js b/modules/UI/prezi/Prezi.jsindex cd5ce88cf8..4c2b6c61ba 100644--- a/modules/UI/prezi/Prezi.js+++ b/modules/UI/prezi/Prezi.js@@ -1,5 +1,8 @@-var UIUtil = require("../util/UIUtil");-var VideoLayout = require("../videolayout/VideoLayout");+/* global $, APP */+/* jshint -W101 */+import UIUtil from "../util/UIUtil";+import VideoLayout from "../videolayout/VideoLayout";+var messageHandler = require("../util/MessageHandler");var PreziPlayer = require("./PreziPlayer");diff --git a/modules/UI/util/UIUtil.js b/modules/UI/util/UIUtil.jsindex 0371a896e6..fec900d2a2 100644--- a/modules/UI/util/UIUtil.js+++ b/modules/UI/util/UIUtil.js@@ -1,13 +1,15 @@/* global $, config, interfaceConfig */++import PanelToggler from "../side_pannels/SidePanelToggler";+/*** Created by hristo on 12/22/14.*/-var UIUtil = module.exports = {+ var UIUtil = {/*** Returns the available video width.*/getAvailableVideoWidth: function (isVisible) {- var PanelToggler = require("../side_pannels/SidePanelToggler");if(typeof isVisible === "undefined" || isVisible === null)isVisible = PanelToggler.isVisible();var rightPanelWidth@@ -114,3 +116,5 @@ var UIUtil = module.exports = {$(selector).hide();}};++export default UIUtil;diff --git a/modules/UI/videolayout/ConnectionIndicator.js b/modules/UI/videolayout/ConnectionIndicator.jsindex 4ee8ae5de7..80b5a2fd6b 100644--- a/modules/UI/videolayout/ConnectionIndicator.js+++ b/modules/UI/videolayout/ConnectionIndicator.js@@ -1,13 +1,13 @@/* global APP, $ *//* jshint -W101 */-var JitsiPopover = require("../util/JitsiPopover");+import JitsiPopover from "../util/JitsiPopover";/*** Constructs new connection indicator.* @param videoContainer the video container associated with the indicator.* @constructor*/-function ConnectionIndicator(videoContainer, jid) {+function ConnectionIndicator(videoContainer, id) {this.videoContainer = videoContainer;this.bandwidth = null;this.packetLoss = null;@@ -16,7 +16,7 @@ function ConnectionIndicator(videoContainer, jid) {this.resolution = null;this.transport = [];this.popover = null;- this.jid = jid;+ this.id = id;this.create();}@@ -87,7 +87,7 @@ ConnectionIndicator.prototype.generateText = function () {}var resolutionValue = null;- if(this.resolution && this.jid) {+ if(this.resolution && this.id) {var keys = Object.keys(this.resolution);for(var ssrc in this.resolution) {// skip resolutions for ssrc that don't have this info@@ -99,7 +99,7 @@ ConnectionIndicator.prototype.generateText = function () {}}- if(this.jid === null) {+ if(this.id === null) {resolution = "";if(this.resolution === null || !Object.keys(this.resolution) ||Object.keys(this.resolution).length === 0) {@@ -144,8 +144,8 @@ ConnectionIndicator.prototype.generateText = function () {if(this.videoContainer.videoSpanId == "localVideoContainer") {result += "<div class=\"jitsipopover_showmore\" " +"onclick = \"APP.UI.connectionIndicatorShowMore('" +- // FIXME: we do not know local jid when this text is generated- //this.jid + "')\" data-i18n='connectionindicator." ++ // FIXME: we do not know local id when this text is generated+ //this.id + "')\" data-i18n='connectionindicator." +"local')\" data-i18n='connectionindicator." +(this.showMoreValue ? "less" : "more") + "'>" +translate("connectionindicator." + (this.showMoreValue ? "less" : "more")) +@@ -385,4 +385,4 @@ ConnectionIndicator.prototype.hideIndicator = function () {this.popover.forceHide();};-module.exports = ConnectionIndicator;\ No newline at end of file+export default ConnectionIndicator;diff --git a/modules/UI/videolayout/LargeVideo.js b/modules/UI/videolayout/LargeVideo.jsindex b32569e48e..dafb921eac 100644--- a/modules/UI/videolayout/LargeVideo.js+++ b/modules/UI/videolayout/LargeVideo.js@@ -1,11 +1,11 @@-/* global $, APP, Strophe, interfaceConfig */+/* global $, APP, interfaceConfig *//* jshint -W101 */-var Avatar = require("../avatar/Avatar");+import Avatar from "../avatar/Avatar";+import ToolbarToggler from "../toolbars/ToolbarToggler";+import UIUtil from "../util/UIUtil";+import UIEvents from "../../../service/UI/UIEvents";+var RTCBrowserType = require("../../RTC/RTCBrowserType");-var UIUtil = require("../util/UIUtil");-var UIEvents = require("../../../service/UI/UIEvents");-var xmpp = require("../../xmpp/xmpp");-var ToolbarToggler = require("../toolbars/ToolbarToggler");// FIXME: With Temasys we have to re-select everytime//var video = $('#largeVideo');@@ -37,22 +37,22 @@ var state = "video";* @param state the state.* @returns {JQuery|*|jQuery|HTMLElement} the container.*/-function getContainerByState(state)-{+function getContainerByState(state) {var selector = null;- switch (state)- {- case "video":- selector = "#largeVideoWrapper";- break;- case "etherpad":- selector = "#etherpad>iframe";- break;- case "prezi":- selector = "#presentation>iframe";- break;+ switch (state) {+ case "video":+ selector = "#largeVideoWrapper";+ break;+ case "etherpad":+ selector = "#etherpad>iframe";+ break;+ case "prezi":+ selector = "#presentation>iframe";+ break;+ default:+ return null;}- return (selector !== null)? $(selector) : null;+ return $(selector);}/**@@ -72,24 +72,25 @@ function positionVideo(video,animate) {if (animate) {video.animate({- width: width,- height: height,- top: verticalIndent,- bottom: verticalIndent,- left: horizontalIndent,- right: horizontalIndent- },- {- queue: false,- duration: 500- });+ width: width,+ height: height,+ top: verticalIndent,+ bottom: verticalIndent,+ left: horizontalIndent,+ right: horizontalIndent+ }, {+ queue: false,+ duration: 500+ });} else {video.width(width);video.height(height);- video.css({ top: verticalIndent + 'px',- bottom: verticalIndent + 'px',- left: horizontalIndent + 'px',- right: horizontalIndent + 'px'});+ video.css({+ top: verticalIndent,+ bottom: verticalIndent,+ left: horizontalIndent,+ right: horizontalIndent+ });}}@@ -237,16 +238,13 @@ function getCameraVideoSize(videoWidth,/*** Updates the src of the active speaker avatar- * @param jid of the current active speaker*/function updateActiveSpeakerAvatarSrc() {- var avatar = $("#activeSpeakerAvatar")[0];- var jid = currentSmallVideo.peerJid;- var url = Avatar.getActiveSpeakerUrl(jid);- if (avatar.src === url)- return;- if (jid) {- avatar.src = url;+ let avatar = $("#activeSpeakerAvatar");+ let id = currentSmallVideo.id;+ let url = Avatar.getActiveSpeakerUrl(id);+ if (id && avatar.attr('src') !== url) {+ avatar.attr('src', url);currentSmallVideo.showAvatar();}}@@ -263,13 +261,15 @@ function changeVideo(isVisible) {}updateActiveSpeakerAvatarSrc();- var largeVideoElement = $('#largeVideo')[0];+ let largeVideoElement = $('#largeVideo');- APP.RTC.setVideoSrc(largeVideoElement, currentSmallVideo.getSrc());+ currentSmallVideo.stream.attach(largeVideoElement);- var flipX = currentSmallVideo.flipX;+ let flipX = currentSmallVideo.flipX;- largeVideoElement.style.transform = flipX ? "scaleX(-1)" : "none";+ largeVideoElement.css({+ transform: flipX ? "scaleX(-1)" : "none"+ });LargeVideo.updateVideoSizeAndPosition(currentSmallVideo.getVideoType());@@ -369,40 +369,35 @@ var LargeVideo = {/*** Returns <tt>true</tt> if the user is currently displayed on large video.*/- isCurrentlyOnLarge: function (resourceJid) {- return currentSmallVideo && resourceJid &&- currentSmallVideo.getResourceJid() === resourceJid;+ isCurrentlyOnLarge: function (id) {+ return id && id === this.getId();},/*** Updates the large video with the given new video source.*/- updateLargeVideo: function (resourceJid, forceUpdate) {- if(!isEnabled)+ updateLargeVideo: function (id, forceUpdate) {+ if(!isEnabled) {return;- var newSmallVideo = this.VideoLayout.getSmallVideo(resourceJid);- console.info('hover in ' + resourceJid + ', video: ', newSmallVideo);+ }+ let newSmallVideo = this.VideoLayout.getSmallVideo(id);+ console.info(`hover in ${id} , video: `, newSmallVideo);if (!newSmallVideo) {- console.error("Small video not found for: " + resourceJid);+ console.error("Small video not found for: " + id);return;}- if (!LargeVideo.isCurrentlyOnLarge(resourceJid) || forceUpdate) {+ if (!LargeVideo.isCurrentlyOnLarge(id) || forceUpdate) {$('#activeSpeaker').css('visibility', 'hidden');- var oldSmallVideo = null;- if (currentSmallVideo) {- oldSmallVideo = currentSmallVideo;- }+ let oldId = this.getId();+currentSmallVideo = newSmallVideo;- var oldJid = null;- if (oldSmallVideo)- oldJid = oldSmallVideo.peerJid;- if (oldJid !== resourceJid) {- // we want the notification to trigger even if userJid is undefined,+ if (oldId !== id) {+ // we want the notification to trigger even if id is undefined,// or null.- this.eventEmitter.emit(UIEvents.SELECTED_ENDPOINT, resourceJid);+ this.eventEmitter.emit(UIEvents.SELECTED_ENDPOINT, id);}// We are doing fadeOut/fadeIn animations on parent div which wraps// largeVideo, because when Temasys plugin is in use it replaces@@ -443,11 +438,10 @@ var LargeVideo = {currentSmallVideo.enableDominantSpeaker(false);}},- onVideoTypeChanged: function (resourceJid, newVideoType) {+ onVideoTypeChanged: function (id, newVideoType) {if (!isEnabled)return;- if (LargeVideo.isCurrentlyOnLarge(resourceJid))- {+ if (LargeVideo.isCurrentlyOnLarge(id)) {LargeVideo.updateVideoSizeAndPosition(newVideoType);this.position(null, null, null, null, true);@@ -562,22 +556,23 @@ var LargeVideo = {getVideoPosition = isDesktop ? getDesktopVideoPosition :getCameraVideoPosition;},- getResourceJid: function () {- return currentSmallVideo ? currentSmallVideo.getResourceJid() : null;+ getId: function () {+ return currentSmallVideo ? currentSmallVideo.id : null;},- updateAvatar: function (resourceJid) {- if(!isEnabled)+ updateAvatar: function (id) {+ if (!isEnabled) {return;- if (resourceJid === this.getResourceJid()) {+ }+ if (id === this.getId()) {updateActiveSpeakerAvatarSrc();}},- showAvatar: function (resourceJid, show) {- if (!isEnabled)+ showAvatar: function (id, show) {+ if (!isEnabled) {return;- if (this.getResourceJid() === resourceJid && state === "video") {- $("#largeVideoWrapper")- .css("visibility", show ? "hidden" : "visible");+ }+ if (this.getId() === id && state === "video") {+ $("#largeVideoWrapper").css("visibility", show ? "hidden" : "visible");$('#activeSpeaker').css("visibility", show ? "visible" : "hidden");return true;}@@ -721,4 +716,4 @@ var LargeVideo = {}};-module.exports = LargeVideo;\ No newline at end of file+export default LargeVideo;diff --git a/modules/UI/videolayout/LocalVideo.js b/modules/UI/videolayout/LocalVideo.jsindex dfc97bb6e7..0dc8f95bfc 100644--- a/modules/UI/videolayout/LocalVideo.js+++ b/modules/UI/videolayout/LocalVideo.js@@ -1,8 +1,9 @@/* global $, interfaceConfig, APP */-var SmallVideo = require("./SmallVideo");-var ConnectionIndicator = require("./ConnectionIndicator");-var UIUtil = require("../util/UIUtil");-var UIEvents = require("../../../service/UI/UIEvents");+import ConnectionIndicator from "./ConnectionIndicator";+import UIUtil from "../util/UIUtil";+import UIEvents from "../../../service/UI/UIEvents";+import SmallVideo from "./SmallVideo";+var LargeVideo = require("./LargeVideo");var RTCBrowserType = require("../../RTC/RTCBrowserType");@@ -13,7 +14,6 @@ function LocalVideo(VideoLayout, emitter) {this.VideoLayout = VideoLayout;this.flipX = true;this.isLocal = true;- this.peerJid = null;this.emitter = emitter;}@@ -143,32 +143,25 @@ LocalVideo.prototype.createConnectionIndicator = function() {this.connectionIndicator = new ConnectionIndicator(this, null);};-LocalVideo.prototype.changeVideo = function (stream, isMuted) {- var self = this;+LocalVideo.prototype.changeVideo = function (stream) {+ this.stream = stream;- function localVideoClick(event) {+ let localVideoClick = (event) => {// FIXME: with Temasys plugin event arg is not an event, but// the clicked object itself, so we have to skip this callif (event.stopPropagation) {event.stopPropagation();}- self.VideoLayout.handleVideoThumbClicked(- true,- APP.xmpp.myResource());- }+ this.VideoLayout.handleVideoThumbClicked(true, this.id);+ };- var localVideoContainerSelector = $('#localVideoContainer');+ let localVideoContainerSelector = $('#localVideoContainer');localVideoContainerSelector.off('click');localVideoContainerSelector.on('click', localVideoClick);- if(isMuted) {- APP.UI.setVideoMute(true);- return;- }this.flipX = stream.videoType != "screen";- var localVideo = document.createElement('video');- localVideo.id = 'localVideo_' +- APP.RTC.getStreamID(stream.getOriginalStream());+ let localVideo = document.createElement('video');+ localVideo.id = 'localVideo_' + stream.getId();if (!RTCBrowserType.isIExplorer()) {localVideo.autoplay = true;localVideo.volume = 0; // is it required if audio is separated ?@@ -192,7 +185,10 @@ LocalVideo.prototype.changeVideo = function (stream, isMuted) {}// Attach WebRTC stream- APP.RTC.attachMediaStream(localVideoSelector, stream.getOriginalStream());+ stream.attach(localVideoSelector);++ // FIXME handle+ return;// Add stream ended handlerAPP.RTC.addMediaStreamInactiveHandler(@@ -201,20 +197,12 @@ LocalVideo.prototype.changeVideo = function (stream, isMuted) {// because <video> element is replaced with <object>localVideo = $('#' + localVideo.id)[0];localVideoContainer.removeChild(localVideo);- self.VideoLayout.updateRemovedVideo(APP.xmpp.myResource());+ self.VideoLayout.updateRemovedVideo(self.id);});};-LocalVideo.prototype.joined = function (jid) {- this.peerJid = jid;-};--LocalVideo.prototype.getResourceJid = function () {- var myResource = APP.xmpp.myResource();- if (!myResource) {- console.error("Requested local resource before we're in the MUC");- }- return myResource;+LocalVideo.prototype.joined = function (id) {+ this.id = id;};-module.exports = LocalVideo;\ No newline at end of file+export default LocalVideo;diff --git a/modules/UI/videolayout/RemoteVideo.js b/modules/UI/videolayout/RemoteVideo.jsindex 7fafb03374..776e3a8e8c 100644--- a/modules/UI/videolayout/RemoteVideo.js+++ b/modules/UI/videolayout/RemoteVideo.js@@ -1,24 +1,25 @@-/* global $, APP, require, Strophe, interfaceConfig */-var ConnectionIndicator = require("./ConnectionIndicator");-var SmallVideo = require("./SmallVideo");-var AudioLevels = require("../audio_levels/AudioLevels");-var MediaStreamType = require("../../../service/RTC/MediaStreamTypes");+/* global $, APP, interfaceConfig */++import ConnectionIndicator from './ConnectionIndicator';++import SmallVideo from "./SmallVideo";+import AudioLevels from "../audio_levels/AudioLevels";+import UIUtils from "../util/UIUtil";+import UIEvents from '../../../service/UI/UIEvents';+var RTCBrowserType = require("../../RTC/RTCBrowserType");-var UIUtils = require("../util/UIUtil");-var XMPPEvents = require("../../../service/xmpp/XMPPEvents");-function RemoteVideo(peerJid, VideoLayout) {- this.peerJid = peerJid;- this.resourceJid = Strophe.getResourceFromJid(peerJid);- this.videoSpanId = 'participant_' + this.resourceJid;+function RemoteVideo(id, VideoLayout, emitter) {+ this.id = id;+ this.emitter = emitter;+ this.videoSpanId = `participant_${id}`;this.VideoLayout = VideoLayout;this.addRemoteVideoContainer();- this.connectionIndicator = new ConnectionIndicator(- this, this.peerJid);+ this.connectionIndicator = new ConnectionIndicator(this, id);this.setDisplayName();var nickfield = document.createElement('span');nickfield.className = "nick";- nickfield.appendChild(document.createTextNode(this.resourceJid));+ nickfield.appendChild(document.createTextNode(id));this.container.appendChild(nickfield);this.bindHoverHandler();this.flipX = false;@@ -30,18 +31,19 @@ RemoteVideo.prototype.constructor = RemoteVideo;RemoteVideo.prototype.addRemoteVideoContainer = function() {this.container = RemoteVideo.createContainer(this.videoSpanId);- if (APP.xmpp.isModerator())+ if (APP.conference.isModerator) {this.addRemoteVideoMenu();- AudioLevels.updateAudioLevelCanvas(this.peerJid, this.VideoLayout);+ }+ AudioLevels.updateAudioLevelCanvas(this.id, this.VideoLayout);return this.container;};/**- * Adds the remote video menu element for the given <tt>jid</tt> in the+ * Adds the remote video menu element for the given <tt>id</tt> in the* given <tt>parentElement</tt>.*- * @param jid the jid indicating the video for which we're adding a menu.+ * @param id the id indicating the video for which we're adding a menu.* @param parentElement the parent element where this menu will be added*/@@ -60,7 +62,7 @@ if (!interfaceConfig.filmStripOnly) {var popupmenuElement = document.createElement('ul');popupmenuElement.className = 'popupmenu';- popupmenuElement.id = 'remote_popupmenu_' + this.getResourceJid();+ popupmenuElement.id = `remote_popupmenu_${this.id}`;spanElement.appendChild(popupmenuElement);var muteMenuItem = document.createElement('li');@@ -88,7 +90,7 @@ if (!interfaceConfig.filmStripOnly) {event.preventDefault();}var isMute = !!self.isMuted;- APP.xmpp.setMute(self.peerJid, !isMute);+ self.emitter.emit(UIEvents.AUDIO_MUTED, !isMute);popupmenuElement.setAttribute('style', 'display:none;');@@ -117,7 +119,7 @@ if (!interfaceConfig.filmStripOnly) {"data-i18n='videothumbnail.kick'> </div>";ejectLinkItem.innerHTML = ejectIndicator + ' ' + ejectText;ejectLinkItem.onclick = function(){- APP.xmpp.eject(self.peerJid);+ self.emitter.emit(UIEvents.USER_KICKED, self.id);popupmenuElement.setAttribute('style', 'display:none;');};@@ -157,36 +159,36 @@ RemoteVideo.prototype.removeRemoteStreamElement =select.remove();console.info((isVideo ? "Video" : "Audio") +- " removed " + this.getResourceJid(), select);+ " removed " + this.id, select);if (isVideo)- this.VideoLayout.updateRemovedVideo(this.getResourceJid());+ this.VideoLayout.updateRemovedVideo(this.id);};/*** Removes RemoteVideo from the page.*/RemoteVideo.prototype.remove = function () {- console.log("Remove thumbnail", this.peerJid);+ console.log("Remove thumbnail", this.id);this.removeConnectionIndicator();// Make sure that the large video is updated if are removing its// corresponding small video.- this.VideoLayout.updateRemovedVideo(this.getResourceJid());+ this.VideoLayout.updateRemovedVideo(this.id);// Remove whole container- if (this.container.parentNode)+ if (this.container.parentNode) {this.container.parentNode.removeChild(this.container);+ }};RemoteVideo.prototype.waitForPlayback = function (sel, stream) {var webRtcStream = stream.getOriginalStream();- var isVideo = stream.isVideoStream();+ var isVideo = stream.isVideoTrack();if (!isVideo || webRtcStream.id === 'mixedmslabel') {return;}var self = this;- var resourceJid = this.getResourceJid();// Register 'onplaying' listener to trigger 'videoactive' on VideoLayout// when video playback starts@@ -198,7 +200,7 @@ RemoteVideo.prototype.waitForPlayback = function (sel, stream) {if (RTCBrowserType.isTemasysPluginUsed()) {sel = self.selectVideoElement();}- self.VideoLayout.videoactive(sel, resourceJid);+ self.VideoLayout.videoactive(sel, self.id);sel[0].onplaying = null;if (RTCBrowserType.isTemasysPluginUsed()) {// 'currentTime' is used to check if the video has started@@ -210,39 +212,33 @@ RemoteVideo.prototype.waitForPlayback = function (sel, stream) {};RemoteVideo.prototype.addRemoteStreamElement = function (stream) {- if (!this.container)+ if (!this.container) {return;+ }- var self = this;- var webRtcStream = stream.getOriginalStream();- var isVideo = stream.isVideoStream();- var streamElement = SmallVideo.createStreamElement(stream);- var newElementId = streamElement.id;+ this.stream = stream;++ let isVideo = stream.isVideoTrack();+ let streamElement = SmallVideo.createStreamElement(stream);+ let newElementId = streamElement.id;// Put new stream element always in frontUIUtils.prependChild(this.container, streamElement);- var sel = $('#' + newElementId);+ let sel = $(`#${newElementId}`);sel.hide();// If the container is currently visible we attach the stream.if (!isVideo || (this.container.offsetParent !== null && isVideo)) {this.waitForPlayback(sel, stream);- APP.RTC.attachMediaStream(sel, webRtcStream);+ stream.attach(sel);}- APP.RTC.addMediaStreamInactiveHandler(- webRtcStream, function () {- console.log('stream ended', this);-- self.removeRemoteStreamElement(webRtcStream, isVideo, newElementId);- });-// Add click handler.- var onClickHandler = function (event) {+ let onClickHandler = (event) => {- self.VideoLayout.handleVideoThumbClicked(false, self.getResourceJid());+ this.VideoLayout.handleVideoThumbClicked(false, this.id);// On IE we need to populate this handler on video <object>// and it does not give event instance as an argument,@@ -255,13 +251,14 @@ RemoteVideo.prototype.addRemoteStreamElement = function (stream) {};this.container.onclick = onClickHandler;// reselect- if (RTCBrowserType.isTemasysPluginUsed())- sel = $('#' + newElementId);- sel[0].onclick = onClickHandler;+ if (RTCBrowserType.isTemasysPluginUsed()) {+ sel = $(`#${newElementId}`);+ }+ sel.click(onClickHandler);},/**- * Show/hide peer container for the given resourceJid.+ * Show/hide peer container for the given id.*/RemoteVideo.prototype.showPeerContainer = function (state) {if (!this.container)@@ -294,7 +291,7 @@ RemoteVideo.prototype.showPeerContainer = function (state) {// We want to be able to pin a participant from the contact list, even// if he's not in the lastN set!- // ContactList.setClickable(resourceJid, !isHide);+ // ContactList.setClickable(id, !isHide);};@@ -311,12 +308,11 @@ RemoteVideo.prototype.hideConnectionIndicator = function () {/*** Updates the remote video menu.*- * @param jid the jid indicating the video for which we're adding a menu.+ * @param id the id indicating the video for which we're adding a menu.* @param isMuted indicates the current mute state*/RemoteVideo.prototype.updateRemoteVideoMenu = function (isMuted) {- var muteMenuItem- = $('#remote_popupmenu_' + this.getResourceJid() + '>li>a.mutelink');+ var muteMenuItem = $(`#remote_popupmenu_${this.id}>li>a.mutelink`);var mutedIndicator = "<i class='icon-mic-disabled'></i>";@@ -423,13 +419,6 @@ RemoteVideo.prototype.removeRemoteVideoMenu = function() {}};-RemoteVideo.prototype.getResourceJid = function () {- if (!this.resourceJid) {- console.error("Undefined resource jid");- }- return this.resourceJid;-};-RemoteVideo.createContainer = function (spanId) {var container = document.createElement('span');container.id = spanId;@@ -439,4 +428,4 @@ RemoteVideo.createContainer = function (spanId) {};-module.exports = RemoteVideo;\ No newline at end of file+export default RemoteVideo;diff --git a/modules/UI/videolayout/SmallVideo.js b/modules/UI/videolayout/SmallVideo.jsindex cea1e6a728..83173dc858 100644--- a/modules/UI/videolayout/SmallVideo.js+++ b/modules/UI/videolayout/SmallVideo.js@@ -1,14 +1,16 @@/* global $, APP, require *//* jshint -W101 */-var Avatar = require("../avatar/Avatar");-var UIUtil = require("../util/UIUtil");-var LargeVideo = require("./LargeVideo");+import Avatar from "../avatar/Avatar";+import UIUtil from "../util/UIUtil";+import LargeVideo from "./LargeVideo";+var RTCBrowserType = require("../../RTC/RTCBrowserType");var MediaStreamType = require("../../../service/RTC/MediaStreamTypes");function SmallVideo() {this.isMuted = false;this.hasAvatar = false;+ this.stream = null;}function setVisibility(selector, show) {@@ -106,9 +108,10 @@ SmallVideo.prototype.setPresenceStatus = function (statusMsg) {* Creates an audio or video element for a particular MediaStream.*/SmallVideo.createStreamElement = function (stream) {- var isVideo = stream.isVideoStream();+ let isVideo = stream.isVideoTrack();- var element = isVideo ? document.createElement('video')+ let element = isVideo+ ? document.createElement('video'): document.createElement('audio');if (isVideo) {element.setAttribute("muted", "true");@@ -118,8 +121,7 @@ SmallVideo.createStreamElement = function (stream) {element.autoplay = true;}- element.id = (isVideo ? 'remoteVideo_' : 'remoteAudio_') +- APP.RTC.getStreamID(stream.getOriginalStream());+ element.id = (isVideo ? 'remoteVideo_' : 'remoteAudio_') + stream.getId();element.onplay = function () {console.log("(TIME) Render " + (isVideo ? 'video' : 'audio') + ":\t",@@ -145,7 +147,7 @@ SmallVideo.prototype.bindHoverHandler = function () {// If the video has been "pinned" by the user we want to// keep the display name on place.if (!LargeVideo.isLargeVideoVisible() ||- !LargeVideo.isCurrentlyOnLarge(self.getResourceJid()))+ !LargeVideo.isCurrentlyOnLarge(self.id))self.showDisplayName(false);});@@ -237,15 +239,14 @@ SmallVideo.prototype.showVideoIndicator = function(isMuted) {};SmallVideo.prototype.enableDominantSpeaker = function (isEnable) {- var resourceJid = this.getResourceJid();- var displayName = resourceJid;+ var displayName = this.id;var nameSpan = $('#' + this.videoSpanId + '>span.displayname');if (nameSpan.length > 0)displayName = nameSpan.html();console.log("UI enable dominant speaker",displayName,- resourceJid,+ this.id,isEnable);@@ -316,6 +317,8 @@ SmallVideo.prototype.createModeratorIndicatorElement = function () {};SmallVideo.prototype.selectVideoElement = function () {+ return $('#' + this.videoSpanId).find(videoElem);+ // FIXME maybe move this to the library?var videoElem = APP.RTC.getVideoElementName();if (!RTCBrowserType.isTemasysPluginUsed()) {return $('#' + this.videoSpanId).find(videoElem);@@ -367,32 +370,31 @@ SmallVideo.prototype.hasVideo = function () {*/SmallVideo.prototype.showAvatar = function (show) {if (!this.hasAvatar) {- if (this.peerJid) {+ if (this.id) {// Init avatar- this.avatarChanged(Avatar.getThumbUrl(this.peerJid));+ this.avatarChanged(Avatar.getThumbUrl(this.id));} else {- console.error("Unable to init avatar - no peerjid", this);+ console.error("Unable to init avatar - no id", this);return;}}- var resourceJid = this.getResourceJid();- var video = this.selectVideoElement();+ let video = this.selectVideoElement();- var avatar = $('#avatar_' + resourceJid);+ let avatar = $(`#avatar_${this.id}`);if (show === undefined || show === null) {if (!this.isLocal &&- !this.VideoLayout.isInLastN(resourceJid)) {+ !this.VideoLayout.isInLastN(this.id)) {show = true;} else {// We want to show the avatar when the video is muted or not exists// that is when 'true' or 'null' is returned- show = APP.RTC.isVideoMuted(this.peerJid) !== false;+ show = !this.stream || this.stream.isMuted();}}- if (LargeVideo.showAvatar(resourceJid, show)) {+ if (LargeVideo.showAvatar(this.id, show)) {setVisibility(avatar, false);setVisibility(video, false);} else {@@ -405,8 +407,7 @@ SmallVideo.prototype.showAvatar = function (show) {SmallVideo.prototype.avatarChanged = function (thumbUrl) {var thumbnail = $('#' + this.videoSpanId);- var resourceJid = this.getResourceJid();- var avatar = $('#avatar_' + resourceJid);+ var avatar = $('#avatar_' + this.id);this.hasAvatar = true;// set the avatar in the thumbnail@@ -415,7 +416,7 @@ SmallVideo.prototype.avatarChanged = function (thumbUrl) {} else {if (thumbnail && thumbnail.length > 0) {avatar = document.createElement('img');- avatar.id = 'avatar_' + resourceJid;+ avatar.id = 'avatar_' + this.id;avatar.className = 'userAvatar';avatar.src = thumbUrl;thumbnail.append(avatar);@@ -423,4 +424,4 @@ SmallVideo.prototype.avatarChanged = function (thumbUrl) {}};-module.exports = SmallVideo;+export default SmallVideo;diff --git a/modules/UI/videolayout/VideoLayout.js b/modules/UI/videolayout/VideoLayout.jsindex d989c84508..9924f6413a 100644--- a/modules/UI/videolayout/VideoLayout.js+++ b/modules/UI/videolayout/VideoLayout.js@@ -1,18 +1,18 @@-/* global config, APP, $, Strophe, require, interfaceConfig */+/* global config, APP, $, interfaceConfig *//* jshint -W101 */-var AudioLevels = require("../audio_levels/AudioLevels");-var ContactList = require("../side_pannels/contactlist/ContactList");-var MediaStreamType = require("../../../service/RTC/MediaStreamTypes");-var UIEvents = require("../../../service/UI/UIEvents");-var UIUtil = require("../util/UIUtil");-var RTC = require("../../RTC/RTC");-var RTCBrowserType = require('../../RTC/RTCBrowserType');+import AudioLevels from "../audio_levels/AudioLevels";+import ContactList from "../side_pannels/contactlist/ContactList";-var RemoteVideo = require("./RemoteVideo");-var LargeVideo = require("./LargeVideo");-var LocalVideo = require("./LocalVideo");+import UIEvents from "../../../service/UI/UIEvents";+import UIUtil from "../util/UIUtil";+import RemoteVideo from "./RemoteVideo";+import LargeVideo from "./LargeVideo";+import LocalVideo from "./LocalVideo";++var MediaStreamType = require("../../../service/RTC/MediaStreamTypes");+var RTCBrowserType = require('../../RTC/RTCBrowserType');var remoteVideos = {};var remoteVideoTypes = {};@@ -23,7 +23,7 @@ var lastNCount = config.channelLastN;var localLastNCount = config.channelLastN;var localLastNSet = [];var lastNEndpointsCache = [];-var lastNPickupJid = null;+var lastNPickupId = null;var eventEmitter = null;@@ -33,8 +33,50 @@ var eventEmitter = null;*/var focusedVideoResourceJid = null;-var VideoLayout = (function (my) {- my.init = function (emitter) {+/**+ * On contact list item clicked.+ */+$(ContactList).bind('contactclicked', function(event, id) {+ if (!id) {+ return;+ }++ if (APP.conference.isLocalId(id)) {+ $("#localVideoContainer").click();+ return;+ }++ var remoteVideo = remoteVideos[id];+ if (remoteVideo && remoteVideo.selectVideoElement().length) {+ var videoThumb = remoteVideo.selectVideoElement()[0];+ // It is not always the case that a videoThumb exists (if there is+ // no actual video).+ if (RTC.getVideoSrc(videoThumb)) {++ // We have a video src, great! Let's update the large video+ // now.+ VideoLayout.handleVideoThumbClicked(false, id);+ } else {++ // If we don't have a video src for jid, there's absolutely+ // no point in calling handleVideoThumbClicked; Quite+ // simply, it won't work because it needs an src to attach+ // to the large video.+ //+ // Instead, we trigger the pinned endpoint changed event to+ // let the bridge adjust its lastN set for myjid and store+ // the pinned user in the lastNPickupId variable to be+ // picked up later by the lastN changed event handler.++ lastNPickupId = id;+ eventEmitter.emit(UIEvents.PINNED_ENDPOINT, id);+ }+ }+});+++var VideoLayout = {+ init (emitter) {eventEmitter = emitter;localVideoThumbnail = new LocalVideo(VideoLayout, emitter);if (interfaceConfig.filmStripOnly) {@@ -45,19 +87,21 @@ var VideoLayout = (function (my) {VideoLayout.resizeLargeVideoContainer();- };+ },- my.isInLastN = function(resource) {+ isInLastN (resource) {return lastNCount < 0 || // lastN is disabled// lastNEndpoints cache not built yet(lastNCount > 0 && !lastNEndpointsCache.length) ||(lastNEndpointsCache &&lastNEndpointsCache.indexOf(resource) !== -1);- };+ },- my.changeLocalAudio = function(stream, isMuted) {- APP.RTC.attachMediaStream($('#localAudio'), stream.getOriginalStream());- var localAudio = document.getElementById('localAudio');+ changeLocalAudio (stream) {+ let localAudio = document.getElementById('localAudio');+ stream.attach($(localAudio));++ return; // FIXME maybe move this into the library?// Writing volume not allowed in IEif (!RTCBrowserType.isIExplorer()) {localAudio.autoplay = true;@@ -73,39 +117,41 @@ var VideoLayout = (function (my) {// which will result in audio mute issues$('#localAudio').hide();}- };+ },- my.changeLocalVideo = function(stream, isMuted) {+ changeLocalVideo (stream) {// Set default display name.localVideoThumbnail.setDisplayName();localVideoThumbnail.createConnectionIndicator();- this.onVideoTypeChanged(APP.xmpp.myResource(), stream.videoType);+ let localId = APP.conference.localId;+ this.onVideoTypeChanged(localId, stream.getType());AudioLevels.updateAudioLevelCanvas(null, VideoLayout);- localVideoThumbnail.changeVideo(stream, isMuted);+ localVideoThumbnail.changeVideo(stream);/* force update if we're currently being displayed */- if (LargeVideo.isCurrentlyOnLarge(APP.xmpp.myResource())) {- LargeVideo.updateLargeVideo(APP.xmpp.myResource(), true);+ if (LargeVideo.isCurrentlyOnLarge(localId)) {+ LargeVideo.updateLargeVideo(localId, true);}- };+ },- my.mucJoined = function () {- var myResourceJid = APP.xmpp.myResource();- localVideoThumbnail.joined(APP.xmpp.myJid());+ mucJoined () {+ let id = APP.conference.localId;+ localVideoThumbnail.joined(id);- if (!LargeVideo.getResourceJid())- LargeVideo.updateLargeVideo(myResourceJid, true);- };+ if (!LargeVideo.id) {+ LargeVideo.updateLargeVideo(id, true);+ }+ },/*** Adds or removes icons for not available camera and microphone.* @param resourceJid the jid of user* @param devices available devices*/- my.setDeviceAvailabilityIcons = function (resourceJid, devices) {+ setDeviceAvailabilityIcons (resourceJid, devices) {if(!devices)return;@@ -115,31 +161,31 @@ var VideoLayout = (function (my) {if(remoteVideos[resourceJid])remoteVideos[resourceJid].setDeviceAvailabilityIcons(devices);}- };+ },/*** Checks if removed video is currently displayed and tries to display* another one instead.*/- my.updateRemovedVideo = function(resourceJid) {- var newResourceJid;+ updateRemovedVideo (id) {+ let newId;- if (resourceJid === LargeVideo.getResourceJid()) {+ if (id === LargeVideo.getId()) {// We'll show user's avatar if he is the dominant speaker or if// his video thumbnail is pinned- if (remoteVideos[resourceJid] &&- resourceJid === focusedVideoResourceJid ||- resourceJid === currentDominantSpeaker) {- newResourceJid = resourceJid;+ if (remoteVideos[id] &&+ id === focusedVideoResourceJid ||+ id === currentDominantSpeaker) {+ newId = id;} else {// Otherwise select last visible video- newResourceJid = this.electLastVisibleVideo();+ newId = this.electLastVisibleVideo();}- LargeVideo.updateLargeVideo(newResourceJid);+ LargeVideo.updateLargeVideo(id);}- };+ },- my.electLastVisibleVideo = function () {+ electLastVisibleVideo () {// pick the last visible video in the row// if nobody else is left, this picks the local videovar jid;@@ -174,39 +220,36 @@ var VideoLayout = (function (my) {console.info("electLastVisibleVideo: " + jid);return jid;- };+ },- my.onRemoteStreamAdded = function (stream) {- if (stream.peerjid) {- VideoLayout.ensurePeerContainerExists(stream.peerjid);+ onRemoteStreamAdded (stream) {+ let id = stream.getParticipantId();+ VideoLayout.ensurePeerContainerExists(id);- var resourceJid = Strophe.getResourceFromJid(stream.peerjid);- remoteVideos[resourceJid].addRemoteStreamElement(stream);- }- };+ remoteVideos[id].addRemoteStreamElement(stream);+ },- my.getLargeVideoResource = function () {- return LargeVideo.getResourceJid();- };+ getLargeVideoId () {+ return LargeVideo.getId();+ },/*** Return the type of the remote video.- * @param jid the jid for the remote video+ * @param id the id for the remote video* @returns the video type video or screen.*/- my.getRemoteVideoType = function (jid) {- return remoteVideoTypes[jid];- };+ getRemoteVideoType (id) {+ return remoteVideoTypes[id];+ },/*** Called when large video update is finished* @param currentSmallVideo small video currently displayed on large video*/- my.largeVideoUpdated = function (currentSmallVideo) {+ largeVideoUpdated (currentSmallVideo) {// Makes sure that dominant speaker UI// is enabled only on current small video- localVideoThumbnail.enableDominantSpeaker(- localVideoThumbnail === currentSmallVideo);+ localVideoThumbnail.enableDominantSpeaker(localVideoThumbnail === currentSmallVideo);Object.keys(remoteVideos).forEach(function (resourceJid) {var remoteVideo = remoteVideos[resourceJid];@@ -216,9 +259,9 @@ var VideoLayout = (function (my) {}});- };+ },- my.handleVideoThumbClicked = function(noPinnedEndpointChangedEvent,+ handleVideoThumbClicked (noPinnedEndpointChangedEvent,resourceJid) {if(focusedVideoResourceJid) {var oldSmallVideo@@ -269,50 +312,46 @@ var VideoLayout = (function (my) {el.volume = 1;});}- };+ },/**- * Checks if container for participant identified by given peerJid exists+ * Checks if container for participant identified by given id exists* in the document and creates it eventually.*- * @param peerJid peer Jid to check.- ** @return Returns <tt>true</tt> if the peer container exists,* <tt>false</tt> - otherwise*/- my.ensurePeerContainerExists = function(peerJid) {- ContactList.ensureAddContact(peerJid);-- var resourceJid = Strophe.getResourceFromJid(peerJid);+ ensurePeerContainerExists (id) {+ ContactList.ensureAddContact(id);- if (!remoteVideos[resourceJid]) {+ if (remoteVideos[id]) {+ return;+ }- var remoteVideo = new RemoteVideo(peerJid, VideoLayout);- remoteVideos[resourceJid] = remoteVideo;+ let remoteVideo = new RemoteVideo(id, VideoLayout, eventEmitter);+ remoteVideos[id] = remoteVideo;- var videoType = remoteVideoTypes[resourceJid];- if (videoType) {- remoteVideo.setVideoType(videoType);- }+ let videoType = remoteVideoTypes[id];+ if (videoType) {+ remoteVideo.setVideoType(videoType);+ }- // In case this is not currently in the last n we don't show it.- if (localLastNCount &&- localLastNCount > 0 &&- $('#remoteVideos>span').length >= localLastNCount + 2) {- remoteVideo.showPeerContainer('hide');- }- else- VideoLayout.resizeThumbnails();+ // In case this is not currently in the last n we don't show it.+ if (localLastNCount && localLastNCount > 0 &&+ $('#remoteVideos>span').length >= localLastNCount + 2) {+ remoteVideo.showPeerContainer('hide');+ } else {+ VideoLayout.resizeThumbnails();}- };+ },- my.inputDisplayNameHandler = function (name) {+ inputDisplayNameHandler (name) {localVideoThumbnail.inputDisplayNameHandler(name);- };+ },- my.videoactive = function (videoelem, resourceJid) {+ videoactive (videoelem, resourceJid) {console.info(resourceJid + " video is now active");@@ -330,61 +369,50 @@ var VideoLayout = (function (my) {currentDominantSpeaker === resourceJid)) {LargeVideo.updateLargeVideo(resourceJid, true);}- };+ },/*** Shows the presence status message for the given video.*/- my.setPresenceStatus = function (resourceJid, statusMsg) {+ setPresenceStatus (resourceJid, statusMsg) {remoteVideos[resourceJid].setPresenceStatus(statusMsg);- };+ },/*** Shows a visual indicator for the moderator of the conference.*/- my.showModeratorIndicator = function () {-- var isModerator = APP.xmpp.isModerator();+ showModeratorIndicator () {+ let isModerator = APP.conference.isModerator;if (isModerator) {localVideoThumbnail.createModeratorIndicatorElement();}- var members = APP.xmpp.getMembers();-- Object.keys(members).forEach(function (jid) {-- var resourceJid = Strophe.getResourceFromJid(jid);- var member = members[jid];-- if (member.isFocus) {- // Skip server side focus- return;- }-- if (member.role === 'moderator') {- remoteVideos[resourceJid].removeRemoteVideoMenu();- remoteVideos[resourceJid].createModeratorIndicatorElement();+ APP.conference.listMembers().forEach(function (member) {+ let id = member.getId();+ if (member.isModerator()) {+ remoteVideos[id].removeRemoteVideoMenu();+ remoteVideos[id].createModeratorIndicatorElement();} else if (isModerator) {// We are moderator, but user is not - add menu- if ($('#remote_popupmenu_' + resourceJid).length <= 0) {- remoteVideos[resourceJid].addRemoteVideoMenu();+ if ($(`#remote_popupmenu_${id}`).length <= 0) {+ remoteVideos[id].addRemoteVideoMenu();}}});- };+ },/** Shows or hides the audio muted indicator over the local thumbnail video.* @param {boolean} isMuted*/- my.showLocalAudioIndicator = function(isMuted) {+ showLocalAudioIndicator (isMuted) {localVideoThumbnail.showAudioIndicator(isMuted);- };+ },/*** Resizes the large video container.*/- my.resizeLargeVideoContainer = function () {+ resizeLargeVideoContainer () {if(LargeVideo.isEnabled()) {LargeVideo.resize();} else {@@ -392,12 +420,12 @@ var VideoLayout = (function (my) {}VideoLayout.resizeThumbnails();LargeVideo.position();- };+ },/*** Resizes thumbnails.*/- my.resizeThumbnails = function(animate) {+ resizeThumbnails (animate) {var videoSpaceWidth = $('#remoteVideos').width();var thumbnailSize = VideoLayout.calculateThumbnailSize(videoSpaceWidth);@@ -441,14 +469,14 @@ var VideoLayout = (function (my) {$(document).trigger("remotevideo.resized", [width, height]);}- };+ },/*** Calculates the thumbnail size.** @param videoSpaceWidth the width of the video space*/- my.calculateThumbnailSize = function (videoSpaceWidth) {+ calculateThumbnailSize (videoSpaceWidth) {// Calculate the available height, which is the inner window height// minus 39px for the header minus 2px for the delimiter lines on the// top and bottom of the large video, minus the 36px space inside the@@ -478,7 +506,7 @@ var VideoLayout = (function (my) {}return [availableWidth, availableHeight];- };+ },/*** Returns the corresponding resource jid to the given peer container@@ -487,66 +515,21 @@ var VideoLayout = (function (my) {* @return the corresponding resource jid to the given peer container* DOM element*/- my.getPeerContainerResourceJid = function (containerElement) {+ getPeerContainerResourceJid (containerElement) {if (localVideoThumbnail.container === containerElement) {- return localVideoThumbnail.getResourceJid();+ return localVideoThumbnail.getId();}var i = containerElement.id.indexOf('participant_');if (i >= 0)return containerElement.id.substring(i + 12);- };-- /**- * On contact list item clicked.- */- $(ContactList).bind('contactclicked', function(event, jid) {- if (!jid) {- return;- }-- if (jid === APP.xmpp.myJid()) {- $("#localVideoContainer").click();- return;- }-- var resource = Strophe.getResourceFromJid(jid);- var remoteVideo = remoteVideos[resource];- if (remoteVideo && remoteVideo.selectVideoElement().length) {- var videoThumb = remoteVideo.selectVideoElement()[0];- // It is not always the case that a videoThumb exists (if there is- // no actual video).- if (RTC.getVideoSrc(videoThumb)) {-- // We have a video src, great! Let's update the large video- // now.- VideoLayout.handleVideoThumbClicked(- false,- Strophe.getResourceFromJid(jid));- } else {-- // If we don't have a video src for jid, there's absolutely- // no point in calling handleVideoThumbClicked; Quite- // simply, it won't work because it needs an src to attach- // to the large video.- //- // Instead, we trigger the pinned endpoint changed event to- // let the bridge adjust its lastN set for myjid and store- // the pinned user in the lastNPickupJid variable to be- // picked up later by the lastN changed event handler.-- lastNPickupJid = jid;- eventEmitter.emit(UIEvents.PINNED_ENDPOINT,- Strophe.getResourceFromJid(jid));- }- }- });+ },/*** On audio muted event.*/- my.onAudioMute = function (jid, isMuted) {+ onAudioMute (jid, isMuted) {var resourceJid = Strophe.getResourceFromJid(jid);if (resourceJid === APP.xmpp.myResource()) {localVideoThumbnail.showAudioIndicator(isMuted);@@ -557,12 +540,12 @@ var VideoLayout = (function (my) {remoteVideos[resourceJid].updateRemoteVideoMenu(isMuted);}}- };+ },/*** On video muted event.*/- my.onVideoMute = function (jid, value) {+ onVideoMute (jid, value) {if (jid !== APP.xmpp.myJid() &&!APP.RTC.muteRemoteVideoStream(jid, value))return;@@ -582,12 +565,12 @@ var VideoLayout = (function (my) {elseel.hide();}- };+ },/*** Display name changed.*/- my.onDisplayNameChanged = function (id, displayName, status) {+ onDisplayNameChanged (id, displayName, status) {if (id === 'localVideoContainer' ||APP.conference.isLocalId(id)) {localVideoThumbnail.setDisplayName(displayName);@@ -595,39 +578,39 @@ var VideoLayout = (function (my) {VideoLayout.ensurePeerContainerExists(id);remoteVideos[id].setDisplayName(displayName, status);}- };+ },/*** On dominant speaker changed event.*/- my.onDominantSpeakerChanged = function (resourceJid) {+ onDominantSpeakerChanged (id) {// We ignore local user events.- if (resourceJid === APP.xmpp.myResource())+ if (APP.conference.isLocalId(id)) {return;+ }- var remoteVideo = remoteVideos[resourceJid];- var members = APP.xmpp.getMembers();- // Update the current dominant speaker.- if (resourceJid !== currentDominantSpeaker) {- if (remoteVideo) {- remoteVideo.updateDominantSpeakerIndicator(true);- // let's remove the indications from the remote video if any- var oldSpeakerRemoteVideo- = remoteVideos[currentDominantSpeaker];- if (oldSpeakerRemoteVideo) {- oldSpeakerRemoteVideo.updateDominantSpeakerIndicator(false);- }- }- currentDominantSpeaker = resourceJid;- } else {+ if (id === currentDominantSpeaker) {return;}- if (!remoteVideo)+ let remoteVideo = remoteVideos[id];++ if (!remoteVideo) {return;+ }++ // Update the current dominant speaker.+ remoteVideo.updateDominantSpeakerIndicator(true);++ // let's remove the indications from the remote video if any+ let oldSpeakerRemoteVideo = remoteVideos[currentDominantSpeaker];+ if (oldSpeakerRemoteVideo) {+ oldSpeakerRemoteVideo.updateDominantSpeakerIndicator(false);+ }+ currentDominantSpeaker = id;// Obtain container for new dominant speaker.- var videoSel = remoteVideo.selectVideoElement();+ let videoSel = remoteVideo.selectVideoElement();// Local video will not have container found, but that's ok// since we don't want to switch to local video.@@ -635,10 +618,10 @@ var VideoLayout = (function (my) {// Update the large video if the video source is already available,// otherwise wait for the "videoactive.jingle" event.if (videoSel[0].currentTime > 0) {- LargeVideo.updateLargeVideo(resourceJid);+ LargeVideo.updateLargeVideo(id);}}- };+ },/*** On last N change event.@@ -647,7 +630,7 @@ var VideoLayout = (function (my) {* @param endpointsEnteringLastN the list currently entering last N* endpoints*/- my.onLastNEndpointsChanged = function (lastNEndpoints, endpointsEnteringLastN) {+ onLastNEndpointsChanged (lastNEndpoints, endpointsEnteringLastN) {if (lastNCount !== lastNEndpoints.length)lastNCount = lastNEndpoints.length;@@ -727,7 +710,7 @@ var VideoLayout = (function (my) {// displayed in the large video we have to switch to another// user.if (!updateLargeVideo &&- resourceJid === LargeVideo.getResourceJid()) {+ resourceJid === LargeVideo.getId()) {updateLargeVideo = true;}}@@ -751,9 +734,9 @@ var VideoLayout = (function (my) {var sel = remoteVideo.selectVideoElement();APP.RTC.attachMediaStream(sel, mediaStream.stream);- if (lastNPickupJid == mediaStream.peerjid) {- // Clean up the lastN pickup jid.- lastNPickupJid = null;+ if (lastNPickupId == mediaStream.peerjid) {+ // Clean up the lastN pickup id.+ lastNPickupId = null;// Don't fire the events again, they've already// been fired in the contact list click handler.@@ -789,14 +772,14 @@ var VideoLayout = (function (my) {break;}}- };+ },/*** Updates local stats* @param percent* @param object*/- my.updateLocalConnectionStats = function (percent, object) {+ updateLocalConnectionStats (percent, object) {var resolution = null;if (object.resolution !== null) {resolution = object.resolution;@@ -814,7 +797,7 @@ var VideoLayout = (function (my) {updateResolution(resolution[jid]);}}- };+ },/*** Updates remote stats.@@ -822,92 +805,90 @@ var VideoLayout = (function (my) {* @param percent the connection quality percent* @param object the stats data*/- my.updateConnectionStats = function (jid, percent, object) {+ updateConnectionStats (jid, percent, object) {var resourceJid = Strophe.getResourceFromJid(jid);if (remoteVideos[resourceJid])remoteVideos[resourceJid].updateStatsIndicator(percent, object);- };+ },/*** Hides the connection indicator* @param jid*/- my.hideConnectionIndicator = function (jid) {+ hideConnectionIndicator (jid) {remoteVideos[Strophe.getResourceFromJid(jid)].hideConnectionIndicator();- };+ },/*** Hides all the indicators*/- my.hideStats = function () {+ hideStats () {for(var video in remoteVideos) {remoteVideos[video].hideIndicator();}localVideoThumbnail.hideIndicator();- };+ },- my.participantLeft = function (jid) {+ participantLeft (id) {// Unlock large video- var resourceJid = Strophe.getResourceFromJid(jid);- if (focusedVideoResourceJid === resourceJid) {+ if (focusedVideoResourceJid === id) {console.info("Focused video owner has left the conference");focusedVideoResourceJid = null;}- if (currentDominantSpeaker === resourceJid) {+ if (currentDominantSpeaker === id) {console.info("Dominant speaker has left the conference");currentDominantSpeaker = null;}- var remoteVideo = remoteVideos[resourceJid];+ var remoteVideo = remoteVideos[id];if (remoteVideo) {// Remove remote video- console.info("Removing remote video: " + resourceJid);- delete remoteVideos[resourceJid];+ console.info("Removing remote video: " + id);+ delete remoteVideos[id];remoteVideo.remove();} else {- console.warn("No remote video for " + resourceJid);+ console.warn("No remote video for " + id);}VideoLayout.resizeThumbnails();- };+ },- my.onVideoTypeChanged = function (resourceJid, newVideoType) {- if (remoteVideoTypes[resourceJid] === newVideoType) {+ onVideoTypeChanged (id, newVideoType) {+ if (remoteVideoTypes[id] === newVideoType) {return;}- console.info("Peer video type changed: ", resourceJid, newVideoType);- remoteVideoTypes[resourceJid] = newVideoType;+ console.info("Peer video type changed: ", id, newVideoType);+ remoteVideoTypes[id] = newVideoType;var smallVideo;- if (resourceJid === APP.xmpp.myResource()) {+ if (APP.conference.isLocalId(id)) {if (!localVideoThumbnail) {console.warn("Local video not ready yet");return;}smallVideo = localVideoThumbnail;- } else if (remoteVideos[resourceJid]) {- smallVideo = remoteVideos[resourceJid];+ } else if (remoteVideos[id]) {+ smallVideo = remoteVideos[id];} else {return;}smallVideo.setVideoType(newVideoType);- LargeVideo.onVideoTypeChanged(resourceJid, newVideoType);-- };+ LargeVideo.onVideoTypeChanged(id, newVideoType);+ },/*** Updates the video size and position.*/- my.updateLargeVideoSize = function () {+ updateLargeVideoSize () {LargeVideo.updateVideoSizeAndPosition();LargeVideo.position(null, null, null, null, true);- };+ },- my.showMore = function (jid) {+ showMore (jid) {if (jid === 'local') {localVideoThumbnail.connectionIndicator.showMore();} else {@@ -918,15 +899,15 @@ var VideoLayout = (function (my) {console.info("Error - no remote video for jid: " + jid);}}- };+ },- my.addPreziContainer = function (id) {+ addPreziContainer (id) {var container = RemoteVideo.createContainer(id);VideoLayout.resizeThumbnails();return container;- };+ },- my.setLargeVideoVisible = function (isVisible) {+ setLargeVideoVisible (isVisible) {LargeVideo.setLargeVideoVisible(isVisible);if(!isVisible && focusedVideoResourceJid) {var smallVideo = VideoLayout.getSmallVideo(focusedVideoResourceJid);@@ -936,7 +917,7 @@ var VideoLayout = (function (my) {}focusedVideoResourceJid = null;}- };+ },/*** Resizes the video area.@@ -945,10 +926,10 @@ var VideoLayout = (function (my) {* @param callback a function to be called when the video space is* resized.*/- my.resizeVideoArea = function(isSideBarVisible, callback) {+ resizeVideoArea (isSideBarVisible, callback) {LargeVideo.resizeVideoAreaAnimated(isSideBarVisible, callback);VideoLayout.resizeThumbnails(true);- };+ },/*** Resizes the #videospace html element@@ -961,7 +942,7 @@ var VideoLayout = (function (my) {* @param completeFunction a function to be called when the video space* is resized.*/- my.resizeVideoSpace = function (animate, isChatVisible, completeFunction) {+ resizeVideoSpace (animate, isChatVisible, completeFunction) {var availableHeight = window.innerHeight;var availableWidth = UIUtil.getAvailableVideoWidth(isChatVisible);@@ -983,19 +964,17 @@ var VideoLayout = (function (my) {$('#videospace').height(availableHeight);}- };+ },- my.getSmallVideo = function (resourceJid) {- if(resourceJid == APP.xmpp.myResource()) {+ getSmallVideo (id) {+ if (APP.conference.isLocalId(id)) {return localVideoThumbnail;} else {- if(!remoteVideos[resourceJid])- return null;- return remoteVideos[resourceJid];+ return remoteVideos[id];}- };+ },- my.changeUserAvatar = function(id, thumbUrl) {+ changeUserAvatar (id, thumbUrl) {var smallVideo = VideoLayout.getSmallVideo(id);if (smallVideo) {smallVideo.avatarChanged(thumbUrl);@@ -1005,46 +984,43 @@ var VideoLayout = (function (my) {);}LargeVideo.updateAvatar(id, thumbUrl);- };+ },- my.createEtherpadIframe = function(src, onloadHandler)- {+ createEtherpadIframe (src, onloadHandler) {return LargeVideo.createEtherpadIframe(src, onloadHandler);- };+ },- my.setLargeVideoState = function (state) {+ setLargeVideoState (state) {LargeVideo.setState(state);- };+ },- my.getLargeVideoState = function () {+ getLargeVideoState () {return LargeVideo.getState();- };+ },- my.setLargeVideoHover = function (inHandler, outHandler) {+ setLargeVideoHover (inHandler, outHandler) {LargeVideo.setHover(inHandler, outHandler);- };+ },/*** Indicates that the video has been interrupted.*/- my.onVideoInterrupted = function () {+ onVideoInterrupted () {LargeVideo.enableVideoProblemFilter(true);var reconnectingKey = "connection.RECONNECTING";$('#videoConnectionMessage').attr("data-i18n", reconnectingKey);$('#videoConnectionMessage').text(APP.translation.translateString(reconnectingKey));$('#videoConnectionMessage').css({display: "block"});- };+ },/*** Indicates that the video has been restored.*/- my.onVideoRestored = function () {+ onVideoRestored () {LargeVideo.enableVideoProblemFilter(false);$('#videoConnectionMessage').css({display: "none"});- };-- return my;-}(VideoLayout || {}));+ }+};-module.exports = VideoLayout;+export default VideoLayout;diff --git a/service/UI/UIEvents.js b/service/UI/UIEvents.jsindex 99015c5aa6..33b9fed58a 100644--- a/service/UI/UIEvents.js+++ b/service/UI/UIEvents.js@@ -25,6 +25,7 @@ export default {ETHERPAD_CLICKED: "UI.etherpad_clicked",ROOM_LOCK_CLICKED: "UI.room_lock_clicked",USER_INVITED: "UI.user_invited",+ USER_KICKED: "UI.user_kicked",FULLSCREEN_TOGGLE: "UI.fullscreen_toggle",AUTH_CLICKED: "UI.auth_clicked",TOGGLE_CHAT: "UI.toggle_chat",