Browse Source

[eslint] prefer-arrow-callback

release-8443
Lyubo Marinov 8 years ago
parent
commit
13bfa61028

+ 1
- 0
.eslintrc.js View File

209
             'always',
209
             'always',
210
             { 'avoidQuotes': true }
210
             { 'avoidQuotes': true }
211
         ],
211
         ],
212
+        'prefer-arrow-callback': [ 'error', { 'allowNamedFunctions': true } ],
212
         'prefer-const': 2,
213
         'prefer-const': 2,
213
         'prefer-reflect': 0,
214
         'prefer-reflect': 0,
214
         'prefer-rest-params': 2,
215
         'prefer-rest-params': 2,

+ 30
- 34
JitsiConference.js View File

246
  * @returns {Promise}
246
  * @returns {Promise}
247
  */
247
  */
248
 JitsiConference.prototype.getExternalAuthUrl = function(urlForPopup) {
248
 JitsiConference.prototype.getExternalAuthUrl = function(urlForPopup) {
249
-    return new Promise(function(resolve, reject) {
249
+    return new Promise((resolve, reject) => {
250
         if (!this.isExternalAuthEnabled()) {
250
         if (!this.isExternalAuthEnabled()) {
251
             reject();
251
             reject();
252
             return;
252
             return;
256
         } else {
256
         } else {
257
             this.room.moderator.getLoginUrl(resolve, reject);
257
             this.room.moderator.getLoginUrl(resolve, reject);
258
         }
258
         }
259
-    }.bind(this));
259
+    });
260
 };
260
 };
261
 
261
 
262
 /**
262
 /**
590
             && newTrack.videoType !== VideoType.DESKTOP)) {
590
             && newTrack.videoType !== VideoType.DESKTOP)) {
591
         // Report active device to statistics
591
         // Report active device to statistics
592
         const devices = RTC.getCurrentlyAvailableMediaDevices();
592
         const devices = RTC.getCurrentlyAvailableMediaDevices();
593
-        const device = devices.find(function(d) {
594
-            return d.kind === `${newTrack.getTrack().kind}input`
595
-                && d.label === newTrack.getTrack().label;
596
-        });
593
+        const device
594
+            = devices.find(
595
+                d =>
596
+                    d.kind === `${newTrack.getTrack().kind}input`
597
+                        && d.label === newTrack.getTrack().label);
597
         if (device) {
598
         if (device) {
598
             Statistics.sendActiveDeviceListEvent(
599
             Statistics.sendActiveDeviceListEvent(
599
                 RTC.getEventDataForActiveDevice(device));
600
                 RTC.getEventDataForActiveDevice(device));
725
     }
726
     }
726
 
727
 
727
     const conference = this;
728
     const conference = this;
728
-    return new Promise(function(resolve, reject) {
729
-        conference.room.lockRoom(password || '', function() {
730
-            resolve();
731
-        }, function(err) {
732
-            reject(err);
733
-        }, function() {
734
-            reject(JitsiConferenceErrors.PASSWORD_NOT_SUPPORTED);
735
-        });
729
+    return new Promise((resolve, reject) => {
730
+        conference.room.lockRoom(
731
+            password || '',
732
+            () => resolve(),
733
+            err => reject(err),
734
+            () => reject(JitsiConferenceErrors.PASSWORD_NOT_SUPPORTED));
736
     });
735
     });
737
 };
736
 };
738
 
737
 
881
 
880
 
882
     const removedTracks = this.rtc.removeRemoteTracks(id);
881
     const removedTracks = this.rtc.removeRemoteTracks(id);
883
 
882
 
884
-    removedTracks.forEach(function(track) {
885
-        this.eventEmitter.emit(JitsiConferenceEvents.TRACK_REMOVED, track);
886
-    }.bind(this));
883
+    removedTracks.forEach(
884
+        track =>
885
+            this.eventEmitter.emit(JitsiConferenceEvents.TRACK_REMOVED, track));
887
 
886
 
888
     // there can be no participant in case the member that left is focus
887
     // there can be no participant in case the member that left is focus
889
     if (participant) {
888
     if (participant) {
942
     const emitter = this.eventEmitter;
941
     const emitter = this.eventEmitter;
943
     track.addEventListener(
942
     track.addEventListener(
944
         JitsiTrackEvents.TRACK_MUTE_CHANGED,
943
         JitsiTrackEvents.TRACK_MUTE_CHANGED,
945
-        function() {
946
-            emitter.emit(JitsiConferenceEvents.TRACK_MUTE_CHANGED, track);
947
-        }
948
-    );
944
+        () => emitter.emit(JitsiConferenceEvents.TRACK_MUTE_CHANGED, track));
949
     track.addEventListener(
945
     track.addEventListener(
950
         JitsiTrackEvents.TRACK_AUDIO_LEVEL_CHANGED,
946
         JitsiTrackEvents.TRACK_AUDIO_LEVEL_CHANGED,
951
-        function(audioLevel) {
947
+        audioLevel => {
952
             emitter.emit(
948
             emitter.emit(
953
                 JitsiConferenceEvents.TRACK_AUDIO_LEVEL_CHANGED,
949
                 JitsiConferenceEvents.TRACK_AUDIO_LEVEL_CHANGED,
954
                 id,
950
                 id,
1016
         jingleSession.terminate(
1012
         jingleSession.terminate(
1017
             'security-error', 'Only focus can start new sessions',
1013
             'security-error', 'Only focus can start new sessions',
1018
             null /* success callback => we don't care */,
1014
             null /* success callback => we don't care */,
1019
-            function(error) {
1015
+            error => {
1020
                 logger.warn(
1016
                 logger.warn(
1021
-                    'An error occurred while trying to terminate'
1022
-                        + ' invalid Jingle session', error);
1017
+                    'An error occurred while trying to terminate invalid Jingle'
1018
+                        + ' session',
1019
+                    error);
1023
             });
1020
             });
1024
 
1021
 
1025
         return;
1022
         return;
1050
 
1047
 
1051
     this.rtc.initializeDataChannels(jingleSession.peerconnection);
1048
     this.rtc.initializeDataChannels(jingleSession.peerconnection);
1052
     // Add local Tracks to the ChatRoom
1049
     // Add local Tracks to the ChatRoom
1053
-    this.getLocalTracks().forEach(function(localTrack) {
1050
+    this.getLocalTracks().forEach(localTrack => {
1054
         let ssrcInfo = null;
1051
         let ssrcInfo = null;
1055
         /**
1052
         /**
1056
          * We don't do this for Firefox because, on Firefox, we keep the
1053
          * We don't do this for Firefox because, on Firefox, we keep the
1102
             GlobalOnErrorHandler.callErrorHandler(e);
1099
             GlobalOnErrorHandler.callErrorHandler(e);
1103
             logger.error(e);
1100
             logger.error(e);
1104
         }
1101
         }
1105
-    }.bind(this));
1102
+    });
1106
     // Generate the 'recvonly' SSRC in case there are no video tracks
1103
     // Generate the 'recvonly' SSRC in case there are no video tracks
1107
     if (!this.getLocalTracks(MediaType.VIDEO).length) {
1104
     if (!this.getLocalTracks(MediaType.VIDEO).length) {
1108
         jingleSession.generateRecvonlySsrc();
1105
         jingleSession.generateRecvonlySsrc();
1109
     }
1106
     }
1110
 
1107
 
1111
     jingleSession.acceptOffer(jingleOffer, null,
1108
     jingleSession.acceptOffer(jingleOffer, null,
1112
-        function(error) {
1109
+        error => {
1113
             GlobalOnErrorHandler.callErrorHandler(error);
1110
             GlobalOnErrorHandler.callErrorHandler(error);
1114
             logger.error(
1111
             logger.error(
1115
                 'Failed to accept incoming Jingle session', error);
1112
                 'Failed to accept incoming Jingle session', error);
1154
     // will learn what their SSRC from the new PeerConnection which will be
1151
     // will learn what their SSRC from the new PeerConnection which will be
1155
     // created on incoming call event.
1152
     // created on incoming call event.
1156
     const self = this;
1153
     const self = this;
1157
-    this.getLocalTracks().forEach(function(localTrack) {
1154
+    this.getLocalTracks().forEach(localTrack => {
1158
         // Reset SSRC as it will no longer be valid
1155
         // Reset SSRC as it will no longer be valid
1159
         localTrack._setSSRC(null);
1156
         localTrack._setSSRC(null);
1160
         // Bind the handler to fetch new SSRC, it will un register itself once
1157
         // Bind the handler to fetch new SSRC, it will un register itself once
1261
  */
1258
  */
1262
 JitsiConference.prototype.toggleRecording = function(options) {
1259
 JitsiConference.prototype.toggleRecording = function(options) {
1263
     if (this.room) {
1260
     if (this.room) {
1264
-        return this.room.toggleRecording(options, function(status, error) {
1261
+        return this.room.toggleRecording(options, (status, error) => {
1265
             this.eventEmitter.emit(
1262
             this.eventEmitter.emit(
1266
                 JitsiConferenceEvents.RECORDER_STATE_CHANGED, status, error);
1263
                 JitsiConferenceEvents.RECORDER_STATE_CHANGED, status, error);
1267
-        }.bind(this));
1264
+        });
1268
     }
1265
     }
1269
     this.eventEmitter.emit(
1266
     this.eventEmitter.emit(
1270
         JitsiConferenceEvents.RECORDER_STATE_CHANGED, 'error',
1267
         JitsiConferenceEvents.RECORDER_STATE_CHANGED, 'error',
1289
     if (this.room) {
1286
     if (this.room) {
1290
         return this.room.dial(number);
1287
         return this.room.dial(number);
1291
     }
1288
     }
1292
-    return new Promise(function(resolve, reject) {
1289
+    return new Promise((resolve, reject) => {
1293
         reject(new Error('The conference is not created yet!'));
1290
         reject(new Error('The conference is not created yet!'));
1294
     });
1291
     });
1295
 };
1292
 };
1301
     if (this.room) {
1298
     if (this.room) {
1302
         return this.room.hangup();
1299
         return this.room.hangup();
1303
     }
1300
     }
1304
-    return new Promise(function(resolve, reject) {
1301
+    return new Promise((resolve, reject) => {
1305
         reject(new Error('The conference is not created yet!'));
1302
         reject(new Error('The conference is not created yet!'));
1306
     });
1303
     });
1307
 };
1304
 };
1335
         return this.jingleSession.getIceConnectionState();
1332
         return this.jingleSession.getIceConnectionState();
1336
     }
1333
     }
1337
     return null;
1334
     return null;
1338
-
1339
 };
1335
 };
1340
 
1336
 
