Sfoglia il codice sorgente

[eslint] prefer-const

tags/v0.0.2
Lyubo Marinov 8 anni fa
parent
commit
1ff84b6781

+ 1
- 0
.eslintrc.js Vedi File

@@ -52,6 +52,7 @@ module.exports = {
52 52
             { 'nestedBinaryExpressions': false }
53 53
         ],
54 54
 
55
+        'prefer-const': 2,
55 56
         'prefer-reflect': 0,
56 57
         'prefer-spread': 2,
57 58
         'require-yield': 2,

+ 1
- 1
JitsiConference.js Vedi File

@@ -180,7 +180,7 @@ JitsiConference.prototype.leave = function () {
180 180
 
181 181
     // leave the conference
182 182
     if (this.room) {
183
-        let room = this.room;
183
+        const room = this.room;
184 184
         this.room = null;
185 185
         return room.leave().catch(() => {
186 186
             // remove all participants because currently the conference won't

+ 1
- 1
JitsiMeetJS.js Vedi File

@@ -36,7 +36,7 @@ function getLowerResolution(resolution) {
36 36
     var order = Resolutions[resolution].order;
37 37
     var res = null;
38 38
     var resName = null;
39
-    for(let i in Resolutions) {
39
+    for(const i in Resolutions) {
40 40
         var tmp = Resolutions[i];
41 41
         if (!res || (res.order < tmp.order && tmp.order < order)) {
42 42
             resName = i;

+ 5
- 5
modules/RTC/JitsiLocalTrack.js Vedi File

@@ -144,11 +144,11 @@ JitsiLocalTrack.prototype.isEnded = function () {
144 144
  */
145 145
 JitsiLocalTrack.prototype._initNoDataFromSourceHandlers = function () {
146 146
     if(this.isVideoTrack() && this.videoType === VideoType.CAMERA) {
147
-        let _onNoDataFromSourceError
147
+        const _onNoDataFromSourceError
148 148
             = this._onNoDataFromSourceError.bind(this);
149 149
         this._setHandler("track_mute", () => {
150 150
             if(this._checkForCameraIssues()) {
151
-                let now = window.performance.now();
151
+                const now = window.performance.now();
152 152
                 this._noDataFromSourceTimeout
153 153
                     = setTimeout(_onNoDataFromSourceError, 3000);
154 154
                 this._setHandler("track_unmute", () => {
@@ -192,9 +192,9 @@ JitsiLocalTrack.prototype._onNoDataFromSourceError = function () {
192 192
  */
193 193
 JitsiLocalTrack.prototype._fireNoDataFromSourceEvent = function () {
194 194
     this.eventEmitter.emit(JitsiTrackEvents.NO_DATA_FROM_SOURCE);
195
-    let eventName = this.getType() + ".no_data_from_source";
195
+    const eventName = this.getType() + ".no_data_from_source";
196 196
     Statistics.analytics.sendEvent(eventName);
197
-    let log = {name: eventName};
197
+    const log = {name: eventName};
198 198
     if (this.isAudioTrack()) {
199 199
         log.isReceivingData = this._isReceivingData();
200 200
     }
@@ -552,7 +552,7 @@ JitsiLocalTrack.prototype._setByteSent = function (bytesSent) {
552 552
     // FIXME it's a shame that PeerConnection and ICE status does not belong
553 553
     // to the RTC module and it has to be accessed through
554 554
     // the conference(and through the XMPP chat room ???) instead
555
-    let iceConnectionState
555
+    const iceConnectionState
556 556
         = this.conference ? this.conference.getConnectionState() : null;
557 557
     if(this._testByteSent && "connected" === iceConnectionState) {
558 558
         setTimeout(function () {

+ 1
- 1
modules/RTC/ScreenObtainer.js Vedi File

@@ -474,7 +474,7 @@ function waitForExtensionAfterInstall(options, waitInterval, retries) {
474 474
     }
475 475
     return new Promise((resolve, reject) => {
476 476
         let currentRetries = retries;
477
-        let interval = window.setInterval(() => {
477
+        const interval = window.setInterval(() => {
478 478
             checkChromeExtInstalled( (installed) => {
479 479
                 if(installed) {
480 480
                     window.clearInterval(interval);

+ 3
- 3
modules/RTC/TraceablePeerConnection.js Vedi File

@@ -298,7 +298,7 @@ TraceablePeerConnection.prototype._remoteTrackAdded = function (stream, track) {
298 298
 
299 299
     // FIXME the length of ssrcLines[0] not verified, but it will fail
300 300
     // with global error handler anyway
301
-    let trackSsrc = ssrcLines[0].substring(7).split(' ')[0];
301
+    const trackSsrc = ssrcLines[0].substring(7).split(' ')[0];
302 302
     const ownerEndpointId = this.signalingLayer.getSSRCOwner(trackSsrc);
303 303
 
304 304
     if (!ownerEndpointId) {
@@ -860,8 +860,8 @@ TraceablePeerConnection.prototype.createAnswer
860 860
 
861 861
                 // Fix the setup attribute (see _fixAnswerRFC4145Setup for
862 862
                 //  details)
863
-                let remoteDescription = new SDP(this.remoteDescription.sdp);
864
-                let localDescription = new SDP(answer.sdp);
863
+                const remoteDescription = new SDP(this.remoteDescription.sdp);
864
+                const localDescription = new SDP(answer.sdp);
865 865
                 _fixAnswerRFC4145Setup(remoteDescription, localDescription);
866 866
                 answer.sdp = localDescription.raw;
867 867
 

+ 14
- 13
modules/connectivity/ConnectionQuality.js Vedi File

@@ -70,7 +70,7 @@ function getTarget(simulcast, resolution, millisSinceStart) {
70 70
     } else {
71 71
         // See GetMaxDefaultVideoBitrateKbps in
72 72
         // media/engine/webrtcvideoengine2.cc from webrtc.org
73
-        let pixels = resolution.width * resolution.height;
73
+        const pixels = resolution.width * resolution.height;
74 74
         if (pixels <= 320 * 240) {
75 75
             target = 600;
76 76
         } else if (pixels <= 640 * 480) {
@@ -248,7 +248,7 @@ export default class ConnectionQuality {
248 248
 
249 249
         // resolutionName is an index into Resolutions (where "720" is
250 250
         // "1280x720" and "960" is "960x720" ...).
251
-        let resolution = Resolutions[resolutionName];
251
+        const resolution = Resolutions[resolutionName];
252 252
 
253 253
         let quality = 100;
254 254
         let packetLoss;
@@ -301,7 +301,7 @@ export default class ConnectionQuality {
301 301
             // Calculate a value based on the sending bitrate.
302 302
 
303 303
             // time since sending of video was enabled.
304
-            let millisSinceStart = window.performance.now()
304
+            const millisSinceStart = window.performance.now()
305 305
                     - Math.max(this._timeVideoUnmuted, this._timeIceConnected);
306 306
 
307 307
             // expected sending bitrate in perfect conditions
@@ -320,9 +320,9 @@ export default class ConnectionQuality {
320 320
         // Make sure that the quality doesn't climb quickly
321 321
         if (this._lastConnectionQualityUpdate > 0)
322 322
         {
323
-            let maxIncreasePerSecond = 2;
324
-            let prevConnectionQuality = this._localStats.connectionQuality;
325
-            let diffSeconds
323
+            const maxIncreasePerSecond = 2;
324
+            const prevConnectionQuality = this._localStats.connectionQuality;
325
+            const diffSeconds
326 326
                 = (window.performance.now()
327 327
                     - this._lastConnectionQualityUpdate) / 1000;
328 328
             quality = Math.min(
@@ -348,7 +348,7 @@ export default class ConnectionQuality {
348 348
      */
349 349
     _broadcastLocalStats() {
350 350
         // Send only the data that remote participants care about.
351
-        let data = {
351
+        const data = {
352 352
             bitrate: this._localStats.bitrate,
353 353
             packetLoss: this._localStats.packetLoss,
354 354
             connectionQuality: this._localStats.connectionQuality
@@ -357,7 +357,7 @@ export default class ConnectionQuality {
357 357
         // TODO: It looks like the remote participants don't really "care"
358 358
         // about the resolution, and they look at their local rendered
359 359
         // resolution instead. Consider removing this.
360
-        let localVideoTrack
360
+        const localVideoTrack
361 361
             = this._conference.getLocalVideoTrack();
362 362
         if (localVideoTrack && localVideoTrack.resolution) {
363 363
             data.resolution = localVideoTrack.resolution;
@@ -386,13 +386,14 @@ export default class ConnectionQuality {
386 386
      */
387 387
     _updateLocalStats(data) {
388 388
         let key;
389
-        let updateLocalConnectionQuality
389
+        const updateLocalConnectionQuality
390 390
             = !this._conference.isConnectionInterrupted();
391
-        let localVideoTrack
391
+        const localVideoTrack
392 392
             = this._conference.getLocalVideoTrack();
393
-        let videoType = localVideoTrack ? localVideoTrack.videoType : undefined;
394
-        let isMuted = localVideoTrack ? localVideoTrack.isMuted() : true;
395
-        let resolution = localVideoTrack ? localVideoTrack.resolution : null;
393
+        const videoType
394
+            = localVideoTrack ? localVideoTrack.videoType : undefined;
395
+        const isMuted = localVideoTrack ? localVideoTrack.isMuted() : true;
396
+        const resolution = localVideoTrack ? localVideoTrack.resolution : null;
396 397
 
397 398
         if (!isMuted) {
398 399
             this._maybeUpdateUnmuteTime();

+ 1
- 1
modules/connectivity/ParticipantConnectionStatus.js Vedi File

@@ -344,7 +344,7 @@ export default class ParticipantConnectionStatus {
344 344
             isConnActiveByJvb = true;
345 345
         }
346 346
 
347
-        let isConnectionActive
347
+        const isConnectionActive
348 348
             = isConnActiveByJvb && (isVideoMuted || !isVideoTrackFrozen);
349 349
 
350 350
         logger.debug(

+ 5
- 5
modules/settings/Settings.js Vedi File

@@ -10,7 +10,7 @@ import UsernameGenerator from "../util/UsernameGenerator";
10 10
  * @returns {Storage} the local Storage object (if any)
11 11
  */
12 12
 function getLocalStorage() {
13
-    let global = typeof window == 'undefined' ? this : window;
13
+    const global = typeof window == 'undefined' ? this : window;
14 14
     return global.localStorage;
15 15
 }
16 16
 
@@ -27,7 +27,7 @@ function generateUniqueId() {
27 27
  * @returns {string} random unique id
28 28
  */
29 29
 function generateJitsiMeetId() {
30
-    let jitsiMeetId = generateUniqueId();
30
+    const jitsiMeetId = generateUniqueId();
31 31
     logger.log("generated id", jitsiMeetId);
32 32
 
33 33
     return jitsiMeetId;
@@ -38,7 +38,7 @@ function generateJitsiMeetId() {
38 38
  * @returns {string} fake random username
39 39
  */
40 40
 function generateCallStatsUsername() {
41
-    let username = UsernameGenerator.generateUsername();
41
+    const username = UsernameGenerator.generateUsername();
42 42
     logger.log('generated callstats uid', username);
43 43
 
44 44
     return username;
@@ -97,7 +97,7 @@ class Settings {
97 97
      * @param {string} sessionId session id
98 98
      */
99 99
     setSessionId (sessionId) {
100
-        let localStorage = getLocalStorage();
100
+        const localStorage = getLocalStorage();
101 101
         if (localStorage) {
102 102
             if (sessionId) {
103 103
                 localStorage.setItem('sessionId', sessionId);
@@ -121,7 +121,7 @@ class Settings {
121 121
     getSessionId () {
122 122
         // We may update sessionId in localStorage from another JitsiConference
123 123
         // instance and that's why we should always re-read it.
124
-        let localStorage = getLocalStorage();
124
+        const localStorage = getLocalStorage();
125 125
         return localStorage ? localStorage.getItem('sessionId') : undefined;
126 126
     }
127 127
 }

+ 3
- 3
modules/statistics/AnalyticsAdapter.js Vedi File

@@ -34,14 +34,14 @@ class CacheAnalytics extends AnalyticsAbstract {
34 34
      * @returns {Array} with the cached events.
35 35
      */
36 36
     drainCachedEvents() {
37
-        let eventCacheCopy = this.eventCache.slice();
37
+        const eventCacheCopy = this.eventCache.slice();
38 38
         this.eventCache = [];
39 39
         return eventCacheCopy;
40 40
     }
41 41
 
42 42
 }
43 43
 
44
-let cacheAnalytics = new CacheAnalytics();
44
+const cacheAnalytics = new CacheAnalytics();
45 45
 
46 46
 /**
47 47
  * This class will store and manage the handlers that are going to be used.
@@ -72,7 +72,7 @@ class AnalyticsAdapter {
72 72
      * @param {Object} data can be any JSON object
73 73
      */
74 74
     sendEvent(action, data = {}) {
75
-        let modifiedData = Object.assign(
75
+        const modifiedData = Object.assign(
76 76
             {browserName: this.browserName}, this.permanentProperties, data);
77 77
         this.analyticsHandlers.forEach(
78 78
             analytics => analytics.sendEvent(action, modifiedData));

+ 2
- 2
modules/xmpp/Caps.js Vedi File

@@ -47,7 +47,7 @@ export default class Caps extends Listenable {
47 47
             room => this._addChatRoom(room));
48 48
         emuc.addListener(XMPPEvents.EMUC_ROOM_REMOVED,
49 49
             room => this._removeChatRoom(room));
50
-        for(let jid in emuc.rooms) {
50
+        for(const jid in emuc.rooms) {
51 51
             this._addChatRoom(this.emuc.rooms[jid]);
52 52
         }
53 53
 
@@ -102,7 +102,7 @@ export default class Caps extends Listenable {
102 102
      * @returns {Promise<Set<String>, Error>}
103 103
      */
104 104
     getFeatures(jid, timeout = 5000) {
105
-        let user
105
+        const user
106 106
             = jid in this.jidToVersion ? this.jidToVersion[jid] : null;
107 107
         if(!user || !(user.version in this.versionToCapabilities))
108 108
         {

+ 3
- 3
modules/xmpp/ChatRoom.js Vedi File

@@ -761,7 +761,7 @@ export default class ChatRoom extends Listenable {
761 761
             mutedNode = filterNodeFromPresenceJSON(pres, "audiomuted");
762 762
         } else if (mediaType === MediaType.VIDEO) {
763 763
             mutedNode = filterNodeFromPresenceJSON(pres, "videomuted");
764
-            let videoTypeNode = filterNodeFromPresenceJSON(pres, "videoType");
764
+            const videoTypeNode = filterNodeFromPresenceJSON(pres, "videoType");
765 765
 
766 766
             if(videoTypeNode.length > 0) {
767 767
                 data.videoType = videoTypeNode[0]["value"];
@@ -901,8 +901,8 @@ export default class ChatRoom extends Listenable {
901 901
      */
902 902
     leave () {
903 903
         return new Promise((resolve, reject) => {
904
-            let timeout = setTimeout(() => onMucLeft(true), 5000);
905
-            let eventEmitter = this.eventEmitter;
904
+            const timeout = setTimeout(() => onMucLeft(true), 5000);
905
+            const eventEmitter = this.eventEmitter;
906 906
             function onMucLeft(doReject = false) {
907 907
                 eventEmitter.removeListener(XMPPEvents.MUC_LEFT, onMucLeft);
908 908
                 clearTimeout(timeout);

+ 2
- 2
modules/xmpp/JingleSessionPC.js Vedi File

@@ -628,7 +628,7 @@ export default class JingleSessionPC extends JingleSession {
628 628
      *  be added to the remote SDP
629 629
      */
630 630
     _parseSsrcInfoFromSourceAdd(sourceAddElem, currentRemoteSdp) {
631
-        let addSsrcInfo = [];
631
+        const addSsrcInfo = [];
632 632
         $(sourceAddElem).each(function (idx, content) {
633 633
             const name = $(content).attr('name');
634 634
             let lines = '';
@@ -881,7 +881,7 @@ export default class JingleSessionPC extends JingleSession {
881 881
                     logger.debug("Renegotiate: creating answer");
882 882
                     this.peerconnection.createAnswer(
883 883
                         (answer) => {
884
-                            let localUfrag = JingleSessionPC.getUfrag(answer.sdp);
884
+                            const localUfrag = JingleSessionPC.getUfrag(answer.sdp);
885 885
                             if (localUfrag != this.localUfrag) {
886 886
                                 this.localUfrag = localUfrag;
887 887
                                 this.room.eventEmitter.emit(

+ 3
- 3
modules/xmpp/RtxModifier.js Vedi File

@@ -130,8 +130,8 @@ export default class RtxModifier {
130 130
         logger.debug("Parsed primary video ssrcs ", primaryVideoSsrcs,
131 131
             " making sure all have rtx streams");
132 132
         for (const ssrc of primaryVideoSsrcs) {
133
-            let msid = videoMLine.getSSRCAttrValue(ssrc, "msid");
134
-            let cname = videoMLine.getSSRCAttrValue(ssrc, "cname");
133
+            const msid = videoMLine.getSSRCAttrValue(ssrc, "msid");
134
+            const cname = videoMLine.getSSRCAttrValue(ssrc, "cname");
135 135
             let correspondingRtxSsrc = this.correspondingRtxSsrcs.get(ssrc);
136 136
             if (correspondingRtxSsrc) {
137 137
                 logger.debug(
@@ -142,7 +142,7 @@ export default class RtxModifier {
142 142
                     `No previously associated rtx ssrc for video ssrc ${ssrc}`);
143 143
                 // If there's one in the sdp already for it, we'll just set
144 144
                 //  that as the corresponding one
145
-                let previousAssociatedRtxStream = videoMLine.getRtxSSRC(ssrc);
145
+                const previousAssociatedRtxStream = videoMLine.getRtxSSRC(ssrc);
146 146
                 if (previousAssociatedRtxStream) {
147 147
                     logger.debug(
148 148
                         `Rtx stream ${previousAssociatedRtxStream} ` +

+ 57
- 57
modules/xmpp/RtxModifier.spec.js Vedi File

@@ -11,7 +11,7 @@ import * as SDPUtil from "./SDPUtil";
11 11
  * @returns {number} the number of video ssrcs in the given sdp
12 12
  */
13 13
 function numVideoSsrcs (parsedSdp) {
14
-  let videoMLine = parsedSdp.media.find(m => m.type === "video");
14
+  const videoMLine = parsedSdp.media.find(m => m.type === "video");
15 15
   return videoMLine.ssrcs
16 16
     .map(ssrcInfo => ssrcInfo.id)
17 17
     .filter((ssrc, index, array) => array.indexOf(ssrc) === index)
@@ -24,7 +24,7 @@ function numVideoSsrcs (parsedSdp) {
24 24
  * @returns {number} the primary video ssrc in the given sdp
25 25
  */
26 26
 function getPrimaryVideoSsrc (parsedSdp) {
27
-  let videoMLine = parsedSdp.media.find(m => m.type === "video");
27
+  const videoMLine = parsedSdp.media.find(m => m.type === "video");
28 28
   return parseInt(SDPUtil.parsePrimaryVideoSsrc(videoMLine));
29 29
 }
30 30
 
@@ -37,15 +37,15 @@ function getPrimaryVideoSsrc (parsedSdp) {
37 37
  * @returns {list<number>} the primary video ssrcs in the given sdp
38 38
  */
39 39
 function getPrimaryVideoSsrcs (parsedSdp) {
40
-  let videoMLine = parsedSdp.media.find(m => m.type === "video");
40
+  const videoMLine = parsedSdp.media.find(m => m.type === "video");
41 41
   if (numVideoSsrcs(parsedSdp) === 1) {
42 42
     return [videoMLine.ssrcs[0].id];
43 43
   } else {
44
-    let simGroups = getVideoGroups(parsedSdp, "SIM");
44
+    const simGroups = getVideoGroups(parsedSdp, "SIM");
45 45
     if (simGroups.length > 1) {
46 46
       return;
47 47
     }
48
-    let simGroup = simGroups[0];
48
+    const simGroup = simGroups[0];
49 49
     return SDPUtil.parseGroupSsrcs(simGroup);
50 50
   }
51 51
 }
@@ -60,7 +60,7 @@ function getPrimaryVideoSsrcs (parsedSdp) {
60 60
  *  that matched the passed semantics
61 61
  */
62 62
 function getVideoGroups (parsedSdp, groupSemantics) {
63
-  let videoMLine = parsedSdp.media.find(m => m.type === "video");
63
+  const videoMLine = parsedSdp.media.find(m => m.type === "video");
64 64
   videoMLine.ssrcGroups = videoMLine.ssrcGroups || [];
65 65
   return videoMLine.ssrcGroups
66 66
     .filter(g => g.semantics === groupSemantics);
@@ -82,18 +82,18 @@ describe ("RtxModifier", function() {
82 82
         it ("should add a single rtx ssrc", function() {
83 83
           // Call rtxModifier.modifyRtxSsrcs with an sdp that contains a single video
84 84
           //  ssrc.  The returned sdp should have an rtx ssrc and an fid group.
85
-          let newSdpStr = this.rtxModifier.modifyRtxSsrcs(this.transform.write(this.singleVideoSdp));
86
-          let newSdp = transform.parse(newSdpStr);
87
-          let newPrimaryVideoSsrc = getPrimaryVideoSsrc(newSdp);
85
+          const newSdpStr = this.rtxModifier.modifyRtxSsrcs(this.transform.write(this.singleVideoSdp));
86
+          const newSdp = transform.parse(newSdpStr);
87
+          const newPrimaryVideoSsrc = getPrimaryVideoSsrc(newSdp);
88 88
           expect(newPrimaryVideoSsrc).toEqual(this.primaryVideoSsrc);
89 89
           // Should now have an rtx ssrc as well
90 90
           expect(numVideoSsrcs(newSdp)).toEqual(2);
91 91
           // Should now have an FID group
92
-          let fidGroups = getVideoGroups(newSdp, "FID");
92
+          const fidGroups = getVideoGroups(newSdp, "FID");
93 93
           expect(fidGroups.length).toEqual(1);
94 94
 
95
-          let fidGroup = fidGroups[0];
96
-          let fidGroupPrimarySsrc = SDPUtil.parseGroupSsrcs(fidGroup)[0];
95
+          const fidGroup = fidGroups[0];
96
+          const fidGroupPrimarySsrc = SDPUtil.parseGroupSsrcs(fidGroup)[0];
97 97
           expect(fidGroupPrimarySsrc).toEqual(this.primaryVideoSsrc);
98 98
         });
99 99
 
@@ -105,13 +105,13 @@ describe ("RtxModifier", function() {
105 105
           let newSdp = transform.parse(newSdpStr);
106 106
 
107 107
           let fidGroup = getVideoGroups(newSdp, "FID")[0];
108
-          let fidGroupRtxSsrc = SDPUtil.parseGroupSsrcs(fidGroup)[1];
108
+          const fidGroupRtxSsrc = SDPUtil.parseGroupSsrcs(fidGroup)[1];
109 109
 
110 110
           // Now pass the original sdp through again 
111 111
           newSdpStr = this.rtxModifier.modifyRtxSsrcs(this.transform.write(this.singleVideoSdp));
112 112
           newSdp = transform.parse(newSdpStr);
113 113
           fidGroup = getVideoGroups(newSdp, "FID")[0];
114
-          let newFidGroupRtxSsrc = SDPUtil.parseGroupSsrcs(fidGroup)[1];
114
+          const newFidGroupRtxSsrc = SDPUtil.parseGroupSsrcs(fidGroup)[1];
115 115
           expect(newFidGroupRtxSsrc).toEqual(fidGroupRtxSsrc);
116 116
         });
117 117
 
@@ -124,14 +124,14 @@ describe ("RtxModifier", function() {
124 124
           let newSdp = transform.parse(newSdpStr);
125 125
 
126 126
           let fidGroup = getVideoGroups(newSdp, "FID")[0];
127
-          let fidGroupRtxSsrc = SDPUtil.parseGroupSsrcs(fidGroup)[1];
127
+          const fidGroupRtxSsrc = SDPUtil.parseGroupSsrcs(fidGroup)[1];
128 128
           this.rtxModifier.clearSsrcCache();
129 129
 
130 130
           // Now pass the original sdp through again
131 131
           newSdpStr = this.rtxModifier.modifyRtxSsrcs(this.transform.write(this.singleVideoSdp));
132 132
           newSdp = transform.parse(newSdpStr);
133 133
           fidGroup = getVideoGroups(newSdp, "FID")[0];
134
-          let newFidGroupRtxSsrc = SDPUtil.parseGroupSsrcs(fidGroup)[1];
134
+          const newFidGroupRtxSsrc = SDPUtil.parseGroupSsrcs(fidGroup)[1];
135 135
           expect(newFidGroupRtxSsrc).not.toEqual(fidGroupRtxSsrc);
136 136
         });
137 137
 
@@ -139,15 +139,15 @@ describe ("RtxModifier", function() {
139 139
           // Manually set an rtx ssrc mapping in the cache
140 140
           // Call modifyRtxSsrcs
141 141
           // -->The rtx ssrc used should be the one we set
142
-          let forcedRtxSsrc = 123456;
143
-          let ssrcCache = new Map();
142
+          const forcedRtxSsrc = 123456;
143
+          const ssrcCache = new Map();
144 144
           ssrcCache.set(this.primaryVideoSsrc, forcedRtxSsrc);
145 145
           this.rtxModifier.setSsrcCache(ssrcCache);
146
-          let newSdpStr = this.rtxModifier.modifyRtxSsrcs(this.transform.write(this.singleVideoSdp));
147
-          let newSdp = transform.parse(newSdpStr);
146
+          const newSdpStr = this.rtxModifier.modifyRtxSsrcs(this.transform.write(this.singleVideoSdp));
147
+          const newSdp = transform.parse(newSdpStr);
148 148
 
149
-          let fidGroup = getVideoGroups(newSdp, "FID")[0];
150
-          let fidGroupRtxSsrc = SDPUtil.parseGroupSsrcs(fidGroup)[1];
149
+          const fidGroup = getVideoGroups(newSdp, "FID")[0];
150
+          const fidGroupRtxSsrc = SDPUtil.parseGroupSsrcs(fidGroup)[1];
151 151
           expect(fidGroupRtxSsrc).toEqual(forcedRtxSsrc);
152 152
         });
153 153
       });
@@ -161,17 +161,17 @@ describe ("RtxModifier", function() {
161 161
         it ("should add rtx ssrcs for all of them", function() {
162 162
           // Call rtxModifier.modifyRtxSsrcs with an sdp that contains multiple video
163 163
           //  ssrcs.  The returned sdp should have an rtx ssrc and an fid group for all of them.
164
-          let newSdpStr = this.rtxModifier.modifyRtxSsrcs(this.transform.write(this.multipleVideoSdp));
165
-          let newSdp = transform.parse(newSdpStr);
166
-          let newPrimaryVideoSsrcs = getPrimaryVideoSsrcs(newSdp);
164
+          const newSdpStr = this.rtxModifier.modifyRtxSsrcs(this.transform.write(this.multipleVideoSdp));
165
+          const newSdp = transform.parse(newSdpStr);
166
+          const newPrimaryVideoSsrcs = getPrimaryVideoSsrcs(newSdp);
167 167
           expect(newPrimaryVideoSsrcs).toEqual(this.primaryVideoSsrcs);
168 168
           // Should now have rtx ssrcs as well
169 169
           expect(numVideoSsrcs(newSdp)).toEqual(this.primaryVideoSsrcs.length * 2);
170 170
           // Should now have FID groups
171
-          let fidGroups = getVideoGroups(newSdp, "FID");
171
+          const fidGroups = getVideoGroups(newSdp, "FID");
172 172
           expect(fidGroups.length).toEqual(this.primaryVideoSsrcs.length);
173 173
           fidGroups.forEach(fidGroup => {
174
-            let fidGroupPrimarySsrc = SDPUtil.parseGroupSsrcs(fidGroup)[0];
174
+            const fidGroupPrimarySsrc = SDPUtil.parseGroupSsrcs(fidGroup)[0];
175 175
             expect(this.primaryVideoSsrcs.indexOf(fidGroupPrimarySsrc)).not.toEqual(-1);
176 176
           });
177 177
         });
@@ -183,13 +183,13 @@ describe ("RtxModifier", function() {
183 183
           let newSdpStr = this.rtxModifier.modifyRtxSsrcs(this.transform.write(this.multipleVideoSdp));
184 184
           let newSdp = transform.parse(newSdpStr);
185 185
 
186
-          let rtxMapping = new Map();
186
+          const rtxMapping = new Map();
187 187
           let fidGroups = getVideoGroups(newSdp, "FID");
188 188
           // Save the first mapping that is made
189 189
           fidGroups.forEach(fidGroup => {
190
-            let fidSsrcs = SDPUtil.parseGroupSsrcs(fidGroup);
191
-            let fidGroupPrimarySsrc = fidSsrcs[0];
192
-            let fidGroupRtxSsrc = fidSsrcs[1];
190
+            const fidSsrcs = SDPUtil.parseGroupSsrcs(fidGroup);
191
+            const fidGroupPrimarySsrc = fidSsrcs[0];
192
+            const fidGroupRtxSsrc = fidSsrcs[1];
193 193
             rtxMapping.set(fidGroupPrimarySsrc, fidGroupRtxSsrc);
194 194
           });
195 195
           // Now pass the original sdp through again and make sure we get the same mapping
@@ -197,9 +197,9 @@ describe ("RtxModifier", function() {
197 197
           newSdp = transform.parse(newSdpStr);
198 198
           fidGroups = getVideoGroups(newSdp, "FID");
199 199
           fidGroups.forEach(fidGroup => {
200
-            let fidSsrcs = SDPUtil.parseGroupSsrcs(fidGroup);
201
-            let fidGroupPrimarySsrc = fidSsrcs[0];
202
-            let fidGroupRtxSsrc = fidSsrcs[1];
200
+            const fidSsrcs = SDPUtil.parseGroupSsrcs(fidGroup);
201
+            const fidGroupPrimarySsrc = fidSsrcs[0];
202
+            const fidGroupRtxSsrc = fidSsrcs[1];
203 203
             expect(rtxMapping.has(fidGroupPrimarySsrc)).toBe(true);
204 204
             expect(rtxMapping.get(fidGroupPrimarySsrc)).toEqual(fidGroupRtxSsrc);
205 205
           });
@@ -213,13 +213,13 @@ describe ("RtxModifier", function() {
213 213
           let newSdpStr = this.rtxModifier.modifyRtxSsrcs(this.transform.write(this.multipleVideoSdp));
214 214
           let newSdp = transform.parse(newSdpStr);
215 215
 
216
-          let rtxMapping = new Map();
216
+          const rtxMapping = new Map();
217 217
           let fidGroups = getVideoGroups(newSdp, "FID");
218 218
           // Save the first mapping that is made
219 219
           fidGroups.forEach(fidGroup => {
220
-            let fidSsrcs = SDPUtil.parseGroupSsrcs(fidGroup);
221
-            let fidGroupPrimarySsrc = fidSsrcs[0];
222
-            let fidGroupRtxSsrc = fidSsrcs[1];
220
+            const fidSsrcs = SDPUtil.parseGroupSsrcs(fidGroup);
221
+            const fidGroupPrimarySsrc = fidSsrcs[0];
222
+            const fidGroupRtxSsrc = fidSsrcs[1];
223 223
             rtxMapping.set(fidGroupPrimarySsrc, fidGroupRtxSsrc);
224 224
           });
225 225
 
@@ -229,9 +229,9 @@ describe ("RtxModifier", function() {
229 229
           newSdp = transform.parse(newSdpStr);
230 230
           fidGroups = getVideoGroups(newSdp, "FID");
231 231
           fidGroups.forEach(fidGroup => {
232
-            let fidSsrcs = SDPUtil.parseGroupSsrcs(fidGroup);
233
-            let fidGroupPrimarySsrc = fidSsrcs[0];
234
-            let fidGroupRtxSsrc = fidSsrcs[1];
232
+            const fidSsrcs = SDPUtil.parseGroupSsrcs(fidGroup);
233
+            const fidGroupPrimarySsrc = fidSsrcs[0];
234
+            const fidGroupRtxSsrc = fidSsrcs[1];
235 235
             expect(rtxMapping.has(fidGroupPrimarySsrc)).toBe(true);
236 236
             expect(rtxMapping.get(fidGroupPrimarySsrc)).not.toEqual(fidGroupRtxSsrc);
237 237
           });
@@ -241,20 +241,20 @@ describe ("RtxModifier", function() {
241 241
           // Manually set an rtx ssrc mapping in the cache
242 242
           // Call modifyRtxSsrcs
243 243
           // -->The rtx ssrc used should be the one we set
244
-          let rtxMapping = new Map();
244
+          const rtxMapping = new Map();
245 245
           this.primaryVideoSsrcs.forEach(ssrc => {
246 246
             rtxMapping.set(ssrc, SDPUtil.generateSsrc());
247 247
           });
248 248
           this.rtxModifier.setSsrcCache(rtxMapping);
249 249
 
250
-          let newSdpStr = this.rtxModifier.modifyRtxSsrcs(this.transform.write(this.multipleVideoSdp));
251
-          let newSdp = transform.parse(newSdpStr);
250
+          const newSdpStr = this.rtxModifier.modifyRtxSsrcs(this.transform.write(this.multipleVideoSdp));
251
+          const newSdp = transform.parse(newSdpStr);
252 252
 
253
-          let fidGroups = getVideoGroups(newSdp, "FID");
253
+          const fidGroups = getVideoGroups(newSdp, "FID");
254 254
           fidGroups.forEach(fidGroup => {
255
-            let fidSsrcs = SDPUtil.parseGroupSsrcs(fidGroup);
256
-            let fidGroupPrimarySsrc = fidSsrcs[0];
257
-            let fidGroupRtxSsrc = fidSsrcs[1];
255
+            const fidSsrcs = SDPUtil.parseGroupSsrcs(fidGroup);
256
+            const fidGroupPrimarySsrc = fidSsrcs[0];
257
+            const fidGroupRtxSsrc = fidSsrcs[1];
258 258
             expect(rtxMapping.has(fidGroupPrimarySsrc)).toBe(true);
259 259
             expect(rtxMapping.get(fidGroupPrimarySsrc)).toEqual(fidGroupRtxSsrc);
260 260
           });
@@ -263,26 +263,26 @@ describe ("RtxModifier", function() {
263 263
 
264 264
       describe ("(corner cases)", function() {
265 265
         it ("should handle a recvonly video mline", function() {
266
-          let sdp = SampleSdpStrings.plainVideoSdp;
267
-          let videoMLine = sdp.media.find(m => m.type === "video");
266
+          const sdp = SampleSdpStrings.plainVideoSdp;
267
+          const videoMLine = sdp.media.find(m => m.type === "video");
268 268
           videoMLine.direction = "recvonly";
269
-          let newSdpStr = this.rtxModifier.modifyRtxSsrcs(this.transform.write(sdp));
269
+          const newSdpStr = this.rtxModifier.modifyRtxSsrcs(this.transform.write(sdp));
270 270
           expect(newSdpStr).toEqual(this.transform.write(sdp));
271 271
         });
272 272
 
273 273
         it ("should handle an inactive video mline", function() {
274
-          let sdp = SampleSdpStrings.plainVideoSdp;
275
-          let videoMLine = sdp.media.find(m => m.type === "video");
274
+          const sdp = SampleSdpStrings.plainVideoSdp;
275
+          const videoMLine = sdp.media.find(m => m.type === "video");
276 276
           videoMLine.direction = "inactive";
277
-          let newSdpStr = this.rtxModifier.modifyRtxSsrcs(this.transform.write(sdp));
277
+          const newSdpStr = this.rtxModifier.modifyRtxSsrcs(this.transform.write(sdp));
278 278
           expect(newSdpStr).toEqual(this.transform.write(sdp));
279 279
         });
280 280
 
281 281
         it ("should handle a video mline with no video ssrcs", function() {
282
-          let sdp = SampleSdpStrings.plainVideoSdp;
283
-          let videoMLine = sdp.media.find(m => m.type === "video");
282
+          const sdp = SampleSdpStrings.plainVideoSdp;
283
+          const videoMLine = sdp.media.find(m => m.type === "video");
284 284
           videoMLine.ssrcs = [];
285
-          let newSdpStr = this.rtxModifier.modifyRtxSsrcs(this.transform.write(sdp));
285
+          const newSdpStr = this.rtxModifier.modifyRtxSsrcs(this.transform.write(sdp));
286 286
           expect(newSdpStr).toEqual(this.transform.write(sdp));
287 287
         });
288 288
       });

+ 5
- 5
modules/xmpp/SDPUtil.js Vedi File

@@ -370,11 +370,11 @@ var SDPUtil = {
370 370
      * @return {number} the primary video ssrc from the given m line
371 371
      */
372 372
     parsePrimaryVideoSsrc: function(videoMLine) {
373
-        let numSsrcs = videoMLine.ssrcs
373
+        const numSsrcs = videoMLine.ssrcs
374 374
             .map(ssrcInfo => ssrcInfo.id)
375 375
             .filter((ssrc, index, array) => array.indexOf(ssrc) === index)
376 376
             .length;
377
-        let numGroups = (videoMLine.ssrcGroups && videoMLine.ssrcGroups.length) || 0;
377
+        const numGroups = (videoMLine.ssrcGroups && videoMLine.ssrcGroups.length) || 0;
378 378
         if (numSsrcs > 1 && numGroups === 0) {
379 379
             // Ambiguous, can't figure out the primary
380 380
             return;
@@ -385,14 +385,14 @@ var SDPUtil = {
385 385
         } else {
386 386
             if (numSsrcs === 2) {
387 387
                 // Can figure it out if there's an FID group
388
-                let fidGroup = videoMLine.ssrcGroups
388
+                const fidGroup = videoMLine.ssrcGroups
389 389
                     .find(group => group.semantics === "FID");
390 390
                 if (fidGroup) {
391 391
                     primarySsrc = fidGroup.ssrcs.split(" ")[0];
392 392
                 }
393 393
             } else if (numSsrcs >= 3) {
394 394
                 // Can figure it out if there's a sim group
395
-                let simGroup = videoMLine.ssrcGroups
395
+                const simGroup = videoMLine.ssrcGroups
396 396
                     .find(group => group.semantics === "SIM");
397 397
                 if (simGroup) {
398 398
                     primarySsrc = simGroup.ssrcs.split(" ")[0];
@@ -421,7 +421,7 @@ var SDPUtil = {
421 421
      */
422 422
     getSsrcAttribute: function (mLine, ssrc, attributeName) {
423 423
         for (let i = 0; i < mLine.ssrcs.length; ++i) {
424
-            let ssrcLine = mLine.ssrcs[i];
424
+            const ssrcLine = mLine.ssrcs[i];
425 425
             if (ssrcLine.id === ssrc &&
426 426
                 ssrcLine.attribute === attributeName) {
427 427
                 return ssrcLine.value;

+ 3
- 3
modules/xmpp/SdpConsistency.js Vedi File

@@ -81,7 +81,7 @@ export default class SdpConsistency {
81 81
                 logger.error("No SSRC found for the recvonly video stream!");
82 82
             }
83 83
         } else {
84
-            let newPrimarySsrc = videoMLine.getPrimaryVideoSsrc();
84
+            const newPrimarySsrc = videoMLine.getPrimaryVideoSsrc();
85 85
             if (!newPrimarySsrc) {
86 86
                 logger.info("Sdp-consistency couldn't parse new primary ssrc");
87 87
                 return sdpStr;
@@ -99,8 +99,8 @@ export default class SdpConsistency {
99 99
                     newPrimarySsrc, this.cachedPrimarySsrc);
100 100
                 for (const group of videoMLine.ssrcGroups) {
101 101
                     if (group.semantics === "FID") {
102
-                        let primarySsrc = parsePrimarySSRC(group);
103
-                        let rtxSsrc = parseSecondarySSRC(group);
102
+                        const primarySsrc = parsePrimarySSRC(group);
103
+                        const rtxSsrc = parseSecondarySSRC(group);
104 104
                         if (primarySsrc === newPrimarySsrc) {
105 105
                             group.ssrcs =
106 106
                                 this.cachedPrimarySsrc + " " +

+ 2
- 2
modules/xmpp/strophe.jingle.js Vedi File

@@ -180,10 +180,10 @@ class JingleConnectionPlugin extends ConnectionPlugin {
180 180
                 .c('services', {xmlns: 'urn:xmpp:extdisco:1'})
181 181
                 .c('service', {host: 'turn.' + this.connection.domain}),
182 182
             res => {
183
-                let iceservers = [];
183
+                const iceservers = [];
184 184
                 $(res).find('>services>service').each((idx, el) => {
185 185
                     el = $(el);
186
-                    let dict = {};
186
+                    const dict = {};
187 187
                     const type = el.attr('type');
188 188
                     switch (type) {
189 189
                         case 'stun':

+ 1
- 1
modules/xmpp/strophe.rayo.js Vedi File

@@ -48,7 +48,7 @@ class RayoConnectionPlugin extends ConnectionPlugin {
48 48
             this.connection.sendIQ(req, (result) => {
49 49
                 logger.info('Dial result ', result);
50 50
 
51
-                let resource = $(result).find('ref').attr('uri');
51
+                const resource = $(result).find('ref').attr('uri');
52 52
                 this.call_resource =
53 53
                     resource.substr('xmpp:'.length);
54 54
                 logger.info("Received call resource: " + this.call_resource);

+ 1
- 1
modules/xmpp/xmpp.js Vedi File

@@ -265,7 +265,7 @@ export default class XMPP extends Listenable {
265 265
         // By default MUC nickname is the resource part of the JID
266 266
         let mucNickname = Strophe.getNodeFromJid(this.connection.jid);
267 267
         let roomjid = roomName  + "@" + this.options.hosts.muc + "/";
268
-        let cfgNickname
268
+        const cfgNickname
269 269
             = options.useNicks && options.nick ? options.nick : null;
270 270
 
271 271
         if (cfgNickname) {

Loading…
Annulla
Salva