浏览代码

Reformat the source code for consistency

tags/v0.0.2
Lyubomir Marinov 9 年前
父节点
当前提交
27a7d7da72
共有 2 个文件被更改,包括 30 次插入43 次删除
  1. 16
    24
      modules/statistics/RTPStatsCollector.js
  2. 14
    19
      modules/statistics/statistics.js

+ 16
- 24
modules/statistics/RTPStatsCollector.js 查看文件

@@ -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
         }

+ 14
- 19
modules/statistics/statistics.js 查看文件

@@ -6,13 +6,13 @@ var StatisticsEvents = require("../../service/statistics/Events");
6 6
 var CallStats = require("./CallStats");
7 7
 var ScriptUtil = require('../util/ScriptUtil');
8 8
 
9
-// Since callstats.io is a third party, we cannot guarantee the quality of
10
-// their service. More specifically, their server may take noticeably long
11
-// time to respond. Consequently, it is in our best interest (in the sense
12
-// that the intergration of callstats.io is pretty important to us but not
13
-// enough to allow it to prevent people from joining a conference) to (1)
14
-// start downloading their API as soon as possible and (2) do the
15
-// downloading asynchronously.
9
+// Since callstats.io is a third party, we cannot guarantee the quality of their
10
+// service. More specifically, their server may take noticeably long time to
11
+// respond. Consequently, it is in our best interest (in the sense that the
12
+// intergration of callstats.io is pretty important to us but not enough to
13
+// allow it to prevent people from joining a conference) to (1) start
14
+// downloading their API as soon as possible and (2) do the downloading
15
+// asynchronously.
16 16
 function loadCallStatsAPI() {
17 17
     ScriptUtil.loadScript(
18 18
             'https://api.callstats.io/static/callstats.min.js',
@@ -22,7 +22,6 @@ function loadCallStatsAPI() {
22 22
     // have loaded by the time we needed it (i.e. CallStats.init is invoked).
23 23
 }
24 24
 
25
-
26 25
 /**
27 26
  * Log stats via the focus once every this many milliseconds.
28 27
  */
@@ -37,17 +36,16 @@ function Statistics(xmpp, options) {
37 36
     this.options = options || {};
38 37
     this.callStatsIntegrationEnabled
39 38
         = this.options.callStatsID && this.options.callStatsSecret
40
-        // Even though AppID and AppSecret may be specified, the integration of
41
-        // callstats.io may be disabled because of globally-disallowed requests
42
-        // to any third parties.
43
-        && (this.options.disableThirdPartyRequests !== true);
39
+            // Even though AppID and AppSecret may be specified, the integration
40
+            // of callstats.io may be disabled because of globally-disallowed
41
+            // requests to any third parties.
42
+            && (this.options.disableThirdPartyRequests !== true);
44 43
     if(this.callStatsIntegrationEnabled)
45 44
         loadCallStatsAPI();
46 45
     this.callStats = null;
47 46
 
48 47
     /**
49
-     * Send the stats already saved in rtpStats to be logged via
50
-     * the focus.
48
+     * Send the stats already saved in rtpStats to be logged via the focus.
51 49
      */
52 50
     this.logStatsIntervalId = null;
53 51
 }
@@ -80,15 +78,13 @@ Statistics.startLocalStats = function (stream, callback) {
80 78
     localStats.start();
81 79
 };
82 80
 
83
-Statistics.prototype.addAudioLevelListener = function(listener)
84
-{
81
+Statistics.prototype.addAudioLevelListener = function(listener) {
85 82
     if(!Statistics.audioLevelsEnabled)
86 83
         return;
87 84
     this.eventEmitter.on(StatisticsEvents.AUDIO_LEVEL, listener);
88 85
 };
89 86
 
90
-Statistics.prototype.removeAudioLevelListener = function(listener)
91
-{
87
+Statistics.prototype.removeAudioLevelListener = function(listener) {
92 88
     if(!Statistics.audioLevelsEnabled)
93 89
         return;
94 90
     this.eventEmitter.removeListener(StatisticsEvents.AUDIO_LEVEL, listener);
@@ -114,7 +110,6 @@ Statistics.prototype.dispose = function () {
114 110
     }
115 111
 };
116 112
 
117
-
118 113
 Statistics.stopAllLocalStats = function () {
119 114
     if(!Statistics.audioLevelsEnabled)
120 115
         return;

正在加载...
取消
保存