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
Removes hard-coded constants and uses the events API in the statistics module.
Boris Grozev506d0722bd98
diff --git a/modules/UI/UI.js b/modules/UI/UI.jsindex 2164e8e0da..5f22514f45 100644--- a/modules/UI/UI.js+++ b/modules/UI/UI.js@@ -30,6 +30,7 @@ var RTCEvents = require("../../service/RTC/RTCEvents");var RTCBrowserType = require("../RTC/RTCBrowserType");var StreamEventTypes = require("../../service/RTC/StreamEventTypes");var XMPPEvents = require("../../service/xmpp/XMPPEvents");+var StatisticsEvents = require("../../service/statistics/Events");var UIEvents = require("../../service/UI/UIEvents");var MemberEvents = require("../../service/members/Events");@@ -180,7 +181,8 @@ function registerListeners() {var userResource = APP.UI.getLargeVideoResource();eventEmitter.emit(UIEvents.SELECTED_ENDPOINT, userResource);});- APP.statistics.addAudioLevelListener(function(jid, audioLevel) {+ APP.statistics.addListener(StatisticsEvents.AUDIO_LEVEL,+ function(jid, audioLevel) {var resourceJid;if(jid === APP.statistics.LOCAL_JID) {resourceJid = AudioLevels.LOCAL_LEVEL;diff --git a/modules/connectionquality/connectionquality.js b/modules/connectionquality/connectionquality.jsindex 0ef0ff75ba..4e2cb742fc 100644--- a/modules/connectionquality/connectionquality.js+++ b/modules/connectionquality/connectionquality.js@@ -4,6 +4,7 @@ var EventEmitter = require("events");var eventEmitter = new EventEmitter();var CQEvents = require("../../service/connectionquality/CQEvents");var XMPPEvents = require("../../service/xmpp/XMPPEvents");+var StatisticsEvents = require("../../service/statistics/Events");/*** local stats@@ -76,9 +77,10 @@ function parseMUCStats(stats) {var ConnectionQuality = {init: function () {APP.xmpp.addListener(XMPPEvents.REMOTE_STATS, this.updateRemoteStats);- APP.statistics.addConnectionStatsListener(this.updateLocalStats);- APP.statistics.addRemoteStatsStopListener(this.stopSendingStats);-+ APP.statistics.addListener(StatisticsEvents.CONNECTION_STATS,+ this.updateLocalStats);+ APP.statistics.addListener(StatisticsEvents.STOP,+ this.stopSendingStats);},/**diff --git a/modules/statistics/LocalStatsCollector.js b/modules/statistics/LocalStatsCollector.jsindex 7f30d9d705..a3df9ed262 100644--- a/modules/statistics/LocalStatsCollector.js+++ b/modules/statistics/LocalStatsCollector.js@@ -4,6 +4,7 @@*/var RTCBrowserType = require('../RTC/RTCBrowserType');+var StatisticsEvents = require('../../service/statistics/Events');/*** Size of the webaudio analyzer buffer.@@ -105,7 +106,7 @@ LocalStatsCollector.prototype.start = function () {if (audioLevel != self.audioLevel) {self.audioLevel = animateLevel(audioLevel, self.audioLevel);self.eventEmitter.emit(- "statistics.audioLevel",+ StatisticsEvents.AUDIO_LEVEL,self.statisticsService.LOCAL_JID,self.audioLevel);}diff --git a/modules/statistics/RTPStatsCollector.js b/modules/statistics/RTPStatsCollector.jsindex e512ed7cda..0dbb6a737a 100644--- a/modules/statistics/RTPStatsCollector.js+++ b/modules/statistics/RTPStatsCollector.js@@ -2,6 +2,7 @@/* jshint -W117 *//* jshint -W101 */var RTCBrowserType = require("../RTC/RTCBrowserType");+var StatisticsEvents = require("../../service/statistics/Events");/* Whether we support the browser we are running into for logging statistics */var browserSupported = RTCBrowserType.isChrome() ||@@ -646,7 +647,7 @@ StatsCollector.prototype.processStatsReport = function () {upload:calculatePacketLoss(lostPackets.upload, totalPackets.upload)};- this.eventEmitter.emit("statistics.connectionstats",+ this.eventEmitter.emit(StatisticsEvents.CONNECTION_STATS,{"bitrate": PeerStats.bitrate,"packetLoss": PeerStats.packetLoss,@@ -712,8 +713,10 @@ StatsCollector.prototype.processAudioLevelReport = function () {// but it seems to vary between 0 and around 32k.audioLevel = audioLevel / 32767;jidStats.setSsrcAudioLevel(ssrc, audioLevel);- if(jid != APP.xmpp.myJid())- this.eventEmitter.emit("statistics.audioLevel", jid, audioLevel);+ if (jid != APP.xmpp.myJid()) {+ this.eventEmitter.emit(+ StatisticsEvents.AUDIO_LEVEL, jid, audioLevel);+ }}}};diff --git a/modules/statistics/statistics.js b/modules/statistics/statistics.jsindex b330540929..5685cbd787 100644--- a/modules/statistics/statistics.js+++ b/modules/statistics/statistics.js@@ -9,6 +9,7 @@ var StreamEventTypes = require("../../service/RTC/StreamEventTypes.js");var XMPPEvents = require("../../service/xmpp/XMPPEvents");var CallStats = require("./CallStats");var RTCEvents = require("../../service/RTC/RTCEvents");+var StatisticsEvents = require("../../service/statistics/Events");var eventEmitter = new EventEmitter();@@ -26,7 +27,7 @@ function stopLocal() {function stopRemote() {if (rtpStats) {rtpStats.stop();- eventEmitter.emit("statistics.stop");+ eventEmitter.emit(StatisticsEvents.STOP);rtpStats = null;}}@@ -66,37 +67,12 @@ var statistics = {*/LOCAL_JID: 'local',- addAudioLevelListener: function(listener)- {- eventEmitter.on("statistics.audioLevel", listener);- },-- removeAudioLevelListener: function(listener)- {- eventEmitter.removeListener("statistics.audioLevel", listener);- },-- addConnectionStatsListener: function(listener)- {- eventEmitter.on("statistics.connectionstats", listener);+ addListener: function(type, listener) {+ eventEmitter.on(type, listener);},-- removeConnectionStatsListener: function(listener)- {- eventEmitter.removeListener("statistics.connectionstats", listener);+ removeListener: function (type, listener) {+ eventEmitter.removeListener(type, listener);},--- addRemoteStatsStopListener: function(listener)- {- eventEmitter.on("statistics.stop", listener);- },-- removeRemoteStatsStopListener: function(listener)- {- eventEmitter.removeListener("statistics.stop", listener);- },-stop: function () {stopLocal();stopRemote();@@ -105,12 +81,10 @@ var statistics = {eventEmitter.removeAllListeners();}},-stopRemoteStatistics: function(){stopRemote();},-start: function () {APP.RTC.addStreamListener(onStreamCreated,StreamEventTypes.EVENT_TYPE_LOCAL_CREATED);diff --git a/service/statistics/Events.js b/service/statistics/Events.jsnew file mode 100644index 0000000000..2618382623--- /dev/null+++ b/service/statistics/Events.js@@ -0,0 +1,14 @@+module.exports = {+ /**+ * An event carrying connection statistics.+ */+ CONNECTION_STATS: "statistics.connectionstats",+ /**+ * FIXME: needs documentation.+ */+ AUDIO_LEVEL: "statistics.audioLevel",+ /**+ * FIXME: needs documentation.+ */+ STOP: "statistics.stop"+};