Browse Source

[eslint] max-len

tags/v0.0.2
Lyubo Marinov 8 years ago
parent
commit
308adc133a

+ 1
- 0
.eslintrc.js View File

179
                 'beforeLineComment': true
179
                 'beforeLineComment': true
180
             }
180
             }
181
         ],
181
         ],
182
+        'max-len': [ 'error', 80 ],
182
         'max-lines': 0,
183
         'max-lines': 0,
183
         'max-nested-callbacks': 2,
184
         'max-nested-callbacks': 2,
184
         'max-statements': 0,
185
         'max-statements': 0,

+ 44
- 20
JitsiConference.js View File

30
  * Creates a JitsiConference object with the given name and properties.
30
  * Creates a JitsiConference object with the given name and properties.
31
  * Note: this constructor is not a part of the public API (objects should be
31
  * Note: this constructor is not a part of the public API (objects should be
32
  * created using JitsiConnection.createConference).
32
  * created using JitsiConnection.createConference).
33
- * @param options.config properties / settings related to the conference that will be created.
33
+ * @param options.config properties / settings related to the conference that
34
+ * will be created.
34
  * @param options.name the name of the conference
35
  * @param options.name the name of the conference
35
- * @param options.connection the JitsiConnection object for this JitsiConference.
36
+ * @param options.connection the JitsiConnection object for this
37
+ * JitsiConference.
36
  * @constructor
38
  * @constructor
37
  */
39
  */
38
 function JitsiConference(options) {
40
 function JitsiConference(options) {
133
             callStatsID: this.options.config.callStatsID,
135
             callStatsID: this.options.config.callStatsID,
134
             callStatsSecret: this.options.config.callStatsSecret,
136
             callStatsSecret: this.options.config.callStatsSecret,
135
             callStatsConfIDNamespace:
137
             callStatsConfIDNamespace:
136
-                this.options.config.callStatsConfIDNamespace || window.location.hostname,
138
+                this.options.config.callStatsConfIDNamespace
139
+                    || window.location.hostname,
137
             callStatsCustomScriptUrl:
140
             callStatsCustomScriptUrl:
138
                 this.options.config.callStatsCustomScriptUrl,
141
                 this.options.config.callStatsCustomScriptUrl,
139
             roomName: this.options.name
142
             roomName: this.options.name
303
 };
306
 };
304
 
307
 
305
 /**
308
 /**
306
- * Attaches a handler for events(For example - "participant joined".) in the conference. All possible event are defined
307
- * in JitsiConferenceEvents.
309
+ * Attaches a handler for events(For example - "participant joined".) in the
310
+ * conference. All possible event are defined in JitsiConferenceEvents.
308
  * @param eventId the event ID.
311
  * @param eventId the event ID.
309
  * @param handler handler for the event.
312
  * @param handler handler for the event.
310
  *
313
  *
311
- * Note: consider adding eventing functionality by extending an EventEmitter impl, instead of rolling ourselves
314
+ * Note: consider adding eventing functionality by extending an EventEmitter
315
+ * impl, instead of rolling ourselves
312
  */
316
  */
