Pārlūkot izejas kodu

Simplify the source code

master
Lyubomir Marinov 9 gadus atpakaļ
vecāks
revīzija
349c6e2c35
1 mainītis faili ar 12 papildinājumiem un 17 dzēšanām
  1. 12
    17
      modules/statistics/RTPStatsCollector.js

+ 12
- 17
modules/statistics/RTPStatsCollector.js Parādīt failu

503
 
503
 
504
         if(now.type == 'googCandidatePair')
504
         if(now.type == 'googCandidatePair')
505
         {
505
         {
506
-            var ip, type, localIP, active;
506
+            var ip, type, localip, active;
507
             try {
507
             try {
508
                 ip = getStatValue(now, 'remoteAddress');
508
                 ip = getStatValue(now, 'remoteAddress');
509
                 type = getStatValue(now, "transportType");
509
                 type = getStatValue(now, "transportType");
510
-                localIP = getStatValue(now, "localAddress");
510
+                localip = getStatValue(now, "localAddress");
511
                 active = getStatValue(now, "activeConnection");
511
                 active = getStatValue(now, "activeConnection");
512
             }
512
             }
513
             catch(e){/*not supported*/}
513
             catch(e){/*not supported*/}
514
-            if(!ip || !type || !localIP || active != "true")
514
+            if(!ip || !type || !localip || active != "true")
515
                 continue;
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
             continue;
524
             continue;
530
         }
525
         }
531
 
526
 
536
             var local = this.currentStatsReport[now.localCandidateId];
531
             var local = this.currentStatsReport[now.localCandidateId];
537
             var remote = this.currentStatsReport[now.remoteCandidateId];
532
             var remote = this.currentStatsReport[now.remoteCandidateId];
538
             this.conferenceStats.transport.push({
533
             this.conferenceStats.transport.push({
539
-                localip: local.ipAddress + ":" + local.portNumber,
540
                 ip: remote.ipAddress + ":" + remote.portNumber,
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
 

Notiek ielāde…
Atcelt
Saglabāt