|
@@ -67,39 +67,6 @@ function calculatePacketLoss(lostPackets, totalPackets) {
|
67
|
67
|
return Math.round((lostPackets/totalPackets)*100);
|
68
|
68
|
}
|
69
|
69
|
|
70
|
|
-/**
|
71
|
|
- * Checks whether a certain record should be included in the logged statistics.
|
72
|
|
- */
|
73
|
|
-function acceptStat(reportId, reportType, statName) {
|
74
|
|
- if (reportType == "googCandidatePair") {
|
75
|
|
- if (statName == "googChannelId")
|
76
|
|
- return false;
|
77
|
|
-
|
78
|
|
- } else if (reportType == "ssrc") {
|
79
|
|
- if (statName == "googTrackId" ||
|
80
|
|
- statName == "transportId" ||
|
81
|
|
- statName == "ssrc")
|
82
|
|
- return false;
|
83
|
|
- }
|
84
|
|
-
|
85
|
|
- return true;
|
86
|
|
-}
|
87
|
|
-
|
88
|
|
-/**
|
89
|
|
- * Checks whether a certain record should be included in the logged statistics.
|
90
|
|
- */
|
91
|
|
-function acceptReport(id, type) {
|
92
|
|
- if (type == "googComponent")
|
93
|
|
- return false;
|
94
|
|
-
|
95
|
|
- if (id.substring(0, 15) == "googCertificate" ||
|
96
|
|
- id.substring(0, 9) == "googTrack" ||
|
97
|
|
- id.substring(0, 20) == "googLibjingleSession")
|
98
|
|
- return false;
|
99
|
|
-
|
100
|
|
- return true;
|
101
|
|
-}
|
102
|
|
-
|
103
|
70
|
/**
|
104
|
71
|
* Holds "statistics" for a single SSRC.
|
105
|
72
|
* @constructor
|
|
@@ -230,24 +197,6 @@ function StatsCollector(
|
230
|
197
|
this.eventEmitter = eventEmitter;
|
231
|
198
|
this.conferenceStats = new ConferenceStats();
|
232
|
199
|
|
233
|
|
- /**
|
234
|
|
- * Gather PeerConnection stats once every this many milliseconds.
|
235
|
|
- */
|
236
|
|
- this.GATHER_INTERVAL = 15000;
|
237
|
|
-
|
238
|
|
- /**
|
239
|
|
- * Gather stats and store them in this.statsToBeLogged.
|
240
|
|
- */
|
241
|
|
- this.gatherStatsIntervalId = null;
|
242
|
|
-
|
243
|
|
- /**
|
244
|
|
- * Stores the statistics which will be send to the focus to be logged.
|
245
|
|
- */
|
246
|
|
- this.statsToBeLogged = {
|
247
|
|
- timestamps: [],
|
248
|
|
- stats: {}
|
249
|
|
- };
|
250
|
|
-
|
251
|
200
|
// Updates stats interval
|
252
|
201
|
this.audioLevelsIntervalMilis = audioLevelsInterval;
|
253
|
202
|
|
|
@@ -272,11 +221,6 @@ StatsCollector.prototype.stop = function () {
|
272
|
221
|
clearInterval(this.statsIntervalId);
|
273
|
222
|
this.statsIntervalId = null;
|
274
|
223
|
}
|
275
|
|
-
|
276
|
|
- if (this.gatherStatsIntervalId) {
|
277
|
|
- clearInterval(this.gatherStatsIntervalId);
|
278
|
|
- this.gatherStatsIntervalId = null;
|
279
|
|
- }
|
280
|
224
|
};
|
281
|
225
|
|
282
|
226
|
/**
|
|
@@ -353,65 +297,6 @@ StatsCollector.prototype.start = function (startAudioLevelStats) {
|
353
|
297
|
self.statsIntervalMilis
|
354
|
298
|
);
|
355
|
299
|
}
|
356
|
|
-
|
357
|
|
- if (browserSupported
|
358
|
|
- // logging statistics does not support firefox
|
359
|
|
- && this._browserType !== RTCBrowserType.RTC_BROWSER_FIREFOX) {
|
360
|
|
- this.gatherStatsIntervalId = setInterval(
|
361
|
|
- function () {
|
362
|
|
- self.peerconnection.getStats(
|
363
|
|
- function (report) {
|
364
|
|
- self.addStatsToBeLogged(report.result());
|
365
|
|
- },
|
366
|
|
- function () {
|
367
|
|
- }
|
368
|
|
- );
|
369
|
|
- },
|
370
|
|
- this.GATHER_INTERVAL
|
371
|
|
- );
|
372
|
|
- }
|
373
|
|
-};
|
374
|
|
-
|
375
|
|
-/**
|
376
|
|
- * Converts the stats to the format used for logging, and saves the data in
|
377
|
|
- * this.statsToBeLogged.
|
378
|
|
- * @param reports Reports as given by webkitRTCPerConnection.getStats.
|
379
|
|
- */
|
380
|
|
-StatsCollector.prototype.addStatsToBeLogged = function (reports) {
|
381
|
|
- var self = this;
|
382
|
|
- var num_records = this.statsToBeLogged.timestamps.length;
|
383
|
|
- this.statsToBeLogged.timestamps.push(new Date().getTime());
|
384
|
|
- reports.forEach(function (report) {
|
385
|
|
- if (!acceptReport(report.id, report.type))
|
386
|
|
- return;
|
387
|
|
- var stat = self.statsToBeLogged.stats[report.id];
|
388
|
|
- if (!stat) {
|
389
|
|
- stat = self.statsToBeLogged.stats[report.id] = {};
|
390
|
|
- }
|
391
|
|
- stat.type = report.type;
|
392
|
|
- report.names().forEach(function (name) {
|
393
|
|
- if (!acceptStat(report.id, report.type, name))
|
394
|
|
- return;
|
395
|
|
- var values = stat[name];
|
396
|
|
- if (!values) {
|
397
|
|
- values = stat[name] = [];
|
398
|
|
- }
|
399
|
|
- while (values.length < num_records) {
|
400
|
|
- values.push(null);
|
401
|
|
- }
|
402
|
|
- values.push(report.stat(name));
|
403
|
|
- });
|
404
|
|
- });
|
405
|
|
-};
|
406
|
|
-
|
407
|
|
-StatsCollector.prototype.getCollectedStats = function () {
|
408
|
|
- return this.statsToBeLogged;
|
409
|
|
-};
|
410
|
|
-
|
411
|
|
-StatsCollector.prototype.clearCollectedStats = function () {
|
412
|
|
- // Reset the stats
|
413
|
|
- this.statsToBeLogged.stats = {};
|
414
|
|
- this.statsToBeLogged.timestamps = [];
|
415
|
300
|
};
|
416
|
301
|
|
417
|
302
|
/**
|