313
 JitsiConference.prototype.on = function(eventId, handler) {
317
 JitsiConference.prototype.on = function(eventId, handler) {
314
     if (this.eventEmitter) {
318
     if (this.eventEmitter) {
321
  * @param eventId the event ID.
325
  * @param eventId the event ID.
322
  * @param [handler] optional, the specific handler to unbind
326
  * @param [handler] optional, the specific handler to unbind
323
  *
327
  *
324
- * Note: consider adding eventing functionality by extending an EventEmitter impl, instead of rolling ourselves
328
+ * Note: consider adding eventing functionality by extending an EventEmitter
329
+ * impl, instead of rolling ourselves
325
  */
330
  */
326
 JitsiConference.prototype.off = function(eventId, handler) {
331
 JitsiConference.prototype.off = function(eventId, handler) {
327
     if (this.eventEmitter) {
332
     if (this.eventEmitter) {
561
                 new JitsiTrackError(JitsiTrackErrors.TRACK_IS_DISPOSED));
566
                 new JitsiTrackError(JitsiTrackErrors.TRACK_IS_DISPOSED));
562
         }
567
         }
563
 
568
 
564
-        // Set up the ssrcHandler for the new track before we add it at the lower levels
569
+        // Set up the ssrcHandler for the new track before we add it at the
570
+        // lower levels
565
         newTrack.ssrcHandler = function(conference, ssrcMap) {
571
         newTrack.ssrcHandler = function(conference, ssrcMap) {
566
             const trackSSRCInfo = ssrcMap.get(this.getMSID());
572
             const trackSSRCInfo = ssrcMap.get(this.getMSID());
567
 
573
 
583
                 this.onLocalTrackRemoved(oldTrack);
589
                 this.onLocalTrackRemoved(oldTrack);
584
             }
590
             }
585
             if (newTrack) {
591
             if (newTrack) {
586
-                // Now handle the addition of the newTrack at the JitsiConference level
592
+                // Now handle the addition of the newTrack at the
593
+                // JitsiConference level
587
                 this._setupNewTrack(newTrack);
594
                 this._setupNewTrack(newTrack);
588
             }
595
             }
589
 
596
 
675
 /**
682
 /**
676
  * Adds loca WebRTC stream to the conference.
683
  * Adds loca WebRTC stream to the conference.
677
  * @param {MediaStream} stream new stream that will be added.
684
  * @param {MediaStream} stream new stream that will be added.
678
- * @param {function} callback callback executed after successful stream addition.
679
- * @param {function(error)} errorCallback callback executed if stream addition fail.
680
- * @param {object} ssrcInfo object with information about the SSRCs associated with the
681
- * stream.
685
+ * @param {function} callback callback executed after successful stream
686
+ * addition.
687
+ * @param {function(error)} errorCallback callback executed if stream addition
688
+ * fail.
689
+ * @param {object} ssrcInfo object with information about the SSRCs associated
690
+ * with the stream.
682
  * @param {boolean} [dontModifySources] if <tt>true</tt> _modifySources won't be
691
  * @param {boolean} [dontModifySources] if <tt>true</tt> _modifySources won't be
683
  * called. The option is used for adding stream, before the Jingle call is
692
  * called. The option is used for adding stream, before the Jingle call is
684
  * started. That is before the 'session-accept' is sent.
693
  * started. That is before the 'session-accept' is sent.
709
             this.jingleSession.removeStream(
718
             this.jingleSession.removeStream(
710
             stream, callback, errorCallback, ssrcInfo);
719
             stream, callback, errorCallback, ssrcInfo);
711
         } else {
720
         } else {
712
-        // We are done immediately
713
-            logger.warn('Remove local MediaStream - no JingleSession started yet');
721
+            // We are done immediately
722
+            logger.warn(
723
+                'Remove local MediaStream - no JingleSession started yet');
714
             callback();
724
             callback();
715
         }
725
         }
716
     };
726
     };
903
 
913
 
904
         participant._role = role;
914
         participant._role = role;
905
         this.participants[id] = participant;
915
         this.participants[id] = participant;
906
-        this.eventEmitter.emit(JitsiConferenceEvents.USER_JOINED, id, participant);
916
+        this.eventEmitter.emit(
917
+            JitsiConferenceEvents.USER_JOINED,
918
+            id,
919
+            participant);
907
         this.xmpp.caps.getFeatures(jid).then(features => {
920
         this.xmpp.caps.getFeatures(jid).then(features => {
908
             participant._supportsDTMF = features.has('urn:xmpp:jingle:dtmf:0');
921
             participant._supportsDTMF = features.has('urn:xmpp:jingle:dtmf:0');
909
             this.updateDTMFSupport();
922
             this.updateDTMFSupport();
957
     }
970
     }
958
 
971
 
959
     participant._displayName = displayName;
972
     participant._displayName = displayName;
960
-    this.eventEmitter.emit(JitsiConferenceEvents.DISPLAY_NAME_CHANGED, id, displayName);
973
+    this.eventEmitter.emit(
974
+        JitsiConferenceEvents.DISPLAY_NAME_CHANGED,
975
+        id,
976
+        displayName);
961
 };
977
 };
962
 
978
 
963
 /**
979
 /**
1113
          *  consistent
1129
          *  consistent
1114
          */
1130
          */
1115
 
1131
 
1116
-        if (localTrack.isVideoTrack() && localTrack.isMuted() && !RTCBrowserType.isFirefox()) {
1132
+        if (localTrack.isVideoTrack()
1133
+                && localTrack.isMuted()
1134
+                && !RTCBrowserType.isFirefox()) {
1117
             /**
1135
             /**
1118
              * Handles issues when the stream is added before the peerconnection
1136
              * Handles issues when the stream is added before the peerconnection
1119
              * is created. The peerconnection is created when second participant
1137
              * is created. The peerconnection is created when second participant
1244
     }
1262
     }
1245
     if (somebodySupportsDTMF !== this.somebodySupportsDTMF) {
1263
     if (somebodySupportsDTMF !== this.somebodySupportsDTMF) {
1246
         this.somebodySupportsDTMF = somebodySupportsDTMF;
1264
         this.somebodySupportsDTMF = somebodySupportsDTMF;
1247
-        this.eventEmitter.emit(JitsiConferenceEvents.DTMF_SUPPORT_CHANGED, somebodySupportsDTMF);
1265
+        this.eventEmitter.emit(
1266
+            JitsiConferenceEvents.DTMF_SUPPORT_CHANGED,
1267
+            somebodySupportsDTMF);
1248
     }
1268
     }
1249
 };
1269
 };
1250
 
1270
 
1262
  * @return {string} local user's ID
1282
  * @return {string} local user's ID
1263
  */
1283
  */
1264
 JitsiConference.prototype.myUserId = function() {
1284
 JitsiConference.prototype.myUserId = function() {
1265
-    return this.room && this.room.myroomjid ? Strophe.getResourceFromJid(this.room.myroomjid) : null;
1285
+    return (
1286
+        this.room
1287
+            && this.room.myroomjid
1288
+                ? Strophe.getResourceFromJid(this.room.myroomjid)
1289
+                : null);
1266
 };
1290
 };
1267
 
1291
 
1268
 JitsiConference.prototype.sendTones = function(tones, duration, pause) {
1292
 JitsiConference.prototype.sendTones = function(tones, duration, pause) {

+ 6
- 4
JitsiConnection.js View File

5
 const Statistics = require('./modules/statistics/statistics');
5
 const Statistics = require('./modules/statistics/statistics');
6
 
6
 
7
 /**
7
 /**
8
- * Creates new connection object for the Jitsi Meet server side video conferencing service. Provides access to the
9
- * JitsiConference interface.
10
- * @param appID identification for the provider of Jitsi Meet video conferencing services.
8
+ * Creates new connection object for the Jitsi Meet server side video
9
+ * conferencing service. Provides access to the JitsiConference interface.
10
+ * @param appID identification for the provider of Jitsi Meet video conferencing
11
+ * services.
11
  * @param token the JWT token used to authenticate with the server(optional)
12
  * @param token the JWT token used to authenticate with the server(optional)
12
- * @param options Object with properties / settings related to connection with the server.
13
+ * @param options Object with properties / settings related to connection with
14
+ * the server.
13
  * @constructor
15
  * @constructor
14
  */
16
  */
15
 function JitsiConnection(appID, token, options) {
17
 function JitsiConnection(appID, token, options) {

+ 9
- 6
JitsiMeetJS.js View File

1
 /* global __filename */
1
 /* global __filename */
2
 
2
 
3
 import AuthUtil from './modules/util/AuthUtil';
3
 import AuthUtil from './modules/util/AuthUtil';
4
-import * as ConnectionQualityEvents from './service/connectivity/ConnectionQualityEvents';
4
+import * as ConnectionQualityEvents
5
+    from './service/connectivity/ConnectionQualityEvents';
5
 import GlobalOnErrorHandler from './modules/util/GlobalOnErrorHandler';
6
 import GlobalOnErrorHandler from './modules/util/GlobalOnErrorHandler';
6
 import * as JitsiConferenceErrors from './JitsiConferenceErrors';
7
 import * as JitsiConferenceErrors from './JitsiConferenceErrors';
7
 import * as JitsiConferenceEvents from './JitsiConferenceEvents';
8
 import * as JitsiConferenceEvents from './JitsiConferenceEvents';
183
 
184
 
184
     /**
185
     /**
185
      * Creates the media tracks and returns them trough the callback.
186
      * Creates the media tracks and returns them trough the callback.
186
-     * @param options Object with properties / settings specifying the tracks which should be created.
187
-     * should be created or some additional configurations about resolution for example.
187
+     * @param options Object with properties / settings specifying the tracks
188
+     * which should be created. should be created or some additional
189
+     * configurations about resolution for example.
188
      * @param {Array} options.devices the devices that will be requested
190
      * @param {Array} options.devices the devices that will be requested
189
      * @param {string} options.resolution resolution constraints
191
      * @param {string} options.resolution resolution constraints
190
-     * @param {bool} options.dontCreateJitsiTrack if <tt>true</tt> objects with the following structure {stream: the Media Stream,
191
-     * type: "audio" or "video", videoType: "camera" or "desktop"}
192
-     * will be returned trough the Promise, otherwise JitsiTrack objects will be returned.
192
+     * @param {bool} options.dontCreateJitsiTrack if <tt>true</tt> objects with
193
+     * the following structure {stream: the Media Stream, type: "audio" or
194
+     * "video", videoType: "camera" or "desktop"} will be returned trough the
195
+     * Promise, otherwise JitsiTrack objects will be returned.
193
      * @param {string} options.cameraDeviceId
196
      * @param {string} options.cameraDeviceId
194
      * @param {string} options.micDeviceId
197
      * @param {string} options.micDeviceId
195
      * @param {object} options.desktopSharingExtensionExternalInstallation -
198
      * @param {object} options.desktopSharingExtensionExternalInstallation -

+ 39
- 23
doc/example/example.js View File

6
         muc: 'conference.jitsi-meet.example.com' // FIXME: use XEP-0030
6
         muc: 'conference.jitsi-meet.example.com' // FIXME: use XEP-0030
7
     },
7
     },
8
     bosh: '//jitsi-meet.example.com/http-bind', // FIXME: use xep-0156 for that
8
     bosh: '//jitsi-meet.example.com/http-bind', // FIXME: use xep-0156 for that
9
-    clientNode: 'http://jitsi.org/jitsimeet' // The name of client node advertised in XEP-0115 'c' stanza
9
+
10
+    // The name of client node advertised in XEP-0115 'c' stanza
11
+    clientNode: 'http://jitsi.org/jitsimeet'
10
 };
12
 };
11
 
13
 
12
 const confOptions = {
14
 const confOptions = {
45
             $('body').append(`<video autoplay='1' id='localVideo${i}' />`);
47
             $('body').append(`<video autoplay='1' id='localVideo${i}' />`);
46
             localTracks[i].attach($(`#localVideo${i}`)[0]);
48
             localTracks[i].attach($(`#localVideo${i}`)[0]);
47
         } else {
49
         } else {
48
-            $('body').append(`<audio autoplay='1' muted='true' id='localAudio${i}' />`);
50
+            $('body').append(
51
+                `<audio autoplay='1' muted='true' id='localAudio${i}' />`);
49
             localTracks[i].attach($(`#localAudio${i}`)[0]);
52
             localTracks[i].attach($(`#localAudio${i}`)[0]);
50
         }
53
         }
51
         if (isJoined) {
54
         if (isJoined) {
85
     const id = participant + track.getType() + idx;
88
     const id = participant + track.getType() + idx;
86
 
89
 
87
     if (track.getType() == 'video') {
90
     if (track.getType() == 'video') {
88
-        $('body').append(`<video autoplay='1' id='${participant}video${idx}' />`);
91
+        $('body').append(
92
+            `<video autoplay='1' id='${participant}video${idx}' />`);
89
     } else {
93
     } else {
90
-        $('body').append(`<audio autoplay='1' id='${participant}audio${idx}' />`);
94
+        $('body').append(
95
+            `<audio autoplay='1' id='${participant}audio${idx}' />`);
91
     }
96
     }
92
     track.attach($(`#${id}`)[0]);
97
     track.attach($(`#${id}`)[0]);
93
 }
98
 }
124
     room.on(JitsiMeetJS.events.conference.TRACK_REMOVED, track => {
129
     room.on(JitsiMeetJS.events.conference.TRACK_REMOVED, track => {
125
         console.log(`track removed!!!${track}`);
130
         console.log(`track removed!!!${track}`);
126
     });
131
     });
127
-    room.on(JitsiMeetJS.events.conference.CONFERENCE_JOINED, onConferenceJoined);
132
+    room.on(
133
+        JitsiMeetJS.events.conference.CONFERENCE_JOINED,
134
+        onConferenceJoined);
128
     room.on(JitsiMeetJS.events.conference.USER_JOINED, id => {
135
     room.on(JitsiMeetJS.events.conference.USER_JOINED, id => {
129
         console.log('user join');
136
         console.log('user join');
130
         remoteTracks[id] = [];
137
         remoteTracks[id] = [];
133
     room.on(JitsiMeetJS.events.conference.TRACK_MUTE_CHANGED, track => {
140
     room.on(JitsiMeetJS.events.conference.TRACK_MUTE_CHANGED, track => {
134
         console.log(`${track.getType()} - ${track.isMuted()}`);
141
         console.log(`${track.getType()} - ${track.isMuted()}`);
135
     });
142
     });
136
-    room.on(JitsiMeetJS.events.conference.DISPLAY_NAME_CHANGED, (userID, displayName) => {
137
-        console.log(`${userID} - ${displayName}`);
138
-    });
143
+    room.on(
144
+        JitsiMeetJS.events.conference.DISPLAY_NAME_CHANGED,
145
+        (userID, displayName) => console.log(`${userID} - ${displayName}`));
139
     room.on(JitsiMeetJS.events.conference.TRACK_AUDIO_LEVEL_CHANGED,
146
     room.on(JitsiMeetJS.events.conference.TRACK_AUDIO_LEVEL_CHANGED,
140
       (userID, audioLevel) => {
147
       (userID, audioLevel) => {
141
           console.log(`${userID} - ${audioLevel}`);
148
           console.log(`${userID} - ${audioLevel}`);
172
  */
179
  */
173
 function disconnect() {
180
 function disconnect() {
174
     console.log('disconnect!');
181
     console.log('disconnect!');
175
-    connection.removeEventListener(JitsiMeetJS.events.connection.CONNECTION_ESTABLISHED, onConnectionSuccess);
176
-    connection.removeEventListener(JitsiMeetJS.events.connection.CONNECTION_FAILED, onConnectionFailed);
177
-    connection.removeEventListener(JitsiMeetJS.events.connection.CONNECTION_DISCONNECTED, disconnect);
182
+    connection.removeEventListener(
183
+        JitsiMeetJS.events.connection.CONNECTION_ESTABLISHED,
184
+        onConnectionSuccess);
185
+    connection.removeEventListener(
186
+        JitsiMeetJS.events.connection.CONNECTION_FAILED,
187
+        onConnectionFailed);
188
+    connection.removeEventListener(
189
+        JitsiMeetJS.events.connection.CONNECTION_DISCONNECTED,
190
+        disconnect);
178
 }
191
 }
179
 
192
 
180
 function unload() {
193
 function unload() {
193
         localTracks[1].dispose();
206
         localTracks[1].dispose();
194
         localTracks.pop();
207
         localTracks.pop();
195
     }
208
     }
196
-    JitsiMeetJS.createLocalTracks({ devices: isVideo ? [ 'video' ] : [ 'desktop' ] })
209
+    JitsiMeetJS.createLocalTracks(
210
+            { devices: isVideo ? [ 'video' ] : [ 'desktop' ] })
197
         .then(tracks => {
211
         .then(tracks => {
198
             localTracks.push(tracks[0]);
212
             localTracks.push(tracks[0]);
199
-            localTracks[1].addEventListener(JitsiMeetJS.events.track.TRACK_MUTE_CHANGED,
200
-                () => {
201
-                    console.log('local track muted');
202
-                });
203
-            localTracks[1].addEventListener(JitsiMeetJS.events.track.LOCAL_TRACK_STOPPED,
204
-                () => {
205
-                    console.log('local track stoped');
206
-                });
213
+            localTracks[1].addEventListener(
214
+                JitsiMeetJS.events.track.TRACK_MUTE_CHANGED,
215
+                () => console.log('local track muted'));
216
+            localTracks[1].addEventListener(
217
+                JitsiMeetJS.events.track.LOCAL_TRACK_STOPPED,
218
+                () => console.log('local track stoped'));
207
             localTracks[1].attach($('#localVideo1')[0]);
219
             localTracks[1].attach($('#localVideo1')[0]);
208
             room.addTrack(localTracks[1]);
220
             room.addTrack(localTracks[1]);
209
         })
221
         })
281
 
293
 
282
 if (JitsiMeetJS.mediaDevices.isDeviceChangeAvailable('output')) {
294
 if (JitsiMeetJS.mediaDevices.isDeviceChangeAvailable('output')) {
283
     JitsiMeetJS.mediaDevices.enumerateDevices(devices => {
295
     JitsiMeetJS.mediaDevices.enumerateDevices(devices => {
284
-        const audioOutputDevices = devices.filter(d => d.kind === 'audiooutput');
296
+        const audioOutputDevices
297
+            = devices.filter(d => d.kind === 'audiooutput');
285
 
298
 
286
         if (audioOutputDevices.length > 1) {
299
         if (audioOutputDevices.length > 1) {
287
             $('#audioOutputSelect').html(
300
             $('#audioOutputSelect').html(
288
-                audioOutputDevices.map(d => `<option value="${d.deviceId}">${d.label}</option>`).join('\n')
289
-            );
301
+                audioOutputDevices
302
+                    .map(
303
+                        d =>
304
+                            `<option value="${d.deviceId}">${d.label}</option>`)
305
+                    .join('\n'));
290
 
306
 
291
             $('#audioOutputSelectWrapper').show();
307
             $('#audioOutputSelectWrapper').show();
292
         }
308
         }

+ 6
- 5
modules/RTC/DataChannels.js View File

16
     this._dataChannels = [];
16
     this._dataChannels = [];
17
 
17
 
18
     // Sample code for opening new data channel from Jitsi Meet to the bridge.
18
     // Sample code for opening new data channel from Jitsi Meet to the bridge.
19
-    // Although it's not a requirement to open separate channels from both bridge
20
-    // and peer as single channel can be used for sending and receiving data.
21
-    // So either channel opened by the bridge or the one opened here is enough
22
-    // for communication with the bridge.
19
+    // Although it's not a requirement to open separate channels from both
20
+    // bridge and peer as single channel can be used for sending and receiving
21
+    // data. So either channel opened by the bridge or the one opened here is
22
+    // enough for communication with the bridge.
23
     /* var dataChannelOptions =
23
     /* var dataChannelOptions =
24
      {
24
      {
25
      reliable: true
25
      reliable: true
141
                 self.eventEmitter.emit(
141
                 self.eventEmitter.emit(
142
                     RTCEvents.ENDPOINT_MESSAGE_RECEIVED, obj.from,
142
                     RTCEvents.ENDPOINT_MESSAGE_RECEIVED, obj.from,
143
                     obj.msgPayload);
143
                     obj.msgPayload);
144
-            } else if (colibriClass === 'EndpointConnectivityStatusChangeEvent') {
144
+            } else if (colibriClass
145
+                    === 'EndpointConnectivityStatusChangeEvent') {
145
                 const endpoint = obj.endpoint;
146
                 const endpoint = obj.endpoint;
146
                 const isActive = obj.active === 'true';
147
                 const isActive = obj.active === 'true';
147
 
148
 

+ 5
- 2
modules/RTC/JitsiLocalTrack.js View File

328
         promise = RTCUtils.obtainAudioAndVideoPermissions(streamOptions)
328
         promise = RTCUtils.obtainAudioAndVideoPermissions(streamOptions)
329
             .then(streamsInfo => {
329
             .then(streamsInfo => {
330
                 const mediaType = self.getType();
330
                 const mediaType = self.getType();
331
-                const streamInfo = streamsInfo.find(info => info.mediaType === mediaType);
331
+                const streamInfo
332
+                    = streamsInfo.find(info => info.mediaType === mediaType);
332
 
333
 
333
                 if (streamInfo) {
334
                 if (streamInfo) {
334
                     self._setStream(streamInfo.stream);
335
                     self._setStream(streamInfo.stream);
347
                         JitsiTrackErrors.TRACK_NO_STREAM_FOUND);
348
                         JitsiTrackErrors.TRACK_NO_STREAM_FOUND);
348
                 }
349
                 }
349
 
350
 
350
-                self.containers = self.containers.map(cont => RTCUtils.attachMediaStream(cont, self.stream));
351
+                self.containers
352
+                    = self.containers.map(
353
+                        cont => RTCUtils.attachMediaStream(cont, self.stream));
351
 
354
 
352
                 return self._addStreamToConferenceAsUnmute();
355
                 return self._addStreamToConferenceAsUnmute();
353
             });
356
             });

+ 27
- 14
modules/RTC/JitsiTrack.js View File

67
  * @param videoType the VideoType for this track if any
67
  * @param videoType the VideoType for this track if any
68
  * @param ssrc the SSRC of this track if known
68
  * @param ssrc the SSRC of this track if known
69
  */
69
  */
70
-function JitsiTrack(conference, stream, track, streamInactiveHandler, trackMediaType,
71
-                    videoType, ssrc) {
70
+function JitsiTrack(
71
+        conference,
72
+        stream,
73
+        track,
74
+        streamInactiveHandler,
75
+        trackMediaType,
76
+        videoType,
77
+        ssrc) {
72
     /**
78
     /**
73
      * Array with the HTML elements that are displaying the streams.
79
      * Array with the HTML elements that are displaying the streams.
74
      * @type {Array}
80
      * @type {Array}
418
         return Promise.resolve();
424
         return Promise.resolve();
419
     }
425
     }
420
 
426
 
421
-    return Promise.all(this.containers.map(element => element.setSinkId(audioOutputDeviceId)
422
-            .catch(error => {
423
-                logger.warn(
424
-                    'Failed to change audio output device on element. Default'
425
-                    + ' or previously set audio output device will be used.',
426
-                    element, error);
427
-                throw error;
428
-            })))
429
-    .then(() => {
430
-        self.eventEmitter.emit(JitsiTrackEvents.TRACK_AUDIO_OUTPUT_CHANGED,
431
-            audioOutputDeviceId);
432
-    });
427
+    return (
428
+        Promise.all(
429
+                this.containers.map(
430
+                    element =>
431
+                        element.setSinkId(audioOutputDeviceId)
432
+                            .catch(error => {
433
+                                logger.warn(
434
+                                    'Failed to change audio output device on'
435
+                                        + ' element. Default or previously set'
436
+                                        + ' audio output device will be used.',
437
+                                    element,
438
+                                    error);
439
+                                throw error;
440
+                            })))
441
+            .then(() => {
442
+                self.eventEmitter.emit(
443
+                    JitsiTrackEvents.TRACK_AUDIO_OUTPUT_CHANGED,
444
+                    audioOutputDeviceId);
445
+            }));
433
 };
446
 };
434
 
447
 
435
 module.exports = JitsiTrack;
448
 module.exports = JitsiTrack;

+ 15
- 15
modules/RTC/RTC.js View File

66
 
66
 
67
         // A flag whether we had received that the data channel had opened
67
         // A flag whether we had received that the data channel had opened
68
         // we can get this flag out of sync if for some reason data channel got
68
         // we can get this flag out of sync if for some reason data channel got
69
-        // closed from server, a desired behaviour so we can see errors when this
70
-        // happen
69
+        // closed from server, a desired behaviour so we can see errors when
70
+        // this happen
71
         this.dataChannelsOpen = false;
71
         this.dataChannelsOpen = false;
72
 
72
 
73
-        // Switch audio output device on all remote audio tracks. Local audio tracks
74
-        // handle this event by themselves.
73
+        // Switch audio output device on all remote audio tracks. Local audio
74
+        // tracks handle this event by themselves.
75
         if (RTCUtils.isDeviceChangeAvailable('output')) {
75
         if (RTCUtils.isDeviceChangeAvailable('output')) {
76
             RTCUtils.addListener(RTCEvents.AUDIO_OUTPUT_DEVICE_CHANGED,
76
             RTCUtils.addListener(RTCEvents.AUDIO_OUTPUT_DEVICE_CHANGED,
77
                 deviceId => {
77
                 deviceId => {
90
      * @param {Object} [options] optional parameters
90
      * @param {Object} [options] optional parameters
91
      * @param {Array} options.devices the devices that will be requested
91
      * @param {Array} options.devices the devices that will be requested
92
      * @param {string} options.resolution resolution constraints
92
      * @param {string} options.resolution resolution constraints
93
-     * @param {bool} options.dontCreateJitsiTrack if <tt>true</tt> objects with the
94
-     * following structure {stream: the Media Stream,
95
-     * type: "audio" or "video", videoType: "camera" or "desktop"}
96
-     * will be returned trough the Promise, otherwise JitsiTrack objects will be
97
-     * returned.
93
+     * @param {bool} options.dontCreateJitsiTrack if <tt>true</tt> objects with
94
+     * the following structure {stream: the Media Stream, type: "audio" or
95
+     * "video", videoType: "camera" or "desktop"} will be returned trough the
96
+     * Promise, otherwise JitsiTrack objects will be returned.
98
      * @param {string} options.cameraDeviceId
97
      * @param {string} options.cameraDeviceId
99
      * @param {string} options.micDeviceId
98
      * @param {string} options.micDeviceId
100
      * @returns {*} Promise object that will receive the new JitsiTracks
99
      * @returns {*} Promise object that will receive the new JitsiTracks
186
      * order to always receive video for this participant (even when last n is
185
      * order to always receive video for this participant (even when last n is
187
      * enabled).
186
      * enabled).
188
      * @param id {string} the user id
187
      * @param id {string} the user id
189
-     * @throws NetworkError or InvalidStateError or Error if the operation fails.
188
+     * @throws NetworkError or InvalidStateError or Error if the operation
189
+     * fails.
190
      */
190
      */
191
     pinEndpoint(id) {
191
     pinEndpoint(id) {
192
         if (this.dataChannels) {
192
         if (this.dataChannels) {
364
     }
364
     }
365
 
365
 
366
     /**
366
     /**
367
-     * Gets JitsiRemoteTrack for AUDIO MediaType associated with given MUC nickname
368
-     * (resource part of the JID).
367
+     * Gets JitsiRemoteTrack for AUDIO MediaType associated with given MUC
368
+     * nickname (resource part of the JID).
369
      * @param resource the resource part of the MUC JID
369
      * @param resource the resource part of the MUC JID
370
      * @returns {JitsiRemoteTrack|null}
370
      * @returns {JitsiRemoteTrack|null}
371
      */
371
      */
374
     }
374
     }
375
 
375
 
376
     /**
376
     /**
377
-     * Gets JitsiRemoteTrack for VIDEO MediaType associated with given MUC nickname
378
-     * (resource part of the JID).
377
+     * Gets JitsiRemoteTrack for VIDEO MediaType associated with given MUC
378
+     * nickname (resource part of the JID).
379
      * @param resource the resource part of the MUC JID
379
      * @param resource the resource part of the MUC JID
380
      * @returns {JitsiRemoteTrack|null}
380
      * @returns {JitsiRemoteTrack|null}
381
      */
381
      */
699
      * matches given SSRC or <tt>undefined</tt> if no such track was found.
699
      * matches given SSRC or <tt>undefined</tt> if no such track was found.
700
      */
700
      */
701
     getRemoteTrackBySSRC(ssrc) {
701
     getRemoteTrackBySSRC(ssrc) {
702
-        return this.getRemoteTracks().find(remoteTrack => ssrc == remoteTrack.getSSRC());
702
+        return this.getRemoteTracks().find(t => ssrc == t.getSSRC());
703
     }
703
     }
704
 
704
 
705
     /**
705
     /**

+ 2
- 1
modules/RTC/RTCBrowserType.js View File

114
      */
114
      */
115
     isTemasysPluginUsed() {
115
     isTemasysPluginUsed() {
116
         // Temasys do not support Microsoft Edge:
116
         // Temasys do not support Microsoft Edge:
117
-        // http://support.temasys.com.sg/support/solutions/articles/5000654345-can-the-temasys-webrtc-plugin-be-used-with-microsoft-edge-
117
+        // http://support.temasys.com.sg/support/solutions/articles/
118
+        // 5000654345-can-the-temasys-webrtc-plugin-be-used-with-microsoft-edge-
118
         if (RTCBrowserType.isIExplorer()
119
         if (RTCBrowserType.isIExplorer()
119
                 && RTCBrowserType.getIExplorerVersion() < 12) {
120
                 && RTCBrowserType.getIExplorerVersion() < 12) {
120
             return true;
121
             return true;

+ 112
- 76
modules/RTC/RTCUtils.js View File

193
             // for some cameras it might be necessary to request 30fps
193
             // for some cameras it might be necessary to request 30fps
194
             // so they choose 30fps mjpg over 10fps yuy2
194
             // so they choose 30fps mjpg over 10fps yuy2
195
             if (options.minFps || options.fps) {
195
             if (options.minFps || options.fps) {
196
-                options.minFps = options.minFps || options.fps; // Fall back to options.fps for backwards compatibility
196
+                // Fall back to options.fps for backwards compatibility
197
+                options.minFps = options.minFps || options.fps;
197
                 constraints.video.mandatory.minFrameRate = options.minFps;
198
                 constraints.video.mandatory.minFrameRate = options.minFps;
198
             }
199
             }
199
             if (options.maxFps) {
200
             if (options.maxFps) {
303
         constraints.video.optional.push({ bandwidth: options.bandwidth });
304
         constraints.video.optional.push({ bandwidth: options.bandwidth });
304
     }
305
     }
305
 
306
 
306
-    // we turn audio for both audio and video tracks, the fake audio & video seems to work
307
-    // only when enabled in one getUserMedia call, we cannot get fake audio separate by fake video
308
-    // this later can be a problem with some of the tests
307
+    // we turn audio for both audio and video tracks, the fake audio & video
308
+    // seems to work only when enabled in one getUserMedia call, we cannot get
309
+    // fake audio separate by fake video this later can be a problem with some
310
+    // of the tests
309
     if (RTCBrowserType.isFirefox() && options.firefox_fake_device) {
311
     if (RTCBrowserType.isFirefox() && options.firefox_fake_device) {
310
         // seems to be fixed now, removing this experimental fix, as having
312
         // seems to be fixed now, removing this experimental fix, as having
311
         // multiple audio tracks brake the tests
313
         // multiple audio tracks brake the tests
401
  */
403
  */
402
 function onMediaDevicesListChanged(devicesReceived) {
404
 function onMediaDevicesListChanged(devicesReceived) {
403
     currentlyAvailableMediaDevices = devicesReceived.slice(0);
405
     currentlyAvailableMediaDevices = devicesReceived.slice(0);
404
-    logger.info('list of media devices has changed:', currentlyAvailableMediaDevices);
406
+    logger.info(
407
+        'list of media devices has changed:',
408
+        currentlyAvailableMediaDevices);
405
 
409
 
406
     const videoInputDevices
410
     const videoInputDevices
407
         = currentlyAvailableMediaDevices.filter(d => d.kind === 'videoinput');
411
         = currentlyAvailableMediaDevices.filter(d => d.kind === 'videoinput');
413
         = audioInputDevices.filter(d => d.label === '');
417
         = audioInputDevices.filter(d => d.label === '');
414
 
418
 
415
     if (videoInputDevices.length
419
     if (videoInputDevices.length
416
-        && videoInputDevices.length === videoInputDevicesWithEmptyLabels.length) {
420
+            && videoInputDevices.length
421
+                === videoInputDevicesWithEmptyLabels.length) {
417
         devices.video = false;
422
         devices.video = false;
418
     }
423
     }
419
 
424
 
420
     if (audioInputDevices.length
425
     if (audioInputDevices.length
421
-        && audioInputDevices.length === audioInputDevicesWithEmptyLabels.length) {
426
+            && audioInputDevices.length
427
+                === audioInputDevicesWithEmptyLabels.length) {
422
         devices.audio = false;
428
         devices.audio = false;
423
     }
429
     }
424
 
430
 
682
                 && audioOutputChanged) {
688
                 && audioOutputChanged) {
683
             element.setSinkId(rtcUtils.getAudioOutputDevice())
689
             element.setSinkId(rtcUtils.getAudioOutputDevice())
684
                 .catch(function(ex) {
690
                 .catch(function(ex) {
685
-                    const err = new JitsiTrackError(ex, null, [ 'audiooutput' ]);
691
+                    const err
692
+                        = new JitsiTrackError(ex, null, [ 'audiooutput' ]);
686
 
693
 
687
                     GlobalOnErrorHandler.callUnhandledRejectionHandler(
694
                     GlobalOnErrorHandler.callUnhandledRejectionHandler(
688
                         { promise: this,
695
                         { promise: this,
780
                     return;
787
                     return;
781
                 }
788
                 }
782
                 this.peerconnection = mozRTCPeerConnection;
789
                 this.peerconnection = mozRTCPeerConnection;
783
-                this.getUserMedia = wrapGetUserMedia(navigator.mozGetUserMedia.bind(navigator));
784
-                this.enumerateDevices = wrapEnumerateDevices(
785
-                    navigator.mediaDevices.enumerateDevices.bind(navigator.mediaDevices)
786
-                );
790
+                this.getUserMedia
791
+                    = wrapGetUserMedia(
792
+                        navigator.mozGetUserMedia.bind(navigator));
793
+                this.enumerateDevices
794
+                    = wrapEnumerateDevices(
795
+                        navigator.mediaDevices.enumerateDevices.bind(
796
+                            navigator.mediaDevices));
787
                 this.pc_constraints = {};
797
                 this.pc_constraints = {};
788
-                this.attachMediaStream = wrapAttachMediaStream((element, stream) => {
789
-                    //  srcObject is being standardized and FF will eventually
790
-                    //  support that unprefixed. FF also supports the
791
-                    //  "element.src = URL.createObjectURL(...)" combo, but that
792
-                    //  will be deprecated in favour of srcObject.
793
-                    //
794
-                    // https://groups.google.com/forum/#!topic/mozilla.dev.media/pKOiioXonJg
795
-                    // https://github.com/webrtc/samples/issues/302
796
-                    if (element) {
797
-                        defaultSetVideoSrc(element, stream);
798
-                        if (stream) {
799
-                            element.play();
798
+                this.attachMediaStream
799
+                    = wrapAttachMediaStream((element, stream) => {
800
+                        // srcObject is being standardized and FF will
801
+                        // eventually support that unprefixed. FF also supports
802
+                        // the "element.src = URL.createObjectURL(...)" combo,
803
+                        // but that will be deprecated in favour of srcObject.
804
+                        //
805
+                        // https://groups.google.com/forum/#!topic/
806
+                        // mozilla.dev.media/pKOiioXonJg
807
+                        // https://github.com/webrtc/samples/issues/302
808
+                        if (element) {
809
+                            defaultSetVideoSrc(element, stream);
810
+                            if (stream) {
811
+                                element.play();
812
+                            }
800
                         }
813
                         }
801
-                    }
802
 
814
 
803
-                    return element;
804
-                });
815
+                        return element;
816
+                    });
805
                 this.getStreamID = function(stream) {
817
                 this.getStreamID = function(stream) {
806
                     let id = stream.id;
818
                     let id = stream.id;
807
 
819
 
816
 
828
 
817
                     return SDPUtil.filter_special_chars(id);
829
                     return SDPUtil.filter_special_chars(id);
818
                 };
830
                 };
819
-                RTCSessionDescription = mozRTCSessionDescription; // eslint-disable-line
820
-                RTCIceCandidate = mozRTCIceCandidate;             // eslint-disable-line
831
+
832
+                /* eslint-disable no-global-assign, no-native-reassign */
833
+
834
+                RTCSessionDescription = mozRTCSessionDescription;
835
+                RTCIceCandidate = mozRTCIceCandidate;
836
+
837
+                /* eslint-enable no-global-assign, no-native-reassign */
821
             } else if (RTCBrowserType.isChrome()
838
             } else if (RTCBrowserType.isChrome()
822
                     || RTCBrowserType.isOpera()
839
                     || RTCBrowserType.isOpera()
823
                     || RTCBrowserType.isNWJS()
840
                     || RTCBrowserType.isNWJS()
825
                     || RTCBrowserType.isReactNative()) {
842
                     || RTCBrowserType.isReactNative()) {
826
 
843
 
827
                 this.peerconnection = webkitRTCPeerConnection;
844
                 this.peerconnection = webkitRTCPeerConnection;
828
-                const getUserMedia = navigator.webkitGetUserMedia.bind(navigator);
845
+                const getUserMedia
846
+                    = navigator.webkitGetUserMedia.bind(navigator);
829
 
847
 
830
                 if (navigator.mediaDevices) {
848
                 if (navigator.mediaDevices) {
831
                     this.getUserMedia = wrapGetUserMedia(getUserMedia);
849
                     this.getUserMedia = wrapGetUserMedia(getUserMedia);
832
-                    this.enumerateDevices = wrapEnumerateDevices(
833
-                        navigator.mediaDevices.enumerateDevices.bind(navigator.mediaDevices)
834
-                    );
850
+                    this.enumerateDevices
851
+                        = wrapEnumerateDevices(
852
+                            navigator.mediaDevices.enumerateDevices.bind(
853
+                                navigator.mediaDevices));
835
                 } else {
854
                 } else {
836
                     this.getUserMedia = getUserMedia;
855
                     this.getUserMedia = getUserMedia;
837
-                    this.enumerateDevices = enumerateDevicesThroughMediaStreamTrack;
856
+                    this.enumerateDevices
857
+                      = enumerateDevicesThroughMediaStreamTrack;
838
                 }
858
                 }
839
-                this.attachMediaStream = wrapAttachMediaStream((element, stream) => {
840
-                    defaultSetVideoSrc(element, stream);
859
+                this.attachMediaStream
860
+                    = wrapAttachMediaStream((element, stream) => {
861
+                        defaultSetVideoSrc(element, stream);
841
 
862
 
842
-                    return element;
843
-                });
863
+                        return element;
864
+                    });
844
                 this.getStreamID = function(stream) {
865
                 this.getStreamID = function(stream) {
845
                     // A. MediaStreams from FF endpoints have the characters '{'
866
                     // A. MediaStreams from FF endpoints have the characters '{'
846
                     // and '}' that make jQuery choke.
867
                     // and '}' that make jQuery choke.
889
                 const webRTCReadyCb = () => {
910
                 const webRTCReadyCb = () => {
890
                     this.peerconnection = RTCPeerConnection;
911
                     this.peerconnection = RTCPeerConnection;
891
                     this.getUserMedia = window.getUserMedia;
912
                     this.getUserMedia = window.getUserMedia;
892
-                    this.enumerateDevices = enumerateDevicesThroughMediaStreamTrack;
893
-                    this.attachMediaStream = wrapAttachMediaStream((element, stream) => {
894
-                        if (stream) {
895
-                            if (stream.id === 'dummyAudio'
896
-                                    || stream.id === 'dummyVideo') {
897
-                                return;
898
-                            }
913
+                    this.enumerateDevices
914
+                        = enumerateDevicesThroughMediaStreamTrack;
915
+                    this.attachMediaStream
916
+                        = wrapAttachMediaStream((element, stream) => {
917
+                            if (stream) {
918
+                                if (stream.id === 'dummyAudio'
919
+                                        || stream.id === 'dummyVideo') {
920
+                                    return;
921
+                                }
899
 
922
 
900
-                            // The container must be visible in order to play or
901
-                            // attach the stream when Temasys plugin is in use
902
-                            const containerSel = $(element);
923
+                                // The container must be visible in order to
924
+                                // play or attach the stream when Temasys plugin
925
+                                // is in use
926
+                                const containerSel = $(element);
903
 
927
 
904
-                            if (RTCBrowserType.isTemasysPluginUsed()
905
-                                    && !containerSel.is(':visible')) {
906
-                                containerSel.show();
907
-                            }
908
-                            const video = stream.getVideoTracks().length > 0;
928
+                                if (RTCBrowserType.isTemasysPluginUsed()
929
+                                        && !containerSel.is(':visible')) {
930
+                                    containerSel.show();
931
+                                }
932
+                                const video
933
+                                    = stream.getVideoTracks().length > 0;
909
 
934
 
910
-                            if (video && !$(element).is(':visible')) {
911
-                                throw new Error(
912
-                                    'video element must be visible to attach'
913
-                                        + ' video stream');
935
+                                if (video && !$(element).is(':visible')) {
936
+                                    throw new Error(
937
+                                        'video element must be visible to'
938
+                                            + ' attach video stream');
939
+                                }
914
                             }
940
                             }
915
-                        }
916
 
941
 
917
-                        return attachMediaStream(element, stream);
918
-                    });
942
+                            return attachMediaStream(element, stream);
943
+                        });
919
                     this.getStreamID
944
                     this.getStreamID
920
                         = stream => SDPUtil.filter_special_chars(stream.label);
945
                         = stream => SDPUtil.filter_special_chars(stream.label);
921
 
946
 
975
     * @param {string} options.cameraDeviceId
1000
     * @param {string} options.cameraDeviceId
976
     * @param {string} options.micDeviceId
1001
     * @param {string} options.micDeviceId
977
     **/
1002
     **/
978
-    getUserMediaWithConstraints(um, success_callback, failure_callback, options) {
1003
+    getUserMediaWithConstraints(
1004
+            um,
1005
+            success_callback,
1006
+            failure_callback,
1007
+            options) {
979
         options = options || {};
1008
         options = options || {};
980
         const constraints = getConstraints(um, options);
1009
         const constraints = getConstraints(um, options);
981
 
1010
 
1013
      * @param {Object} [options] optional parameters
1042
      * @param {Object} [options] optional parameters
1014
      * @param {Array} options.devices the devices that will be requested
1043
      * @param {Array} options.devices the devices that will be requested
1015
      * @param {string} options.resolution resolution constraints
1044
      * @param {string} options.resolution resolution constraints
1016
-     * @param {bool} options.dontCreateJitsiTrack if <tt>true</tt> objects with the following structure {stream: the Media Stream,
1017
-     * type: "audio" or "video", videoType: "camera" or "desktop"}
1018
-     * will be returned trough the Promise, otherwise JitsiTrack objects will be returned.
1045
+     * @param {bool} options.dontCreateJitsiTrack if <tt>true</tt> objects with
1046
+     * the following structure {stream: the Media Stream, type: "audio" or
1047
+     * "video", videoType: "camera" or "desktop"} will be returned trough the
1048
+     * Promise, otherwise JitsiTrack objects will be returned.
1019
      * @param {string} options.cameraDeviceId
1049
      * @param {string} options.cameraDeviceId
1020
      * @param {string} options.micDeviceId
1050
      * @param {string} options.micDeviceId
1021
      * @returns {*} Promise object that will receive the new JitsiTracks
1051
      * @returns {*} Promise object that will receive the new JitsiTracks
1062
                         dsOptions);
1092
                         dsOptions);
1063
                 }
1093
                 }
1064
 
1094
 
1065
-                // With FF/IE we can't split the stream into audio and video because FF
1066
-                // doesn't support media stream constructors. So, we need to get the
1067
-                // audio stream separately from the video stream using two distinct GUM
1068
-                // calls. Not very user friendly :-( but we don't have many other
1069
-                // options neither.
1095
+                // With FF/IE we can't split the stream into audio and video
1096
+                // because FF doesn't support media stream constructors. So, we
1097
+                // need to get the audio stream separately from the video stream
1098
+                // using two distinct GUM calls. Not very user friendly :-( but
1099
+                // we don't have many other options neither.
1070
                 //
1100
                 //
1071
-                // Note that we pack those 2 streams in a single object and pass it to
1072
-                // the successCallback method.
1101
+                // Note that we pack those 2 streams in a single object and pass
1102
+                // it to the successCallback method.
1073
                 obtainDevices({
1103
                 obtainDevices({
1074
                     devices: options.devices,
1104
                     devices: options.devices,
1075
                     streams: [],
1105
                     streams: [],
1081
                 const hasDesktop = options.devices.indexOf('desktop') > -1;
1111
                 const hasDesktop = options.devices.indexOf('desktop') > -1;
1082
 
1112
 
1083
                 if (hasDesktop) {
1113
                 if (hasDesktop) {
1084
-                    options.devices.splice(options.devices.indexOf('desktop'), 1);
1114
+                    options.devices.splice(
1115
+                        options.devices.indexOf('desktop'),
1116
+                        1);
1085
                 }
1117
                 }
1086
                 options.resolution = options.resolution || '360';
1118
                 options.resolution = options.resolution || '360';
1087
                 if (options.devices.length) {
1119
                 if (options.devices.length) {
1098
                                 = stream.getVideoTracks().length > 0;
1130
                                 = stream.getVideoTracks().length > 0;
1099
 
1131
 
1100
                             if ((audioDeviceRequested && !audioTracksReceived)
1132
                             if ((audioDeviceRequested && !audioTracksReceived)
1101
-                                || (videoDeviceRequested && !videoTracksReceived)) {
1133
+                                    || (videoDeviceRequested
1134
+                                        && !videoTracksReceived)) {
1102
                                 self.stopMediaStream(stream);
1135
                                 self.stopMediaStream(stream);
1103
 
1136
 
1104
                                 // We are getting here in case if we requested
1137
                                 // We are getting here in case if we requested
1108
                                 // this happened, so reject with general error.
1141
                                 // this happened, so reject with general error.
1109
                                 const devices = [];
1142
                                 const devices = [];
1110
 
1143
 
1111
-                                if (audioDeviceRequested && !audioTracksReceived) {
1144
+                                if (audioDeviceRequested
1145
+                                        && !audioTracksReceived) {
1112
                                     devices.push('audio');
1146
                                     devices.push('audio');
1113
                                 }
1147
                                 }
1114
 
1148
 
1115
-                                if (videoDeviceRequested && !videoTracksReceived) {
1149
+                                if (videoDeviceRequested
1150
+                                        && !videoTracksReceived) {
1116
                                     devices.push('video');
1151
                                     devices.push('video');
1117
                                 }
1152
                                 }
1118
 
1153
 
1135
                                         reject(new JitsiTrackError(
1170
                                         reject(new JitsiTrackError(
1136
                                             { name: 'UnknownError' },
1171
                                             { name: 'UnknownError' },
1137
                                             getConstraints(
1172
                                             getConstraints(
1138
-                                                options.devices, options),
1173
+                                                options.devices,
1174
+                                                options),
1139
                                             devices)
1175
                                             devices)
1140
                                         );
1176
                                         );
1141
                                     },
1177
                                     },

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

228
 TraceablePeerConnection.prototype._remoteStreamAdded = function(stream) {
228
 TraceablePeerConnection.prototype._remoteStreamAdded = function(stream) {
229
     if (!RTC.isUserStream(stream)) {
229
     if (!RTC.isUserStream(stream)) {
230
         logger.info(
230
         logger.info(
231
-            'Ignored remote \'stream added\' event for non-user stream', stream);
231
+            'Ignored remote \'stream added\' event for non-user stream',
232
+            stream);
232
 
233
 
233
         return;
234
         return;
234
     }
235
     }
545
     const session = transform.parse(desc.sdp);
546
     const session = transform.parse(desc.sdp);
546
 
547
 
547
     if (typeof session !== 'undefined'
548
     if (typeof session !== 'undefined'
548
-        && typeof session.media !== 'undefined' && Array.isArray(session.media)) {
549
+            && typeof session.media !== 'undefined'
550
+            && Array.isArray(session.media)) {
549
         session.media.forEach(mLine => {
551
         session.media.forEach(mLine => {
550
 
552
 
551
             // Chrome appears to be picky about the order in which a=ssrc lines
553
             // Chrome appears to be picky about the order in which a=ssrc lines
696
 
698
 
697
 TraceablePeerConnection.prototype.setLocalDescription
699
 TraceablePeerConnection.prototype.setLocalDescription
698
         = function(description, successCallback, failureCallback) {
700
         = function(description, successCallback, failureCallback) {
699
-            this.trace('setLocalDescription::preTransform', dumpSDP(description));
701
+            this.trace(
702
+                'setLocalDescription::preTransform',
703
+                dumpSDP(description));
700
 
704
 
701
-    // if we're running on FF, transform to Plan A first.
705
+            // if we're running on FF, transform to Plan A first.
702
             if (RTCBrowserType.usesUnifiedPlan()) {
706
             if (RTCBrowserType.usesUnifiedPlan()) {
703
                 description = this.interop.toUnifiedPlan(description);
707
                 description = this.interop.toUnifiedPlan(description);
704
                 this.trace('setLocalDescription::postTransform (Plan A)',
708
                 this.trace('setLocalDescription::postTransform (Plan A)',
724
 
728
 
725
 TraceablePeerConnection.prototype.setRemoteDescription
729
 TraceablePeerConnection.prototype.setRemoteDescription
726
         = function(description, successCallback, failureCallback) {
730
         = function(description, successCallback, failureCallback) {
727
-            this.trace('setRemoteDescription::preTransform', dumpSDP(description));
731
+            this.trace(
732
+                'setRemoteDescription::preTransform',
733
+                dumpSDP(description));
728
 
734
 
729
-    // TODO the focus should squeze or explode the remote simulcast
735
+            // TODO the focus should squeze or explode the remote simulcast
730
             description = this.simulcast.mungeRemoteDescription(description);
736
             description = this.simulcast.mungeRemoteDescription(description);
731
             this.trace(
737
             this.trace(
732
-        'setRemoteDescription::postTransform (simulcast)',
733
-        dumpSDP(description));
738
+                'setRemoteDescription::postTransform (simulcast)',
739
+                dumpSDP(description));
734
 
740
 
735
             if (this.options.preferH264) {
741
             if (this.options.preferH264) {
736
                 const parsedSdp = transform.parse(description.sdp);
742
                 const parsedSdp = transform.parse(description.sdp);
737
-                const videoMLine = parsedSdp.media.find(m => m.type === 'video');
743
+                const videoMLine
744
+                    = parsedSdp.media.find(m => m.type === 'video');
738
 
745
 
739
                 SDPUtil.preferVideoCodec(videoMLine, 'h264');
746
                 SDPUtil.preferVideoCodec(videoMLine, 'h264');
740
                 description.sdp = transform.write(parsedSdp);
747
                 description.sdp = transform.write(parsedSdp);
741
             }
748
             }
742
 
749
 
743
-    // if we're running on FF, transform to Plan A first.
750
+            // if we're running on FF, transform to Plan A first.
744
             if (RTCBrowserType.usesUnifiedPlan()) {
751
             if (RTCBrowserType.usesUnifiedPlan()) {
745
                 description.sdp = this.rtxModifier.stripRtx(description.sdp);
752
                 description.sdp = this.rtxModifier.stripRtx(description.sdp);
746
-                this.trace('setRemoteDescription::postTransform (stripRtx)', dumpSDP(description));
753
+                this.trace(
754
+                    'setRemoteDescription::postTransform (stripRtx)',
755
+                    dumpSDP(description));
747
                 description = this.interop.toUnifiedPlan(description);
756
                 description = this.interop.toUnifiedPlan(description);
748
                 this.trace(
757
                 this.trace(
749
             'setRemoteDescription::postTransform (Plan A)',
758
             'setRemoteDescription::postTransform (Plan A)',
900
                         = this.sdpConsistency.makeVideoPrimarySsrcsConsistent(
909
                         = this.sdpConsistency.makeVideoPrimarySsrcsConsistent(
901
                             answer.sdp);
910
                             answer.sdp);
902
                     this.trace(
911
                     this.trace(
903
-                        'createAnswerOnSuccess::postTransform (make primary video ssrcs consistent)',
912
+                        'createAnswerOnSuccess::postTransform (make primary'
913
+                          + ' video ssrcs consistent)',
904
                         dumpSDP(answer));
914
                         dumpSDP(answer));
905
                 }
915
                 }
906
 
916
 

+ 4
- 2
modules/statistics/RTPStatsCollector.js View File

66
  * @returns {number} packet loss percent
66
  * @returns {number} packet loss percent
67
  */
67
  */
68
 function calculatePacketLoss(lostPackets, totalPackets) {
68
 function calculatePacketLoss(lostPackets, totalPackets) {
69
-    if (!totalPackets || totalPackets <= 0 || !lostPackets || lostPackets <= 0) {
69
+    if (!totalPackets || totalPackets <= 0
70
+            || !lostPackets || lostPackets <= 0) {
70
         return 0;
71
         return 0;
71
     }
72
     }
72
 
73
 
517
 
518
 
518
         const bytesReceivedNow = getNonNegativeStat(now, 'bytesReceived');
519
         const bytesReceivedNow = getNonNegativeStat(now, 'bytesReceived');
519
         const bytesReceivedBefore = getNonNegativeStat(before, 'bytesReceived');
520
         const bytesReceivedBefore = getNonNegativeStat(before, 'bytesReceived');
520
-        const bytesReceived = Math.max(0, bytesReceivedNow - bytesReceivedBefore);
521
+        const bytesReceived
522
+            = Math.max(0, bytesReceivedNow - bytesReceivedBefore);
521
 
523
 
522
         let bytesSent = 0;
524
         let bytesSent = 0;
523
 
525
 

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

168
 };
168
 };
169
 
169
 
170
 Statistics.prototype.removeConnectionStatsListener = function(listener) {
170
 Statistics.prototype.removeConnectionStatsListener = function(listener) {
171
-    this.eventEmitter.removeListener(StatisticsEvents.CONNECTION_STATS, listener);
171
+    this.eventEmitter.removeListener(
172
+        StatisticsEvents.CONNECTION_STATS,
173
+        listener);
172
 };
174
 };
173
 
175
 
174
 Statistics.prototype.addByteSentStatsListener = function(listener) {
176
 Statistics.prototype.addByteSentStatsListener = function(listener) {

+ 137
- 68
modules/xmpp/ChatRoom.js View File

93
         this.focusMucJid = null;
93
         this.focusMucJid = null;
94
         this.noBridgeAvailable = false;
94
         this.noBridgeAvailable = false;
95
         this.options = options || {};
95
         this.options = options || {};
96
-        this.moderator = new Moderator(this.roomjid, this.xmpp, this.eventEmitter,
97
-            { connection: this.xmpp.options,
98
-                conference: this.options });
96
+        this.moderator
97
+            = new Moderator(this.roomjid, this.xmpp, this.eventEmitter, {
98
+                connection: this.xmpp.options,
99
+                conference: this.options
100
+            });
99
         this.initPresenceMap();
101
         this.initPresenceMap();
100
         this.lastPresences = {};
102
         this.lastPresences = {};
101
         this.phoneNumber = null;
103
         this.phoneNumber = null;
116
             'attributes': { xmlns: 'http://jitsi.org/jitmeet/user-agent' }
118
             'attributes': { xmlns: 'http://jitsi.org/jitmeet/user-agent' }
117
         });
119
         });
118
 
120
 
119
-        // We need to broadcast 'videomuted' status from the beginning, cause Jicofo
120
-        // makes decisions based on that. Initialize it with 'false' here.
121
+        // We need to broadcast 'videomuted' status from the beginning, cause
122
+        // Jicofo makes decisions based on that. Initialize it with 'false'
123
+        // here.
121
         this.addVideoInfoToPresence(false);
124
         this.addVideoInfoToPresence(false);
122
     }
125
     }
123
 
126
 
153
         const pres = $pres({ to });
156
         const pres = $pres({ to });
154
 
157
 
155
         // xep-0045 defines: "including in the initial presence stanza an empty
158
         // xep-0045 defines: "including in the initial presence stanza an empty
156
-        // <x/> element qualified by the 'http://jabber.org/protocol/muc' namespace"
157
-        // and subsequent presences should not include that or it can be considered
158
-        // as joining, and server can send us the message history for the room on
159
-        // every presence
159
+        // <x/> element qualified by the 'http://jabber.org/protocol/muc'
160
+        // namespace" and subsequent presences should not include that or it can
161
+        // be considered as joining, and server can send us the message history
162
+        // for the room on every presence
160
         if (fromJoin) {
163
         if (fromJoin) {
161
             pres.c('x', { xmlns: this.presMap.xns });
164
             pres.c('x', { xmlns: this.presMap.xns });
162
 
165
 
171
         if (fromJoin) {
174
         if (fromJoin) {
172
             // XXX We're pressed for time here because we're beginning a complex
175
             // XXX We're pressed for time here because we're beginning a complex
173
             // and/or lengthy conference-establishment process which supposedly
176
             // and/or lengthy conference-establishment process which supposedly
174
-            // involves multiple RTTs. We don't have the time to wait for Strophe to
175
-            // decide to send our IQ.
177
+            // involves multiple RTTs. We don't have the time to wait for
178
+            // Strophe to decide to send our IQ.
176
             this.connection.flush();
179
             this.connection.flush();
177
         }
180
         }
178
     }
181
     }
189
         this.presMap.length = 0;
192
         this.presMap.length = 0;
190
 
193
 
191
         // XXX Strophe is asynchronously sending by default. Unfortunately, that
194
         // XXX Strophe is asynchronously sending by default. Unfortunately, that
192
-        // means that there may not be enough time to send the unavailable presence.
193
-        // Switching Strophe to synchronous sending is not much of an option because
194
-        // it may lead to a noticeable delay in navigating away from the current
195
-        // location. As a compromise, we will try to increase the chances of sending
196
-        // the unavailable presence within the short time span that we have upon
197
-        // unloading by invoking flush() on the connection. We flush() once before
198
-        // sending/queuing the unavailable presence in order to attemtp to have the
199
-        // unavailable presence at the top of the send queue. We flush() once more
200
-        // after sending/queuing the unavailable presence in order to attempt to
201
-        // have it sent as soon as possible.
195
+        // means that there may not be enough time to send the unavailable
196
+        // presence. Switching Strophe to synchronous sending is not much of an
197
+        // option because it may lead to a noticeable delay in navigating away
198
+        // from the current location. As a compromise, we will try to increase
199
+        // the chances of sending the unavailable presence within the short time
200
+        // span that we have upon unloading by invoking flush() on the
201
+        // connection. We flush() once before sending/queuing the unavailable
202
+        // presence in order to attemtp to have the unavailable presence at the
203
+        // top of the send queue. We flush() once more after sending/queuing the
204
+        // unavailable presence in order to attempt to have it sent as soon as
205
+        // possible.
202
         this.connection.flush();
206
         this.connection.flush();
203
         this.connection.send(pres);
207
         this.connection.send(pres);
204
         this.connection.flush();
208
         this.connection.flush();
323
         }
327
         }
324
 
328
 
325
         if (from == this.myroomjid) {
329
         if (from == this.myroomjid) {
326
-            const newRole = member.affiliation == 'owner' ? member.role : 'none';
330
+            const newRole
331
+                = member.affiliation == 'owner' ? member.role : 'none';
327
 
332
 
328
             if (this.role !== newRole) {
333
             if (this.role !== newRole) {
329
                 this.role = newRole;
334
                 this.role = newRole;
330
-                this.eventEmitter.emit(XMPPEvents.LOCAL_ROLE_CHANGED, this.role);
335
+                this.eventEmitter.emit(
336
+                    XMPPEvents.LOCAL_ROLE_CHANGED,
337
+                    this.role);
331
             }
338
             }
332
             if (!this.joined) {
339
             if (!this.joined) {
333
                 this.joined = true;
340
                 this.joined = true;
367
 
374
 
368
             if (member.isFocus) {
375
             if (member.isFocus) {
369
                 // From time to time first few presences of the focus are not
376
                 // From time to time first few presences of the focus are not
370
-                // containing it's jid. That way we can mark later the focus member
371
-                // instead of not marking it at all and not starting the conference.
372
-                // FIXME: Maybe there is a better way to handle this issue. It seems
373
-                // there is some period of time in prosody that the configuration
374
-                // form is received but not applied. And if any participant joins
375
-                // during that period of time the first presence from the focus
376
-                // won't conain <item jid="focus..." />.
377
+                // containing it's jid. That way we can mark later the focus
378
+                // member instead of not marking it at all and not starting the
379
+                // conference.
380
+                // FIXME: Maybe there is a better way to handle this issue. It
381
+                // seems there is some period of time in prosody that the
382
+                // configuration form is received but not applied. And if any
383
+                // participant joins during that period of time the first
384
+                // presence from the focus won't conain <item jid="focus..." />.
377
                 memberOfThis.isFocus = true;
385
                 memberOfThis.isFocus = true;
378
                 this._initFocus(from, jid);
386
                 this._initFocus(from, jid);
379
             }
387
             }
397
 
405
 
398
                     if (displayName && displayName.length > 0) {
406
                     if (displayName && displayName.length > 0) {
399
                         this.eventEmitter.emit(
407
                         this.eventEmitter.emit(
400
-                                XMPPEvents.DISPLAY_NAME_CHANGED, from, displayName);
408
+                            XMPPEvents.DISPLAY_NAME_CHANGED,
409
+                            from,
410
+                            displayName);
401
                     }
411
                     }
402
                 }
412
                 }
403
                 break;
413
                 break;
461
     }
471
     }
462
 
472
 
463
     /**
473
     /**
464
-     * Sets the special listener to be used for "command"s whose name starts with
465
-     * "jitsi_participant_".
474
+     * Sets the special listener to be used for "command"s whose name starts
475
+     * with "jitsi_participant_".
466
      */
476
      */
467
     setParticipantPropertyListener(listener) {
477
     setParticipantPropertyListener(listener) {
468
         this.participantPropertyListener = listener;
478
         this.participantPropertyListener = listener;
493
 
503
 
494
         msg.c('body', body).up();
504
         msg.c('body', body).up();
495
         if (nickname) {
505
         if (nickname) {
496
-            msg.c('nick', { xmlns: 'http://jabber.org/protocol/nick' }).t(nickname).up().up();
506
+            msg.c('nick', { xmlns: 'http://jabber.org/protocol/nick' })
507
+                .t(nickname)
508
+                .up()
509
+                .up();
497
         }
510
         }
498
         this.connection.send(msg);
511
         this.connection.send(msg);
499
         this.eventEmitter.emit(XMPPEvents.SENDING_CHAT_MESSAGE, body);
512
         this.eventEmitter.emit(XMPPEvents.SENDING_CHAT_MESSAGE, body);
548
         }
561
         }
549
 
562
 
550
         // Status code 110 indicates that this notification is "self-presence".
563
         // Status code 110 indicates that this notification is "self-presence".
551
-        const isSelfPresence = $(pres).find(
552
-                '>x[xmlns="http://jabber.org/protocol/muc#user"]>status[code="110"]'
553
-            ).length !== 0;
554
-        const isKick = $(pres).find(
555
-                '>x[xmlns="http://jabber.org/protocol/muc#user"]>status[code="307"]'
556
-            ).length !== 0;
564
+        const isSelfPresence
565
+            = $(pres)
566
+                    .find(
567
+                        '>x[xmlns="http://jabber.org/protocol/muc#user"]>'
568
+                            + 'status[code="110"]')
569
+                    .length
570
+                !== 0;
571
+        const isKick
572
+            = $(pres)
573
+                    .find(
574
+                        '>x[xmlns="http://jabber.org/protocol/muc#user"]'
575
+                            + '>status[code="307"]')
576
+                    .length
577
+                !== 0;
557
         const membersKeys = Object.keys(this.members);
578
         const membersKeys = Object.keys(this.members);
558
 
579
 
559
         if (!isSelfPresence) {
580
         if (!isSelfPresence) {
620
 
641
 
621
             if (stamp) {
642
             if (stamp) {
622
                 // the format is CCYYMMDDThh:mm:ss
643
                 // the format is CCYYMMDDThh:mm:ss
623
-                const dateParts = stamp.match(/(\d{4})(\d{2})(\d{2}T\d{2}:\d{2}:\d{2})/);
644
+                const dateParts
645
+                    = stamp.match(/(\d{4})(\d{2})(\d{2}T\d{2}:\d{2}:\d{2})/);
624
 
646
 
625
                 stamp = `${dateParts[1]}-${dateParts[2]}-${dateParts[3]}Z`;
647
                 stamp = `${dateParts[1]}-${dateParts[2]}-${dateParts[3]}Z`;
626
             }
648
             }
627
         }
649
         }
628
 
650
 
629
-        if (from == this.roomjid && $(msg).find('>x[xmlns="http://jabber.org/protocol/muc#user"]>status[code="104"]').length) {
651
+        if (from == this.roomjid
652
+                && $(msg)
653
+                    .find(
654
+                        '>x[xmlns="http://jabber.org/protocol/muc#user"]'
655
+                            + '>status[code="104"]')
656
+                    .length) {
630
             this.discoRoomInfo();
657
             this.discoRoomInfo();
631
         }
658
         }
632
 
659
 
638
     }
665
     }
639
 
666
 
640
     onPresenceError(pres, from) {
667
     onPresenceError(pres, from) {
641
-        if ($(pres).find('>error[type="auth"]>not-authorized[xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"]').length) {
668
+        if ($(pres)
669
+                .find(
670
+                    '>error[type="auth"]'
671
+                        + '>not-authorized['
672
+                        + 'xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"]')
673
+                .length) {
642
             logger.log('on password required', from);
674
             logger.log('on password required', from);
643
             this.eventEmitter.emit(XMPPEvents.PASSWORD_REQUIRED);
675
             this.eventEmitter.emit(XMPPEvents.PASSWORD_REQUIRED);
644
-        } else if ($(pres).find(
645
-            '>error[type="cancel"]>not-allowed[xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"]').length) {
676
+        } else if ($(pres)
677
+                .find(
678
+                    '>error[type="cancel"]'
679
+                        + '>not-allowed['
680
+                        + 'xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"]')
681
+                .length) {
646
             const toDomain = Strophe.getDomainFromJid(pres.getAttribute('to'));
682
             const toDomain = Strophe.getDomainFromJid(pres.getAttribute('to'));
647
 
683
 
648
             if (toDomain === this.xmpp.options.hosts.anonymousdomain) {
684
             if (toDomain === this.xmpp.options.hosts.anonymousdomain) {
654
 
690
 
655
             } else {
691
             } else {
656
                 logger.warn('onPresError ', pres);
692
                 logger.warn('onPresError ', pres);
657
-                this.eventEmitter.emit(XMPPEvents.ROOM_CONNECT_NOT_ALLOWED_ERROR);
693
+                this.eventEmitter.emit(
694
+                    XMPPEvents.ROOM_CONNECT_NOT_ALLOWED_ERROR);
658
             }
695
             }
659
         } else if ($(pres).find('>error>service-unavailable').length) {
696
         } else if ($(pres).find('>error>service-unavailable').length) {
660
             logger.warn('Maximum users limit for the room has been reached',
697
             logger.warn('Maximum users limit for the room has been reached',
683
     lockRoom(key, onSuccess, onError, onNotSupported) {
720
     lockRoom(key, onSuccess, onError, onNotSupported) {
684
         // http://xmpp.org/extensions/xep-0045.html#roomconfig
721
         // http://xmpp.org/extensions/xep-0045.html#roomconfig
685
         this.connection.sendIQ(
722
         this.connection.sendIQ(
686
-            $iq({ to: this.roomjid,
687
-                type: 'get' }).c('query', { xmlns: 'http://jabber.org/protocol/muc#owner' }),
723
+            $iq({
724
+                to: this.roomjid,
725
+                type: 'get'
726
+            })
727
+                .c('query', { xmlns: 'http://jabber.org/protocol/muc#owner' }),
688
             res => {
728
             res => {
689
-                if ($(res).find('>query>x[xmlns="jabber:x:data"]>field[var="muc#roomconfig_roomsecret"]').length) {
729
+                if ($(res)
730
+                        .find(
731
+                            '>query>x[xmlns="jabber:x:data"]'
732
+                                + '>field[var="muc#roomconfig_roomsecret"]')
733
+                        .length) {
690
                     const formsubmit
734
                     const formsubmit
691
-                        = $iq({ to: this.roomjid,
692
-                            type: 'set' })
693
-                            .c('query', { xmlns: 'http://jabber.org/protocol/muc#owner' });
694
-
695
-                    formsubmit.c('x', { xmlns: 'jabber:x:data',
696
-                        type: 'submit' });
697
-                    formsubmit.c('field', { 'var': 'FORM_TYPE' }).c('value').t('http://jabber.org/protocol/muc#roomconfig').up().up();
698
-                    formsubmit.c('field', { 'var': 'muc#roomconfig_roomsecret' }).c('value').t(key).up().up();
699
-
700
-                    // Fixes a bug in prosody 0.9.+ https://code.google.com/p/lxmppd/issues/detail?id=373
701
-                    formsubmit.c('field', { 'var': 'muc#roomconfig_whois' }).c('value').t('anyone').up().up();
735
+                        = $iq({
736
+                            to: this.roomjid,
737
+                            type: 'set'
738
+                        })
739
+                            .c('query', {
740
+                                xmlns: 'http://jabber.org/protocol/muc#owner'
741
+                            });
742
+
743
+                    formsubmit.c('x', {
744
+                        xmlns: 'jabber:x:data',
745
+                        type: 'submit'
746
+                    });
747
+                    formsubmit
748
+                        .c('field', { 'var': 'FORM_TYPE' })
749
+                        .c('value')
750
+                        .t('http://jabber.org/protocol/muc#roomconfig')
751
+                        .up()
752
+                        .up();
753
+                    formsubmit
754
+                        .c('field', { 'var': 'muc#roomconfig_roomsecret' })
755
+                        .c('value')
756
+                        .t(key)
757
+                        .up()
758
+                        .up();
759
+
760
+                    // Fixes a bug in prosody 0.9.+
761
+                    // https://code.google.com/p/lxmppd/issues/detail?id=373
762
+                    formsubmit
763
+                        .c('field', { 'var': 'muc#roomconfig_whois' })
764
+                        .c('value')
765
+                        .t('anyone')
766
+                        .up()
767
+                        .up();
702
 
768
 
703
                     // FIXME: is muc#roomconfig_passwordprotectedroom required?
769
                     // FIXME: is muc#roomconfig_passwordprotectedroom required?
704
                     this.connection.sendIQ(formsubmit, onSuccess, onError);
770
                     this.connection.sendIQ(formsubmit, onSuccess, onError);
733
      * Checks if the user identified by given <tt>mucJid</tt> is the conference
799
      * Checks if the user identified by given <tt>mucJid</tt> is the conference
734
      * focus.
800
      * focus.
735
      * @param mucJid the full MUC address of the user to be checked.
801
      * @param mucJid the full MUC address of the user to be checked.
736
-     * @returns {boolean|null} <tt>true</tt> if MUC user is the conference focus or
737
-     * <tt>false</tt> if is not. When given <tt>mucJid</tt> does not exist in
802
+     * @returns {boolean|null} <tt>true</tt> if MUC user is the conference focus
803
+     * or <tt>false</tt> if is not. When given <tt>mucJid</tt> does not exist in
738
      * the MUC then <tt>null</tt> is returned.
804
      * the MUC then <tt>null</tt> is returned.
739
      */
805
      */
740
     isFocus(mucJid) {
806
     isFocus(mucJid) {
861
     }
927
     }
862
 
928
 
863
     /**
929
     /**
864
-     * Returns null if the recording is not supported, "on" if the recording started
865
-     * and "off" if the recording is not started.
930
+     * Returns null if the recording is not supported, "on" if the recording
931
+     * started and "off" if the recording is not started.
866
      */
932
      */
867
     getRecordingState() {
933
     getRecordingState() {
868
         return this.recording ? this.recording.getState() : undefined;
934
         return this.recording ? this.recording.getState() : undefined;
878
     /**
944
     /**
879
      * Starts/stops the recording
945
      * Starts/stops the recording
880
      * @param token token for authentication
946
      * @param token token for authentication
881
-     * @param statusChangeHandler {function} receives the new status as argument.
947
+     * @param statusChangeHandler {function} receives the new status as
948
+     * argument.
882
      */
949
      */
883
     toggleRecording(options, statusChangeHandler) {
950
     toggleRecording(options, statusChangeHandler) {
884
         if (this.recording) {
951
         if (this.recording) {
967
         if (mute.length) {
1034
         if (mute.length) {
968
             const doMuteAudio = mute.text() === 'true';
1035
             const doMuteAudio = mute.text() === 'true';
969
 
1036
 
970
-            this.eventEmitter.emit(XMPPEvents.AUDIO_MUTED_BY_FOCUS, doMuteAudio);
1037
+            this.eventEmitter.emit(
1038
+                XMPPEvents.AUDIO_MUTED_BY_FOCUS,
1039
+                doMuteAudio);
971
         }
1040
         }
972
 
1041
 
973
         return true;
1042
         return true;
975
 
1044
 
976
     /**
1045
     /**
977
      * Leaves the room. Closes the jingle session.
1046
      * Leaves the room. Closes the jingle session.
978
-     * @returns {Promise} which is resolved if XMPPEvents.MUC_LEFT is received less
979
-     * than 5s after sending presence unavailable. Otherwise the promise is
1047
+     * @returns {Promise} which is resolved if XMPPEvents.MUC_LEFT is received
1048
+     * less than 5s after sending presence unavailable. Otherwise the promise is
980
      * rejected.
1049
      * rejected.
981
      */
1050
      */
982
     leave() {
1051
     leave() {

+ 9
- 4
modules/xmpp/JingleSessionPC.js View File

779
                     finishedCallback();
779
                     finishedCallback();
780
                 }, error => {
780
                 }, error => {
781
                     logger.error(
781
                     logger.error(
782
-                        `Error renegotiating after processing remote source-add: ${error}`);
782
+                        'Error renegotiating after processing remote'
783
+                            + ` source-add: ${error}`);
783
                     finishedCallback(error);
784
                     finishedCallback(error);
784
                 });
785
                 });
785
         };
786
         };
823
                     finishedCallback();
824
                     finishedCallback();
824
                 }, error => {
825
                 }, error => {
825
                     logger.error(
826
                     logger.error(
826
-                        `Error renegotiating after processing remote source-remove: ${error}`);
827
+                        'Error renegotiating after processing remote'
828
+                          + ` source-remove: ${error}`);
827
                     finishedCallback(error);
829
                     finishedCallback(error);
828
                 });
830
                 });
829
         };
831
         };
954
                 remoteDescription,
956
                 remoteDescription,
955
                 () => {
957
                 () => {
956
                     if (this.signalingState === 'closed') {
958
                     if (this.signalingState === 'closed') {
957
-                        reject('Attempted to setRemoteDescription in state closed');
959
+                        reject(
960
+                            'Attempted to setRemoteDescription in state'
961
+                                + ' closed');
958
 
962
 
959
                         return;
963
                         return;
960
                     }
964
                     }
1165
         const workFunction = finishedCallback => {
1169
         const workFunction = finishedCallback => {
1166
             if (!this.peerconnection) {
1170
             if (!this.peerconnection) {
1167
                 finishedCallback(
1171
                 finishedCallback(
1168
-                    'Error: tried adding stream with no active peer connection');
1172
+                    'Error: tried adding stream with no active peer'
1173
+                        + ' connection');
1169
 
1174
 
1170
                 return;
1175
                 return;
1171
             }
1176
             }

+ 121
- 61
modules/xmpp/SDP.js View File

51
 
51
 
52
     for (let mediaindex = 0; mediaindex < self.media.length; mediaindex++) {
52
     for (let mediaindex = 0; mediaindex < self.media.length; mediaindex++) {
53
         tmp = SDPUtil.find_lines(self.media[mediaindex], 'a=ssrc:');
53
         tmp = SDPUtil.find_lines(self.media[mediaindex], 'a=ssrc:');
54
-        const mid = SDPUtil.parse_mid(SDPUtil.find_line(self.media[mediaindex], 'a=mid:'));
54
+        const mid
55
+            = SDPUtil.parse_mid(
56
+                SDPUtil.find_line(self.media[mediaindex],
57
+                'a=mid:'));
55
         const media = {
58
         const media = {
56
             mediaindex,
59
             mediaindex,
57
             mid,
60
             mid,
223
                 elem.attrs({ ssrc });
226
                 elem.attrs({ ssrc });
224
             }
227
             }
225
             for (j = 0; j < mline.fmt.length; j++) {
228
             for (j = 0; j < mline.fmt.length; j++) {
226
-                rtpmap = SDPUtil.find_line(this.media[i], `a=rtpmap:${mline.fmt[j]}`);
229
+                rtpmap
230
+                    = SDPUtil.find_line(
231
+                        this.media[i],
232
+                        `a=rtpmap:${mline.fmt[j]}`);
227
                 elem.c('payload-type', SDPUtil.parse_rtpmap(rtpmap));
233
                 elem.c('payload-type', SDPUtil.parse_rtpmap(rtpmap));
228
 
234
 
229
-                // put any 'a=fmtp:' + mline.fmt[j] lines into <param name=foo value=bar/>
230
-                const afmtpline = SDPUtil.find_line(this.media[i], `a=fmtp:${mline.fmt[j]}`);
235
+                // put any 'a=fmtp:' + mline.fmt[j] lines into <param name=foo
236
+                // value=bar/>
237
+                const afmtpline
238
+                    = SDPUtil.find_line(
239
+                        this.media[i],
240
+                        `a=fmtp:${mline.fmt[j]}`);
231
 
241
 
232
                 if (afmtpline) {
242
                 if (afmtpline) {
233
                     tmp = SDPUtil.parse_fmtp(afmtpline);
243
                     tmp = SDPUtil.parse_fmtp(afmtpline);
235
                         elem.c('parameter', tmp[k]).up();
245
                         elem.c('parameter', tmp[k]).up();
236
                     }
246
                     }
237
                 }
247
                 }
238
-                this.rtcpFbToJingle(i, elem, mline.fmt[j]); // XEP-0293 -- map a=rtcp-fb
248
+
249
+                // XEP-0293 -- map a=rtcp-fb
250
+                this.rtcpFbToJingle(i, elem, mline.fmt[j]);
239
 
251
 
240
                 elem.up();
252
                 elem.up();
241
             }
253
             }
242
-            const crypto = SDPUtil.find_lines(this.media[i], 'a=crypto:', this.session);
254
+            const crypto
255
+                = SDPUtil.find_lines(this.media[i], 'a=crypto:', this.session);
243
 
256
 
244
             if (crypto.length) {
257
             if (crypto.length) {
245
                 elem.c('encryption', { required: 1 });
258
                 elem.c('encryption', { required: 1 });
327
                 elem.up();
340
                 elem.up();
328
 
341
 
329
                 // XEP-0339 handle ssrc-group attributes
342
                 // XEP-0339 handle ssrc-group attributes
330
-                const ssrc_group_lines = SDPUtil.find_lines(this.media[i], 'a=ssrc-group:');
343
+                const ssrc_group_lines
344
+                    = SDPUtil.find_lines(this.media[i], 'a=ssrc-group:');
331
 
345
 
332
                 ssrc_group_lines.forEach(line => {
346
                 ssrc_group_lines.forEach(line => {
333
                     const idx = line.indexOf(' ');
347
                     const idx = line.indexOf(' ');
355
             if (lines.length) {
369
             if (lines.length) {
356
                 for (j = 0; j < lines.length; j++) {
370
                 for (j = 0; j < lines.length; j++) {
357
                     tmp = SDPUtil.parse_extmap(lines[j]);
371
                     tmp = SDPUtil.parse_extmap(lines[j]);
358
-                    elem.c('rtp-hdrext', { xmlns: 'urn:xmpp:jingle:apps:rtp:rtp-hdrext:0',
372
+                    elem.c('rtp-hdrext', {
373
+                        xmlns: 'urn:xmpp:jingle:apps:rtp:rtp-hdrext:0',
359
                         uri: tmp.uri,
374
                         uri: tmp.uri,
360
-                        id: tmp.value });
375
+                        id: tmp.value
376
+                    });
361
                     if (tmp.hasOwnProperty('direction')) {
377
                     if (tmp.hasOwnProperty('direction')) {
362
                         switch (tmp.direction) {
378
                         switch (tmp.direction) {
363
                         case 'sendonly':
379
                         case 'sendonly':
385
         // map ice-ufrag/pwd, dtls fingerprint, candidates
401
         // map ice-ufrag/pwd, dtls fingerprint, candidates
386
         this.transportToJingle(i, elem);
402
         this.transportToJingle(i, elem);
387
 
403
 
388
-        if (SDPUtil.find_line(this.media[i], 'a=sendrecv', this.session)) {
404
+        const m = this.media[i];
405
+
406
+        if (SDPUtil.find_line(m, 'a=sendrecv', this.session)) {
389
             elem.attrs({ senders: 'both' });
407
             elem.attrs({ senders: 'both' });
390
-        } else if (SDPUtil.find_line(this.media[i], 'a=sendonly', this.session)) {
408
+        } else if (SDPUtil.find_line(m, 'a=sendonly', this.session)) {
391
             elem.attrs({ senders: 'initiator' });
409
             elem.attrs({ senders: 'initiator' });
392
-        } else if (SDPUtil.find_line(this.media[i], 'a=recvonly', this.session)) {
410
+        } else if (SDPUtil.find_line(m, 'a=recvonly', this.session)) {
393
             elem.attrs({ senders: 'responder' });
411
             elem.attrs({ senders: 'responder' });
394
-        } else if (SDPUtil.find_line(this.media[i], 'a=inactive', this.session)) {
412
+        } else if (SDPUtil.find_line(m, 'a=inactive', this.session)) {
395
             elem.attrs({ senders: 'none' });
413
             elem.attrs({ senders: 'none' });
396
         }
414
         }
397
         if (mline.port == '0') {
415
         if (mline.port == '0') {
433
 
451
 
434
     // XEP-0320
452
     // XEP-0320
435
     const fingerprints
453
     const fingerprints
436
-        = SDPUtil.find_lines(this.media[mediaindex], 'a=fingerprint:', this.session);
454
+        = SDPUtil.find_lines(
455
+            this.media[mediaindex],
456
+            'a=fingerprint:',
457
+            this.session);
437
 
458
 
438
     fingerprints.forEach(line => {
459
     fingerprints.forEach(line => {
439
         tmp = SDPUtil.parse_fingerprint(line);
460
         tmp = SDPUtil.parse_fingerprint(line);
440
         tmp.xmlns = 'urn:xmpp:jingle:apps:dtls:0';
461
         tmp.xmlns = 'urn:xmpp:jingle:apps:dtls:0';
441
         elem.c('fingerprint').t(tmp.fingerprint);
462
         elem.c('fingerprint').t(tmp.fingerprint);
442
         delete tmp.fingerprint;
463
         delete tmp.fingerprint;
443
-        line = SDPUtil.find_line(self.media[mediaindex], 'a=setup:', self.session);
464
+        line
465
+            = SDPUtil.find_line(
466
+                self.media[mediaindex],
467
+                'a=setup:',
468
+                self.session);
444
         if (line) {
469
         if (line) {
445
             tmp.setup = line.substr(8);
470
             tmp.setup = line.substr(8);
446
         }
471
         }
453
         elem.attrs(tmp);
478
         elem.attrs(tmp);
454
 
479
 
455
         // XEP-0176
480
         // XEP-0176
456
-        if (SDPUtil.find_line(this.media[mediaindex], 'a=candidate:', this.session)) { // add any a=candidate lines
457
-            const lines = SDPUtil.find_lines(this.media[mediaindex], 'a=candidate:', this.session);
481
+        const lines
482
+            = SDPUtil.find_lines(
483
+                this.media[mediaindex],
484
+                'a=candidate:',
485
+                this.session);
458
 
486
 
487
+        if (lines.length) { // add any a=candidate lines
459
             lines.forEach(line => {
488
             lines.forEach(line => {
460
                 const candidate = SDPUtil.candidateToJingle(line);
489
                 const candidate = SDPUtil.candidateToJingle(line);
461
 
490
 
462
                 if (self.failICE) {
491
                 if (self.failICE) {
463
                     candidate.ip = '1.1.1.1';
492
                     candidate.ip = '1.1.1.1';
464
                 }
493
                 }
465
-                const protocol = candidate
466
-                        && typeof candidate.protocol === 'string'
467
-                    ? candidate.protocol.toLowerCase() : '';
494
+                const protocol
495
+                    = candidate && typeof candidate.protocol === 'string'
496
+                        ? candidate.protocol.toLowerCase()
497
+                        : '';
468
 
498
 
469
                 if ((self.removeTcpCandidates
499
                 if ((self.removeTcpCandidates
470
                         && (protocol === 'tcp' || protocol === 'ssltcp'))
500
                         && (protocol === 'tcp' || protocol === 'ssltcp'))
478
     elem.up(); // end of transport
508
     elem.up(); // end of transport
479
 };
509
 };
480
 
510
 
481
-SDP.prototype.rtcpFbToJingle = function(mediaindex, elem, payloadtype) { // XEP-0293
482
-    const lines = SDPUtil.find_lines(this.media[mediaindex], `a=rtcp-fb:${payloadtype}`);
511
+// XEP-0293
512
+SDP.prototype.rtcpFbToJingle = function(mediaindex, elem, payloadtype) {
513
+    const lines
514
+        = SDPUtil.find_lines(
515
+            this.media[mediaindex],
516
+            `a=rtcp-fb:${payloadtype}`);
483
 
517
 
484
     lines.forEach(line => {
518
     lines.forEach(line => {
485
         const tmp = SDPUtil.parse_rtcpfb(line);
519
         const tmp = SDPUtil.parse_rtcpfb(line);
486
 
520
 
487
         if (tmp.type == 'trr-int') {
521
         if (tmp.type == 'trr-int') {
488
-            elem.c('rtcp-fb-trr-int', { xmlns: 'urn:xmpp:jingle:apps:rtp:rtcp-fb:0',
489
-                value: tmp.params[0] });
522
+            elem.c('rtcp-fb-trr-int', {
523
+                xmlns: 'urn:xmpp:jingle:apps:rtp:rtcp-fb:0',
524
+                value: tmp.params[0]
525
+            });
490
             elem.up();
526
             elem.up();
491
         } else {
527
         } else {
492
-            elem.c('rtcp-fb', { xmlns: 'urn:xmpp:jingle:apps:rtp:rtcp-fb:0',
493
-                type: tmp.type });
528
+            elem.c('rtcp-fb', {
529
+                xmlns: 'urn:xmpp:jingle:apps:rtp:rtcp-fb:0',
530
+                type: tmp.type
531
+            });
494
             if (tmp.params.length > 0) {
532
             if (tmp.params.length > 0) {
495
                 elem.attrs({ 'subtype': tmp.params[0] });
533
                 elem.attrs({ 'subtype': tmp.params[0] });
496
             }
534
             }
501
 
539
 
502
 SDP.prototype.rtcpFbFromJingle = function(elem, payloadtype) { // XEP-0293
540
 SDP.prototype.rtcpFbFromJingle = function(elem, payloadtype) { // XEP-0293
503
     let media = '';
541
     let media = '';
504
-    let tmp = elem.find('>rtcp-fb-trr-int[xmlns="urn:xmpp:jingle:apps:rtp:rtcp-fb:0"]');
542
+    let tmp
543
+        = elem.find(
544
+            '>rtcp-fb-trr-int[xmlns="urn:xmpp:jingle:apps:rtp:rtcp-fb:0"]');
505
 
545
 
506
     if (tmp.length) {
546
     if (tmp.length) {
507
         media += 'a=rtcp-fb:* trr-int ';
547
         media += 'a=rtcp-fb:* trr-int ';
533
         + 's=-\r\n'
573
         + 's=-\r\n'
534
         + 't=0 0\r\n';
574
         + 't=0 0\r\n';
535
 
575
 
536
-    // http://tools.ietf.org/html/draft-ietf-mmusic-sdp-bundle-negotiation-04#section-8
576
+    // http://tools.ietf.org/html/draft-ietf-mmusic-sdp-bundle-negotiation-04
577
+    // #section-8
537
     const groups
578
     const groups
538
         = $(jingle).find('>group[xmlns="urn:xmpp:jingle:apps:grouping:0"]');
579
         = $(jingle).find('>group[xmlns="urn:xmpp:jingle:apps:grouping:0"]');
539
 
580
 
547
 
588
 
548
             if (contents.length > 0) {
589
             if (contents.length > 0) {
549
                 self.raw
590
                 self.raw
550
-                    += `a=group:${group.getAttribute('semantics') || group.getAttribute('type')} ${contents.join(' ')}\r\n`;
591
+                    += `a=group:${
592
+                        group.getAttribute('semantics')
593
+                            || group.getAttribute('type')} ${
594
+                        contents.join(' ')}\r\n`;
551
             }
595
             }
552
         });
596
         });
553
     }
597
     }
617
     if (!sctp.length) {
661
     if (!sctp.length) {
618
         media += 'a=rtcp:1 IN IP4 0.0.0.0\r\n';
662
         media += 'a=rtcp:1 IN IP4 0.0.0.0\r\n';
619
     }
663
     }
620
-    tmp = content.find('>transport[xmlns="urn:xmpp:jingle:transports:ice-udp:1"]');
664
+    tmp
665
+        = content.find(
666
+            '>transport[xmlns="urn:xmpp:jingle:transports:ice-udp:1"]');
621
     if (tmp.length) {
667
     if (tmp.length) {
622
         if (tmp.attr('ufrag')) {
668
         if (tmp.attr('ufrag')) {
623
             media += `${SDPUtil.build_iceufrag(tmp.attr('ufrag'))}\r\n`;
669
             media += `${SDPUtil.build_iceufrag(tmp.attr('ufrag'))}\r\n`;
652
     media += `a=mid:${content.attr('name')}\r\n`;
698
     media += `a=mid:${content.attr('name')}\r\n`;
653
 
699
 
654
     // <description><rtcp-mux/></description>
700
     // <description><rtcp-mux/></description>
655
-    // see http://code.google.com/p/libjingle/issues/detail?id=309 -- no spec though
701
+    // see http://code.google.com/p/libjingle/issues/detail?id=309 -- no spec
702
+    // though
656
     // and http://mail.jabber.org/pipermail/jingle/2011-December/001761.html
703
     // and http://mail.jabber.org/pipermail/jingle/2011-December/001761.html
657
     if (desc.find('rtcp-mux').length) {
704
     if (desc.find('rtcp-mux').length) {
658
         media += 'a=rtcp-mux\r\n';
705
         media += 'a=rtcp-mux\r\n';
694
     media += self.rtcpFbFromJingle(desc, '*');
741
     media += self.rtcpFbFromJingle(desc, '*');
695
 
742
 
696
     // xep-0294
743
     // xep-0294
697
-    tmp = desc.find('>rtp-hdrext[xmlns="urn:xmpp:jingle:apps:rtp:rtp-hdrext:0"]');
744
+    tmp
745
+        = desc.find(
746
+            '>rtp-hdrext[xmlns="urn:xmpp:jingle:apps:rtp:rtp-hdrext:0"]');
698
     tmp.each(function() {
747
     tmp.each(function() {
699
-        media += `a=extmap:${this.getAttribute('id')} ${this.getAttribute('uri')}\r\n`;
748
+        media
749
+            += `a=extmap:${this.getAttribute('id')} ${
750
+                this.getAttribute('uri')}\r\n`;
700
     });
751
     });
701
 
752
 
702
-    content.find('>transport[xmlns="urn:xmpp:jingle:transports:ice-udp:1"]>candidate').each(function() {
703
-        let protocol = this.getAttribute('protocol');
704
-
705
-        protocol = typeof protocol === 'string' ? protocol.toLowerCase() : '';
706
-
707
-        if ((self.removeTcpCandidates
708
-                && (protocol === 'tcp' || protocol === 'ssltcp'))
709
-            || (self.removeUdpCandidates && protocol === 'udp')) {
710
-            return;
711
-        } else if (self.failICE) {
712
-            this.setAttribute('ip', '1.1.1.1');
713
-        }
753
+    content
754
+        .find(
755
+            '>transport[xmlns="urn:xmpp:jingle:transports:ice-udp:1"]'
756
+                + '>candidate')
757
+        .each(function() {
758
+            let protocol = this.getAttribute('protocol');
759
+
760
+            protocol
761
+                = typeof protocol === 'string' ? protocol.toLowerCase() : '';
762
+
763
+            if ((self.removeTcpCandidates
764
+                    && (protocol === 'tcp' || protocol === 'ssltcp'))
765
+                || (self.removeUdpCandidates && protocol === 'udp')) {
766
+                return;
767
+            } else if (self.failICE) {
768
+                this.setAttribute('ip', '1.1.1.1');
769
+            }
714
 
770
 
715
-        media += SDPUtil.candidateFromJingle(this);
716
-    });
771
+            media += SDPUtil.candidateFromJingle(this);
772
+        });
717
 
773
 
718
     // XEP-0339 handle ssrc-group attributes
774
     // XEP-0339 handle ssrc-group attributes
719
-    content.find('description>ssrc-group[xmlns="urn:xmpp:jingle:apps:rtp:ssma:0"]').each(function() {
720
-        const semantics = this.getAttribute('semantics');
721
-        const ssrcs
722
-            = $(this)
723
-                .find('>source')
724
-                .map(function() {
725
-                    return this.getAttribute('ssrc');
726
-                })
727
-                .get();
775
+    content
776
+        .find('description>ssrc-group[xmlns="urn:xmpp:jingle:apps:rtp:ssma:0"]')
777
+        .each(function() {
778
+            const semantics = this.getAttribute('semantics');
779
+            const ssrcs
780
+                = $(this)
781
+                    .find('>source')
782
+                    .map(function() {
783
+                        return this.getAttribute('ssrc');
784
+                    })
785
+                    .get();
728
 
786
 
729
-        if (ssrcs.length) {
730
-            media += `a=ssrc-group:${semantics} ${ssrcs.join(' ')}\r\n`;
731
-        }
732
-    });
787
+            if (ssrcs.length) {
788
+                media += `a=ssrc-group:${semantics} ${ssrcs.join(' ')}\r\n`;
789
+            }
790
+        });
733
 
791
 
734
-    tmp = content.find('description>source[xmlns="urn:xmpp:jingle:apps:rtp:ssma:0"]');
792
+    tmp
793
+        = content.find(
794
+            'description>source[xmlns="urn:xmpp:jingle:apps:rtp:ssma:0"]');
735
     tmp.each(function() {
795
     tmp.each(function() {
736
         const ssrc = this.getAttribute('ssrc');
796
         const ssrc = this.getAttribute('ssrc');
737
 
797
 

+ 41
- 14
modules/xmpp/SDPUtil.js View File

16
         let pwd, ufrag;
16
         let pwd, ufrag;
17
 
17
 
18
         if ((ufrag = SDPUtil.find_line(mediadesc, 'a=ice-ufrag:', sessiondesc))
18
         if ((ufrag = SDPUtil.find_line(mediadesc, 'a=ice-ufrag:', sessiondesc))
19
-                && (pwd = SDPUtil.find_line(mediadesc, 'a=ice-pwd:', sessiondesc))) {
19
+                && (pwd
20
+                    = SDPUtil.find_line(
21
+                        mediadesc,
22
+                        'a=ice-pwd:',
23
+                        sessiondesc))) {
20
             data = {
24
             data = {
21
                 ufrag: SDPUtil.parse_iceufrag(ufrag),
25
                 ufrag: SDPUtil.parse_iceufrag(ufrag),
22
                 pwd: SDPUtil.parse_icepwd(pwd)
26
                 pwd: SDPUtil.parse_icepwd(pwd)
55
         return data;
59
         return data;
56
     },
60
     },
57
     build_mline(mline) {
61
     build_mline(mline) {
58
-        return `m=${mline.media} ${mline.port} ${mline.proto} ${mline.fmt.join(' ')}`;
62
+        return (
63
+            `m=${mline.media} ${mline.port} ${mline.proto} ${
64
+                mline.fmt.join(' ')}`);
59
     },
65
     },
60
     parse_rtpmap(line) {
66
     parse_rtpmap(line) {
61
         const data = {};
67
         const data = {};
87
         return [ sctpPort, protocol, streamCount ];// SCTP port
93
         return [ sctpPort, protocol, streamCount ];// SCTP port
88
     },
94
     },
89
     build_rtpmap(el) {
95
     build_rtpmap(el) {
90
-        let line = `a=rtpmap:${el.getAttribute('id')} ${el.getAttribute('name')}/${el.getAttribute('clockrate')}`;
96
+        let line
97
+            = `a=rtpmap:${el.getAttribute('id')} ${el.getAttribute('name')}/${
98
+                el.getAttribute('clockrate')}`;
91
 
99
 
92
         if (el.getAttribute('channels') && el.getAttribute('channels') != '1') {
100
         if (el.getAttribute('channels') && el.getAttribute('channels') != '1') {
93
             line += `/${el.getAttribute('channels')}`;
101
             line += `/${el.getAttribute('channels')}`;
173
                 candidate.tcptype = elems[i + 1];
181
                 candidate.tcptype = elems[i + 1];
174
                 break;
182
                 break;
175
             default: // TODO
183
             default: // TODO
176
-                logger.log(`parse_icecandidate not translating "${elems[i]}" = "${elems[i + 1]}"`);
184
+                logger.log(
185
+                    `parse_icecandidate not translating "${
186
+                        elems[i]}" = "${elems[i + 1]}"`);
177
             }
187
             }
178
         }
188
         }
179
         candidate.network = '1';
189
         candidate.network = '1';
185
         return candidate;
195
         return candidate;
186
     },
196
     },
187
     build_icecandidate(cand) {
197
     build_icecandidate(cand) {
188
-        let line = [ `a=candidate:${cand.foundation}`, cand.component, cand.protocol, cand.priority, cand.ip, cand.port, 'typ', cand.type ].join(' ');
198
+        let line = [
199
+            `a=candidate:${cand.foundation}`,
200
+            cand.component,
201
+            cand.protocol,
202
+            cand.priority,
203
+            cand.ip,
204
+            cand.port,
205
+            'typ',
206
+            cand.type
207
+        ].join(' ');
189
 
208
 
190
         line += ' ';
209
         line += ' ';
191
         switch (cand.type) {
210
         switch (cand.type) {
192
         case 'srflx':
211
         case 'srflx':
193
         case 'prflx':
212
         case 'prflx':
194
         case 'relay':
213
         case 'relay':
195
-            if (cand.hasOwnAttribute('rel-addr') && cand.hasOwnAttribute('rel-port')) {
214
+            if (cand.hasOwnAttribute('rel-addr')
215
+                    && cand.hasOwnAttribute('rel-port')) {
196
                 line += 'raddr';
216
                 line += 'raddr';
197
                 line += ' ';
217
                 line += ' ';
198
                 line += cand['rel-addr'];
218
                 line += cand['rel-addr'];
218
     },
238
     },
219
     parse_ssrc(desc) {
239
     parse_ssrc(desc) {
220
         // proprietary mapping of a=ssrc lines
240
         // proprietary mapping of a=ssrc lines
221
-        // TODO: see "Jingle RTP Source Description" by Juberti and P. Thatcher on google docs
222
-        // and parse according to that
241
+        // TODO: see "Jingle RTP Source Description" by Juberti and P. Thatcher
242
+        // on google docs and parse according to that
223
         const data = {};
243
         const data = {};
224
         const lines = desc.split('\r\n');
244
         const lines = desc.split('\r\n');
225
 
245
 
227
             if (lines[i].substring(0, 7) == 'a=ssrc:') {
247
             if (lines[i].substring(0, 7) == 'a=ssrc:') {
228
                 const idx = lines[i].indexOf(' ');
248
                 const idx = lines[i].indexOf(' ');
229
 
249
 
230
-                data[lines[i].substr(idx + 1).split(':', 2)[0]] = lines[i].substr(idx + 1).split(':', 2)[1];
250
+                data[lines[i].substr(idx + 1).split(':', 2)[0]]
251
+                    = lines[i].substr(idx + 1).split(':', 2)[1];
231
             }
252
             }
232
         }
253
         }
233
 
254
 
305
         return needles;
326
         return needles;
306
     },
327
     },
307
     candidateToJingle(line) {
328
     candidateToJingle(line) {
308
-        // a=candidate:2979166662 1 udp 2113937151 192.168.2.100 57698 typ host generation 0
309
-        //      <candidate component=... foundation=... generation=... id=... ip=... network=... port=... priority=... protocol=... type=.../>
329
+        // a=candidate:2979166662 1 udp 2113937151 192.168.2.100 57698 typ host
330
+        // generation 0
331
+        //      <candidate component=... foundation=... generation=... id=...
332
+        // ip=... network=... port=... priority=... protocol=... type=.../>
310
         if (line.indexOf('candidate:') === 0) {
333
         if (line.indexOf('candidate:') === 0) {
311
             line = `a=${line}`;
334
             line = `a=${line}`;
312
         } else if (line.substring(0, 12) != 'a=candidate:') {
335
         } else if (line.substring(0, 12) != 'a=candidate:') {
313
-            logger.log('parseCandidate called with a line that is not a candidate line');
336
+            logger.log(
337
+                'parseCandidate called with a line that is not a candidate'
338
+                    + ' line');
314
             logger.log(line);
339
             logger.log(line);
315
 
340
 
316
             return null;
341
             return null;
395
         case 'srflx':
420
         case 'srflx':
396
         case 'prflx':
421
         case 'prflx':
397
         case 'relay':
422
         case 'relay':
398
-            if (cand.getAttribute('rel-addr') && cand.getAttribute('rel-port')) {
423
+            if (cand.getAttribute('rel-addr')
424
+                    && cand.getAttribute('rel-port')) {
399
                 line += 'raddr';
425
                 line += 'raddr';
400
                 line += ' ';
426
                 line += ' ';
401
                 line += cand.getAttribute('rel-addr');
427
                 line += cand.getAttribute('rel-addr');
540
             }
566
             }
541
         }
567
         }
542
         if (payloadType) {
568
         if (payloadType) {
543
-            const payloadTypes = videoMLine.payloads.split(' ').map(p => parseInt(p));
569
+            const payloadTypes
570
+                = videoMLine.payloads.split(' ').map(p => parseInt(p));
544
             const payloadIndex = payloadTypes.indexOf(payloadType);
571
             const payloadIndex = payloadTypes.indexOf(payloadType);
545
 
572
 
546
             payloadTypes.splice(payloadIndex, 1);
573
             payloadTypes.splice(payloadIndex, 1);

+ 27
- 12
modules/xmpp/strophe.jingle.js View File

55
                 ack.attrs({ type: 'error' });
55
                 ack.attrs({ type: 'error' });
56
                 ack.c('error', { type: 'cancel' })
56
                 ack.c('error', { type: 'cancel' })
57
                     .c('item-not-found', {
57
                     .c('item-not-found', {
58
-                        xmlns: 'urn:ietf:params:xml:ns:xmpp-stanzas' }).up()
59
-                    .c('unknown-session', { xmlns: 'urn:xmpp:jingle:errors:1' });
58
+                        xmlns: 'urn:ietf:params:xml:ns:xmpp-stanzas'
59
+                    })
60
+                    .up()
61
+                    .c('unknown-session', {
62
+                        xmlns: 'urn:xmpp:jingle:errors:1'
63
+                    });
60
                 logger.warn('invalid session id', iq);
64
                 logger.warn('invalid session id', iq);
61
                 this.connection.send(ack);
65
                 this.connection.send(ack);
62
 
66
 
69
                     'jid mismatch for session id', sid, sess.peerjid, iq);
73
                     'jid mismatch for session id', sid, sess.peerjid, iq);
70
                 ack.attrs({ type: 'error' });
74
                 ack.attrs({ type: 'error' });
71
                 ack.c('error', { type: 'cancel' })
75
                 ack.c('error', { type: 'cancel' })
72
-                    .c('item-not-found', { xmlns: 'urn:ietf:params:xml:ns:xmpp-stanzas' }).up()
73
-                    .c('unknown-session', { xmlns: 'urn:xmpp:jingle:errors:1' });
76
+                    .c('item-not-found', {
77
+                        xmlns: 'urn:ietf:params:xml:ns:xmpp-stanzas'
78
+                    })
79
+                    .up()
80
+                    .c('unknown-session', {
81
+                        xmlns: 'urn:xmpp:jingle:errors:1'
82
+                    });
74
                 this.connection.send(ack);
83
                 this.connection.send(ack);
75
 
84
 
76
                 return true;
85
                 return true;
77
             }
86
             }
78
         } else if (sess !== undefined) {
87
         } else if (sess !== undefined) {
79
-            // existing session with same session id
80
-            // this might be out-of-order if the sess.peerjid is the same as from
88
+            // Existing session with same session id. This might be out-of-order
89
+            // if the sess.peerjid is the same as from.
81
             ack.attrs({ type: 'error' });
90
             ack.attrs({ type: 'error' });
82
             ack.c('error', { type: 'cancel' })
91
             ack.c('error', { type: 'cancel' })
83
-                .c('service-unavailable', { xmlns: 'urn:ietf:params:xml:ns:xmpp-stanzas' }).up();
92
+                .c('service-unavailable', {
93
+                    xmlns: 'urn:ietf:params:xml:ns:xmpp-stanzas'
94
+                })
95
+                .up();
84
             logger.warn('duplicate session id', sid, iq);
96
             logger.warn('duplicate session id', sid, iq);
85
             this.connection.send(ack);
97
             this.connection.send(ack);
86
 
98
 
188
         // uses time-limited credentials as described in
200
         // uses time-limited credentials as described in
189
         // http://tools.ietf.org/html/draft-uberti-behave-turn-rest-00
201
         // http://tools.ietf.org/html/draft-uberti-behave-turn-rest-00
190
         //
202
         //
191
-        // see https://code.google.com/p/prosody-modules/source/browse/mod_turncredentials/mod_turncredentials.lua
192
-        // for a prosody module which implements this
203
+        // See https://code.google.com/p/prosody-modules/source/browse/
204
+        // mod_turncredentials/mod_turncredentials.lua
205
+        // for a prosody module which implements this.
193
         //
206
         //
194
-        // currently, this doesn't work with updateIce and therefore credentials with a long
195
-        // validity have to be fetched before creating the peerconnection
207
+        // Currently, this doesn't work with updateIce and therefore credentials
208
+        // with a long validity have to be fetched before creating the
209
+        // peerconnection.
196
         // TODO: implement refresh via updateIce as described in
210
         // TODO: implement refresh via updateIce as described in
197
         //      https://code.google.com/p/webrtc/issues/detail?id=1650
211
         //      https://code.google.com/p/webrtc/issues/detail?id=1650
198
         this.connection.sendIQ(
212
         this.connection.sendIQ(
221
                         dict.url = `${type}:`;
235
                         dict.url = `${type}:`;
222
                         const username = el.attr('username');
236
                         const username = el.attr('username');
223
 
237
 
224
-                            // https://code.google.com/p/webrtc/issues/detail?id=1508
238
+                        // https://code.google.com/p/webrtc/issues/detail
239
+                        // ?id=1508
225
 
240
 
226
                         if (username) {
241
                         if (username) {
227
                             if (navigator.userAgent.match(
242
                             if (navigator.userAgent.match(

+ 24
- 22
modules/xmpp/xmpp.js View File

47
 
47
 
48
         // Setup a disconnect on unload as a way to facilitate API consumers. It
48
         // Setup a disconnect on unload as a way to facilitate API consumers. It
49
         // sounds like they would want that. A problem for them though may be if
49
         // sounds like they would want that. A problem for them though may be if
50
-        // they wanted to utilize the connected connection in an unload handler of
51
-        // their own. However, it should be fairly easy for them to do that by
52
-        // registering their unload handler before us.
50
+        // they wanted to utilize the connected connection in an unload handler
51
+        // of their own. However, it should be fairly easy for them to do that
52
+        // by registering their unload handler before us.
53
         $(window).on('beforeunload unload', this.disconnect.bind(this));
53
         $(window).on('beforeunload unload', this.disconnect.bind(this));
54
     }
54
     }
55
 
55
 
56
     /**
56
     /**
57
-     * Initializes the list of feature advertised through the disco-info mechanism
57
+     * Initializes the list of feature advertised through the disco-info
58
+     * mechanism.
58
      */
59
      */
59
     initFeaturesList() {
60
     initFeaturesList() {
60
         // http://xmpp.org/extensions/xep-0167.html#support
61
         // http://xmpp.org/extensions/xep-0167.html#support
237
     }
238
     }
238
 
239
 
239
     /**
240
     /**
240
-     * Attach to existing connection. Can be used for optimizations. For example:
241
-     * if the connection is created on the server we can attach to it and start
242
-     * using it.
241
+     * Attach to existing connection. Can be used for optimizations. For
242
+     * example: if the connection is created on the server we can attach to it
243
+     * and start using it.
243
      *
244
      *
244
      * @param options {object} connecting options - rid, sid, jid and password.
245
      * @param options {object} connecting options - rid, sid, jid and password.
245
      */
246
      */
339
     /**
340
     /**
340
      * Disconnects this from the XMPP server (if this is connected).
341
      * Disconnects this from the XMPP server (if this is connected).
341
      *
342
      *
342
-     * @param ev optionally, the event which triggered the necessity to disconnect
343
-     * from the XMPP server (e.g. beforeunload, unload)
343
+     * @param ev optionally, the event which triggered the necessity to
344
+     * disconnect from the XMPP server (e.g. beforeunload, unload).
344
      */
345
      */
345
     disconnect(ev) {
346
     disconnect(ev) {
346
         if (this.disconnectInProgress
347
         if (this.disconnectInProgress
354
         this.disconnectInProgress = true;
355
         this.disconnectInProgress = true;
355
 
356
 
356
         // XXX Strophe is asynchronously sending by default. Unfortunately, that
357
         // XXX Strophe is asynchronously sending by default. Unfortunately, that
357
-        // means that there may not be enough time to send an unavailable presence
358
-        // or disconnect at all. Switching Strophe to synchronous sending is not
359
-        // much of an option because it may lead to a noticeable delay in navigating
360
-        // away from the current location. As a compromise, we will try to increase
361
-        // the chances of sending an unavailable presence and/or disconecting within
362
-        // the short time span that we have upon unloading by invoking flush() on
363
-        // the connection. We flush() once before disconnect() in order to attemtp
364
-        // to have its unavailable presence at the top of the send queue. We flush()
365
-        // once more after disconnect() in order to attempt to have its unavailable
366
-        // presence sent as soon as possible.
358
+        // means that there may not be enough time to send an unavailable
359
+        // presence or disconnect at all. Switching Strophe to synchronous
360
+        // sending is not much of an option because it may lead to a noticeable
361
+        // delay in navigating away from the current location. As a compromise,
362
+        // we will try to increase the chances of sending an unavailable
363
+        // presence and/or disconecting within the short time span that we have
364
+        // upon unloading by invoking flush() on the connection. We flush() once
365
+        // before disconnect() in order to attemtp to have its unavailable
366
+        // presence at the top of the send queue. We flush() once more after
367
+        // disconnect() in order to attempt to have its unavailable presence
368
+        // sent as soon as possible.
367
         this.connection.flush();
369
         this.connection.flush();
368
 
370
 
369
         if (ev !== null && typeof ev !== 'undefined') {
371
         if (ev !== null && typeof ev !== 'undefined') {
372
             if (evType == 'beforeunload' || evType == 'unload') {
374
             if (evType == 'beforeunload' || evType == 'unload') {
373
                 // XXX Whatever we said above, synchronous sending is the best
375
                 // XXX Whatever we said above, synchronous sending is the best
374
                 // (known) way to properly disconnect from the XMPP server.
376
                 // (known) way to properly disconnect from the XMPP server.
375
-                // Consequently, it may be fine to have the source code and comment
376
-                // it in or out depending on whether we want to run with it for some
377
-                // time.
377
+                // Consequently, it may be fine to have the source code and
378
+                // comment it in or out depending on whether we want to run with
379
+                // it for some time.
378
                 this.connection.options.sync = true;
380
                 this.connection.options.sync = true;
379
             }
381
             }
380
         }
382
         }

+ 2
- 2
service/RTC/CameraFacingMode.js View File

1
-/* global module */
2
 /**
1
 /**
3
  * The possible camera facing modes. For now support only 'user' and
2
  * The possible camera facing modes. For now support only 'user' and
4
  * 'environment' because 'left' and 'right' are not used anywhere in our
3
  * 'environment' because 'left' and 'right' are not used anywhere in our
5
  * projects at the time of this writing. For more information please refer to
4
  * projects at the time of this writing. For more information please refer to
6
- * https://w3c.github.io/mediacapture-main/getusermedia.html#def-constraint-facingMode
5
+ * https://w3c.github.io/mediacapture-main/getusermedia.html
6
+ * #def-constraint-facingMode.
7
  *
7
  *
8
  * @enum {string}
8
  * @enum {string}
9
  */
9
  */

Loading…
Cancel
Save