Browse Source

Simplify the source code

master
Lyubomir Marinov 9 years ago
parent
commit
349c6e2c35
1 changed files with 12 additions and 17 deletions
  1. 12
    17
      modules/statistics/RTPStatsCollector.js

+ 12
- 17
modules/statistics/RTPStatsCollector.js View File

@@ -503,29 +503,24 @@ StatsCollector.prototype.processStatsReport = function () {
503 503
 
504 504
         if(now.type == 'googCandidatePair')
505 505
         {
506
-            var ip, type, localIP, active;
506
+            var ip, type, localip, active;
507 507
             try {
508 508
                 ip = getStatValue(now, 'remoteAddress');
509 509
                 type = getStatValue(now, "transportType");
510
-                localIP = getStatValue(now, "localAddress");
510
+                localip = getStatValue(now, "localAddress");
511 511
                 active = getStatValue(now, "activeConnection");
512 512
             }
513 513
             catch(e){/*not supported*/}
514
-            if(!ip || !type || !localIP || active != "true")
514
+            if(!ip || !type || !localip || active != "true")
515 515
                 continue;
516
-            var addressSaved = false;
517
-            for(var i = 0; i < this.conferenceStats.transport.length; i++)
518
-            {
519
-                if(this.conferenceStats.transport[i].ip == ip &&
520
-                    this.conferenceStats.transport[i].type == type &&
521
-                    this.conferenceStats.transport[i].localip == localIP)
522
-                {
523
-                    addressSaved = true;
524
-                }
516
+            // Save the address unless it has been saved already.
517
+            var conferenceStatsTransport = this.conferenceStats.transport;
518
+            if(!conferenceStatsTransport.some(function (t) { return (
519
+                        t.ip == ip && t.type == type && t.localip == localip
520
+                    )})) {
521
+                conferenceStatsTransport.push(
522
+                    {ip: ip, type: type, localip: localip});
525 523
             }
526
-            if(addressSaved)
527
-                continue;
528
-            this.conferenceStats.transport.push({localip: localIP, ip: ip, type: type});
529 524
             continue;
530 525
         }
531 526
 
@@ -536,9 +531,9 @@ StatsCollector.prototype.processStatsReport = function () {
536 531
             var local = this.currentStatsReport[now.localCandidateId];
537 532
             var remote = this.currentStatsReport[now.remoteCandidateId];
538 533
             this.conferenceStats.transport.push({
539
-                localip: local.ipAddress + ":" + local.portNumber,
540 534
                 ip: remote.ipAddress + ":" + remote.portNumber,
541
-                type: local.transport
535
+                type: local.transport,
536
+                localip: local.ipAddress + ":" + local.portNumber
542 537
             });
543 538
         }
544 539
 

Loading…
Cancel
Save