Browse Source

refactor(statistics): Remove unused code

dev1
hristoterezov 9 years ago
parent
commit
14053f3b83
4 changed files with 0 additions and 170 deletions
  1. 0
    115
      modules/statistics/RTPStatsCollector.js
  2. 0
    23
      modules/statistics/statistics.js
  3. 0
    31
      modules/xmpp/xmpp.js
  4. 0
    1
      package.json

+ 0
- 115
modules/statistics/RTPStatsCollector.js View File

67
     return Math.round((lostPackets/totalPackets)*100);
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
  * Holds "statistics" for a single SSRC.
71
  * Holds "statistics" for a single SSRC.
105
  * @constructor
72
  * @constructor
230
     this.eventEmitter = eventEmitter;
197
     this.eventEmitter = eventEmitter;
231
     this.conferenceStats = new ConferenceStats();
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
     // Updates stats interval
200
     // Updates stats interval
252
     this.audioLevelsIntervalMilis = audioLevelsInterval;
201
     this.audioLevelsIntervalMilis = audioLevelsInterval;
253
 
202
 
272
         clearInterval(this.statsIntervalId);
221
         clearInterval(this.statsIntervalId);
273
         this.statsIntervalId = null;
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
             self.statsIntervalMilis
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
 /**

+ 0
- 23
modules/statistics/statistics.js View File

58
         });
58
         });
59
 }
59
 }
60
 
60
 
61
-/**
62
- * Log stats via the focus once every this many milliseconds.
63
- */
64
-var LOG_INTERVAL = 60000;
65
-
66
 /**
61
 /**
67
  * callstats strips any additional fields from Error except for "name", "stack",
62
  * callstats strips any additional fields from Error except for "name", "stack",
68
  * "message" and "constraintName". So we need to bundle additional information
63
  * "message" and "constraintName". So we need to bundle additional information
128
     // Flag indicates whether or not the CallStats have been started for this
123
     // Flag indicates whether or not the CallStats have been started for this
129
     // Statistics instance
124
     // Statistics instance
130
     this.callStatsStarted = false;
125
     this.callStatsStarted = false;
131
-
132
-    /**
133
-     * Send the stats already saved in rtpStats to be logged via the focus.
134
-     */
135
-    this.logStatsIntervalId = null;
136
 }
126
 }
137
 Statistics.audioLevelsEnabled = false;
127
 Statistics.audioLevelsEnabled = false;
138
 Statistics.audioLevelsInterval = 200;
128
 Statistics.audioLevelsInterval = 200;
157
         this.rtpStats = null;
147
         this.rtpStats = null;
158
         logger.error('Failed to start collecting remote statistics: ' + e);
148
         logger.error('Failed to start collecting remote statistics: ' + e);
159
     }
149
     }
160
-    if (this.rtpStats) {
161
-        this.logStatsIntervalId = setInterval(function () {
162
-            var stats = this.rtpStats.getCollectedStats();
163
-            if (this.xmpp.sendLogs(stats)) {
164
-                this.rtpStats.clearCollectedStats();
165
-            }
166
-        }.bind(this), LOG_INTERVAL);
167
-    }
168
 };
150
 };
169
 
151
 
170
 Statistics.localStats = [];
152
 Statistics.localStats = [];
233
 
215
 
234
     this.rtpStats.stop();
216
     this.rtpStats.stop();
235
     this.rtpStats = null;
217
     this.rtpStats = null;
236
-
237
-    if (this.logStatsIntervalId) {
238
-        clearInterval(this.logStatsIntervalId);
239
-        this.logStatsIntervalId = null;
240
-    }
241
 };
218
 };
242
 
219
 
243
 //CALSTATS METHODS
220
 //CALSTATS METHODS

+ 0
- 31
modules/xmpp/xmpp.js View File

3
 import { getLogger } from "jitsi-meet-logger";
3
 import { getLogger } from "jitsi-meet-logger";
4
 const logger = getLogger(__filename);
4
 const logger = getLogger(__filename);
5
 import EventEmitter from "events";
5
 import EventEmitter from "events";
6
-import Pako from "pako";
7
 import RandomUtil from "../util/RandomUtil";
6
 import RandomUtil from "../util/RandomUtil";
8
 import * as JitsiConnectionErrors from "../../JitsiConnectionErrors";
7
 import * as JitsiConnectionErrors from "../../JitsiConnectionErrors";
9
 import * as JitsiConnectionEvents from "../../JitsiConnectionEvents";
8
 import * as JitsiConnectionEvents from "../../JitsiConnectionEvents";
286
         this.eventEmitter.removeListener(type, listener);
285
         this.eventEmitter.removeListener(type, listener);
287
     }
286
     }
288
 
287
 
289
-    /**
290
-     * Sends 'data' as a log message to the focus. Returns true iff a message
291
-     * was sent.
292
-     * @param data
293
-     * @returns {boolean} true iff a message was sent.
294
-     */
295
-    sendLogs (data) {
296
-        if (!this.connection.emuc.focusMucJid)
297
-            return false;
298
-
299
-        const content = Base64.encode(
300
-            String.fromCharCode.apply(null,
301
-                Pako.deflateRaw(JSON.stringify(data))));
302
-        // XEP-0337-ish
303
-        const message = $msg({
304
-            to: this.connection.emuc.focusMucJid,
305
-            type: "normal"
306
-        });
307
-        message.c("log", {
308
-            xmlns: "urn:xmpp:eventlog",
309
-            id: "PeerConnectionStats"
310
-        });
311
-        message.c("message").t(content).up();
312
-        message.c("tag", {name: "deflated", value: "true"}).up();
313
-        message.up();
314
-
315
-        this.connection.send(message);
316
-        return true;
317
-    }
318
-
319
     /**
288
     /**
320
      * Returns the logs from strophe.jingle.
289
      * Returns the logs from strophe.jingle.
321
      * @returns {Object}
290
      * @returns {Object}

+ 0
- 1
package.json View File

21
     "events": "*",
21
     "events": "*",
22
     "jitsi-meet-logger": "jitsi/jitsi-meet-logger",
22
     "jitsi-meet-logger": "jitsi/jitsi-meet-logger",
23
     "jssha": "1.5.0",
23
     "jssha": "1.5.0",
24
-    "pako": "*",
25
     "retry": "0.6.1",
24
     "retry": "0.6.1",
26
     "sdp-interop": "0.1.11",
25
     "sdp-interop": "0.1.11",
27
     "sdp-simulcast": "0.1.7",
26
     "sdp-simulcast": "0.1.7",

Loading…
Cancel
Save