|
|
@@ -106,8 +106,7 @@ function acceptReport(id, type) {
|
|
106
|
106
|
* Peer statistics data holder.
|
|
107
|
107
|
* @constructor
|
|
108
|
108
|
*/
|
|
109
|
|
-function PeerStats()
|
|
110
|
|
-{
|
|
|
109
|
+function PeerStats() {
|
|
111
|
110
|
this.ssrc2Loss = {};
|
|
112
|
111
|
this.ssrc2AudioLevel = {};
|
|
113
|
112
|
this.ssrc2bitrate = {
|
|
|
@@ -167,7 +166,6 @@ PeerStats.prototype.setSsrcAudioLevel = function (audioLevel) {
|
|
167
|
166
|
|
|
168
|
167
|
function ConferenceStats() {
|
|
169
|
168
|
|
|
170
|
|
-
|
|
171
|
169
|
/**
|
|
172
|
170
|
* The bandwidth
|
|
173
|
171
|
* @type {{}}
|
|
|
@@ -186,7 +184,6 @@ function ConferenceStats() {
|
|
186
|
184
|
*/
|
|
187
|
185
|
this.packetLoss = null;
|
|
188
|
186
|
|
|
189
|
|
-
|
|
190
|
187
|
/**
|
|
191
|
188
|
* Array with the transport information.
|
|
192
|
189
|
* @type {Array}
|
|
|
@@ -233,8 +230,7 @@ function StatsCollector(peerconnection, audioLevelsInterval, statsInterval, even
|
|
233
|
230
|
/**
|
|
234
|
231
|
* Stores the statistics which will be send to the focus to be logged.
|
|
235
|
232
|
*/
|
|
236
|
|
- this.statsToBeLogged =
|
|
237
|
|
- {
|
|
|
233
|
+ this.statsToBeLogged = {
|
|
238
|
234
|
timestamps: [],
|
|
239
|
235
|
stats: {}
|
|
240
|
236
|
};
|
|
|
@@ -259,14 +255,12 @@ StatsCollector.prototype.stop = function () {
|
|
259
|
255
|
this.audioLevelsIntervalId = null;
|
|
260
|
256
|
}
|
|
261
|
257
|
|
|
262
|
|
- if (this.statsIntervalId)
|
|
263
|
|
- {
|
|
|
258
|
+ if (this.statsIntervalId) {
|
|
264
|
259
|
clearInterval(this.statsIntervalId);
|
|
265
|
260
|
this.statsIntervalId = null;
|
|
266
|
261
|
}
|
|
267
|
262
|
|
|
268
|
|
- if(this.gatherStatsIntervalId)
|
|
269
|
|
- {
|
|
|
263
|
+ if (this.gatherStatsIntervalId) {
|
|
270
|
264
|
clearInterval(this.gatherStatsIntervalId);
|
|
271
|
265
|
this.gatherStatsIntervalId = null;
|
|
272
|
266
|
}
|
|
|
@@ -276,8 +270,7 @@ StatsCollector.prototype.stop = function () {
|
|
276
|
270
|
* Callback passed to <tt>getStats</tt> method.
|
|
277
|
271
|
* @param error an error that occurred on <tt>getStats</tt> call.
|
|
278
|
272
|
*/
|
|
279
|
|
-StatsCollector.prototype.errorCallback = function (error)
|
|
280
|
|
-{
|
|
|
273
|
+StatsCollector.prototype.errorCallback = function (error) {
|
|
281
|
274
|
logger.error("Get stats error", error);
|
|
282
|
275
|
this.stop();
|
|
283
|
276
|
};
|
|
|
@@ -285,8 +278,7 @@ StatsCollector.prototype.errorCallback = function (error)
|
|
285
|
278
|
/**
|
|
286
|
279
|
* Starts stats updates.
|
|
287
|
280
|
*/
|
|
288
|
|
-StatsCollector.prototype.start = function ()
|
|
289
|
|
-{
|
|
|
281
|
+StatsCollector.prototype.start = function () {
|
|
290
|
282
|
var self = this;
|
|
291
|
283
|
this.audioLevelsIntervalId = setInterval(
|
|
292
|
284
|
function () {
|
|
|
@@ -458,16 +450,17 @@ StatsCollector.prototype.processStatsReport = function () {
|
|
458
|
450
|
continue;
|
|
459
|
451
|
}
|
|
460
|
452
|
|
|
461
|
|
- if(now.type == "candidatepair")
|
|
462
|
|
- {
|
|
|
453
|
+ if(now.type == "candidatepair") {
|
|
463
|
454
|
if(now.state == "succeeded")
|
|
464
|
455
|
continue;
|
|
465
|
456
|
|
|
466
|
457
|
var local = this.currentStatsReport[now.localCandidateId];
|
|
467
|
458
|
var remote = this.currentStatsReport[now.remoteCandidateId];
|
|
468
|
|
- this.conferenceStats.transport.push({localip: local.ipAddress + ":" + local.portNumber,
|
|
469
|
|
- ip: remote.ipAddress + ":" + remote.portNumber, type: local.transport});
|
|
470
|
|
-
|
|
|
459
|
+ this.conferenceStats.transport.push({
|
|
|
460
|
+ localip: local.ipAddress + ":" + local.portNumber,
|
|
|
461
|
+ ip: remote.ipAddress + ":" + remote.portNumber,
|
|
|
462
|
+ type: local.transport
|
|
|
463
|
+ });
|
|
471
|
464
|
}
|
|
472
|
465
|
|
|
473
|
466
|
if (now.type != 'ssrc' && now.type != "outboundrtp" &&
|
|
|
@@ -619,7 +612,8 @@ StatsCollector.prototype.processStatsReport = function () {
|
|
619
|
612
|
this
|
|
620
|
613
|
);
|
|
621
|
614
|
|
|
622
|
|
- this.conferenceStats.bitrate = {"upload": bitrateUpload, "download": bitrateDownload};
|
|
|
615
|
+ this.conferenceStats.bitrate
|
|
|
616
|
+ = {"upload": bitrateUpload, "download": bitrateDownload};
|
|
623
|
617
|
|
|
624
|
618
|
this.conferenceStats.packetLoss = {
|
|
625
|
619
|
total:
|
|
|
@@ -630,8 +624,7 @@ StatsCollector.prototype.processStatsReport = function () {
|
|
630
|
624
|
upload:
|
|
631
|
625
|
calculatePacketLoss(lostPackets.upload, totalPackets.upload)
|
|
632
|
626
|
};
|
|
633
|
|
- this.eventEmitter.emit(StatisticsEvents.CONNECTION_STATS,
|
|
634
|
|
- {
|
|
|
627
|
+ this.eventEmitter.emit(StatisticsEvents.CONNECTION_STATS, {
|
|
635
|
628
|
"bitrate": this.conferenceStats.bitrate,
|
|
636
|
629
|
"packetLoss": this.conferenceStats.packetLoss,
|
|
637
|
630
|
"bandwidth": this.conferenceStats.bandwidth,
|
|
|
@@ -639,7 +632,6 @@ StatsCollector.prototype.processStatsReport = function () {
|
|
639
|
632
|
"transport": this.conferenceStats.transport
|
|
640
|
633
|
});
|
|
641
|
634
|
this.conferenceStats.transport = [];
|
|
642
|
|
-
|
|
643
|
635
|
};
|
|
644
|
636
|
|
|
645
|
637
|
/**
|
|
|
@@ -666,7 +658,7 @@ StatsCollector.prototype.processAudioLevelReport = function () {
|
|
666
|
658
|
|
|
667
|
659
|
var ssrc = getStatValue(now, 'ssrc');
|
|
668
|
660
|
if (!ssrc) {
|
|
669
|
|
- if((Date.now() - now.timestamp) < 3000)
|
|
|
661
|
+ if ((Date.now() - now.timestamp) < 3000)
|
|
670
|
662
|
logger.warn("No ssrc: ");
|
|
671
|
663
|
continue;
|
|
672
|
664
|
}
|