Removes hard-coded constants and uses the events API in the statistics
module.
This commit is contained in:
parent
62d3b749bb
commit
506d0722bd
|
@ -30,6 +30,7 @@ var RTCEvents = require("../../service/RTC/RTCEvents");
|
||||||
var RTCBrowserType = require("../RTC/RTCBrowserType");
|
var RTCBrowserType = require("../RTC/RTCBrowserType");
|
||||||
var StreamEventTypes = require("../../service/RTC/StreamEventTypes");
|
var StreamEventTypes = require("../../service/RTC/StreamEventTypes");
|
||||||
var XMPPEvents = require("../../service/xmpp/XMPPEvents");
|
var XMPPEvents = require("../../service/xmpp/XMPPEvents");
|
||||||
|
var StatisticsEvents = require("../../service/statistics/Events");
|
||||||
var UIEvents = require("../../service/UI/UIEvents");
|
var UIEvents = require("../../service/UI/UIEvents");
|
||||||
var MemberEvents = require("../../service/members/Events");
|
var MemberEvents = require("../../service/members/Events");
|
||||||
|
|
||||||
|
@ -180,7 +181,8 @@ function registerListeners() {
|
||||||
var userResource = APP.UI.getLargeVideoResource();
|
var userResource = APP.UI.getLargeVideoResource();
|
||||||
eventEmitter.emit(UIEvents.SELECTED_ENDPOINT, userResource);
|
eventEmitter.emit(UIEvents.SELECTED_ENDPOINT, userResource);
|
||||||
});
|
});
|
||||||
APP.statistics.addAudioLevelListener(function(jid, audioLevel) {
|
APP.statistics.addListener(StatisticsEvents.AUDIO_LEVEL,
|
||||||
|
function(jid, audioLevel) {
|
||||||
var resourceJid;
|
var resourceJid;
|
||||||
if(jid === APP.statistics.LOCAL_JID) {
|
if(jid === APP.statistics.LOCAL_JID) {
|
||||||
resourceJid = AudioLevels.LOCAL_LEVEL;
|
resourceJid = AudioLevels.LOCAL_LEVEL;
|
||||||
|
|
|
@ -4,6 +4,7 @@ var EventEmitter = require("events");
|
||||||
var eventEmitter = new EventEmitter();
|
var eventEmitter = new EventEmitter();
|
||||||
var CQEvents = require("../../service/connectionquality/CQEvents");
|
var CQEvents = require("../../service/connectionquality/CQEvents");
|
||||||
var XMPPEvents = require("../../service/xmpp/XMPPEvents");
|
var XMPPEvents = require("../../service/xmpp/XMPPEvents");
|
||||||
|
var StatisticsEvents = require("../../service/statistics/Events");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* local stats
|
* local stats
|
||||||
|
@ -76,9 +77,10 @@ function parseMUCStats(stats) {
|
||||||
var ConnectionQuality = {
|
var ConnectionQuality = {
|
||||||
init: function () {
|
init: function () {
|
||||||
APP.xmpp.addListener(XMPPEvents.REMOTE_STATS, this.updateRemoteStats);
|
APP.xmpp.addListener(XMPPEvents.REMOTE_STATS, this.updateRemoteStats);
|
||||||
APP.statistics.addConnectionStatsListener(this.updateLocalStats);
|
APP.statistics.addListener(StatisticsEvents.CONNECTION_STATS,
|
||||||
APP.statistics.addRemoteStatsStopListener(this.stopSendingStats);
|
this.updateLocalStats);
|
||||||
|
APP.statistics.addListener(StatisticsEvents.STOP,
|
||||||
|
this.stopSendingStats);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var RTCBrowserType = require('../RTC/RTCBrowserType');
|
var RTCBrowserType = require('../RTC/RTCBrowserType');
|
||||||
|
var StatisticsEvents = require('../../service/statistics/Events');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Size of the webaudio analyzer buffer.
|
* Size of the webaudio analyzer buffer.
|
||||||
|
@ -105,7 +106,7 @@ LocalStatsCollector.prototype.start = function () {
|
||||||
if (audioLevel != self.audioLevel) {
|
if (audioLevel != self.audioLevel) {
|
||||||
self.audioLevel = animateLevel(audioLevel, self.audioLevel);
|
self.audioLevel = animateLevel(audioLevel, self.audioLevel);
|
||||||
self.eventEmitter.emit(
|
self.eventEmitter.emit(
|
||||||
"statistics.audioLevel",
|
StatisticsEvents.AUDIO_LEVEL,
|
||||||
self.statisticsService.LOCAL_JID,
|
self.statisticsService.LOCAL_JID,
|
||||||
self.audioLevel);
|
self.audioLevel);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
/* jshint -W117 */
|
/* jshint -W117 */
|
||||||
/* jshint -W101 */
|
/* jshint -W101 */
|
||||||
var RTCBrowserType = require("../RTC/RTCBrowserType");
|
var RTCBrowserType = require("../RTC/RTCBrowserType");
|
||||||
|
var StatisticsEvents = require("../../service/statistics/Events");
|
||||||
|
|
||||||
/* Whether we support the browser we are running into for logging statistics */
|
/* Whether we support the browser we are running into for logging statistics */
|
||||||
var browserSupported = RTCBrowserType.isChrome() ||
|
var browserSupported = RTCBrowserType.isChrome() ||
|
||||||
|
@ -646,7 +647,7 @@ StatsCollector.prototype.processStatsReport = function () {
|
||||||
upload:
|
upload:
|
||||||
calculatePacketLoss(lostPackets.upload, totalPackets.upload)
|
calculatePacketLoss(lostPackets.upload, totalPackets.upload)
|
||||||
};
|
};
|
||||||
this.eventEmitter.emit("statistics.connectionstats",
|
this.eventEmitter.emit(StatisticsEvents.CONNECTION_STATS,
|
||||||
{
|
{
|
||||||
"bitrate": PeerStats.bitrate,
|
"bitrate": PeerStats.bitrate,
|
||||||
"packetLoss": PeerStats.packetLoss,
|
"packetLoss": PeerStats.packetLoss,
|
||||||
|
@ -712,8 +713,10 @@ StatsCollector.prototype.processAudioLevelReport = function () {
|
||||||
// but it seems to vary between 0 and around 32k.
|
// but it seems to vary between 0 and around 32k.
|
||||||
audioLevel = audioLevel / 32767;
|
audioLevel = audioLevel / 32767;
|
||||||
jidStats.setSsrcAudioLevel(ssrc, audioLevel);
|
jidStats.setSsrcAudioLevel(ssrc, audioLevel);
|
||||||
if(jid != APP.xmpp.myJid())
|
if (jid != APP.xmpp.myJid()) {
|
||||||
this.eventEmitter.emit("statistics.audioLevel", jid, audioLevel);
|
this.eventEmitter.emit(
|
||||||
|
StatisticsEvents.AUDIO_LEVEL, jid, audioLevel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,6 +9,7 @@ var StreamEventTypes = require("../../service/RTC/StreamEventTypes.js");
|
||||||
var XMPPEvents = require("../../service/xmpp/XMPPEvents");
|
var XMPPEvents = require("../../service/xmpp/XMPPEvents");
|
||||||
var CallStats = require("./CallStats");
|
var CallStats = require("./CallStats");
|
||||||
var RTCEvents = require("../../service/RTC/RTCEvents");
|
var RTCEvents = require("../../service/RTC/RTCEvents");
|
||||||
|
var StatisticsEvents = require("../../service/statistics/Events");
|
||||||
|
|
||||||
var eventEmitter = new EventEmitter();
|
var eventEmitter = new EventEmitter();
|
||||||
|
|
||||||
|
@ -26,7 +27,7 @@ function stopLocal() {
|
||||||
function stopRemote() {
|
function stopRemote() {
|
||||||
if (rtpStats) {
|
if (rtpStats) {
|
||||||
rtpStats.stop();
|
rtpStats.stop();
|
||||||
eventEmitter.emit("statistics.stop");
|
eventEmitter.emit(StatisticsEvents.STOP);
|
||||||
rtpStats = null;
|
rtpStats = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,37 +67,12 @@ var statistics = {
|
||||||
*/
|
*/
|
||||||
LOCAL_JID: 'local',
|
LOCAL_JID: 'local',
|
||||||
|
|
||||||
addAudioLevelListener: function(listener)
|
addListener: function(type, listener) {
|
||||||
{
|
eventEmitter.on(type, listener);
|
||||||
eventEmitter.on("statistics.audioLevel", listener);
|
|
||||||
},
|
},
|
||||||
|
removeListener: function (type, listener) {
|
||||||
removeAudioLevelListener: function(listener)
|
eventEmitter.removeListener(type, listener);
|
||||||
{
|
|
||||||
eventEmitter.removeListener("statistics.audioLevel", listener);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
addConnectionStatsListener: function(listener)
|
|
||||||
{
|
|
||||||
eventEmitter.on("statistics.connectionstats", listener);
|
|
||||||
},
|
|
||||||
|
|
||||||
removeConnectionStatsListener: function(listener)
|
|
||||||
{
|
|
||||||
eventEmitter.removeListener("statistics.connectionstats", listener);
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
addRemoteStatsStopListener: function(listener)
|
|
||||||
{
|
|
||||||
eventEmitter.on("statistics.stop", listener);
|
|
||||||
},
|
|
||||||
|
|
||||||
removeRemoteStatsStopListener: function(listener)
|
|
||||||
{
|
|
||||||
eventEmitter.removeListener("statistics.stop", listener);
|
|
||||||
},
|
|
||||||
|
|
||||||
stop: function () {
|
stop: function () {
|
||||||
stopLocal();
|
stopLocal();
|
||||||
stopRemote();
|
stopRemote();
|
||||||
|
@ -105,12 +81,10 @@ var statistics = {
|
||||||
eventEmitter.removeAllListeners();
|
eventEmitter.removeAllListeners();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
stopRemoteStatistics: function()
|
stopRemoteStatistics: function()
|
||||||
{
|
{
|
||||||
stopRemote();
|
stopRemote();
|
||||||
},
|
},
|
||||||
|
|
||||||
start: function () {
|
start: function () {
|
||||||
APP.RTC.addStreamListener(onStreamCreated,
|
APP.RTC.addStreamListener(onStreamCreated,
|
||||||
StreamEventTypes.EVENT_TYPE_LOCAL_CREATED);
|
StreamEventTypes.EVENT_TYPE_LOCAL_CREATED);
|
||||||
|
|
|
@ -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"
|
||||||
|
};
|
Loading…
Reference in New Issue