1341
 /**
1337
 /**

+ 40
- 42
JitsiConferenceEventManager.js View File

22
 
22
 
23
     // Listeners related to the conference only
23
     // Listeners related to the conference only
24
     conference.on(JitsiConferenceEvents.TRACK_MUTE_CHANGED,
24
     conference.on(JitsiConferenceEvents.TRACK_MUTE_CHANGED,
25
-        function(track) {
25
+        track => {
26
             if(!track.isLocal() || !conference.statistics) {
26
             if(!track.isLocal() || !conference.statistics) {
27
                 return;
27
                 return;
28
             }
28
             }
40
     this.chatRoomForwarder = new EventEmitterForwarder(chatRoom,
40
     this.chatRoomForwarder = new EventEmitterForwarder(chatRoom,
41
         this.conference.eventEmitter);
41
         this.conference.eventEmitter);
42
 
42
 
43
-    chatRoom.addListener(XMPPEvents.ICE_RESTARTING, function() {
43
+    chatRoom.addListener(XMPPEvents.ICE_RESTARTING, () => {
44
         // All data channels have to be closed, before ICE restart
44
         // All data channels have to be closed, before ICE restart
45
         // otherwise Chrome will not trigger "opened" event for the channel
45
         // otherwise Chrome will not trigger "opened" event for the channel
46
         // established with the new bridge
46
         // established with the new bridge
48
     });
48
     });
49
 
49
 
50
     chatRoom.addListener(XMPPEvents.AUDIO_MUTED_BY_FOCUS,
50
     chatRoom.addListener(XMPPEvents.AUDIO_MUTED_BY_FOCUS,
51
-        function(value) {
51
+        value => {
52
             // set isMutedByFocus when setAudioMute Promise ends
52
             // set isMutedByFocus when setAudioMute Promise ends
53
             conference.rtc.setAudioMute(value).then(
53
             conference.rtc.setAudioMute(value).then(
54
-                function() {
54
+                () => {
55
                     conference.isMutedByFocus = true;
55
                     conference.isMutedByFocus = true;
56
                 },
56
                 },
57
-                function() {
57
+                () =>
58
                     logger.warn(
58
                     logger.warn(
59
-                        'Error while audio muting due to focus request');
60
-                });
59
+                        'Error while audio muting due to focus request'));
61
         }
60
         }
62
     );
61
     );
63
 
62
 
120
         JitsiConferenceErrors.GRACEFUL_SHUTDOWN);
119
         JitsiConferenceErrors.GRACEFUL_SHUTDOWN);
121
 
120
 
122
     chatRoom.addListener(XMPPEvents.JINGLE_FATAL_ERROR,
121
     chatRoom.addListener(XMPPEvents.JINGLE_FATAL_ERROR,
123
-        function(session, error) {
122
+        (session, error) => {
124
             conference.eventEmitter.emit(
123
             conference.eventEmitter.emit(
125
                 JitsiConferenceEvents.CONFERENCE_FAILED,
124
                 JitsiConferenceEvents.CONFERENCE_FAILED,
126
                 JitsiConferenceErrors.JINGLE_FATAL_ERROR, error);
125
                 JitsiConferenceErrors.JINGLE_FATAL_ERROR, error);
127
         });
126
         });
128
 
127
 
129
     chatRoom.addListener(XMPPEvents.CONNECTION_ICE_FAILED,
128
     chatRoom.addListener(XMPPEvents.CONNECTION_ICE_FAILED,
130
-        function() {
129
+        () => {
131
             chatRoom.eventEmitter.emit(
130
             chatRoom.eventEmitter.emit(
132
                 XMPPEvents.CONFERENCE_SETUP_FAILED,
131
                 XMPPEvents.CONFERENCE_SETUP_FAILED,
133
                 new Error('ICE fail'));
132
                 new Error('ICE fail'));
146
         JitsiConferenceErrors.FOCUS_DISCONNECTED);
145
         JitsiConferenceErrors.FOCUS_DISCONNECTED);
147
 
146
 
148
     chatRoom.addListener(XMPPEvents.FOCUS_LEFT,
147
     chatRoom.addListener(XMPPEvents.FOCUS_LEFT,
149
-        function() {
148
+        () => {
150
             Statistics.analytics.sendEvent('conference.focusLeft');
149
             Statistics.analytics.sendEvent('conference.focusLeft');
151
             conference.eventEmitter.emit(
150
             conference.eventEmitter.emit(
152
                 JitsiConferenceEvents.CONFERENCE_FAILED,
151
                 JitsiConferenceEvents.CONFERENCE_FAILED,
184
         JitsiConferenceEvents.CONFERENCE_FAILED,
183
         JitsiConferenceEvents.CONFERENCE_FAILED,
185
         JitsiConferenceErrors.SETUP_FAILED);
184
         JitsiConferenceErrors.SETUP_FAILED);
186
 
185
 
187
-    chatRoom.setParticipantPropertyListener(function(node, from) {
186
+    chatRoom.setParticipantPropertyListener((node, from) => {
188
         const participant = conference.getParticipantById(from);
187
         const participant = conference.getParticipantById(from);
189
         if (!participant) {
188
         if (!participant) {
190
             return;
189
             return;
198
     this.chatRoomForwarder.forward(XMPPEvents.KICKED,
197
     this.chatRoomForwarder.forward(XMPPEvents.KICKED,
199
         JitsiConferenceEvents.KICKED);
198
         JitsiConferenceEvents.KICKED);
200
     chatRoom.addListener(XMPPEvents.KICKED,
199
     chatRoom.addListener(XMPPEvents.KICKED,
201
-        function() {
200
+        () => {
202
             conference.room = null;
201
             conference.room = null;
203
             conference.leave();
202
             conference.leave();
204
         });
203
         });
218
     chatRoom.addListener(XMPPEvents.DISPLAY_NAME_CHANGED,
217
     chatRoom.addListener(XMPPEvents.DISPLAY_NAME_CHANGED,
219
         conference.onDisplayNameChanged.bind(conference));
218
         conference.onDisplayNameChanged.bind(conference));
220
 
219
 
221
-    chatRoom.addListener(XMPPEvents.LOCAL_ROLE_CHANGED, function(role) {
220
+    chatRoom.addListener(XMPPEvents.LOCAL_ROLE_CHANGED, role => {
222
         conference.eventEmitter.emit(JitsiConferenceEvents.USER_ROLE_CHANGED,
221
         conference.eventEmitter.emit(JitsiConferenceEvents.USER_ROLE_CHANGED,
223
             conference.myUserId(), role);
222
             conference.myUserId(), role);
224
 
223
 
225
         // log all events for the recorder operated by the moderator
224
         // log all events for the recorder operated by the moderator
226
         if (conference.statistics && conference.isModerator()) {
225
         if (conference.statistics && conference.isModerator()) {
227
             conference.on(JitsiConferenceEvents.RECORDER_STATE_CHANGED,
226
             conference.on(JitsiConferenceEvents.RECORDER_STATE_CHANGED,
228
-                function(status, error) {
227
+                (status, error) => {
229
                     const logObject = {
228
                     const logObject = {
230
                         id: 'recorder_status',
229
                         id: 'recorder_status',
231
                         status
230
                         status
242
         conference.onUserRoleChanged.bind(conference));
241
         conference.onUserRoleChanged.bind(conference));
243
 
242
 
244
     chatRoom.addListener(AuthenticationEvents.IDENTITY_UPDATED,
243
     chatRoom.addListener(AuthenticationEvents.IDENTITY_UPDATED,
245
-        function(authEnabled, authIdentity) {
244
+        (authEnabled, authIdentity) => {
246
             conference.authEnabled = authEnabled;
245
             conference.authEnabled = authEnabled;
247
             conference.authIdentity = authIdentity;
246
             conference.authIdentity = authIdentity;
248
             conference.eventEmitter.emit(
247
             conference.eventEmitter.emit(
251
         });
250
         });
252
 
251
 
253
     chatRoom.addListener(XMPPEvents.MESSAGE_RECEIVED,
252
     chatRoom.addListener(XMPPEvents.MESSAGE_RECEIVED,
254
-        function(jid, displayName, txt, myJid, ts) {
253
+        (jid, displayName, txt, myJid, ts) => {
255
             const id = Strophe.getResourceFromJid(jid);
254
             const id = Strophe.getResourceFromJid(jid);
256
             conference.eventEmitter.emit(JitsiConferenceEvents.MESSAGE_RECEIVED,
255
             conference.eventEmitter.emit(JitsiConferenceEvents.MESSAGE_RECEIVED,
257
                 id, txt, ts);
256
                 id, txt, ts);
258
         });
257
         });
259
 
258
 
260
     chatRoom.addListener(XMPPEvents.PRESENCE_STATUS,
259
     chatRoom.addListener(XMPPEvents.PRESENCE_STATUS,
261
-        function(jid, status) {
260
+        (jid, status) => {
262
             const id = Strophe.getResourceFromJid(jid);
261
             const id = Strophe.getResourceFromJid(jid);
263
             const participant = conference.getParticipantById(id);
262
             const participant = conference.getParticipantById(id);
264
             if (!participant || participant._status === status) {
263
             if (!participant || participant._status === status) {
270
         });
269
         });
271
 
270
 
272
     conference.room.addListener(XMPPEvents.LOCAL_UFRAG_CHANGED,
271
     conference.room.addListener(XMPPEvents.LOCAL_UFRAG_CHANGED,
273
-        function(ufrag) {
272
+        ufrag => {
274
             Statistics.sendLog(
273
             Statistics.sendLog(
275
                 JSON.stringify({id: 'local_ufrag', value: ufrag}));
274
                 JSON.stringify({id: 'local_ufrag', value: ufrag}));
276
         });
275
         });
277
     conference.room.addListener(XMPPEvents.REMOTE_UFRAG_CHANGED,
276
     conference.room.addListener(XMPPEvents.REMOTE_UFRAG_CHANGED,
278
-        function(ufrag) {
277
+        ufrag => {
279
             Statistics.sendLog(
278
             Statistics.sendLog(
280
                 JSON.stringify({id: 'remote_ufrag', value: ufrag}));
279
                 JSON.stringify({id: 'remote_ufrag', value: ufrag}));
281
         });
280
         });
282
 
281
 
283
-    chatRoom.addPresenceListener('startmuted', function(data, from) {
282
+    chatRoom.addPresenceListener('startmuted', (data, from) => {
284
         let isModerator = false;
283
         let isModerator = false;
285
         if (conference.myUserId() === from && conference.isModerator()) {
284
         if (conference.myUserId() === from && conference.isModerator()) {
286
             isModerator = true;
285
             isModerator = true;
318
         }
317
         }
319
     });
318
     });
320
 
319
 
321
-    chatRoom.addPresenceListener('videomuted', function(values, from) {
320
+    chatRoom.addPresenceListener('videomuted', (values, from) => {
322
         conference.rtc.handleRemoteTrackMute(MediaType.VIDEO,
321
         conference.rtc.handleRemoteTrackMute(MediaType.VIDEO,
323
             values.value == 'true', from);
322
             values.value == 'true', from);
324
     });
323
     });
325
 
324
 
326
-    chatRoom.addPresenceListener('audiomuted', function(values, from) {
325
+    chatRoom.addPresenceListener('audiomuted', (values, from) => {
327
         conference.rtc.handleRemoteTrackMute(MediaType.AUDIO,
326
         conference.rtc.handleRemoteTrackMute(MediaType.AUDIO,
328
             values.value == 'true', from);
327
             values.value == 'true', from);
329
     });
328
     });
330
 
329
 
331
-    chatRoom.addPresenceListener('videoType', function(data, from) {
330
+    chatRoom.addPresenceListener('videoType', (data, from) => {
332
         conference.rtc.handleRemoteTrackVideoTypeChanged(data.value, from);
331
         conference.rtc.handleRemoteTrackVideoTypeChanged(data.value, from);
333
     });
332
     });
334
 
333
 
335
-    chatRoom.addPresenceListener('devices', function(data, from) {
334
+    chatRoom.addPresenceListener('devices', (data, from) => {
336
         let isAudioAvailable = false;
335
         let isAudioAvailable = false;
337
         let isVideoAvailable = false;
336
         let isVideoAvailable = false;
338
-        data.children.forEach(function(config) {
337
+        data.children.forEach(config => {
339
             if (config.tagName === 'audio') {
338
             if (config.tagName === 'audio') {
340
                 isAudioAvailable = config.value === 'true';
339
                 isAudioAvailable = config.value === 'true';
341
             }
340
             }
378
     if(conference.statistics) {
377
     if(conference.statistics) {
379
         // FIXME ICE related events should end up in RTCEvents eventually
378
         // FIXME ICE related events should end up in RTCEvents eventually
380
         chatRoom.addListener(XMPPEvents.CONNECTION_ICE_FAILED,
379
         chatRoom.addListener(XMPPEvents.CONNECTION_ICE_FAILED,
381
-            function(pc) {
380
+            pc => {
382
                 conference.statistics.sendIceConnectionFailedEvent(pc);
381
                 conference.statistics.sendIceConnectionFailedEvent(pc);
383
             });
382
             });
384
         chatRoom.addListener(XMPPEvents.ADD_ICE_CANDIDATE_FAILED,
383
         chatRoom.addListener(XMPPEvents.ADD_ICE_CANDIDATE_FAILED,
385
-            function(e, pc) {
384
+            (e, pc) => {
386
                 conference.statistics.sendAddIceCandidateFailed(e, pc);
385
                 conference.statistics.sendAddIceCandidateFailed(e, pc);
387
             });
386
             });
388
     }
387
     }
407
         conference.onRemoteTrackRemoved.bind(conference));
406
         conference.onRemoteTrackRemoved.bind(conference));
408
 
407
 
409
     rtc.addListener(RTCEvents.DOMINANT_SPEAKER_CHANGED,
408
     rtc.addListener(RTCEvents.DOMINANT_SPEAKER_CHANGED,
410
-        function(id) {
409
+        id => {
411
             if(conference.lastDominantSpeaker !== id && conference.room) {
410
             if(conference.lastDominantSpeaker !== id && conference.room) {
412
                 conference.lastDominantSpeaker = id;
411
                 conference.lastDominantSpeaker = id;
413
                 conference.eventEmitter.emit(
412
                 conference.eventEmitter.emit(
419
             }
418
             }
420
         });
419
         });
421
 
420
 
422
-    rtc.addListener(RTCEvents.DATA_CHANNEL_OPEN, function() {
421
+    rtc.addListener(RTCEvents.DATA_CHANNEL_OPEN, () => {
423
         const now = window.performance.now();
422
         const now = window.performance.now();
424
         logger.log('(TIME) data channel opened ', now);
423
         logger.log('(TIME) data channel opened ', now);
425
         conference.room.connectionTimes['data.channel.opened'] = now;
424
         conference.room.connectionTimes['data.channel.opened'] = now;
433
     this.rtcForwarder.forward(RTCEvents.LASTN_ENDPOINT_CHANGED,
432
     this.rtcForwarder.forward(RTCEvents.LASTN_ENDPOINT_CHANGED,
434
         JitsiConferenceEvents.LAST_N_ENDPOINTS_CHANGED);
433
         JitsiConferenceEvents.LAST_N_ENDPOINTS_CHANGED);
435
 
434
 
436
-    rtc.addListener(RTCEvents.AVAILABLE_DEVICES_CHANGED,
437
-        function(devices) {
438
-            conference.room.updateDeviceAvailability(devices);
439
-        });
435
+    rtc.addListener(
436
+        RTCEvents.AVAILABLE_DEVICES_CHANGED,
437
+        devices => conference.room.updateDeviceAvailability(devices));
440
 
438
 
441
     rtc.addListener(RTCEvents.ENDPOINT_MESSAGE_RECEIVED,
439
     rtc.addListener(RTCEvents.ENDPOINT_MESSAGE_RECEIVED,
442
-        function(from, payload) {
440
+        (from, payload) => {
443
             const participant = conference.getParticipantById(from);
441
             const participant = conference.getParticipantById(from);
444
             if (participant) {
442
             if (participant) {
445
                 conference.eventEmitter.emit(
443
                 conference.eventEmitter.emit(
497
         XMPPEvents.CALL_ENDED, conference.onCallEnded.bind(conference));
495
         XMPPEvents.CALL_ENDED, conference.onCallEnded.bind(conference));
498
 
496
 
499
     conference.xmpp.addListener(XMPPEvents.START_MUTED_FROM_FOCUS,
497
     conference.xmpp.addListener(XMPPEvents.START_MUTED_FROM_FOCUS,
500
-        function(audioMuted, videoMuted) {
498
+        (audioMuted, videoMuted) => {
501
             conference.startAudioMuted = audioMuted;
499
             conference.startAudioMuted = audioMuted;
502
             conference.startVideoMuted = videoMuted;
500
             conference.startVideoMuted = videoMuted;
503
 
501
 
504
             // mute existing local tracks because this is initial mute from
502
             // mute existing local tracks because this is initial mute from
505
             // Jicofo
503
             // Jicofo
506
-            conference.getLocalTracks().forEach(function(track) {
504
+            conference.getLocalTracks().forEach(track => {
507
                 switch (track.getType()) {
505
                 switch (track.getType()) {
508
                 case MediaType.AUDIO:
506
                 case MediaType.AUDIO:
509
                     conference.startAudioMuted && track.mute();
507
                     conference.startAudioMuted && track.mute();
527
         return;
525
         return;
528
     }
526
     }
529
 
527
 
530
-    conference.statistics.addAudioLevelListener(function(ssrc, level) {
528
+    conference.statistics.addAudioLevelListener((ssrc, level) => {
531
         const resource = conference.rtc.getResourceBySSRC(ssrc);
529
         const resource = conference.rtc.getResourceBySSRC(ssrc);
532
         if (!resource) {
530
         if (!resource) {
533
             return;
531
             return;
536
         conference.rtc.setAudioLevel(resource, level);
534
         conference.rtc.setAudioLevel(resource, level);
537
     });
535
     });
538
     // Forward the "before stats disposed" event
536
     // Forward the "before stats disposed" event
539
-    conference.statistics.addBeforeDisposedListener(function() {
537
+    conference.statistics.addBeforeDisposedListener(() => {
540
         conference.eventEmitter.emit(
538
         conference.eventEmitter.emit(
541
             JitsiConferenceEvents.BEFORE_STATISTICS_DISPOSED);
539
             JitsiConferenceEvents.BEFORE_STATISTICS_DISPOSED);
542
     });
540
     });
543
-    conference.statistics.addConnectionStatsListener(function(stats) {
541
+    conference.statistics.addConnectionStatsListener(stats => {
544
         const ssrc2resolution = stats.resolution;
542
         const ssrc2resolution = stats.resolution;
545
 
543
 
546
         const id2resolution = {};
544
         const id2resolution = {};
547
 
545
 
548
         // preprocess resolutions: group by user id, skip incorrect
546
         // preprocess resolutions: group by user id, skip incorrect
549
         // resolutions etc.
547
         // resolutions etc.
550
-        Object.keys(ssrc2resolution).forEach(function(ssrc) {
548
+        Object.keys(ssrc2resolution).forEach(ssrc => {
551
             const resolution = ssrc2resolution[ssrc];
549
             const resolution = ssrc2resolution[ssrc];
552
 
550
 
553
             if (!resolution.width || !resolution.height
551
             if (!resolution.width || !resolution.height
573
             JitsiConferenceEvents.CONNECTION_STATS, stats);
571
             JitsiConferenceEvents.CONNECTION_STATS, stats);
574
     });
572
     });
575
 
573
 
576
-    conference.statistics.addByteSentStatsListener(function(stats) {
577
-        conference.getLocalTracks(MediaType.AUDIO).forEach(function(track) {
574
+    conference.statistics.addByteSentStatsListener(stats => {
575
+        conference.getLocalTracks(MediaType.AUDIO).forEach(track => {
578
             const ssrc = track.getSSRC();
576
             const ssrc = track.getSSRC();
579
             if (!ssrc || !stats.hasOwnProperty(ssrc)) {
577
             if (!ssrc || !stats.hasOwnProperty(ssrc)) {
580
                 return;
578
                 return;

+ 2
- 2
JitsiConnection.js View File

18
     this.xmpp = new XMPP(options, token);
18
     this.xmpp = new XMPP(options, token);
19
 
19
 
20
     this.addEventListener(JitsiConnectionEvents.CONNECTION_FAILED,
20
     this.addEventListener(JitsiConnectionEvents.CONNECTION_FAILED,
21
-        function(errType, msg) {
21
+        (errType, msg) => {
22
             // sends analytics and callstats event
22
             // sends analytics and callstats event
23
             Statistics.sendEventToAll(`connection.failed.${errType}`,
23
             Statistics.sendEventToAll(`connection.failed.${errType}`,
24
                 {label: msg});
24
                 {label: msg});
25
         });
25
         });
26
 
26
 
27
     this.addEventListener(JitsiConnectionEvents.CONNECTION_DISCONNECTED,
27
     this.addEventListener(JitsiConnectionEvents.CONNECTION_DISCONNECTED,
28
-        function(msg) {
28
+        msg => {
29
             // we can see disconnects from normal tab closing of the browser
29
             // we can see disconnects from normal tab closing of the browser
30
             // and then there are no msgs, but we want to log only disconnects
30
             // and then there are no msgs, but we want to log only disconnects
31
             // when there is real error
31
             // when there is real error

+ 10
- 8
JitsiMediaDevices.js View File

7
 
7
 
8
 const eventEmitter = new EventEmitter();
8
 const eventEmitter = new EventEmitter();
9
 
9
 
10
-RTC.addListener(RTCEvents.DEVICE_LIST_CHANGED,
11
-    function(devices) {
12
-        eventEmitter.emit(JitsiMediaDevicesEvents.DEVICE_LIST_CHANGED, devices);
13
-    });
10
+RTC.addListener(
11
+    RTCEvents.DEVICE_LIST_CHANGED,
12
+    devices =>
13
+        eventEmitter.emit(
14
+            JitsiMediaDevicesEvents.DEVICE_LIST_CHANGED,
15
+            devices));
14
 
16
 
15
 RTC.addListener(RTCEvents.DEVICE_LIST_AVAILABLE,
17
 RTC.addListener(RTCEvents.DEVICE_LIST_AVAILABLE,
16
-    function(devices) {
18
+    devices => {
17
         // log output device
19
         // log output device
18
         logOutputDevice(
20
         logOutputDevice(
19
             JitsiMediaDevices.getAudioOutputDevice(),
21
             JitsiMediaDevices.getAudioOutputDevice(),
26
  * @param devices list of devices
28
  * @param devices list of devices
27
  */
29
  */
