diff --git a/modules/connectionquality/connectionquality.js b/modules/connectionquality/connectionquality.js index c1ddb14b8..48d1356e9 100644 --- a/modules/connectionquality/connectionquality.js +++ b/modules/connectionquality/connectionquality.js @@ -3,6 +3,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 @@ -96,9 +97,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.js index 4431ff7f8..f224871a3 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'); var LOCAL_JID = require("../../service/statistics/constants").LOCAL_JID; @@ -106,8 +107,8 @@ LocalStatsCollector.prototype.start = function () { if (audioLevel != self.audioLevel) { self.audioLevel = animateLevel(audioLevel, self.audioLevel); self.eventEmitter.emit( - "statistics.audioLevel", - LOCAL_JID, + StatisticsEvents.AUDIO_LEVEL, + self.statisticsService.LOCAL_JID, self.audioLevel); } }, diff --git a/modules/statistics/RTPStatsCollector.js b/modules/statistics/RTPStatsCollector.js index e9647a8be..588496d7a 100644 --- a/modules/statistics/RTPStatsCollector.js +++ b/modules/statistics/RTPStatsCollector.js @@ -3,6 +3,7 @@ var logger = require("jitsi-meet-logger").getLogger(__filename); 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() || @@ -649,7 +650,7 @@ StatsCollector.prototype.processStatsReport = function () { upload: calculatePacketLoss(lostPackets.upload, totalPackets.upload) }; - this.eventEmitter.emit("statistics.connectionstats", + this.eventEmitter.emit(StatisticsEvents.CONNECTION_STATS, { "bitrate": this.conferenceStats.bitrate, "packetLoss": this.conferenceStats.packetLoss, @@ -715,7 +716,8 @@ StatsCollector.prototype.processAudioLevelReport = function () { // but it seems to vary between 0 and around 32k. audioLevel = audioLevel / 32767; ssrcStats.setSsrcAudioLevel(ssrc, audioLevel); - this.eventEmitter.emit("statistics.audioLevel", ssrc, audioLevel); + this.eventEmitter.emit( + StatisticsEvents.AUDIO_LEVEL, ssrc, audioLevel); } } }; diff --git a/modules/statistics/statistics.js b/modules/statistics/statistics.js index c8b5de8ed..ee95349a8 100644 --- a/modules/statistics/statistics.js +++ b/modules/statistics/statistics.js @@ -2,6 +2,7 @@ var LocalStats = require("./LocalStatsCollector.js"); var RTPStats = require("./RTPStatsCollector.js"); var EventEmitter = require("events"); +var StatisticsEvents = require("../../service/statistics/Events"); //var StreamEventTypes = require("../../service/RTC/StreamEventTypes.js"); //var XMPPEvents = require("../../service/xmpp/XMPPEvents"); //var CallStats = require("./CallStats"); @@ -43,12 +44,12 @@ Statistics.prototype.startLocalStats = function (stream) { Statistics.prototype.addAudioLevelListener = function(listener) { - this.eventEmitter.on("statistics.audioLevel", listener); + this.eventEmitter.on(StatisticsEvents.AUDIO_LEVEL, listener); } Statistics.prototype.removeAudioLevelListener = function(listener) { - this.eventEmitter.removeListener("statistics.audioLevel", listener); + this.eventEmitter.removeListener(StatisticsEvents.AUDIO_LEVEL, listener); } Statistics.prototype.dispose = function () { @@ -71,7 +72,7 @@ Statistics.prototype.stopLocal = function () { Statistics.prototype.stopRemote = function () { if (this.rtpStats) { this.rtpStats.stop(); - this.eventEmitter.emit("statistics.stop"); + this.eventEmitter.emit(StatisticsEvents.STOP); this.rtpStats = null; } } diff --git a/service/statistics/Events.js b/service/statistics/Events.js new file mode 100644 index 000000000..261838262 --- /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" +};