28
 function logOutputDevice(deviceID, devices) {
30
 function logOutputDevice(deviceID, devices) {
29
-    const device = devices.find(function(d) {
30
-        return d.kind === 'audiooutput' && d.deviceId === deviceID;
31
-    });
31
+    const device
32
+        = devices.find(
33
+            d => d.kind === 'audiooutput' && d.deviceId === deviceID);
32
 
34
 
33
     if (device) {
35
     if (device) {
34
         Statistics.sendActiveDeviceListEvent(
36
         Statistics.sendActiveDeviceListEvent(

+ 4
- 4
JitsiMeetJS.js View File

214
         let promiseFulfilled = false;
214
         let promiseFulfilled = false;
215
 
215
 
216
         if (firePermissionPromptIsShownEvent === true) {
216
         if (firePermissionPromptIsShownEvent === true) {
217
-            window.setTimeout(function() {
217
+            window.setTimeout(() => {
218
                 if (!promiseFulfilled) {
218
                 if (!promiseFulfilled) {
219
                     JitsiMediaDevices.emitEvent(
219
                     JitsiMediaDevices.emitEvent(
220
                         JitsiMediaDevicesEvents.PERMISSION_PROMPT_IS_SHOWN,
220
                         JitsiMediaDevicesEvents.PERMISSION_PROMPT_IS_SHOWN,
230
             = window.performance.now();
230
             = window.performance.now();
231
 
231
 
232
         return RTC.obtainAudioAndVideoPermissions(options || {})
232
         return RTC.obtainAudioAndVideoPermissions(options || {})
233
-            .then(function(tracks) {
233
+            .then(tracks => {
234
                 promiseFulfilled = true;
234
                 promiseFulfilled = true;
235
 
235
 
236
                 window.connectionTimes['obtainPermissions.end']
236
                 window.connectionTimes['obtainPermissions.end']
248
                                 track.setAudioLevel.bind(track));
248
                                 track.setAudioLevel.bind(track));
249
                             track.addEventListener(
249
                             track.addEventListener(
250
                                 JitsiTrackEvents.LOCAL_TRACK_STOPPED,
250
                                 JitsiTrackEvents.LOCAL_TRACK_STOPPED,
251
-                                function() {
251
+                                () => {
252
                                     Statistics.stopLocalStats(mStream);
252
                                     Statistics.stopLocalStats(mStream);
253
                                 });
253
                                 });
254
                         }
254
                         }
267
                 }
267
                 }
268
 
268
 
269
                 return tracks;
269
                 return tracks;
270
-            }).catch(function(error) {
270
+            }).catch(error => {
271
                 promiseFulfilled = true;
271
                 promiseFulfilled = true;
272
 
272
 
273
                 if(error.name === JitsiTrackErrors.UNSUPPORTED_RESOLUTION) {
273
                 if(error.name === JitsiTrackErrors.UNSUPPORTED_RESOLUTION) {

+ 5
- 4
JitsiParticipant.js View File

58
      * {@link JitsiTrack.isWebRTCTrackMuted}.
58
      * {@link JitsiTrack.isWebRTCTrackMuted}.
59
      */
59
      */
60
     hasAnyVideoTrackWebRTCMuted() {
60
     hasAnyVideoTrackWebRTCMuted() {
61
-        return this.getTracks().some(function(jitsiTrack) {
62
-            return jitsiTrack.getType() === MediaType.VIDEO
63
-                && jitsiTrack.isWebRTCTrackMuted();
64
-        });
61
+        return (
62
+            this.getTracks().some(
63
+                jitsiTrack =>
64
+                    jitsiTrack.getType() === MediaType.VIDEO
65
+                        && jitsiTrack.isWebRTCTrackMuted()));
65
     }
66
     }
66
 
67
 
67
     /**
68
     /**

+ 43
- 52
doc/example/example.js View File

27
 function onLocalTracks(tracks) {
27
 function onLocalTracks(tracks) {
28
     localTracks = tracks;
28
     localTracks = tracks;
29
     for(let i = 0; i < localTracks.length; i++) {
29
     for(let i = 0; i < localTracks.length; i++) {
30
-        localTracks[i].addEventListener(JitsiMeetJS.events.track.TRACK_AUDIO_LEVEL_CHANGED,
31
-            function(audioLevel) {
32
-                console.log(`Audio Level local: ${audioLevel}`);
33
-            });
34
-        localTracks[i].addEventListener(JitsiMeetJS.events.track.TRACK_MUTE_CHANGED,
35
-            function() {
36
-                console.log('local track muted');
37
-            });
38
-        localTracks[i].addEventListener(JitsiMeetJS.events.track.LOCAL_TRACK_STOPPED,
39
-            function() {
40
-                console.log('local track stoped');
41
-            });
42
-        localTracks[i].addEventListener(JitsiMeetJS.events.track.TRACK_AUDIO_OUTPUT_CHANGED,
43
-            function(deviceId) {
44
-                console.log(`track audio output device was changed to ${deviceId}`);
45
-            });
30
+        localTracks[i].addEventListener(
31
+            JitsiMeetJS.events.track.TRACK_AUDIO_LEVEL_CHANGED,
32
+            audioLevel => console.log(`Audio Level local: ${audioLevel}`));
33
+        localTracks[i].addEventListener(
34
+            JitsiMeetJS.events.track.TRACK_MUTE_CHANGED,
35
+            () => console.log('local track muted'));
36
+        localTracks[i].addEventListener(
37
+            JitsiMeetJS.events.track.LOCAL_TRACK_STOPPED,
38
+            () => console.log('local track stoped'));
39
+        localTracks[i].addEventListener(
40
+            JitsiMeetJS.events.track.TRACK_AUDIO_OUTPUT_CHANGED,
41
+            deviceId =>
42
+                console.log(
43
+                    `track audio output device was changed to ${deviceId}`));
46
         if(localTracks[i].getType() == 'video') {
44
         if(localTracks[i].getType() == 'video') {
47
             $('body').append(`<video autoplay='1' id='localVideo${i}' />`);
45
             $('body').append(`<video autoplay='1' id='localVideo${i}' />`);
48
             localTracks[i].attach($(`#localVideo${i}`)[0]);
46
             localTracks[i].attach($(`#localVideo${i}`)[0]);
69
         remoteTracks[participant] = [];
67
         remoteTracks[participant] = [];
70
     }
68
     }
71
     const idx = remoteTracks[participant].push(track);
69
     const idx = remoteTracks[participant].push(track);
72
-    track.addEventListener(JitsiMeetJS.events.track.TRACK_AUDIO_LEVEL_CHANGED,
73
-        function(audioLevel) {
74
-            console.log(`Audio Level remote: ${audioLevel}`);
75
-        });
76
-    track.addEventListener(JitsiMeetJS.events.track.TRACK_MUTE_CHANGED,
77
-        function() {
78
-            console.log('remote track muted');
79
-        });
80
-    track.addEventListener(JitsiMeetJS.events.track.LOCAL_TRACK_STOPPED,
81
-        function() {
82
-            console.log('remote track stoped');
83
-        });
70
+    track.addEventListener(
71
+        JitsiMeetJS.events.track.TRACK_AUDIO_LEVEL_CHANGED,
72
+        audioLevel => console.log(`Audio Level remote: ${audioLevel}`));
73
+    track.addEventListener(
74
+        JitsiMeetJS.events.track.TRACK_MUTE_CHANGED,
75
+        () => console.log('remote track muted'));
76
+    track.addEventListener(
77
+        JitsiMeetJS.events.track.LOCAL_TRACK_STOPPED,
78
+        () => console.log('remote track stoped'));
84
     track.addEventListener(JitsiMeetJS.events.track.TRACK_AUDIO_OUTPUT_CHANGED,
79
     track.addEventListener(JitsiMeetJS.events.track.TRACK_AUDIO_OUTPUT_CHANGED,
85
-        function(deviceId) {
86
-            console.log(`track audio output device was changed to ${deviceId}`);
87
-        });
80
+        deviceId =>
81
+            console.log(
82
+                `track audio output device was changed to ${deviceId}`));
88
     const id = participant + track.getType() + idx;
83
     const id = participant + track.getType() + idx;
89
     if(track.getType() == 'video') {
84
     if(track.getType() == 'video') {
90
         $('body').append(`<video autoplay='1' id='${participant}video${idx}' />`);
85
         $('body').append(`<video autoplay='1' id='${participant}video${idx}' />`);
122
 function onConnectionSuccess() {
117
 function onConnectionSuccess() {
123
     room = connection.initJitsiConference('conference', confOptions);
118
     room = connection.initJitsiConference('conference', confOptions);
124
     room.on(JitsiMeetJS.events.conference.TRACK_ADDED, onRemoteTrack);
119
     room.on(JitsiMeetJS.events.conference.TRACK_ADDED, onRemoteTrack);
125
-    room.on(JitsiMeetJS.events.conference.TRACK_REMOVED, function(track) {
120
+    room.on(JitsiMeetJS.events.conference.TRACK_REMOVED, track => {
126
         console.log(`track removed!!!${track}`);
121
         console.log(`track removed!!!${track}`);
127
     });
122
     });
128
     room.on(JitsiMeetJS.events.conference.CONFERENCE_JOINED, onConferenceJoined);
123
     room.on(JitsiMeetJS.events.conference.CONFERENCE_JOINED, onConferenceJoined);
129
-    room.on(JitsiMeetJS.events.conference.USER_JOINED, function(id) {
124
+    room.on(JitsiMeetJS.events.conference.USER_JOINED, id => {
130
         console.log('user join'); remoteTracks[id] = [];
125
         console.log('user join'); remoteTracks[id] = [];
131
     });
126
     });
132
     room.on(JitsiMeetJS.events.conference.USER_LEFT, onUserLeft);
127
     room.on(JitsiMeetJS.events.conference.USER_LEFT, onUserLeft);
133
-    room.on(JitsiMeetJS.events.conference.TRACK_MUTE_CHANGED, function(track) {
128
+    room.on(JitsiMeetJS.events.conference.TRACK_MUTE_CHANGED, track => {
134
         console.log(`${track.getType()} - ${track.isMuted()}`);
129
         console.log(`${track.getType()} - ${track.isMuted()}`);
135
     });
130
     });
136
-    room.on(JitsiMeetJS.events.conference.DISPLAY_NAME_CHANGED, function(userID, displayName) {
131
+    room.on(JitsiMeetJS.events.conference.DISPLAY_NAME_CHANGED, (userID, displayName) => {
137
         console.log(`${userID} - ${displayName}`);
132
         console.log(`${userID} - ${displayName}`);
138
     });
133
     });
139
     room.on(JitsiMeetJS.events.conference.TRACK_AUDIO_LEVEL_CHANGED,
134
     room.on(JitsiMeetJS.events.conference.TRACK_AUDIO_LEVEL_CHANGED,
140
-      function(userID, audioLevel) {
135
+      (userID, audioLevel) => {
141
           console.log(`${userID} - ${audioLevel}`);
136
           console.log(`${userID} - ${audioLevel}`);
142
       });
137
       });
143
-    room.on(JitsiMeetJS.events.conference.RECORDER_STATE_CHANGED, function() {
138
+    room.on(JitsiMeetJS.events.conference.RECORDER_STATE_CHANGED, () => {
144
         console.log(`${room.isRecordingSupported()} - ${
139
         console.log(`${room.isRecordingSupported()} - ${
145
              room.getRecordingState()} - ${
140
              room.getRecordingState()} - ${
146
              room.getRecordingURL()}`);
141
              room.getRecordingURL()}`);
147
     });
142
     });
148
-    room.on(JitsiMeetJS.events.conference.PHONE_NUMBER_CHANGED, function() {
143
+    room.on(JitsiMeetJS.events.conference.PHONE_NUMBER_CHANGED, () => {
149
         console.log(
144
         console.log(
150
             `${room.getPhoneNumber()} - ${
145
             `${room.getPhoneNumber()} - ${
151
              room.getPhonePin()}`);
146
              room.getPhonePin()}`);
193
         localTracks.pop();
188
         localTracks.pop();
194
     }
189
     }
195
     JitsiMeetJS.createLocalTracks({devices: isVideo ? ['video'] : ['desktop']})
190
     JitsiMeetJS.createLocalTracks({devices: isVideo ? ['video'] : ['desktop']})
196
-        .then(function(tracks) {
191
+        .then(tracks => {
197
             localTracks.push(tracks[0]);
192
             localTracks.push(tracks[0]);
198
             localTracks[1].addEventListener(JitsiMeetJS.events.track.TRACK_MUTE_CHANGED,
193
             localTracks[1].addEventListener(JitsiMeetJS.events.track.TRACK_MUTE_CHANGED,
199
-                function() {
194
+                () => {
200
                     console.log('local track muted');
195
                     console.log('local track muted');
201
                 });
196
                 });
202
             localTracks[1].addEventListener(JitsiMeetJS.events.track.LOCAL_TRACK_STOPPED,
197
             localTracks[1].addEventListener(JitsiMeetJS.events.track.LOCAL_TRACK_STOPPED,
203
-                function() {
198
+                () => {
204
                     console.log('local track stoped');
199
                     console.log('local track stoped');
205
                 });
200
                 });
206
             localTracks[1].attach($('#localVideo1')[0]);
201
             localTracks[1].attach($('#localVideo1')[0]);
207
             room.addTrack(localTracks[1]);
202
             room.addTrack(localTracks[1]);
208
-        }).catch(function(error) {
203
+        }).catch(error => {
209
             console.log(error);
204
             console.log(error);
210
         });
205
         });
211
 }
206
 }
244
     // The URL to the Firefox extension for desktop sharing.
239
     // The URL to the Firefox extension for desktop sharing.
245
     desktopSharingFirefoxExtensionURL: null
240
     desktopSharingFirefoxExtensionURL: null
246
 };
241
 };
247
-JitsiMeetJS.init(initOptions).then(function() {
242
+JitsiMeetJS.init(initOptions).then(() => {
248
     connection = new JitsiMeetJS.JitsiConnection(null, null, options);
243
     connection = new JitsiMeetJS.JitsiConnection(null, null, options);
249
 
244
 
250
     connection.addEventListener(JitsiMeetJS.events.connection.CONNECTION_ESTABLISHED, onConnectionSuccess);
245
     connection.addEventListener(JitsiMeetJS.events.connection.CONNECTION_ESTABLISHED, onConnectionSuccess);
255
 
250
 
256
     connection.connect();
251
     connection.connect();
257
     JitsiMeetJS.createLocalTracks({devices: ['audio', 'video']})
252
     JitsiMeetJS.createLocalTracks({devices: ['audio', 'video']})
258
-        .then(onLocalTracks).catch(function(error) {
253
+        .then(onLocalTracks).catch(error => {
259
             throw error;
254
             throw error;
260
         });
255
         });
261
-}).catch(function(error) {
256
+}).catch(error => {
262
     console.log(error);
257
     console.log(error);
263
 });
258
 });
264
 
259
 
265
 if (JitsiMeetJS.mediaDevices.isDeviceChangeAvailable('output')) {
260
 if (JitsiMeetJS.mediaDevices.isDeviceChangeAvailable('output')) {
266
-    JitsiMeetJS.mediaDevices.enumerateDevices(function(devices) {
267
-        const audioOutputDevices = devices.filter(function(d) {
268
-            return d.kind === 'audiooutput';
269
-        });
261
+    JitsiMeetJS.mediaDevices.enumerateDevices(devices => {
262
+        const audioOutputDevices = devices.filter(d => d.kind === 'audiooutput');
270
 
263
 
271
         if (audioOutputDevices.length > 1) {
264
         if (audioOutputDevices.length > 1) {
272
             $('#audioOutputSelect').html(
265
             $('#audioOutputSelect').html(
273
-                audioOutputDevices.map(function(d) {
274
-                    return `<option value="${d.deviceId}">${d.label}</option>`;
275
-                }).join('\n')
266
+                audioOutputDevices.map(d => `<option value="${d.deviceId}">${d.label}</option>`).join('\n')
276
             );
267
             );
277
 
268
 
278
             $('#audioOutputSelectWrapper').show();
269
             $('#audioOutputSelectWrapper').show();

+ 2
- 2
modules/RTC/DataChannels.js View File

169
  * Closes all currently opened data channels.
169
  * Closes all currently opened data channels.
170
  */
170
  */
171
 DataChannels.prototype.closeAllChannels = function() {
171
 DataChannels.prototype.closeAllChannels = function() {
172
-    this._dataChannels.forEach(function(dc) {
172
+    this._dataChannels.forEach(dc => {
173
         // the DC will be removed from the array on 'onclose' event
173
         // the DC will be removed from the array on 'onclose' event
174
         dc.close();
174
         dc.close();
175
     });
175
     });
253
  * or Error with "No opened data channels found!" message.
253
  * or Error with "No opened data channels found!" message.
254
  */
254
  */
255
 DataChannels.prototype.send = function(jsonObject) {
255
 DataChannels.prototype.send = function(jsonObject) {
256
-    if(!this._some(function(dataChannel) {
256
+    if(!this._some(dataChannel => {
257
         if (dataChannel.readyState == 'open') {
257
         if (dataChannel.readyState == 'open') {
258
             dataChannel.send(JSON.stringify(jsonObject));
258
             dataChannel.send(JSON.stringify(jsonObject));
259
             return true;
259
             return true;

+ 13
- 22
modules/RTC/JitsiLocalTrack.js View File

33
 
33
 
34
     JitsiTrack.call(this,
34
     JitsiTrack.call(this,
35
         null /* RTC */, stream, track,
35
         null /* RTC */, stream, track,
36
-        function() {
36
+        () => {
37
             if(!this.dontFireRemoveEvent) {
37
             if(!this.dontFireRemoveEvent) {
38
                 this.eventEmitter.emit(
38
                 this.eventEmitter.emit(
39
                     JitsiTrackEvents.LOCAL_TRACK_STOPPED);
39
                     JitsiTrackEvents.LOCAL_TRACK_STOPPED);
40
             }
40
             }
41
             this.dontFireRemoveEvent = false;
41
             this.dontFireRemoveEvent = false;
42
-        }.bind(this) /* inactiveHandler */,
42
+        } /* inactiveHandler */,
43
         mediaType, videoType, null /* ssrc */);
43
         mediaType, videoType, null /* ssrc */);
44
     this.dontFireRemoveEvent = false;
44
     this.dontFireRemoveEvent = false;
45
     this.resolution = resolution;
45
     this.resolution = resolution;
106
         // device ID "".
106
         // device ID "".
107
         if (typeof self.getTrack().readyState === 'undefined'
107
         if (typeof self.getTrack().readyState === 'undefined'
108
             && typeof self._realDeviceId !== 'undefined'
108
             && typeof self._realDeviceId !== 'undefined'
109
-            && !devices.find(function(d) {
110
-                return d.deviceId === self._realDeviceId;
111
-            })) {
109
+            && !devices.find(d => d.deviceId === self._realDeviceId)) {
112
             self._trackEnded = true;
110
             self._trackEnded = true;
113
         }
111
         }
114
     };
112
     };
257
     track.inMuteOrUnmuteProgress = true;
255
     track.inMuteOrUnmuteProgress = true;
258
 
256
 
259
     return track._setMute(mute)
257
     return track._setMute(mute)
260
-        .then(function() {
258
+        .then(() => {
261
             track.inMuteOrUnmuteProgress = false;
259
             track.inMuteOrUnmuteProgress = false;
262
         })
260
         })
263
-        .catch(function(status) {
261
+        .catch(status => {
264
             track.inMuteOrUnmuteProgress = false;
262
             track.inMuteOrUnmuteProgress = false;
265
             throw status;
263
             throw status;
266
         });
264
         });
324
             }
322
             }
325
 
323
 
326
             promise = RTCUtils.obtainAudioAndVideoPermissions(streamOptions)
324
             promise = RTCUtils.obtainAudioAndVideoPermissions(streamOptions)
327
-                .then(function(streamsInfo) {
325
+                .then(streamsInfo => {
328
                     const mediaType = self.getType();
326
                     const mediaType = self.getType();
329
-                    const streamInfo = streamsInfo.find(function(info) {
330
-                        return info.mediaType === mediaType;
331
-                    });
327
+                    const streamInfo = streamsInfo.find(info => info.mediaType === mediaType);
332
 
328
 
333
                     if(!streamInfo) {
329
                     if(!streamInfo) {
334
                         throw new JitsiTrackError(
330
                         throw new JitsiTrackError(
346
                         }
342
                         }
347
                     }
343
                     }
348
 
344
 
349
-                    self.containers = self.containers.map(function(cont) {
350
-                        return RTCUtils.attachMediaStream(cont, self.stream);
351
-                    });
345
+                    self.containers = self.containers.map(cont => RTCUtils.attachMediaStream(cont, self.stream));
352
 
346
 
353
                     return self._addStreamToConferenceAsUnmute();
347
                     return self._addStreamToConferenceAsUnmute();
354
                 });
348
                 });
356
     }
350
     }
357
 
351
 
358
     return promise
352
     return promise
359
-        .then(function() {
360
-            return self._sendMuteStatus(mute);
361
-        })
353
+        .then(() => self._sendMuteStatus(mute))
362
         .then(function() {
354
         .then(function() {
363
             self.eventEmitter.emit(JitsiTrackEvents.TRACK_MUTE_CHANGED, this);
355
             self.eventEmitter.emit(JitsiTrackEvents.TRACK_MUTE_CHANGED, this);
364
         });
356
         });
466
     }
458
     }
467
 
459
 
468
     return promise
460
     return promise
469
-        .then(function() {
470
-            return JitsiTrack.prototype.dispose.call(self); // super.dispose();
471
-        });
461
+        .then(() => JitsiTrack.prototype.dispose.call(self) // super.dispose();
462
+        );
472
 };
463
 };
473
 
464
 
474
 /**
465
 /**
561
     const iceConnectionState
552
     const iceConnectionState
562
         = this.conference ? this.conference.getConnectionState() : null;
553
         = this.conference ? this.conference.getConnectionState() : null;
563
     if(this._testByteSent && 'connected' === iceConnectionState) {
554
     if(this._testByteSent && 'connected' === iceConnectionState) {
564
-        setTimeout(function() {
555
+        setTimeout(() => {
565
             if(this._bytesSent <= 0) {
556
             if(this._bytesSent <= 0) {
566
                 // we are not receiving anything from the microphone
557
                 // we are not receiving anything from the microphone
567
                 this._fireNoDataFromSourceEvent();
558
                 this._fireNoDataFromSourceEvent();
568
             }
559
             }
569
-        }.bind(this), 3000);
560
+        }, 3000);
570
         this._testByteSent = false;
561
         this._testByteSent = false;
571
     }
562
     }
572
 };
563
 };

+ 4
- 4
modules/RTC/JitsiRemoteTrack.js View File

61
     // 2. It does mix MediaStream('inactive') with MediaStreamTrack events
61
     // 2. It does mix MediaStream('inactive') with MediaStreamTrack events
62
     // 3. Allowing to bind more than one event handler requires too much
62
     // 3. Allowing to bind more than one event handler requires too much
63
     //    refactoring around camera issues detection.
63
     //    refactoring around camera issues detection.
64
-    this.track.addEventListener('mute', function() {
64
+    this.track.addEventListener('mute', () => {
65
 
65
 
66
         logger.debug(
66
         logger.debug(
67
             `"onmute" event(${Date.now()}): `,
67
             `"onmute" event(${Date.now()}): `,
68
             this.getParticipantId(), this.getType(), this.getSSRC());
68
             this.getParticipantId(), this.getType(), this.getSSRC());
69
 
69
 
70
         this.rtc.eventEmitter.emit(RTCEvents.REMOTE_TRACK_MUTE, this);
70
         this.rtc.eventEmitter.emit(RTCEvents.REMOTE_TRACK_MUTE, this);
71
-    }.bind(this));
71
+    });
72
 
72
 
73
     // Bind 'onunmute'
73
     // Bind 'onunmute'
74
-    this.track.addEventListener('unmute', function() {
74
+    this.track.addEventListener('unmute', () => {
75
 
75
 
76
         logger.debug(
76
         logger.debug(
77
             `"onunmute" event(${Date.now()}): `,
77
             `"onunmute" event(${Date.now()}): `,
78
             this.getParticipantId(), this.getType(), this.getSSRC());
78
             this.getParticipantId(), this.getType(), this.getSSRC());
79
 
79
 
80
         this.rtc.eventEmitter.emit(RTCEvents.REMOTE_TRACK_UNMUTE, this);
80
         this.rtc.eventEmitter.emit(RTCEvents.REMOTE_TRACK_UNMUTE, this);
81
-    }.bind(this));
81
+    });
82
 };
82
 };
83
 
83
 
84
 /**
84
 /**

+ 5
- 7
modules/RTC/JitsiTrack.js View File

112
         }
112
         }
113
         addMediaStreamInactiveHandler(this.stream, handler);
113
         addMediaStreamInactiveHandler(this.stream, handler);
114
     } else if(trackHandler2Prop.hasOwnProperty(type)) {
114
     } else if(trackHandler2Prop.hasOwnProperty(type)) {
115
-        this.stream.getVideoTracks().forEach(function(track) {
115
+        this.stream.getVideoTracks().forEach(track => {
116
             track[trackHandler2Prop[type]] = handler;
116
             track[trackHandler2Prop[type]] = handler;
117
         }, this);
117
         }, this);
118
     }
118
     }
411
         return Promise.resolve();
411
         return Promise.resolve();
412
     }
412
     }
413
 
413
 
414
-    return Promise.all(this.containers.map(function(element) {
415
-        return element.setSinkId(audioOutputDeviceId)
416
-            .catch(function(error) {
414
+    return Promise.all(this.containers.map(element => element.setSinkId(audioOutputDeviceId)
415
+            .catch(error => {
417
                 logger.warn(
416
                 logger.warn(
418
                     'Failed to change audio output device on element. Default'
417
                     'Failed to change audio output device on element. Default'
419
                     + ' or previously set audio output device will be used.',
418
                     + ' or previously set audio output device will be used.',
420
                     element, error);
419
                     element, error);
421
                 throw error;
420
                 throw error;
422
-            });
423
-    }))
424
-    .then(function() {
421
+            })))
422
+    .then(() => {
425
         self.eventEmitter.emit(JitsiTrackEvents.TRACK_AUDIO_OUTPUT_CHANGED,
423
         self.eventEmitter.emit(JitsiTrackEvents.TRACK_AUDIO_OUTPUT_CHANGED,
426
             audioOutputDeviceId);
424
             audioOutputDeviceId);
427
     });
425
     });

+ 4
- 6
modules/RTC/RTC.js View File

18
 function createLocalTracks(tracksInfo, options) {
18
 function createLocalTracks(tracksInfo, options) {
19
     const newTracks = [];
19
     const newTracks = [];
20
     let deviceId = null;
20
     let deviceId = null;
21
-    tracksInfo.forEach(function(trackInfo) {
21
+    tracksInfo.forEach(trackInfo => {
22
         if (trackInfo.mediaType === MediaType.AUDIO) {
22
         if (trackInfo.mediaType === MediaType.AUDIO) {
23
             deviceId = options.micDeviceId;
23
             deviceId = options.micDeviceId;
24
         } else if (trackInfo.videoType === VideoType.CAMERA) {
24
         } else if (trackInfo.videoType === VideoType.CAMERA) {
93
      */
93
      */
94
     static obtainAudioAndVideoPermissions(options) {
94
     static obtainAudioAndVideoPermissions(options) {
95
         return RTCUtils.obtainAudioAndVideoPermissions(options).then(
95
         return RTCUtils.obtainAudioAndVideoPermissions(options).then(
96
-            function(tracksInfo) {
96
+            tracksInfo => {
97
                 const tracks = createLocalTracks(tracksInfo, options);
97
                 const tracks = createLocalTracks(tracksInfo, options);
98
                 return !tracks.some(track =>
98
                 return !tracks.some(track =>
99
                     !track._isReceivingData()) ? tracks
99
                     !track._isReceivingData()) ? tracks
366
      */
366
      */
367
     setAudioMute(value) {
367
     setAudioMute(value) {
368
         const mutePromises = [];
368
         const mutePromises = [];
369
-        this.getLocalTracks(MediaType.AUDIO).forEach(function(audioTrack) {
369
+        this.getLocalTracks(MediaType.AUDIO).forEach(audioTrack => {
370
             // this is a Promise
370
             // this is a Promise
371
             mutePromises.push(value ? audioTrack.mute() : audioTrack.unmute());
371
             mutePromises.push(value ? audioTrack.mute() : audioTrack.unmute());
372
         });
372
         });
665
      * matches given SSRC or <tt>undefined</tt> if no such track was found.
665
      * matches given SSRC or <tt>undefined</tt> if no such track was found.
666
      */
666
      */
667
     getRemoteTrackBySSRC(ssrc) {
667
     getRemoteTrackBySSRC(ssrc) {
668
-        return this.getRemoteTracks().find(function(remoteTrack) {
669
-            return ssrc == remoteTrack.getSSRC();
670
-        });
668
+        return this.getRemoteTracks().find(remoteTrack => ssrc == remoteTrack.getSSRC());
671
     }
669
     }
672
 
670
 
673
     /**
671
     /**

+ 43
- 53
modules/RTC/RTCUtils.js View File

71
         && navigator.mediaDevices.enumerateDevices
71
         && navigator.mediaDevices.enumerateDevices
72
         ? function(callback) {
72
         ? function(callback) {
73
             navigator.mediaDevices.enumerateDevices().then(
73
             navigator.mediaDevices.enumerateDevices().then(
74
-                callback, function() {
75
-                    callback([]);
76
-                });
74
+                callback,
75
+                () => callback([]));
77
         }
76
         }
78
         // Safari:
77
         // Safari:
79
         // "ReferenceError: Can't find variable: MediaStreamTrack"
78
         // "ReferenceError: Can't find variable: MediaStreamTrack"
81
         // until WebRTC is ready.
80
         // until WebRTC is ready.
82
         : MediaStreamTrack && MediaStreamTrack.getSources
81
         : MediaStreamTrack && MediaStreamTrack.getSources
83
         ? function(callback) {
82
         ? function(callback) {
84
-            MediaStreamTrack.getSources(function(sources) {
85
-                callback(sources.map(convertMediaStreamTrackSource));
86
-            });
83
+            MediaStreamTrack.getSources(
84
+                sources =>
85
+                    callback(sources.map(convertMediaStreamTrackSource)));
87
         }
86
         }
88
         : undefined;
87
         : undefined;
89
 }
88
 }
359
     // do not matter. This fixes situation when we have no devices initially,
358
     // do not matter. This fixes situation when we have no devices initially,
360
     // and then plug in a new one.
359
     // and then plug in a new one.
361
     if (rawEnumerateDevicesWithCallback) {
360
     if (rawEnumerateDevicesWithCallback) {
362
-        rawEnumerateDevicesWithCallback(function(devices) {
361
+        rawEnumerateDevicesWithCallback(devices => {
363
             // We don't fire RTCEvents.DEVICE_LIST_CHANGED for the first time
362
             // We don't fire RTCEvents.DEVICE_LIST_CHANGED for the first time
364
             // we call enumerateDevices(). This is the initial step.
363
             // we call enumerateDevices(). This is the initial step.
365
             if (typeof currentlyAvailableMediaDevices === 'undefined') {
364
             if (typeof currentlyAvailableMediaDevices === 'undefined') {
418
     initRawEnumerateDevicesWithCallback();
417
     initRawEnumerateDevicesWithCallback();
419
 
418
 
420
     if (rtcUtils.isDeviceListAvailable() && rawEnumerateDevicesWithCallback) {
419
     if (rtcUtils.isDeviceListAvailable() && rawEnumerateDevicesWithCallback) {
421
-        rawEnumerateDevicesWithCallback(function(devices) {
420
+        rawEnumerateDevicesWithCallback(devices => {
422
             currentlyAvailableMediaDevices = devices.splice(0);
421
             currentlyAvailableMediaDevices = devices.splice(0);
423
 
422
 
424
             eventEmitter.emit(RTCEvents.DEVICE_LIST_AVAILABLE,
423
             eventEmitter.emit(RTCEvents.DEVICE_LIST_AVAILABLE,
427
             if (isDeviceChangeEventSupported) {
426
             if (isDeviceChangeEventSupported) {
428
                 navigator.mediaDevices.addEventListener(
427
                 navigator.mediaDevices.addEventListener(
429
                     'devicechange',
428
                     'devicechange',
430
-                    function() {
431
-                        rtcUtils.enumerateDevices(
432
-                            onMediaDevicesListChanged);
433
-                    });
429
+                    () => rtcUtils.enumerateDevices(onMediaDevicesListChanged));
434
             } else {
430
             } else {
435
                 pollForAvailableMediaDevices();
431
                 pollForAvailableMediaDevices();
436
             }
432
             }
461
  */
457
  */
462
 function wrapGetUserMedia(getUserMedia) {
458
 function wrapGetUserMedia(getUserMedia) {
463
     return function(constraints, successCallback, errorCallback) {
459
     return function(constraints, successCallback, errorCallback) {
464
-        getUserMedia(constraints, function(stream) {
460
+        getUserMedia(constraints, stream => {
465
             maybeApply(successCallback, [stream]);
461
             maybeApply(successCallback, [stream]);
466
             if (!getUserMediaStatus.initialized) {
462
             if (!getUserMediaStatus.initialized) {
467
                 getUserMediaStatus.initialized = true;
463
                 getUserMediaStatus.initialized = true;
468
-                getUserMediaStatus.callbacks.forEach(function(callback) {
469
-                    callback();
470
-                });
464
+                getUserMediaStatus.callbacks.forEach(callback => callback());
471
                 getUserMediaStatus.callbacks.length = 0;
465
                 getUserMediaStatus.callbacks.length = 0;
472
             }
466
             }
473
-        }, function(error) {
467
+        }, error => {
474
             maybeApply(errorCallback, [error]);
468
             maybeApply(errorCallback, [error]);
475
         });
469
         });
476
     };
470
     };
497
 function wrapEnumerateDevices(enumerateDevices) {
491
 function wrapEnumerateDevices(enumerateDevices) {
498
     return function(callback) {
492
     return function(callback) {
499
         // enumerate devices only after initial getUserMedia
493
         // enumerate devices only after initial getUserMedia
500
-        afterUserMediaInitialized(function() {
501
-            enumerateDevices().then(callback, function(err) {
494
+        afterUserMediaInitialized(() => {
495
+            enumerateDevices().then(callback, err => {
502
                 logger.error('cannot enumerate devices: ', err);
496
                 logger.error('cannot enumerate devices: ', err);
503
                 callback([]);
497
                 callback([]);
504
             });
498
             });
512
  * @param {Function} callback function to call when received devices list.
506
  * @param {Function} callback function to call when received devices list.
513
  */
507
  */
514
 function enumerateDevicesThroughMediaStreamTrack(callback) {
508
 function enumerateDevicesThroughMediaStreamTrack(callback) {
515
-    MediaStreamTrack.getSources(function(sources) {
516
-        callback(sources.map(convertMediaStreamTrackSource));
517
-    });
509
+    MediaStreamTrack.getSources(
510
+        sources => callback(sources.map(convertMediaStreamTrackSource)));
518
 }
511
 }
519
 
512
 
520
 /**
513
 /**
546
     const device = options.devices.splice(0, 1);
539
     const device = options.devices.splice(0, 1);
547
     const devices = [];
540
     const devices = [];
548
     devices.push(device);
541
     devices.push(device);
549
-    options.deviceGUM[device](function(stream) {
550
-        options.streams = options.streams || {};
551
-        options.streams[device] = stream;
552
-        obtainDevices(options);
553
-    },
554
-        function(error) {
555
-            Object.keys(options.streams).forEach(function(device) {
542
+    options.deviceGUM[device](
543
+        stream => {
544
+            options.streams = options.streams || {};
545
+            options.streams[device] = stream;
546
+            obtainDevices(options);
547
+        },
548
+        error => {
549
+            Object.keys(options.streams).forEach(device => {
556
                 rtcUtils.stopMediaStream(options.streams[device]);
550
                 rtcUtils.stopMediaStream(options.streams[device]);
557
             });
551
             });
558
             logger.error(
552
             logger.error(
741
             logger.info(`Disable NS: ${disableNS}`);
735
             logger.info(`Disable NS: ${disableNS}`);
742
         }
736
         }
743
 
737
 
744
-        return new Promise(function(resolve, reject) {
738
+        return new Promise((resolve, reject) => {
745
             if (RTCBrowserType.isFirefox()) {
739
             if (RTCBrowserType.isFirefox()) {
746
                 const FFversion = RTCBrowserType.getFirefoxVersion();
740
                 const FFversion = RTCBrowserType.getFirefoxVersion();
747
                 if (FFversion < 40) {
741
                 if (FFversion < 40) {
758
                     navigator.mediaDevices.enumerateDevices.bind(navigator.mediaDevices)
752
                     navigator.mediaDevices.enumerateDevices.bind(navigator.mediaDevices)
759
                 );
753
                 );
760
                 this.pc_constraints = {};
754
                 this.pc_constraints = {};
761
-                this.attachMediaStream = wrapAttachMediaStream(function(element, stream) {
755
+                this.attachMediaStream = wrapAttachMediaStream((element, stream) => {
762
                     //  srcObject is being standardized and FF will eventually
756
                     //  srcObject is being standardized and FF will eventually
763
                     //  support that unprefixed. FF also supports the
757
                     //  support that unprefixed. FF also supports the
764
                     //  "element.src = URL.createObjectURL(...)" combo, but that
758
                     //  "element.src = URL.createObjectURL(...)" combo, but that
804
                     this.getUserMedia = getUserMedia;
798
                     this.getUserMedia = getUserMedia;
805
                     this.enumerateDevices = enumerateDevicesThroughMediaStreamTrack;
799
                     this.enumerateDevices = enumerateDevicesThroughMediaStreamTrack;
806
                 }
800
                 }
807
-                this.attachMediaStream = wrapAttachMediaStream(function(element, stream) {
801
+                this.attachMediaStream = wrapAttachMediaStream((element, stream) => {
808
                     defaultSetVideoSrc(element, stream);
802
                     defaultSetVideoSrc(element, stream);
809
                     return element;
803
                     return element;
810
                 });
804
                 });
923
                 onReady(options, this.getUserMediaWithConstraints.bind(this));
917
                 onReady(options, this.getUserMediaWithConstraints.bind(this));
924
                 resolve();
918
                 resolve();
925
             }
919
             }
926
-        }.bind(this));
920
+        });
927
     }
921
     }
928
 
922
 
929
     /**
923
     /**
945
         logger.info('Get media constraints', constraints);
939
         logger.info('Get media constraints', constraints);
946
 
940
 
947
         try {
941
         try {
948
-            this.getUserMedia(constraints,
949
-                function(stream) {
942
+            this.getUserMedia(
943
+                constraints,
944
+                stream => {
950
                     logger.log('onUserMediaSuccess');
945
                     logger.log('onUserMediaSuccess');
951
                     setAvailableDevices(um, stream);
946
                     setAvailableDevices(um, stream);
952
                     success_callback(stream);
947
                     success_callback(stream);
953
                 },
948
                 },
954
-                function(error) {
949
+                error => {
955
                     setAvailableDevices(um, undefined);
950
                     setAvailableDevices(um, undefined);
956
                     logger.warn('Failed to get access to local media. Error ',
951
                     logger.warn('Failed to get access to local media. Error ',
957
                         error, constraints);
952
                         error, constraints);
987
 
982
 
988
         options = options || {};
983
         options = options || {};
989
         const dsOptions = options.desktopSharingExtensionExternalInstallation;
984
         const dsOptions = options.desktopSharingExtensionExternalInstallation;
990
-        return new Promise(function(resolve, reject) {
985
+        return new Promise((resolve, reject) => {
991
             const successCallback = function(stream) {
986
             const successCallback = function(stream) {
992
                 resolve(handleLocalStream(stream, options.resolution));
987
                 resolve(handleLocalStream(stream, options.resolution));
993
             };
988
             };
1044
                 if(options.devices.length) {
1039
                 if(options.devices.length) {
1045
                     this.getUserMediaWithConstraints(
1040
                     this.getUserMediaWithConstraints(
1046
                         options.devices,
1041
                         options.devices,
1047
-                        function(stream) {
1042
+                        stream => {
1048
                             const audioDeviceRequested
1043
                             const audioDeviceRequested
1049
                                 = options.devices.indexOf('audio') !== -1;
1044
                                 = options.devices.indexOf('audio') !== -1;
1050
                             const videoDeviceRequested
1045
                             const videoDeviceRequested
1083
                                 // set to not ask for permissions)
1078
                                 // set to not ask for permissions)
1084
                                 self.getUserMediaWithConstraints(
1079
                                 self.getUserMediaWithConstraints(
1085
                                     devices,
1080
                                     devices,
1086
-                                    function() {
1081
+                                    () => {
1087
                                         // we already failed to obtain this
1082
                                         // we already failed to obtain this
1088
                                         // media, so we are not supposed in any
1083
                                         // media, so we are not supposed in any
1089
                                         // way to receive success for this call
1084
                                         // way to receive success for this call
1096
                                             devices)
1091
                                             devices)
1097
                                         );
1092
                                         );
1098
                                     },
1093
                                     },
1099
-                                    function(error) {
1094
+                                    error => {
1100
                                         // rejects with real error for not
1095
                                         // rejects with real error for not
1101
                                         // obtaining the media
1096
                                         // obtaining the media
1102
                                         reject(error);
1097
                                         reject(error);
1107
                             if(hasDesktop) {
1102
                             if(hasDesktop) {
1108
                                 screenObtainer.obtainStream(
1103
                                 screenObtainer.obtainStream(
1109
                                     dsOptions,
1104
                                     dsOptions,
1110
-                                    function(desktopStream) {
1105
+                                    desktopStream => {
1111
                                         successCallback({audioVideo: stream,
1106
                                         successCallback({audioVideo: stream,
1112
                                             desktopStream});
1107
                                             desktopStream});
1113
-                                    }, function(error) {
1108
+                                    }, error => {
1114
                                         self.stopMediaStream(stream);
1109
                                         self.stopMediaStream(stream);
1115
 
1110
 
1116
                                         reject(error);
1111
                                         reject(error);
1119
                                 successCallback({audioVideo: stream});
1114
                                 successCallback({audioVideo: stream});
1120
                             }
1115
                             }
1121
                         },
1116
                         },
1122
-                        function(error) {
1123
-                            reject(error);
1124
-                        },
1117
+                        error => reject(error),
1125
                         options);
1118
                         options);
1126
                 } else if (hasDesktop) {
1119
                 } else if (hasDesktop) {
1127
                     screenObtainer.obtainStream(
1120
                     screenObtainer.obtainStream(
1128
                         dsOptions,
1121
                         dsOptions,
1129
-                        function(stream) {
1130
-                            successCallback({desktopStream: stream});
1131
-                        }, function(error) {
1132
-                            reject(error);
1133
-                        });
1122
+                        stream => successCallback({desktopStream: stream}),
1123
+                        error => reject(error));
1134
                 }
1124
                 }
1135
             }
1125
             }
1136
-        }.bind(this));
1126
+        });
1137
     }
1127
     }
1138
 
1128
 
1139
     getDeviceAvailability() {
1129
     getDeviceAvailability() {
1212
      * @param mediaStream MediaStream object to stop.
1202
      * @param mediaStream MediaStream object to stop.
1213
      */
1203
      */
1214
     stopMediaStream(mediaStream) {
1204
     stopMediaStream(mediaStream) {
1215
-        mediaStream.getTracks().forEach(function(track) {
1205
+        mediaStream.getTracks().forEach(track => {
1216
             // stop() not supported with IE
1206
             // stop() not supported with IE
1217
             if (!RTCBrowserType.isTemasysPluginUsed() && track.stop) {
1207
             if (!RTCBrowserType.isTemasysPluginUsed() && track.stop) {
1218
                 track.stop();
1208
                 track.stop();
1262
         }
1252
         }
1263
 
1253
 
1264
         return featureDetectionAudioEl.setSinkId(deviceId)
1254
         return featureDetectionAudioEl.setSinkId(deviceId)
1265
-            .then(function() {
1255
+            .then(() => {
1266
                 audioOutputDeviceId = deviceId;
1256
                 audioOutputDeviceId = deviceId;
1267
                 audioOutputChanged = true;
1257
                 audioOutputChanged = true;
1268
 
1258
 

+ 12
- 12
modules/RTC/TraceablePeerConnection.js View File

167
     };
167
     };
168
     // XXX: do all non-firefox browsers which we support also support this?
168
     // XXX: do all non-firefox browsers which we support also support this?
169
     if (!RTCBrowserType.isFirefox() && this.maxstats) {
169
     if (!RTCBrowserType.isFirefox() && this.maxstats) {
170
-        this.statsinterval = window.setInterval(function() {
171
-            self.peerconnection.getStats(function(stats) {
170
+        this.statsinterval = window.setInterval(() => {
171
+            self.peerconnection.getStats(stats => {
172
                 const results = stats.result();
172
                 const results = stats.result();
173
                 const now = new Date();
173
                 const now = new Date();
174
                 for (let i = 0; i < results.length; ++i) {
174
                 for (let i = 0; i < results.length; ++i) {
175
-                    results[i].names().forEach(function(name) {
175
+                    results[i].names().forEach(name => {
176
                         const id = `${results[i].id}-${name}`;
176
                         const id = `${results[i].id}-${name}`;
177
                         if (!self.stats[id]) {
177
                         if (!self.stats[id]) {
178
                             self.stats[id] = {
178
                             self.stats[id] = {
281
     let ssrcLines = SDPUtil.find_lines(mediaLines[0], 'a=ssrc:');
281
     let ssrcLines = SDPUtil.find_lines(mediaLines[0], 'a=ssrc:');
282
 
282
 
283
     ssrcLines = ssrcLines.filter(
283
     ssrcLines = ssrcLines.filter(
284
-        function(line) {
284
+        line => {
285
             const msid
285
             const msid
286
                 = RTCBrowserType.isTemasysPluginUsed() ? 'mslabel' : 'msid';
286
                 = RTCBrowserType.isTemasysPluginUsed() ? 'mslabel' : 'msid';
287
             return line.indexOf(`${msid}:${streamId}`) !== -1;
287
             return line.indexOf(`${msid}:${streamId}`) !== -1;
508
 
508
 
509
     if (typeof session !== 'undefined'
509
     if (typeof session !== 'undefined'
510
         && typeof session.media !== 'undefined' && Array.isArray(session.media)) {
510
         && typeof session.media !== 'undefined' && Array.isArray(session.media)) {
511
-        session.media.forEach(function(mLine) {
511
+        session.media.forEach(mLine => {
512
 
512
 
513
             // Chrome appears to be picky about the order in which a=ssrc lines
513
             // Chrome appears to be picky about the order in which a=ssrc lines
514
             // are listed in an m-line when rtx is enabled (and thus there are
514
             // are listed in an m-line when rtx is enabled (and thus there are
522
 
522
 
523
             if (typeof mLine.ssrcGroups !== 'undefined'
523
             if (typeof mLine.ssrcGroups !== 'undefined'
524
                 && Array.isArray(mLine.ssrcGroups)) {
524
                 && Array.isArray(mLine.ssrcGroups)) {
525
-                mLine.ssrcGroups.forEach(function(group) {
525
+                mLine.ssrcGroups.forEach(group => {
526
                     if (typeof group.semantics !== 'undefined'
526
                     if (typeof group.semantics !== 'undefined'
527
                         && group.semantics === 'FID') {
527
                         && group.semantics === 'FID') {
528
                         if (typeof group.ssrcs !== 'undefined') {
528
                         if (typeof group.ssrcs !== 'undefined') {
594
         return desc;
594
         return desc;
595
     }
595
     }
596
 };
596
 };
597
-Object.keys(getters).forEach(function(prop) {
597
+Object.keys(getters).forEach(prop => {
598
     Object.defineProperty(
598
     Object.defineProperty(
599
         TraceablePeerConnection.prototype,
599
         TraceablePeerConnection.prototype,
600
         prop, {
600
         prop, {
655
 
655
 
656
             const self = this;
656
             const self = this;
657
             this.peerconnection.setLocalDescription(description,
657
             this.peerconnection.setLocalDescription(description,
658
-        function() {
658
+        () => {
659
             self.trace('setLocalDescriptionOnSuccess');
659
             self.trace('setLocalDescriptionOnSuccess');
660
             successCallback();
660
             successCallback();
661
         },
661
         },
662
-        function(err) {
662
+        err => {
663
             self.trace('setLocalDescriptionOnFailure', err);
663
             self.trace('setLocalDescriptionOnFailure', err);
664
             self.eventEmitter.emit(
664
             self.eventEmitter.emit(
665
                 RTCEvents.SET_LOCAL_DESCRIPTION_FAILED,
665
                 RTCEvents.SET_LOCAL_DESCRIPTION_FAILED,
701
 
701
 
702
             const self = this;
702
             const self = this;
703
             this.peerconnection.setRemoteDescription(description,
703
             this.peerconnection.setRemoteDescription(description,
704
-        function() {
704
+        () => {
705
             self.trace('setRemoteDescriptionOnSuccess');
705
             self.trace('setRemoteDescriptionOnSuccess');
706
             successCallback();
706
             successCallback();
707
         },
707
         },
708
-        function(err) {
708
+        err => {
709
             self.trace('setRemoteDescriptionOnFailure', err);
709
             self.trace('setRemoteDescriptionOnFailure', err);
710
             self.eventEmitter.emit(RTCEvents.SET_REMOTE_DESCRIPTION_FAILED,
710
             self.eventEmitter.emit(RTCEvents.SET_REMOTE_DESCRIPTION_FAILED,
711
                 err, self.peerconnection);
711
                 err, self.peerconnection);
799
     if (offer && answer
799
     if (offer && answer
800
             && offer.media && answer.media
800
             && offer.media && answer.media
801
             && offer.media.length == answer.media.length) {
801
             && offer.media.length == answer.media.length) {
802
-        answer.media.forEach(function(a, i) {
802
+        answer.media.forEach((a, i) => {
803
             if (SDPUtil.find_line(
803
             if (SDPUtil.find_line(
804
                     offer.media[i],
804
                     offer.media[i],
805
                     'a=setup:actpass',
805
                     'a=setup:actpass',

+ 4
- 4
modules/connectivity/ParticipantConnectionStatus.js View File

155
                 this._onRemoteTrackRemoved);
155
                 this._onRemoteTrackRemoved);
156
         }
156
         }
157
 
157
 
158
-        Object.keys(this.trackTimers).forEach(function(participantId) {
158
+        Object.keys(this.trackTimers).forEach(participantId => {
159
             this.clearTimeout(participantId);
159
             this.clearTimeout(participantId);
160
             this.clearRtcMutedTimestamp(participantId);
160
             this.clearRtcMutedTimestamp(participantId);
161
-        }.bind(this));
161
+        });
162
 
162
 
163
         // Clear RTC connection status cache
163
         // Clear RTC connection status cache
164
         this.connStatusFromJvb = {};
164
         this.connStatusFromJvb = {};
375
             // it some time, before the connection interrupted event is
375
             // it some time, before the connection interrupted event is
376
             // triggered.
376
             // triggered.
377
             this.clearTimeout(participantId);
377
             this.clearTimeout(participantId);
378
-            this.trackTimers[participantId] = window.setTimeout(function() {
378
+            this.trackTimers[participantId] = window.setTimeout(() => {
379
                 logger.debug(`RTC mute timeout for: ${participantId}`);
379
                 logger.debug(`RTC mute timeout for: ${participantId}`);
380
                 this.clearTimeout(participantId);
380
                 this.clearTimeout(participantId);
381
                 this.figureOutConnectionStatus(participantId);
381
                 this.figureOutConnectionStatus(participantId);
382
-            }.bind(this), this.rtcMuteTimeout);
382
+            }, this.rtcMuteTimeout);
383
         }
383
         }
384
     }
384
     }
385
 
385
 

+ 13
- 13
modules/statistics/CallStats.js View File

235
     MST_WITH_USERID: 'mstWithUserID'
235
     MST_WITH_USERID: 'mstWithUserID'
236
 };
236
 };
237
 
237
 
238
-CallStats.prototype.pcCallback = _try_catch(function(err, msg) {
238
+CallStats.prototype.pcCallback = _try_catch((err, msg) => {
239
     if (callStats && err !== 'success') {
239
     if (callStats && err !== 'success') {
240
         logger.error(`Monitoring status: ${err} msg: ${msg}`);
240
         logger.error(`Monitoring status: ${err} msg: ${msg}`);
241
     }
241
     }
300
  * @param type {String} "audio"/"video"
300
  * @param type {String} "audio"/"video"
301
  * @param {CallStats} cs callstats instance related to the event
301
  * @param {CallStats} cs callstats instance related to the event
302
  */
302
  */
303
-CallStats.sendMuteEvent = _try_catch(function(mute, type, cs) {
303
+CallStats.sendMuteEvent = _try_catch((mute, type, cs) => {
304
     let event;
304
     let event;
305
 
305
 
306
     if (type === 'video') {
306
     if (type === 'video') {
318
  * false for not stopping
318
  * false for not stopping
319
  * @param {CallStats} cs callstats instance related to the event
319
  * @param {CallStats} cs callstats instance related to the event
320
  */
320
  */
321
-CallStats.sendScreenSharingEvent = _try_catch(function(start, cs) {
321
+CallStats.sendScreenSharingEvent = _try_catch((start, cs) => {
322
     CallStats._reportEvent.call(
322
     CallStats._reportEvent.call(
323
         cs,
323
         cs,
324
         start ? fabricEvent.screenShareStart : fabricEvent.screenShareStop);
324
         start ? fabricEvent.screenShareStart : fabricEvent.screenShareStop);
328
  * Notifies CallStats that we are the new dominant speaker in the conference.
328
  * Notifies CallStats that we are the new dominant speaker in the conference.
329
  * @param {CallStats} cs callstats instance related to the event
329
  * @param {CallStats} cs callstats instance related to the event
330
  */
330
  */
331
-CallStats.sendDominantSpeakerEvent = _try_catch(function(cs) {
331
+CallStats.sendDominantSpeakerEvent = _try_catch(cs => {
332
     CallStats._reportEvent.call(cs, fabricEvent.dominantSpeaker);
332
     CallStats._reportEvent.call(cs, fabricEvent.dominantSpeaker);
333
 });
333
 });
334
 
334
 
337
  * @param {{deviceList: {String:String}}} list of devices with their data
337
  * @param {{deviceList: {String:String}}} list of devices with their data
338
  * @param {CallStats} cs callstats instance related to the event
338
  * @param {CallStats} cs callstats instance related to the event
339
  */
339
  */
340
-CallStats.sendActiveDeviceListEvent = _try_catch(function(devicesData, cs) {
340
+CallStats.sendActiveDeviceListEvent = _try_catch((devicesData, cs) => {
341
     CallStats._reportEvent.call(cs, fabricEvent.activeDeviceList, devicesData);
341
     CallStats._reportEvent.call(cs, fabricEvent.activeDeviceList, devicesData);
342
 });
342
 });
343
 
343
 
379
  * @param {RTCPeerConnection} pc connection on which failure occured.
379
  * @param {RTCPeerConnection} pc connection on which failure occured.
380
  * @param {CallStats} cs callstats instance related to the error (optional)
380
  * @param {CallStats} cs callstats instance related to the error (optional)
381
  */
381
  */
382
-CallStats.prototype.sendIceConnectionFailedEvent = _try_catch(function(pc, cs) {
382
+CallStats.prototype.sendIceConnectionFailedEvent = _try_catch((pc, cs) => {
383
     CallStats._reportError.call(
383
     CallStats._reportError.call(
384
         cs, wrtcFuncNames.iceConnectionFailure, null, pc);
384
         cs, wrtcFuncNames.iceConnectionFailure, null, pc);
385
 });
385
 });
435
  * @param {Error} e error to send
435
  * @param {Error} e error to send
436
  * @param {CallStats} cs callstats instance related to the error (optional)
436
  * @param {CallStats} cs callstats instance related to the error (optional)
437
  */
437
  */
438
-CallStats.sendGetUserMediaFailed = _try_catch(function(e, cs) {
438
+CallStats.sendGetUserMediaFailed = _try_catch((e, cs) => {
439
     CallStats._reportError.call(cs, wrtcFuncNames.getUserMedia, e, null);
439
     CallStats._reportError.call(cs, wrtcFuncNames.getUserMedia, e, null);
440
 });
440
 });
441
 
441
 
446
  * @param {RTCPeerConnection} pc connection on which failure occured.
446
  * @param {RTCPeerConnection} pc connection on which failure occured.
447
  * @param {CallStats} cs callstats instance related to the error (optional)
447
  * @param {CallStats} cs callstats instance related to the error (optional)
448
  */
448
  */
449
-CallStats.sendCreateOfferFailed = _try_catch(function(e, pc, cs) {
449
+CallStats.sendCreateOfferFailed = _try_catch((e, pc, cs) => {
450
     CallStats._reportError.call(cs, wrtcFuncNames.createOffer, e, pc);
450
     CallStats._reportError.call(cs, wrtcFuncNames.createOffer, e, pc);
451
 });
451
 });
452
 
452
 
457
  * @param {RTCPeerConnection} pc connection on which failure occured.
457
  * @param {RTCPeerConnection} pc connection on which failure occured.
458
  * @param {CallStats} cs callstats instance related to the error (optional)
458
  * @param {CallStats} cs callstats instance related to the error (optional)
459
  */
459
  */
460
-CallStats.sendCreateAnswerFailed = _try_catch(function(e, pc, cs) {
460
+CallStats.sendCreateAnswerFailed = _try_catch((e, pc, cs) => {
461
     CallStats._reportError.call(cs, wrtcFuncNames.createAnswer, e, pc);
461
     CallStats._reportError.call(cs, wrtcFuncNames.createAnswer, e, pc);
462
 });
462
 });
463
 
463
 
468
  * @param {RTCPeerConnection} pc connection on which failure occured.
468
  * @param {RTCPeerConnection} pc connection on which failure occured.
469
  * @param {CallStats} cs callstats instance related to the error (optional)
469
  * @param {CallStats} cs callstats instance related to the error (optional)
470
  */
470
  */
471
-CallStats.sendSetLocalDescFailed = _try_catch(function(e, pc, cs) {
471
+CallStats.sendSetLocalDescFailed = _try_catch((e, pc, cs) => {
472
     CallStats._reportError.call(cs, wrtcFuncNames.setLocalDescription, e, pc);
472
     CallStats._reportError.call(cs, wrtcFuncNames.setLocalDescription, e, pc);
473
 });
473
 });
474
 
474
 
479
  * @param {RTCPeerConnection} pc connection on which failure occured.
479
  * @param {RTCPeerConnection} pc connection on which failure occured.
480
  * @param {CallStats} cs callstats instance related to the error (optional)
480
  * @param {CallStats} cs callstats instance related to the error (optional)
481
  */
481
  */
482
-CallStats.sendSetRemoteDescFailed = _try_catch(function(e, pc, cs) {
482
+CallStats.sendSetRemoteDescFailed = _try_catch((e, pc, cs) => {
483
     CallStats._reportError.call(cs, wrtcFuncNames.setRemoteDescription, e, pc);
483
     CallStats._reportError.call(cs, wrtcFuncNames.setRemoteDescription, e, pc);
484
 });
484
 });
485
 
485
 
490
  * @param {RTCPeerConnection} pc connection on which failure occured.
490
  * @param {RTCPeerConnection} pc connection on which failure occured.
491
  * @param {CallStats} cs callstats instance related to the error (optional)
491
  * @param {CallStats} cs callstats instance related to the error (optional)
492
  */
492
  */
493
-CallStats.sendAddIceCandidateFailed = _try_catch(function(e, pc, cs) {
493
+CallStats.sendAddIceCandidateFailed = _try_catch((e, pc, cs) => {
494
     CallStats._reportError.call(cs, wrtcFuncNames.addIceCandidate, e, pc);
494
     CallStats._reportError.call(cs, wrtcFuncNames.addIceCandidate, e, pc);
495
 });
495
 });
496
 
496
 
500
  * @param {Error} e error to send or {String} message
500
  * @param {Error} e error to send or {String} message
501
  * @param {CallStats} cs callstats instance related to the error (optional)
501
  * @param {CallStats} cs callstats instance related to the error (optional)
502
  */
502
  */
503
-CallStats.sendApplicationLog = _try_catch(function(e, cs) {
503
+CallStats.sendApplicationLog = _try_catch((e, cs) => {
504
     CallStats._reportError.call(cs, wrtcFuncNames.applicationLog, e, null);
504
     CallStats._reportError.call(cs, wrtcFuncNames.applicationLog, e, null);
505
 });
505
 });
506
 
506
 

+ 1
- 1
modules/statistics/LocalStatsCollector.js View File

111
     const self = this;
111
     const self = this;
112
 
112
 
113
     this.intervalId = setInterval(
113
     this.intervalId = setInterval(
114
-        function() {
114
+        () => {
115
             const array = new Uint8Array(analyser.frequencyBinCount);
115
             const array = new Uint8Array(analyser.frequencyBinCount);
116
             analyser.getByteTimeDomainData(array);
116
             analyser.getByteTimeDomainData(array);
117
             const audioLevel = timeDomainDataToAudioLevel(array);
117
             const audioLevel = timeDomainDataToAudioLevel(array);

+ 5
- 5
modules/statistics/RTPStatsCollector.js View File

244
     const self = this;
244
     const self = this;
245
     if(startAudioLevelStats) {
245
     if(startAudioLevelStats) {
246
         this.audioLevelsIntervalId = setInterval(
246
         this.audioLevelsIntervalId = setInterval(
247
-            function() {
247
+            () => {
248
                 // Interval updates
248
                 // Interval updates
249
                 self.peerconnection.getStats(
249
                 self.peerconnection.getStats(
250
-                    function(report) {
250
+                    report => {
251
                         let results = null;
251
                         let results = null;
252
                         if (!report || !report.result
252
                         if (!report || !report.result
253
                             || typeof report.result != 'function') {
253
                             || typeof report.result != 'function') {
269
 
269
 
270
     if (browserSupported) {
270
     if (browserSupported) {
271
         this.statsIntervalId = setInterval(
271
         this.statsIntervalId = setInterval(
272
-            function() {
272
+            () => {
273
                 // Interval updates
273
                 // Interval updates
274
                 self.peerconnection.getStats(
274
                 self.peerconnection.getStats(
275
-                    function(report) {
275
+                    report => {
276
                         let results = null;
276
                         let results = null;
277
                         if (!report || !report.result
277
                         if (!report || !report.result
278
                             || typeof report.result != 'function') {
278
                             || typeof report.result != 'function') {
345
         // Array in which each element is a key-value pair.
345
         // Array in which each element is a key-value pair.
346
         itemStatByKey = function(item, key) {
346
         itemStatByKey = function(item, key) {
347
             let value;
347
             let value;
348
-            item.values.some(function(pair) {
348
+            item.values.some(pair => {
349
                 if (pair.hasOwnProperty(key)) {
349
                 if (pair.hasOwnProperty(key)) {
350
                     value = pair[key];
350
                     value = pair[key];
351
                     return true;
351
                     return true;

+ 10
- 11
modules/statistics/statistics.js View File

302
  */
302
  */
303
 Statistics.sendActiveDeviceListEvent = function(devicesData) {
303
 Statistics.sendActiveDeviceListEvent = function(devicesData) {
304
     if (Statistics.callsStatsInstances.length) {
304
     if (Statistics.callsStatsInstances.length) {
305
-        Statistics.callsStatsInstances.forEach(function(cs) {
305
+        Statistics.callsStatsInstances.forEach(cs => {
306
             CallStats.sendActiveDeviceListEvent(devicesData, cs);
306
             CallStats.sendActiveDeviceListEvent(devicesData, cs);
307
         });
307
         });
308
     } else {
308
     } else {
337
 Statistics.sendGetUserMediaFailed = function(e) {
337
 Statistics.sendGetUserMediaFailed = function(e) {
338
 
338
 
339
     if (Statistics.callsStatsInstances.length) {
339
     if (Statistics.callsStatsInstances.length) {
340
-        Statistics.callsStatsInstances.forEach(function(cs) {
341
-            CallStats.sendGetUserMediaFailed(
342
-                e instanceof JitsiTrackError
343
-                    ? formatJitsiTrackErrorForCallStats(e)
344
-                    : e,
345
-                cs);
346
-        });
340
+        Statistics.callsStatsInstances.forEach(
341
+            cs =>
342
+                CallStats.sendGetUserMediaFailed(
343
+                    e instanceof JitsiTrackError
344
+                        ? formatJitsiTrackErrorForCallStats(e)
345
+                        : e,
346
+                    cs));
347
     } else {
347
     } else {
348
         CallStats.sendGetUserMediaFailed(
348
         CallStats.sendGetUserMediaFailed(
349
             e instanceof JitsiTrackError
349
             e instanceof JitsiTrackError
420
  */
420
  */
421
 Statistics.sendLog = function(m) {
421
 Statistics.sendLog = function(m) {
422
     if (Statistics.callsStatsInstances.length) {
422
     if (Statistics.callsStatsInstances.length) {
423
-        Statistics.callsStatsInstances.forEach(function(cs) {
424
-            CallStats.sendApplicationLog(m, cs);
425
-        });
423
+        Statistics.callsStatsInstances.forEach(
424
+            cs => CallStats.sendApplicationLog(m, cs));
426
     } else {
425
     } else {
427
         CallStats.sendApplicationLog(m, null);
426
         CallStats.sendApplicationLog(m, null);
428
     }
427
     }

+ 11
- 17
modules/transcription/audioRecorder.js View File

65
     // Create a new stream which only holds the audio track
65
     // Create a new stream which only holds the audio track
66
     const originalStream = trackRecorder.track.getOriginalStream();
66
     const originalStream = trackRecorder.track.getOriginalStream();
67
     const stream = createEmptyStream();
67
     const stream = createEmptyStream();
68
-    originalStream.getAudioTracks().forEach(function(track) {
69
-        stream.addTrack(track);
70
-    });
68
+    originalStream.getAudioTracks().forEach(track => stream.addTrack(track));
71
     // Create the MediaRecorder
69
     // Create the MediaRecorder
72
     trackRecorder.recorder = new MediaRecorder(stream,
70
     trackRecorder.recorder = new MediaRecorder(stream,
73
         {mimeType: audioRecorder.fileType});
71
         {mimeType: audioRecorder.fileType});
186
  */
184
  */
187
 audioRecorder.prototype.updateNames = function() {
185
 audioRecorder.prototype.updateNames = function() {
188
     const conference = this.jitsiConference;
186
     const conference = this.jitsiConference;
189
-    this.recorders.forEach(function(trackRecorder) {
187
+    this.recorders.forEach(trackRecorder => {
190
         if(trackRecorder.track.isLocal()) {
188
         if(trackRecorder.track.isLocal()) {
191
             trackRecorder.name = 'the transcriber';
189
             trackRecorder.name = 'the transcriber';
192
         } else {
190
         } else {
211
     // conference, that track can instantly start recording as well
209
     // conference, that track can instantly start recording as well
212
     this.isRecording = true;
210
     this.isRecording = true;
213
     // start all the mediaRecorders
211
     // start all the mediaRecorders
214
-    this.recorders.forEach(function(trackRecorder) {
215
-        startRecorder(trackRecorder);
216
-    });
212
+    this.recorders.forEach(trackRecorder => startRecorder(trackRecorder));
217
     // log that recording has started
213
     // log that recording has started
218
     console.log(
214
     console.log(
219
         `Started the recording of the audio. There are currently ${
215
         `Started the recording of the audio. There are currently ${
236
  */
232
  */
237
 audioRecorder.prototype.download = function() {
233
 audioRecorder.prototype.download = function() {
238
     const t = this;
234
     const t = this;
239
-    this.recorders.forEach(function(trackRecorder) {
235
+    this.recorders.forEach(trackRecorder => {
240
         const blob = new Blob(trackRecorder.data, {type: t.fileType});
236
         const blob = new Blob(trackRecorder.data, {type: t.fileType});
241
         const url = URL.createObjectURL(blob);
237
         const url = URL.createObjectURL(blob);
242
         const a = document.createElement('a');
238
         const a = document.createElement('a');
264
 
260
 
265
     const array = [];
261
     const array = [];
266
     const t = this;
262
     const t = this;
267
-    this.recorders.forEach(function(recorder) {
268
-        array.push(
269
-            new RecordingResult(
270
-            new Blob(recorder.data, {type: t.fileType}),
271
-            recorder.name,
272
-            recorder.startTime)
273
-        );
274
-    });
263
+    this.recorders.forEach(
264
+          recorder =>
265
+              array.push(
266
+                  new RecordingResult(
267
+                      new Blob(recorder.data, {type: t.fileType}),
268
+                      recorder.name,
269
+                      recorder.startTime)));
275
     return array;
270
     return array;
276
 };
271
 };
277
 
272
 
296
         return new webkitMediaStream(); // eslint-disable-line new-cap
291
         return new webkitMediaStream(); // eslint-disable-line new-cap
297
     }
292
     }
298
     throw new Error('cannot create a clean mediaStream');
293
     throw new Error('cannot create a clean mediaStream');
299
-
300
 }
294
 }
301
 
295
 
302
 /**
296
 /**

+ 5
- 7
modules/transcription/transcriber.js View File

79
     const t = this;
79
     const t = this;
80
 
80
 
81
     const callBack = blobCallBack.bind(this);
81
     const callBack = blobCallBack.bind(this);
82
-    this.audioRecorder.getRecordingResults().forEach(function(recordingResult) {
82
+    this.audioRecorder.getRecordingResults().forEach(recordingResult => {
83
         t.transcriptionService.send(recordingResult, callBack);
83
         t.transcriptionService.send(recordingResult, callBack);
84
         t.counter++;
84
         t.counter++;
85
     });
85
     });
114
         }
114
         }
115
 
115
 
116
         let array = '[';
116
         let array = '[';
117
-        answer.wordArray.forEach(function(wordObject) {
117
+        answer.wordArray.forEach(wordObject => {
118
             wordObject.begin += offset;
118
             wordObject.begin += offset;
119
             wordObject.end += offset;
119
             wordObject.end += offset;
120
             array += `${wordObject.word},`;
120
             array += `${wordObject.word},`;
167
     hasPopulatedArrays(arrays);
167
     hasPopulatedArrays(arrays);
168
 
168
 
169
     // populate all the potential Words for a first time
169
     // populate all the potential Words for a first time
170
-    arrays.forEach(function(array) {
171
-        pushWordToSortedArray(potentialWords, array);
172
-    });
170
+    arrays.forEach(array => pushWordToSortedArray(potentialWords, array));
173
 
171
 
174
     // keep adding words to transcription until all arrays are exhausted
172
     // keep adding words to transcription until all arrays are exhausted
175
     let lowestWordArray;
173
     let lowestWordArray;
178
     while(hasPopulatedArrays(arrays)) {
176
     while(hasPopulatedArrays(arrays)) {
179
         // first select the lowest array;
177
         // first select the lowest array;
180
         lowestWordArray = arrays[0];
178
         lowestWordArray = arrays[0];
181
-        arrays.forEach(function(wordArray) {
179
+        arrays.forEach(wordArray => {
182
             if(wordArray[0].begin < lowestWordArray[0].begin) {
180
             if(wordArray[0].begin < lowestWordArray[0].begin) {
183
                 lowestWordArray = wordArray;
181
                 lowestWordArray = wordArray;
184
             }
182
             }
190
         // keep going until a word in another array has a smaller time
188
         // keep going until a word in another array has a smaller time
191
         // or the array is empty
189
         // or the array is empty
192
         while(!foundSmaller && lowestWordArray.length > 0) {
190
         while(!foundSmaller && lowestWordArray.length > 0) {
193
-            arrays.forEach(function(wordArray) {
191
+            arrays.forEach(wordArray => {
194
                 if(wordArray[0].begin < lowestWordArray[0].begin) {
192
                 if(wordArray[0].begin < lowestWordArray[0].begin) {
195
                     foundSmaller = true;
193
                     foundSmaller = true;
196
                 }
194
                 }

+ 1
- 1
modules/transcription/transcriptionServices/AbstractTranscriptionService.js View File

18
  */
18
  */
19
 TranscriptionService.prototype.send = function send(recordingResult, callback) {
19
 TranscriptionService.prototype.send = function send(recordingResult, callback) {
20
     const t = this;
20
     const t = this;
21
-    this.sendRequest(recordingResult.blob, function(response) {
21
+    this.sendRequest(recordingResult.blob, response => {
22
         if(!t.verify(response)) {
22
         if(!t.verify(response)) {
23
             console.log('the retrieved response from the server'
23
             console.log('the retrieved response from the server'
24
                    + ' is not valid!');
24
                    + ' is not valid!');

+ 2
- 7
modules/util/GlobalOnErrorHandler.js View File

19
  * all handlers that were previously added.
19
  * all handlers that were previously added.
20
  */
20
  */
21
 function JitsiGlobalErrorHandler(message, source, lineno, colno, error) {
21
 function JitsiGlobalErrorHandler(message, source, lineno, colno, error) {
22
-    handlers.forEach(function(handler) {
23
-        handler(message, source, lineno, colno, error);
24
-    });
22
+    handlers.forEach(handler => handler(message, source, lineno, colno, error));
25
     if (oldOnErrorHandler) {
23
     if (oldOnErrorHandler) {
26
         oldOnErrorHandler(message, source, lineno, colno, error);
24
         oldOnErrorHandler(message, source, lineno, colno, error);
27
     }
25
     }
35
  * that were previously added. This handler handles rejected Promises.
33
  * that were previously added. This handler handles rejected Promises.
36
  */
34
  */
37
 function JitsiGlobalUnhandledRejection(event) {
35
 function JitsiGlobalUnhandledRejection(event) {
38
-    handlers.forEach(function(handler) {
39
-        handler(null, null, null, null, event.reason);
40
-    });
36
+    handlers.forEach(handler => handler(null, null, null, null, event.reason));
41
     if(oldOnUnhandledRejection) {
37
     if(oldOnUnhandledRejection) {
42
         oldOnUnhandledRejection(event);
38
         oldOnUnhandledRejection(event);
43
     }
39
     }
47
 window.onerror = JitsiGlobalErrorHandler;
43
 window.onerror = JitsiGlobalErrorHandler;
48
 window.onunhandledrejection = JitsiGlobalUnhandledRejection;
44
 window.onunhandledrejection = JitsiGlobalUnhandledRejection;
49
 
45
 
50
-
51
 const GlobalOnErrorHandler = {
46
 const GlobalOnErrorHandler = {
52
     /**
47
     /**
53
      * Adds new error handlers.
48
      * Adds new error handlers.

+ 2
- 2
modules/version/ComponentsVersions.js View File

49
         }
49
         }
50
 
50
 
51
         const log = [];
51
         const log = [];
52
-        node.children.forEach(function(item) {
52
+        node.children.forEach(item => {
53
 
53
 
54
             const componentName = item.attributes.name;
54
             const componentName = item.attributes.name;
55
             if (componentName !== ComponentsVersions.FOCUS_COMPONENT
55
             if (componentName !== ComponentsVersions.FOCUS_COMPONENT
72
                     version
72
                     version
73
                 });
73
                 });
74
             }
74
             }
75
-        }.bind(this));
75
+        });
76
 
76
 
77
         // logs versions to stats
77
         // logs versions to stats
78
         if (log.length > 0) {
78
         if (log.length > 0) {

+ 28
- 39
modules/xmpp/ChatRoom.js View File

18
                 tagName
18
                 tagName
19
             };
19
             };
20
             node.attributes = {};
20
             node.attributes = {};
21
-            $($(this)[0].attributes).each(function(index, attr) {
21
+            $($(this)[0].attributes).each((index, attr) => {
22
                 node.attributes[ attr.name ] = attr.value;
22
                 node.attributes[ attr.name ] = attr.value;
23
             });
23
             });
24
             const text = Strophe.getText($(this)[0]);
24
             const text = Strophe.getText($(this)[0]);
50
 };
50
 };
51
 
51
 
52
 /**
52
 /**
53
- * Returns array of JS objects from the presence JSON associated with the passed nodeName
53
+ * Returns array of JS objects from the presence JSON associated with the passed
54
+ / nodeName
54
  * @param pres the presence JSON
55
  * @param pres the presence JSON
55
  * @param nodeName the name of the node (videomuted, audiomuted, etc)
56
  * @param nodeName the name of the node (videomuted, audiomuted, etc)
56
  */
57
  */
126
 
127
 
127
     join(password) {
128
     join(password) {
128
         this.password = password;
129
         this.password = password;
129
-        const self = this;
130
-        this.moderator.allocateConferenceFocus(function() {
131
-            self.sendPresence(true);
132
-        });
130
+        this.moderator.allocateConferenceFocus(() => this.sendPresence(true));
133
     }
131
     }
134
 
132
 
135
     sendPresence(fromJoin) {
133
     sendPresence(fromJoin) {
197
         const getInfo = $iq({type: 'get', to: this.roomjid})
195
         const getInfo = $iq({type: 'get', to: this.roomjid})
198
         .c('query', {xmlns: Strophe.NS.DISCO_INFO});
196
         .c('query', {xmlns: Strophe.NS.DISCO_INFO});
199
 
197
 
200
-        this.connection.sendIQ(getInfo, function(result) {
201
-            const locked = $(result).find('>query>feature[var="muc_passwordprotected"]')
202
-            .length === 1;
198
+        this.connection.sendIQ(getInfo, result => {
199
+            const locked
200
+                = $(result).find('>query>feature[var="muc_passwordprotected"]')
201
+                        .length
202
+                    === 1;
203
             if (locked != this.locked) {
203
             if (locked != this.locked) {
204
                 this.eventEmitter.emit(XMPPEvents.MUC_LOCK_CHANGED, locked);
204
                 this.eventEmitter.emit(XMPPEvents.MUC_LOCK_CHANGED, locked);
205
                 this.locked = locked;
205
                 this.locked = locked;
206
             }
206
             }
207
-        }.bind(this), function(error) {
207
+        }, error => {
208
             GlobalOnErrorHandler.callErrorHandler(error);
208
             GlobalOnErrorHandler.callErrorHandler(error);
209
             logger.error('Error getting room info: ', error);
209
             logger.error('Error getting room info: ', error);
210
         });
210
         });
220
 
220
 
221
         const self = this;
221
         const self = this;
222
 
222
 
223
-        this.connection.sendIQ(getForm, function(form) {
224
-
223
+        this.connection.sendIQ(getForm, form => {
225
             if (!$(form).find(
224
             if (!$(form).find(
226
                     '>query>x[xmlns="jabber:x:data"]'
225
                     '>query>x[xmlns="jabber:x:data"]'
227
                     + '>field[var="muc#roomconfig_whois"]').length) {
226
                     + '>field[var="muc#roomconfig_whois"]').length) {
245
 
244
 
246
             self.connection.sendIQ(formSubmit);
245
             self.connection.sendIQ(formSubmit);
247
 
246
 
248
-        }, function(error) {
247
+        }, error => {
249
             GlobalOnErrorHandler.callErrorHandler(error);
248
             GlobalOnErrorHandler.callErrorHandler(error);
250
             logger.error('Error getting room configuration form: ', error);
249
             logger.error('Error getting room configuration form: ', error);
251
         });
250
         });
277
         parser.packet2JSON(pres, nodes);
276
         parser.packet2JSON(pres, nodes);
278
         this.lastPresences[from] = nodes;
277
         this.lastPresences[from] = nodes;
279
         let jibri = null;
278
         let jibri = null;
280
-        // process nodes to extract data needed for MUC_JOINED and MUC_MEMBER_JOINED
281
-        // events
279
+        // process nodes to extract data needed for MUC_JOINED and
280
+        // MUC_MEMBER_JOINED events
282
         for(let i = 0; i < nodes.length; i++) {
281
         for(let i = 0; i < nodes.length; i++) {
283
             const node = nodes[i];
282
             const node = nodes[i];
284
             switch(node.tagName) {
283
             switch(node.tagName) {
623
 
622
 
624
         this.connection.sendIQ(
623
         this.connection.sendIQ(
625
             kickIQ,
624
             kickIQ,
626
-            function(result) {
627
-                logger.log('Kick participant with jid: ', jid, result);
628
-            },
629
-            function(error) {
630
-                logger.log('Kick participant error: ', error);
631
-            });
625
+            result => logger.log('Kick participant with jid: ', jid, result),
626
+            error => logger.log('Kick participant error: ', error));
632
     }
627
     }
633
 
628
 
634
     lockRoom(key, onSuccess, onError, onNotSupported) {
629
     lockRoom(key, onSuccess, onError, onNotSupported) {
635
         // http://xmpp.org/extensions/xep-0045.html#roomconfig
630
         // http://xmpp.org/extensions/xep-0045.html#roomconfig
636
-        const ob = this;
637
-        this.connection.sendIQ($iq({to: this.roomjid, type: 'get'}).c('query', {xmlns: 'http://jabber.org/protocol/muc#owner'}),
638
-            function(res) {
631
+        this.connection.sendIQ(
632
+            $iq({to: this.roomjid, type: 'get'}).c('query', {xmlns: 'http://jabber.org/protocol/muc#owner'}),
633
+            res => {
639
                 if ($(res).find('>query>x[xmlns="jabber:x:data"]>field[var="muc#roomconfig_roomsecret"]').length) {
634
                 if ($(res).find('>query>x[xmlns="jabber:x:data"]>field[var="muc#roomconfig_roomsecret"]').length) {
640
-                    const formsubmit = $iq({to: ob.roomjid, type: 'set'}).c('query', {xmlns: 'http://jabber.org/protocol/muc#owner'});
635
+                    const formsubmit
636
+                        = $iq({to: this.roomjid, type: 'set'})
637
+                            .c('query', {xmlns: 'http://jabber.org/protocol/muc#owner'});
641
                     formsubmit.c('x', {xmlns: 'jabber:x:data', type: 'submit'});
638
                     formsubmit.c('x', {xmlns: 'jabber:x:data', type: 'submit'});
642
                     formsubmit.c('field', {'var': 'FORM_TYPE'}).c('value').t('http://jabber.org/protocol/muc#roomconfig').up().up();
639
                     formsubmit.c('field', {'var': 'FORM_TYPE'}).c('value').t('http://jabber.org/protocol/muc#roomconfig').up().up();
643
                     formsubmit.c('field', {'var': 'muc#roomconfig_roomsecret'}).c('value').t(key).up().up();
640
                     formsubmit.c('field', {'var': 'muc#roomconfig_roomsecret'}).c('value').t(key).up().up();
644
                     // Fixes a bug in prosody 0.9.+ https://code.google.com/p/lxmppd/issues/detail?id=373
641
                     // Fixes a bug in prosody 0.9.+ https://code.google.com/p/lxmppd/issues/detail?id=373
645
                     formsubmit.c('field', {'var': 'muc#roomconfig_whois'}).c('value').t('anyone').up().up();
642
                     formsubmit.c('field', {'var': 'muc#roomconfig_whois'}).c('value').t('anyone').up().up();
646
                     // FIXME: is muc#roomconfig_passwordprotectedroom required?
643
                     // FIXME: is muc#roomconfig_passwordprotectedroom required?
647
-                    ob.connection.sendIQ(formsubmit,
648
-                        onSuccess,
649
-                        onError);
644
+                    this.connection.sendIQ(formsubmit, onSuccess, onError);
650
                 } else {
645
                 } else {
651
                     onNotSupported();
646
                     onNotSupported();
652
                 }
647
                 }
653
-            }, onError);
648
+            },
649
+            onError);
654
     }
650
     }
655
 
651
 
656
     addToPresence(key, values) {
652
     addToPresence(key, values) {
660
     }
656
     }
661
 
657
 
662
     removeFromPresence(key) {
658
     removeFromPresence(key) {
663
-        const nodes = this.presMap.nodes.filter(function(node) {
664
-            return key !== node.tagName;
665
-        });
659
+        const nodes = this.presMap.nodes.filter(node => key !== node.tagName);
666
         this.presMap.nodes = nodes;
660
         this.presMap.nodes = nodes;
667
     }
661
     }
668
 
662
 
688
             return member.isFocus;
682
             return member.isFocus;
689
         }
683
         }
690
         return null;
684
         return null;
691
-
692
     }
685
     }
693
 
686
 
694
     isModerator() {
687
     isModerator() {
888
 
881
 
889
         this.connection.sendIQ(
882
         this.connection.sendIQ(
890
             iqToFocus,
883
             iqToFocus,
891
-            function(result) {
892
-                logger.log('set mute', result);
893
-            },
894
-            function(error) {
895
-                logger.log('set mute error', error);
896
-            });
884
+            result => logger.log('set mute', result),
885
+            error => logger.log('set mute error', error));
897
     }
886
     }
898
 
887
 
899
     onMute(iq) {
888
     onMute(iq) {

+ 25
- 27
modules/xmpp/JingleSessionPC.js View File

267
 
267
 
268
         const localSDP = new SDP(this.peerconnection.localDescription.sdp);
268
         const localSDP = new SDP(this.peerconnection.localDescription.sdp);
269
         for (let mid = 0; mid < localSDP.media.length; mid++) {
269
         for (let mid = 0; mid < localSDP.media.length; mid++) {
270
-            const cands = candidates.filter(function(el) {
271
-                return el.sdpMLineIndex == mid;
272
-            });
270
+            const cands = candidates.filter(el => el.sdpMLineIndex == mid);
273
             const mline
271
             const mline
274
                 = SDPUtil.parse_mline(localSDP.media[mid].split('\r\n')[0]);
272
                 = SDPUtil.parse_mline(localSDP.media[mid].split('\r\n')[0]);
275
             if (cands.length > 0) {
273
             if (cands.length > 0) {
315
         // a lot later. See webrtc issue #2340
313
         // a lot later. See webrtc issue #2340
316
         // logger.log('was this the last candidate', this.lasticecandidate);
314
         // logger.log('was this the last candidate', this.lasticecandidate);
317
         this.connection.sendIQ(
315
         this.connection.sendIQ(
318
-            cand, null, this.newJingleErrorHandler(cand, function(error) {
316
+            cand, null, this.newJingleErrorHandler(cand, error => {
319
                 GlobalOnErrorHandler.callErrorHandler(
317
                 GlobalOnErrorHandler.callErrorHandler(
320
                     new Error(`Jingle error: ${JSON.stringify(error)}`));
318
                     new Error(`Jingle error: ${JSON.stringify(error)}`));
321
             }), IQ_TIMEOUT);
319
             }), IQ_TIMEOUT);
640
      */
638
      */
641
     _parseSsrcInfoFromSourceAdd(sourceAddElem, currentRemoteSdp) {
639
     _parseSsrcInfoFromSourceAdd(sourceAddElem, currentRemoteSdp) {
642
         const addSsrcInfo = [];
640
         const addSsrcInfo = [];
643
-        $(sourceAddElem).each(function(idx, content) {
641
+        $(sourceAddElem).each((idx, content) => {
644
             const name = $(content).attr('name');
642
             const name = $(content).attr('name');
645
             let lines = '';
643
             let lines = '';
646
             $(content)
644
             $(content)
676
                     lines += '\r\n';
674
                     lines += '\r\n';
677
                 });
675
                 });
678
             });
676
             });
679
-            currentRemoteSdp.media.forEach(function(media, idx) {
677
+            currentRemoteSdp.media.forEach((media, idx) => {
680
                 if (!SDPUtil.find_line(media, `a=mid:${name}`)) {
678
                 if (!SDPUtil.find_line(media, `a=mid:${name}`)) {
681
                     return;
679
                     return;
682
                 }
680
                 }
818
      */
816
      */
819
     _processRemoteRemoveSource(removeSsrcInfo) {
817
     _processRemoteRemoveSource(removeSsrcInfo) {
820
         const remoteSdp = new SDP(this.peerconnection.remoteDescription.sdp);
818
         const remoteSdp = new SDP(this.peerconnection.remoteDescription.sdp);
821
-        removeSsrcInfo.forEach(function(lines, idx) {
819
+        removeSsrcInfo.forEach((lines, idx) => {
822
             lines = lines.split('\r\n');
820
             lines = lines.split('\r\n');
823
             lines.pop(); // remove empty last element;
821
             lines.pop(); // remove empty last element;
824
-            lines.forEach(function(line) {
822
+            lines.forEach(line => {
825
                 remoteSdp.media[idx]
823
                 remoteSdp.media[idx]
826
                     = remoteSdp.media[idx].replace(`${line}\r\n`, '');
824
                     = remoteSdp.media[idx].replace(`${line}\r\n`, '');
827
             });
825
             });
840
      */
838
      */
841
     _processRemoteAddSource(addSsrcInfo) {
839
     _processRemoteAddSource(addSsrcInfo) {
842
         const remoteSdp = new SDP(this.peerconnection.remoteDescription.sdp);
840
         const remoteSdp = new SDP(this.peerconnection.remoteDescription.sdp);
843
-        addSsrcInfo.forEach(function(lines, idx) {
841
+        addSsrcInfo.forEach((lines, idx) => {
844
             remoteSdp.media[idx] += lines;
842
             remoteSdp.media[idx] += lines;
845
         });
843
         });
846
         remoteSdp.raw = remoteSdp.session + remoteSdp.media.join('');
844
         remoteSdp.raw = remoteSdp.session + remoteSdp.media.join('');
1015
      */
1013
      */
1016
     _parseSsrcInfoFromSourceRemove(sourceRemoveElem, currentRemoteSdp) {
1014
     _parseSsrcInfoFromSourceRemove(sourceRemoveElem, currentRemoteSdp) {
1017
         const removeSsrcInfo = [];
1015
         const removeSsrcInfo = [];
1018
-        $(sourceRemoveElem).each(function(idx, content) {
1016
+        $(sourceRemoveElem).each((idx, content) => {
1019
             const name = $(content).attr('name');
1017
             const name = $(content).attr('name');
1020
             let lines = '';
1018
             let lines = '';
1021
             $(content)
1019
             $(content)
1041
                 const ssrc = $(this).attr('ssrc');
1039
                 const ssrc = $(this).attr('ssrc');
1042
                 ssrcs.push(ssrc);
1040
                 ssrcs.push(ssrc);
1043
             });
1041
             });
1044
-            currentRemoteSdp.media.forEach(function(media, idx) {
1042
+            currentRemoteSdp.media.forEach((media, idx) => {
1045
                 if (!SDPUtil.find_line(media, `a=mid:${name}`)) {
1043
                 if (!SDPUtil.find_line(media, `a=mid:${name}`)) {
1046
                     return;
1044
                     return;
1047
                 }
1045
                 }
1048
                 if (!removeSsrcInfo[idx]) {
1046
                 if (!removeSsrcInfo[idx]) {
1049
                     removeSsrcInfo[idx] = '';
1047
                     removeSsrcInfo[idx] = '';
1050
                 }
1048
                 }
1051
-                ssrcs.forEach(function(ssrc) {
1049
+                ssrcs.forEach(ssrc => {
1052
                     const ssrcLines
1050
                     const ssrcLines
1053
                         = SDPUtil.find_lines(media, `a=ssrc:${ssrc}`);
1051
                         = SDPUtil.find_lines(media, `a=ssrc:${ssrc}`);
1054
                     if (ssrcLines.length) {
1052
                     if (ssrcLines.length) {
1160
         }
1158
         }
1161
 
1159
 
1162
         // Find the right sender (for audio or video)
1160
         // Find the right sender (for audio or video)
1163
-        this.peerconnection.peerconnection.getSenders().some(function(s) {
1161
+        this.peerconnection.peerconnection.getSenders().some(s => {
1164
             if (s.track === track) {
1162
             if (s.track === track) {
1165
                 sender = s;
1163
                 sender = s;
1166
                 return true;
1164
                 return true;
1274
             logger.info('Sending source-remove', remove.tree());
1272
             logger.info('Sending source-remove', remove.tree());
1275
             this.connection.sendIQ(
1273
             this.connection.sendIQ(
1276
                 remove, null,
1274
                 remove, null,
1277
-                this.newJingleErrorHandler(remove, function(error) {
1275
+                this.newJingleErrorHandler(remove, error => {
1278
                     GlobalOnErrorHandler.callErrorHandler(
1276
                     GlobalOnErrorHandler.callErrorHandler(
1279
                         new Error(`Jingle error: ${JSON.stringify(error)}`));
1277
                         new Error(`Jingle error: ${JSON.stringify(error)}`));
1280
                 }), IQ_TIMEOUT);
1278
                 }), IQ_TIMEOUT);
1299
         if (added && add) {
1297
         if (added && add) {
1300
             logger.info('Sending source-add', add.tree());
1298
             logger.info('Sending source-add', add.tree());
1301
             this.connection.sendIQ(
1299
             this.connection.sendIQ(
1302
-                add, null, this.newJingleErrorHandler(add, function(error) {
1300
+                add, null, this.newJingleErrorHandler(add, error => {
1303
                     GlobalOnErrorHandler.callErrorHandler(
1301
                     GlobalOnErrorHandler.callErrorHandler(
1304
                         new Error(`Jingle error: ${JSON.stringify(error)}`));
1302
                         new Error(`Jingle error: ${JSON.stringify(error)}`));
1305
                 }), IQ_TIMEOUT);
1303
                 }), IQ_TIMEOUT);
1447
         let ssrcs = this.modifiedSSRCs.unmute;
1445
         let ssrcs = this.modifiedSSRCs.unmute;
1448
         this.modifiedSSRCs.unmute = [];
1446
         this.modifiedSSRCs.unmute = [];
1449
         if (ssrcs && ssrcs.length) {
1447
         if (ssrcs && ssrcs.length) {
1450
-            ssrcs.forEach(function(ssrcObj) {
1448
+            ssrcs.forEach(ssrcObj => {
1451
                 const desc
1449
                 const desc
1452
                     = $(jingle.tree()).find(
1450
                     = $(jingle.tree()).find(
1453
                         `>jingle>content[name="${ssrcObj.mtype}"]>description`);
1451
                         `>jingle>content[name="${ssrcObj.mtype}"]>description`);
1454
                 if (!desc || !desc.length) {
1452
                 if (!desc || !desc.length) {
1455
                     return;
1453
                     return;
1456
                 }
1454
                 }
1457
-                ssrcObj.ssrcs.forEach(function(ssrc) {
1455
+                ssrcObj.ssrcs.forEach(ssrc => {
1458
                     const sourceNode = desc.find(`>source[ssrc="${ssrc}"]`);
1456
                     const sourceNode = desc.find(`>source[ssrc="${ssrc}"]`);
1459
                     sourceNode.remove();
1457
                     sourceNode.remove();
1460
                 });
1458
                 });
1461
-                ssrcObj.groups.forEach(function(group) {
1459
+                ssrcObj.groups.forEach(group => {
1462
                     const groupNode = desc.find(`>ssrc-group[semantics="${
1460
                     const groupNode = desc.find(`>ssrc-group[semantics="${
1463
                          group.semantics}"]:has(source[ssrc="${
1461
                          group.semantics}"]:has(source[ssrc="${
1464
                          group.ssrcs[0]}"])`);
1462
                          group.ssrcs[0]}"])`);
1470
         ssrcs = this.modifiedSSRCs.addMuted;
1468
         ssrcs = this.modifiedSSRCs.addMuted;
1471
         this.modifiedSSRCs.addMuted = [];
1469
         this.modifiedSSRCs.addMuted = [];
1472
         if (ssrcs && ssrcs.length) {
1470
         if (ssrcs && ssrcs.length) {
1473
-            ssrcs.forEach(function(ssrcObj) {
1471
+            ssrcs.forEach(ssrcObj => {
1474
                 const desc
1472
                 const desc
1475
                     = JingleSessionPC.createDescriptionNode(
1473
                     = JingleSessionPC.createDescriptionNode(
1476
                         jingle, ssrcObj.mtype);
1474
                         jingle, ssrcObj.mtype);
1477
                 const cname = Math.random().toString(36).substring(2);
1475
                 const cname = Math.random().toString(36).substring(2);
1478
-                ssrcObj.ssrcs.forEach(function(ssrc) {
1476
+                ssrcObj.ssrcs.forEach(ssrc => {
1479
                     const sourceNode
1477
                     const sourceNode
1480
                         = desc.find(`>source[ssrc="${ssrc}"]`);
1478
                         = desc.find(`>source[ssrc="${ssrc}"]`);
1481
                     sourceNode.remove();
1479
                     sourceNode.remove();
1489
                         + '</source>';
1487
                         + '</source>';
1490
                     desc.append(sourceXML);
1488
                     desc.append(sourceXML);
1491
                 });
1489
                 });
1492
-                ssrcObj.groups.forEach(function(group) {
1490
+                ssrcObj.groups.forEach(group => {
1493
                     const groupNode
1491
                     const groupNode
1494
                         = desc.find(
1492
                         = desc.find(
1495
                             `>ssrc-group[semantics="${group.semantics
1493
                             `>ssrc-group[semantics="${group.semantics
1515
         let ssrcs = this.modifiedSSRCs.mute;
1513
         let ssrcs = this.modifiedSSRCs.mute;
1516
         this.modifiedSSRCs.mute = [];
1514
         this.modifiedSSRCs.mute = [];
1517
         if (ssrcs && ssrcs.length) {
1515
         if (ssrcs && ssrcs.length) {
1518
-            ssrcs.forEach(function(ssrcObj) {
1519
-                ssrcObj.ssrcs.forEach(function(ssrc) {
1516
+            ssrcs.forEach(ssrcObj => {
1517
+                ssrcObj.ssrcs.forEach(ssrc => {
1520
                     const sourceNode
1518
                     const sourceNode
1521
                         = $(jingle.tree()).find(
1519
                         = $(jingle.tree()).find(
1522
                             `>jingle>content[name="${ssrcObj.mtype
1520
                             `>jingle>content[name="${ssrcObj.mtype
1523
                                 }"]>description>source[ssrc="${ssrc}"]`);
1521
                                 }"]>description>source[ssrc="${ssrc}"]`);
1524
                     sourceNode.remove();
1522
                     sourceNode.remove();
1525
                 });
1523
                 });
1526
-                ssrcObj.groups.forEach(function(group) {
1524
+                ssrcObj.groups.forEach(group => {
1527
                     const groupNode
1525
                     const groupNode
1528
                         = $(jingle.tree()).find(
1526
                         = $(jingle.tree()).find(
1529
                             `>jingle>content[name="${ssrcObj.mtype
1527
                             `>jingle>content[name="${ssrcObj.mtype
1538
         ssrcs = this.modifiedSSRCs.remove;
1536
         ssrcs = this.modifiedSSRCs.remove;
1539
         this.modifiedSSRCs.remove = [];
1537
         this.modifiedSSRCs.remove = [];
1540
         if (ssrcs && ssrcs.length) {
1538
         if (ssrcs && ssrcs.length) {
1541
-            ssrcs.forEach(function(ssrcObj) {
1539
+            ssrcs.forEach(ssrcObj => {
1542
                 const desc
1540
                 const desc
1543
                     = JingleSessionPC.createDescriptionNode(
1541
                     = JingleSessionPC.createDescriptionNode(
1544
                         jingle, ssrcObj.mtype);
1542
                         jingle, ssrcObj.mtype);
1545
-                ssrcObj.ssrcs.forEach(function(ssrc) {
1543
+                ssrcObj.ssrcs.forEach(ssrc => {
1546
                     const sourceNode
1544
                     const sourceNode
1547
                         = desc.find(`>source[ssrc="${ssrc}"]`);
1545
                         = desc.find(`>source[ssrc="${ssrc}"]`);
1548
                     if (!sourceNode || !sourceNode.length) {
1546
                     if (!sourceNode || !sourceNode.length) {
1552
                                 + `ssrc="${ssrc}"></source>`);
1550
                                 + `ssrc="${ssrc}"></source>`);
1553
                     }
1551
                     }
1554
                 });
1552
                 });
1555
-                ssrcObj.groups.forEach(function(group) {
1553
+                ssrcObj.groups.forEach(group => {
1556
                     const groupNode
1554
                     const groupNode
1557
                         = desc.find(`>ssrc-group[semantics="${
1555
                         = desc.find(`>ssrc-group[semantics="${
1558
                              group.semantics}"]:has(source[ssrc="${
1556
                              group.semantics}"]:has(source[ssrc="${

+ 7
- 7
modules/xmpp/RtxModifier.spec.js View File

66
     .filter(g => g.semantics === groupSemantics);
66
     .filter(g => g.semantics === groupSemantics);
67
 }
67
 }
68
 
68
 
69
-describe('RtxModifier', function() {
69
+describe('RtxModifier', () => {
70
     beforeEach(function() {
70
     beforeEach(function() {
71
         this.rtxModifier = new RtxModifier();
71
         this.rtxModifier = new RtxModifier();
72
         this.transform = transform;
72
         this.transform = transform;
73
         this.SDPUtil = SDPUtil;
73
         this.SDPUtil = SDPUtil;
74
     });
74
     });
75
 
75
 
76
-    describe('modifyRtxSsrcs', function() {
77
-        describe('when given an sdp with a single video ssrc', function() {
76
+    describe('modifyRtxSsrcs', () => {
77
+        describe('when given an sdp with a single video ssrc', () => {
78
             beforeEach(function() {
78
             beforeEach(function() {
79
                 this.singleVideoSdp = SampleSdpStrings.plainVideoSdp;
79
                 this.singleVideoSdp = SampleSdpStrings.plainVideoSdp;
80
                 this.primaryVideoSsrc = getPrimaryVideoSsrc(this.singleVideoSdp);
80
                 this.primaryVideoSsrc = getPrimaryVideoSsrc(this.singleVideoSdp);
152
             });
152
             });
153
         });
153
         });
154
 
154
 
155
-        describe('when given an sdp with multiple video ssrcs', function() {
155
+        describe('when given an sdp with multiple video ssrcs', () => {
156
             beforeEach(function() {
156
             beforeEach(function() {
157
                 this.multipleVideoSdp = SampleSdpStrings.simulcastSdp;
157
                 this.multipleVideoSdp = SampleSdpStrings.simulcastSdp;
158
                 this.primaryVideoSsrcs = getPrimaryVideoSsrcs(this.multipleVideoSdp);
158
                 this.primaryVideoSsrcs = getPrimaryVideoSsrcs(this.multipleVideoSdp);
261
             });
261
             });
262
         });
262
         });
263
 
263
 
264
-        describe('(corner cases)', function() {
264
+        describe('(corner cases)', () => {
265
             it('should handle a recvonly video mline', function() {
265
             it('should handle a recvonly video mline', function() {
266
                 const sdp = SampleSdpStrings.plainVideoSdp;
266
                 const sdp = SampleSdpStrings.plainVideoSdp;
267
                 const videoMLine = sdp.media.find(m => m.type === 'video');
267
                 const videoMLine = sdp.media.find(m => m.type === 'video');
288
         });
288
         });
289
     });
289
     });
290
 
290
 
291
-    describe('stripRtx', function() {
292
-        beforeEach(function() { }); // eslint-disable-line no-empty-function
291
+    describe('stripRtx', () => {
292
+        beforeEach(() => { }); // eslint-disable-line no-empty-function
293
         it('should strip all rtx streams from an sdp with rtx', function() {
293
         it('should strip all rtx streams from an sdp with rtx', function() {
294
             const sdpStr = transform.write(SampleSdpStrings.rtxVideoSdp);
294
             const sdpStr = transform.write(SampleSdpStrings.rtxVideoSdp);
295
             const newSdpStr = this.rtxModifier.stripRtx(sdpStr);
295
             const newSdpStr = this.rtxModifier.stripRtx(sdpStr);

+ 17
- 23
modules/xmpp/SDP.js View File

56
             ssrcGroups: []
56
             ssrcGroups: []
57
         };
57
         };
58
         media_ssrcs[mediaindex] = media;
58
         media_ssrcs[mediaindex] = media;
59
-        tmp.forEach(function(line) {
59
+        tmp.forEach(line => {
60
             const linessrc = line.substring(7).split(' ')[0];
60
             const linessrc = line.substring(7).split(' ')[0];
61
             // allocate new ChannelSsrc
61
             // allocate new ChannelSsrc
62
             if(!media.ssrcs[linessrc]) {
62
             if(!media.ssrcs[linessrc]) {
68
             media.ssrcs[linessrc].lines.push(line);
68
             media.ssrcs[linessrc].lines.push(line);
69
         });
69
         });
70
         tmp = SDPUtil.find_lines(self.media[mediaindex], 'a=ssrc-group:');
70
         tmp = SDPUtil.find_lines(self.media[mediaindex], 'a=ssrc-group:');
71
-        tmp.forEach(function(line) {
71
+        tmp.forEach(line => {
72
             const idx = line.indexOf(' ');
72
             const idx = line.indexOf(' ');
73
             const semantics = line.substr(0, idx).substr(13);
73
             const semantics = line.substr(0, idx).substr(13);
74
             const ssrcs = line.substr(14 + semantics.length).split(' ');
74
             const ssrcs = line.substr(14 + semantics.length).split(' ');
91
     // FIXME this code is really strange - improve it if you can
91
     // FIXME this code is really strange - improve it if you can
92
     const medias = this.getMediaSsrcMap();
92
     const medias = this.getMediaSsrcMap();
93
     let result = false;
93
     let result = false;
94
-    Object.keys(medias).forEach(function(mediaindex) {
94
+    Object.keys(medias).forEach(mediaindex => {
95
         if (result) {
95
         if (result) {
96
             return;
96
             return;
97
         }
97
         }
133
 SDP.prototype.removeSessionLines = function(prefix) {
133
 SDP.prototype.removeSessionLines = function(prefix) {
134
     const self = this;
134
     const self = this;
135
     const lines = SDPUtil.find_lines(this.session, prefix);
135
     const lines = SDPUtil.find_lines(this.session, prefix);
136
-    lines.forEach(function(line) {
136
+    lines.forEach(line => {
137
         self.session = self.session.replace(`${line}\r\n`, '');
137
         self.session = self.session.replace(`${line}\r\n`, '');
138
     });
138
     });
139
     this.raw = this.session + this.media.join('');
139
     this.raw = this.session + this.media.join('');
144
 SDP.prototype.removeMediaLines = function(mediaindex, prefix) {
144
 SDP.prototype.removeMediaLines = function(mediaindex, prefix) {
145
     const self = this;
145
     const self = this;
146
     const lines = SDPUtil.find_lines(this.media[mediaindex], prefix);
146
     const lines = SDPUtil.find_lines(this.media[mediaindex], prefix);
147
-    lines.forEach(function(line) {
148
-        self.media[mediaindex] = self.media[mediaindex].replace(`${line}\r\n`, '');
147
+    lines.forEach(line => {
148
+        self.media[mediaindex]
149
+            = self.media[mediaindex].replace(`${line}\r\n`, '');
149
     });
150
     });
150
     this.raw = this.session + this.media.join('');
151
     this.raw = this.session + this.media.join('');
151
     return lines;
152
     return lines;
214
             const crypto = SDPUtil.find_lines(this.media[i], 'a=crypto:', this.session);
215
             const crypto = SDPUtil.find_lines(this.media[i], 'a=crypto:', this.session);
215
             if (crypto.length) {
216
             if (crypto.length) {
216
                 elem.c('encryption', {required: 1});
217
                 elem.c('encryption', {required: 1});
217
-                crypto.forEach(function(line) {
218
-                    elem.c('crypto', SDPUtil.parse_crypto(line)).up();
219
-                });
218
+                crypto.forEach(
219
+                    line => elem.c('crypto', SDPUtil.parse_crypto(line)).up());
220
                 elem.up(); // end of encryption
220
                 elem.up(); // end of encryption
221
             }
221
             }
222
 
222
 
226
                 // FIXME: group by ssrc and support multiple different ssrcs
226
                 // FIXME: group by ssrc and support multiple different ssrcs
227
                 const ssrclines = SDPUtil.find_lines(this.media[i], 'a=ssrc:');
227
                 const ssrclines = SDPUtil.find_lines(this.media[i], 'a=ssrc:');
228
                 if(ssrclines.length > 0) {
228
                 if(ssrclines.length > 0) {
229
-                    ssrclines.forEach(function(line) {
229
+                    ssrclines.forEach(line => {
230
                         const idx = line.indexOf(' ');
230
                         const idx = line.indexOf(' ');
231
                         const linessrc = line.substr(0, idx).substr(7);
231
                         const linessrc = line.substr(0, idx).substr(7);
232
                         if (linessrc != ssrc) {
232
                         if (linessrc != ssrc) {
280
 
280
 
281
                 // XEP-0339 handle ssrc-group attributes
281
                 // XEP-0339 handle ssrc-group attributes
282
                 const ssrc_group_lines = SDPUtil.find_lines(this.media[i], 'a=ssrc-group:');
282
                 const ssrc_group_lines = SDPUtil.find_lines(this.media[i], 'a=ssrc-group:');
283
-                ssrc_group_lines.forEach(function(line) {
283
+                ssrc_group_lines.forEach(line => {
284
                     const idx = line.indexOf(' ');
284
                     const idx = line.indexOf(' ');
285
                     const semantics = line.substr(0, idx).substr(13);
285
                     const semantics = line.substr(0, idx).substr(13);
286
                     const ssrcs = line.substr(14 + semantics.length).split(' ');
286
                     const ssrcs = line.substr(14 + semantics.length).split(' ');
287
                     if (ssrcs.length) {
287
                     if (ssrcs.length) {
288
                         elem.c('ssrc-group', { semantics, xmlns: 'urn:xmpp:jingle:apps:rtp:ssma:0' });
288
                         elem.c('ssrc-group', { semantics, xmlns: 'urn:xmpp:jingle:apps:rtp:ssma:0' });
289
-                        ssrcs.forEach(function(ssrc) {
290
-                            elem.c('source', { ssrc })
291
-                                .up();
292
-                        });
289
+                        ssrcs.forEach(ssrc => elem.c('source', { ssrc }).up());
293
                         elem.up();
290
                         elem.up();
294
                     }
291
                     }
295
                 });
292
                 });
379
     // XEP-0320
376
     // XEP-0320
380
     const fingerprints
377
     const fingerprints
381
         = SDPUtil.find_lines(this.media[mediaindex], 'a=fingerprint:', this.session);
378
         = SDPUtil.find_lines(this.media[mediaindex], 'a=fingerprint:', this.session);
382
-    fingerprints.forEach(function(line) {
379
+    fingerprints.forEach(line => {
383
         tmp = SDPUtil.parse_fingerprint(line);
380
         tmp = SDPUtil.parse_fingerprint(line);
384
         tmp.xmlns = 'urn:xmpp:jingle:apps:dtls:0';
381
         tmp.xmlns = 'urn:xmpp:jingle:apps:dtls:0';
385
         elem.c('fingerprint').t(tmp.fingerprint);
382
         elem.c('fingerprint').t(tmp.fingerprint);
398
         // XEP-0176
395
         // XEP-0176
399
         if (SDPUtil.find_line(this.media[mediaindex], 'a=candidate:', this.session)) { // add any a=candidate lines
396
         if (SDPUtil.find_line(this.media[mediaindex], 'a=candidate:', this.session)) { // add any a=candidate lines
400
             const lines = SDPUtil.find_lines(this.media[mediaindex], 'a=candidate:', this.session);
397
             const lines = SDPUtil.find_lines(this.media[mediaindex], 'a=candidate:', this.session);
401
-            lines.forEach(function(line) {
398
+            lines.forEach(line => {
402
                 const candidate = SDPUtil.candidateToJingle(line);
399
                 const candidate = SDPUtil.candidateToJingle(line);
403
                 if (self.failICE) {
400
                 if (self.failICE) {
404
                     candidate.ip = '1.1.1.1';
401
                     candidate.ip = '1.1.1.1';
420
 
417
 
421
 SDP.prototype.rtcpFbToJingle = function(mediaindex, elem, payloadtype) { // XEP-0293
418
 SDP.prototype.rtcpFbToJingle = function(mediaindex, elem, payloadtype) { // XEP-0293
422
     const lines = SDPUtil.find_lines(this.media[mediaindex], `a=rtcp-fb:${payloadtype}`);
419
     const lines = SDPUtil.find_lines(this.media[mediaindex], `a=rtcp-fb:${payloadtype}`);
423
-    lines.forEach(function(line) {
420
+    lines.forEach(line => {
424
         const tmp = SDPUtil.parse_rtcpfb(line);
421
         const tmp = SDPUtil.parse_rtcpfb(line);
425
         if (tmp.type == 'trr-int') {
422
         if (tmp.type == 'trr-int') {
426
             elem.c('rtcp-fb-trr-int', {xmlns: 'urn:xmpp:jingle:apps:rtp:rtcp-fb:0', value: tmp.params[0]});
423
             elem.c('rtcp-fb-trr-int', {xmlns: 'urn:xmpp:jingle:apps:rtp:rtcp-fb:0', value: tmp.params[0]});
467
         + 't=0 0\r\n';
464
         + 't=0 0\r\n';
468
     // http://tools.ietf.org/html/draft-ietf-mmusic-sdp-bundle-negotiation-04#section-8
465
     // http://tools.ietf.org/html/draft-ietf-mmusic-sdp-bundle-negotiation-04#section-8
469
     if ($(jingle).find('>group[xmlns="urn:xmpp:jingle:apps:grouping:0"]').length) {
466
     if ($(jingle).find('>group[xmlns="urn:xmpp:jingle:apps:grouping:0"]').length) {
470
-        $(jingle).find('>group[xmlns="urn:xmpp:jingle:apps:grouping:0"]').each(function(idx, group) {
471
-            const contents = $(group).find('>content').map(function(idx, content) {
472
-                return content.getAttribute('name');
473
-            }).get();
467
+        $(jingle).find('>group[xmlns="urn:xmpp:jingle:apps:grouping:0"]').each((idx, group) => {
468
+            const contents = $(group).find('>content').map((idx, content) => content.getAttribute('name')).get();
474
             if (contents.length > 0) {
469
             if (contents.length > 0) {
475
                 self.raw += `a=group:${group.getAttribute('semantics') || group.getAttribute('type')} ${contents.join(' ')}\r\n`;
470
                 self.raw += `a=group:${group.getAttribute('semantics') || group.getAttribute('type')} ${contents.join(' ')}\r\n`;
476
             }
471
             }
658
     return media;
653
     return media;
659
 };
654
 };
660
 
655
 
661
-
662
 module.exports = SDP;
656
 module.exports = SDP;

+ 8
- 8
modules/xmpp/SDPDiffer.js View File

42
     const myMedias = this.mySDP.getMediaSsrcMap();
42
     const myMedias = this.mySDP.getMediaSsrcMap();
43
     const othersMedias = this.otherSDP.getMediaSsrcMap();
43
     const othersMedias = this.otherSDP.getMediaSsrcMap();
44
     const newMedia = {};
44
     const newMedia = {};
45
-    Object.keys(othersMedias).forEach(function(othersMediaIdx) {
45
+    Object.keys(othersMedias).forEach(othersMediaIdx => {
46
         const myMedia = myMedias[othersMediaIdx];
46
         const myMedia = myMedias[othersMediaIdx];
47
         const othersMedia = othersMedias[othersMediaIdx];
47
         const othersMedia = othersMedias[othersMediaIdx];
48
         if(!myMedia && othersMedia) {
48
         if(!myMedia && othersMedia) {
51
             return;
51
             return;
52
         }
52
         }
53
         // Look for new ssrcs across the channel
53
         // Look for new ssrcs across the channel
54
-        Object.keys(othersMedia.ssrcs).forEach(function(ssrc) {
54
+        Object.keys(othersMedia.ssrcs).forEach(ssrc => {
55
             if(Object.keys(myMedia.ssrcs).indexOf(ssrc) === -1) {
55
             if(Object.keys(myMedia.ssrcs).indexOf(ssrc) === -1) {
56
                 // Allocate channel if we've found ssrc that doesn't exist in
56
                 // Allocate channel if we've found ssrc that doesn't exist in
57
                 // our channel
57
                 // our channel
68
         });
68
         });
69
 
69
 
70
         // Look for new ssrc groups across the channels
70
         // Look for new ssrc groups across the channels
71
-        othersMedia.ssrcGroups.forEach(function(otherSsrcGroup) {
71
+        othersMedia.ssrcGroups.forEach(otherSsrcGroup => {
72
 
72
 
73
             // try to match the other ssrc-group with an ssrc-group of ours
73
             // try to match the other ssrc-group with an ssrc-group of ours
74
             let matched = false;
74
             let matched = false;
109
     const sdpMediaSsrcs = this.getNewMedia();
109
     const sdpMediaSsrcs = this.getNewMedia();
110
 
110
 
111
     let modified = false;
111
     let modified = false;
112
-    Object.keys(sdpMediaSsrcs).forEach(function(mediaindex) {
112
+    Object.keys(sdpMediaSsrcs).forEach(mediaindex => {
113
         modified = true;
113
         modified = true;
114
         const media = sdpMediaSsrcs[mediaindex];
114
         const media = sdpMediaSsrcs[mediaindex];
115
         modify.c('content', {name: media.mid});
115
         modify.c('content', {name: media.mid});
119
         // FIXME: not completely sure this operates on blocks and / or handles
119
         // FIXME: not completely sure this operates on blocks and / or handles
120
         // different ssrcs correctly
120
         // different ssrcs correctly
121
         // generate sources from lines
121
         // generate sources from lines
122
-        Object.keys(media.ssrcs).forEach(function(ssrcNum) {
122
+        Object.keys(media.ssrcs).forEach(ssrcNum => {
123
             const mediaSsrc = media.ssrcs[ssrcNum];
123
             const mediaSsrc = media.ssrcs[ssrcNum];
124
             modify.c('source', { xmlns: 'urn:xmpp:jingle:apps:rtp:ssma:0' });
124
             modify.c('source', { xmlns: 'urn:xmpp:jingle:apps:rtp:ssma:0' });
125
             modify.attrs({ssrc: mediaSsrc.ssrc});
125
             modify.attrs({ssrc: mediaSsrc.ssrc});
126
             // iterate over ssrc lines
126
             // iterate over ssrc lines
127
-            mediaSsrc.lines.forEach(function(line) {
127
+            mediaSsrc.lines.forEach(line => {
128
                 const idx = line.indexOf(' ');
128
                 const idx = line.indexOf(' ');
129
                 const kv = line.substr(idx + 1);
129
                 const kv = line.substr(idx + 1);
130
                 modify.c('parameter');
130
                 modify.c('parameter');
143
         });
143
         });
144
 
144
 
145
         // generate source groups from lines
145
         // generate source groups from lines
146
-        media.ssrcGroups.forEach(function(ssrcGroup) {
146
+        media.ssrcGroups.forEach(ssrcGroup => {
147
             if (ssrcGroup.ssrcs.length) {
147
             if (ssrcGroup.ssrcs.length) {
148
 
148
 
149
                 modify.c('ssrc-group', {
149
                 modify.c('ssrc-group', {
151
                     xmlns: 'urn:xmpp:jingle:apps:rtp:ssma:0'
151
                     xmlns: 'urn:xmpp:jingle:apps:rtp:ssma:0'
152
                 });
152
                 });
153
 
153
 
154
-                ssrcGroup.ssrcs.forEach(function(ssrc) {
154
+                ssrcGroup.ssrcs.forEach(ssrc => {
155
                     modify.c('source', { ssrc })
155
                     modify.c('source', { ssrc })
156
                         .up(); // end of source
156
                         .up(); // end of source
157
                 });
157
                 });

+ 4
- 4
modules/xmpp/SDPUtil.spec.js View File

1
 import * as SDPUtil from './SDPUtil';
1
 import * as SDPUtil from './SDPUtil';
2
 import * as SampleSdpStrings from './SampleSdpStrings.js';
2
 import * as SampleSdpStrings from './SampleSdpStrings.js';
3
 
3
 
4
-describe('SDPUtil', function() {
5
-    it('should parse an ice ufrag correctly', function() {
4
+describe('SDPUtil', () => {
5
+    it('should parse an ice ufrag correctly', () => {
6
         const line = 'a=ice-ufrag:3jlcc1b3j1rqt6';
6
         const line = 'a=ice-ufrag:3jlcc1b3j1rqt6';
7
         const parsed = SDPUtil.parse_iceufrag(line);
7
         const parsed = SDPUtil.parse_iceufrag(line);
8
 
8
 
9
         expect(parsed).toEqual('3jlcc1b3j1rqt6');
9
         expect(parsed).toEqual('3jlcc1b3j1rqt6');
10
     });
10
     });
11
 
11
 
12
-    describe('preferVideoCodec', function() {
13
-        it('should move a preferred codec to the front', function() {
12
+    describe('preferVideoCodec', () => {
13
+        it('should move a preferred codec to the front', () => {
14
             const sdp = SampleSdpStrings.multiCodecVideoSdp;
14
             const sdp = SampleSdpStrings.multiCodecVideoSdp;
15
             const videoMLine = sdp.media.find(m => m.type === 'video');
15
             const videoMLine = sdp.media.find(m => m.type === 'video');
16
             SDPUtil.preferVideoCodec(videoMLine, 'H264');
16
             SDPUtil.preferVideoCodec(videoMLine, 'H264');

+ 3
- 3
modules/xmpp/moderator.js View File

434
     }
434
     }
435
     this.connection.sendIQ(
435
     this.connection.sendIQ(
436
         iq,
436
         iq,
437
-        function(result) {
437
+        result => {
438
             let url = $(result).find('login-url').attr('url');
438
             let url = $(result).find('login-url').attr('url');
439
             url = decodeURIComponent(url);
439
             url = decodeURIComponent(url);
440
             if (url) {
440
             if (url) {
465
     });
465
     });
466
     this.connection.sendIQ(
466
     this.connection.sendIQ(
467
         iq,
467
         iq,
468
-        function(result) {
468
+        result => {
469
             let logoutUrl = $(result).find('logout').attr('logout-url');
469
             let logoutUrl = $(result).find('logout').attr('logout-url');
470
             if (logoutUrl) {
470
             if (logoutUrl) {
471
                 logoutUrl = decodeURIComponent(logoutUrl);
471
                 logoutUrl = decodeURIComponent(logoutUrl);
474
             Settings.clearSessionId();
474
             Settings.clearSessionId();
475
             callback(logoutUrl);
475
             callback(logoutUrl);
476
         },
476
         },
477
-        function(error) {
477
+        error => {
478
             const errmsg = 'Logout error';
478
             const errmsg = 'Logout error';
479
             GlobalOnErrorHandler.callErrorHandler(new Error(errmsg));
479
             GlobalOnErrorHandler.callErrorHandler(new Error(errmsg));
480
             logger.error(errmsg, error);
480
             logger.error(errmsg, error);

+ 13
- 12
modules/xmpp/recording.js View File

106
         logger.log(iq.nodeTree);
106
         logger.log(iq.nodeTree);
107
         this.connection.sendIQ(
107
         this.connection.sendIQ(
108
         iq,
108
         iq,
109
-        function(result) {
109
+        result => {
110
             logger.log('Result', result);
110
             logger.log('Result', result);
111
             callback($(result).find('jibri').attr('state'),
111
             callback($(result).find('jibri').attr('state'),
112
             $(result).find('jibri').attr('url'));
112
             $(result).find('jibri').attr('url'));
113
         },
113
         },
114
-        function(error) {
114
+        error => {
115
             logger.log('Failed to start recording, error: ', error);
115
             logger.log('Failed to start recording, error: ', error);
116
             errCallback(error);
116
             errCallback(error);
117
         });
117
         });
138
         const self = this;
138
         const self = this;
139
         this.connection.sendIQ(
139
         this.connection.sendIQ(
140
         iq,
140
         iq,
141
-        function(result) {
141
+        result => {
142
             // TODO wait for an IQ with the real status, since this is
142
             // TODO wait for an IQ with the real status, since this is
143
             // provisional?
143
             // provisional?
144
             self.jireconRid = $(result).find('recording').attr('rid');
144
             self.jireconRid = $(result).find('recording').attr('rid');
153
 
153
 
154
             callback(state);
154
             callback(state);
155
         },
155
         },
156
-        function(error) {
156
+        error => {
157
             logger.log('Failed to start recording, error: ', error);
157
             logger.log('Failed to start recording, error: ', error);
158
             errCallback(error);
158
             errCallback(error);
159
         });
159
         });
172
 
172
 
173
     const self = this;
173
     const self = this;
174
     this.connection.sendIQ(elem,
174
     this.connection.sendIQ(elem,
175
-        function(result) {
175
+        result => {
176
             logger.log('Set recording "', state, '". Result:', result);
176
             logger.log('Set recording "', state, '". Result:', result);
177
             const recordingElem = $(result).find('>conference>recording');
177
             const recordingElem = $(result).find('>conference>recording');
178
             const newState = recordingElem.attr('state');
178
             const newState = recordingElem.attr('state');
181
             callback(newState);
181
             callback(newState);
182
 
182
 
183
             if (newState === 'pending') {
183
             if (newState === 'pending') {
184
-                self.connection.addHandler(function(iq) {
184
+                self.connection.addHandler(iq => {
185
                     const state = $(iq).find('recording').attr('state');
185
                     const state = $(iq).find('recording').attr('state');
186
                     if (state) {
186
                     if (state) {
187
                         self.state = newState;
187
                         self.state = newState;
190
                 }, 'http://jitsi.org/protocol/colibri', 'iq', null, null, null);
190
                 }, 'http://jitsi.org/protocol/colibri', 'iq', null, null, null);
191
             }
191
             }
192
         },
192
         },
193
-        function(error) {
193
+        error => {
194
             logger.warn(error);
194
             logger.warn(error);
195
             errCallback(error);
195
             errCallback(error);
196
         }
196
         }
256
 
256
 
257
     const self = this;
257
     const self = this;
258
     logger.log('Toggle recording (old state, new state): ', oldState, newState);
258
     logger.log('Toggle recording (old state, new state): ', oldState, newState);
259
-    this.setRecording(newState,
260
-        function(state, url) {
259
+    this.setRecording(
260
+        newState,
261
+        (state, url) => {
261
             // If the state is undefined we're going to wait for presence
262
             // If the state is undefined we're going to wait for presence
262
             // update.
263
             // update.
263
             if (state && state !== oldState) {
264
             if (state && state !== oldState) {
265
                 self.url = url;
266
                 self.url = url;
266
                 statusChangeHandler(state);
267
                 statusChangeHandler(state);
267
             }
268
             }
268
-        }, function(error) {
269
-            statusChangeHandler(Recording.status.FAILED, error);
270
-        }, options);
269
+        },
270
+        error => statusChangeHandler(Recording.status.FAILED, error),
271
+        options);
271
 };
272
 };
272
 
273
 
273
 /**
274
 /**

+ 2
- 2
modules/xmpp/xmpp.js View File

121
             const pingJid = this.connection.domain;
121
             const pingJid = this.connection.domain;
122
             this.connection.ping.hasPingSupport(
122
             this.connection.ping.hasPingSupport(
123
                 pingJid,
123
                 pingJid,
124
-                function(hasPing) {
124
+                hasPing => {
125
                     if (hasPing) {
125
                     if (hasPing) {
126
                         this.connection.ping.startInterval(pingJid);
126
                         this.connection.ping.startInterval(pingJid);
127
                     } else {
127
                     } else {
128
                         logger.warn(`Ping NOT supported by ${pingJid}`);
128
                         logger.warn(`Ping NOT supported by ${pingJid}`);
129
                     }
129
                     }
130
-                }.bind(this));
130
+                });
131
 
131
 
132
             if (password) {
132
             if (password) {
133
                 this.authenticatedUser = true;
133
                 this.authenticatedUser = true;

Loading…
Cancel
Save