|
|
@@ -19,7 +19,7 @@ const ConferenceErrors = JitsiMeetJS.errors.conference;
|
|
19
|
19
|
const TrackEvents = JitsiMeetJS.events.track;
|
|
20
|
20
|
const TrackErrors = JitsiMeetJS.errors.track;
|
|
21
|
21
|
|
|
22
|
|
-let room, connection, localTracks, localAudio, localVideo, roomLocker;
|
|
|
22
|
+let room, connection, localAudio, localVideo, roomLocker;
|
|
23
|
23
|
|
|
24
|
24
|
/**
|
|
25
|
25
|
* Known custom conference commands.
|
|
|
@@ -120,6 +120,8 @@ function createLocalTracks (...devices) {
|
|
120
|
120
|
// copy array to avoid mutations inside library
|
|
121
|
121
|
devices: devices.slice(0),
|
|
122
|
122
|
resolution: config.resolution,
|
|
|
123
|
+ cameraDeviceId: APP.settings.getCameraDeviceId(),
|
|
|
124
|
+ micDeviceId: APP.settings.getMicDeviceId(),
|
|
123
|
125
|
// adds any ff fake device settings if any
|
|
124
|
126
|
firefox_fake_device: config.firefox_fake_device
|
|
125
|
127
|
}).catch(function (err) {
|
|
|
@@ -293,11 +295,19 @@ export default {
|
|
293
|
295
|
]);
|
|
294
|
296
|
}).then(([tracks, con]) => {
|
|
295
|
297
|
console.log('initialized with %s local tracks', tracks.length);
|
|
296
|
|
- localTracks = tracks;
|
|
297
|
298
|
connection = con;
|
|
298
|
|
- this._createRoom();
|
|
|
299
|
+ this._createRoom(tracks);
|
|
299
|
300
|
this.isDesktopSharingEnabled =
|
|
300
|
301
|
JitsiMeetJS.isDesktopSharingEnabled();
|
|
|
302
|
+
|
|
|
303
|
+ // update list of available devices
|
|
|
304
|
+ if (JitsiMeetJS.isDeviceListAvailable() &&
|
|
|
305
|
+ JitsiMeetJS.isDeviceChangeAvailable()) {
|
|
|
306
|
+ JitsiMeetJS.enumerateDevices((devices) => {
|
|
|
307
|
+ this.availableDevices = devices;
|
|
|
308
|
+ APP.UI.onAvailableDevicesChanged();
|
|
|
309
|
+ });
|
|
|
310
|
+ }
|
|
301
|
311
|
// XXX The API will take care of disconnecting from the XMPP server
|
|
302
|
312
|
// (and, thus, leaving the room) on unload.
|
|
303
|
313
|
return new Promise((resolve, reject) => {
|
|
|
@@ -360,6 +370,10 @@ export default {
|
|
360
|
370
|
listMembersIds () {
|
|
361
|
371
|
return room.getParticipants().map(p => p.getId());
|
|
362
|
372
|
},
|
|
|
373
|
+ /**
|
|
|
374
|
+ * List of available cameras and microphones.
|
|
|
375
|
+ */
|
|
|
376
|
+ availableDevices: [],
|
|
363
|
377
|
/**
|
|
364
|
378
|
* Check if SIP is supported.
|
|
365
|
379
|
* @returns {boolean}
|
|
|
@@ -449,32 +463,30 @@ export default {
|
|
449
|
463
|
getLogs () {
|
|
450
|
464
|
return room.getLogs();
|
|
451
|
465
|
},
|
|
452
|
|
- _createRoom () {
|
|
|
466
|
+ _createRoom (localTracks) {
|
|
453
|
467
|
room = connection.initJitsiConference(APP.conference.roomName,
|
|
454
|
468
|
this._getConferenceOptions());
|
|
455
|
469
|
this.localId = room.myUserId();
|
|
456
|
470
|
localTracks.forEach((track) => {
|
|
457
|
|
- if(track.isAudioTrack()) {
|
|
458
|
|
- localAudio = track;
|
|
459
|
|
- }
|
|
460
|
|
- else if (track.isVideoTrack()) {
|
|
461
|
|
- localVideo = track;
|
|
462
|
|
- }
|
|
463
|
471
|
room.addTrack(track);
|
|
464
|
|
- APP.UI.addLocalStream(track);
|
|
|
472
|
+
|
|
|
473
|
+ if (track.isAudioTrack()) {
|
|
|
474
|
+ this.useAudioStream(track);
|
|
|
475
|
+ } else if (track.isVideoTrack()) {
|
|
|
476
|
+ this.useVideoStream(track);
|
|
|
477
|
+ }
|
|
465
|
478
|
});
|
|
466
|
479
|
roomLocker = createRoomLocker(room);
|
|
467
|
480
|
this._room = room; // FIXME do not use this
|
|
468
|
|
- this.localId = room.myUserId();
|
|
469
|
481
|
|
|
470
|
482
|
let email = APP.settings.getEmail();
|
|
471
|
483
|
email && sendEmail(email);
|
|
472
|
484
|
|
|
473
|
485
|
let nick = APP.settings.getDisplayName();
|
|
474
|
|
- (config.useNicks && !nick) && (() => {
|
|
|
486
|
+ if (config.useNicks && !nick) {
|
|
475
|
487
|
nick = APP.UI.askForNickname();
|
|
476
|
488
|
APP.settings.setDisplayName(nick);
|
|
477
|
|
- })();
|
|
|
489
|
+ }
|
|
478
|
490
|
nick && room.setDisplayName(nick);
|
|
479
|
491
|
|
|
480
|
492
|
this._setupListeners();
|
|
|
@@ -489,6 +501,55 @@ export default {
|
|
489
|
501
|
return options;
|
|
490
|
502
|
},
|
|
491
|
503
|
|
|
|
504
|
+ /**
|
|
|
505
|
+ * Start using provided video stream.
|
|
|
506
|
+ * Stops previous video stream.
|
|
|
507
|
+ * @param {JitsiLocalTrack} [stream] new stream to use or null
|
|
|
508
|
+ */
|
|
|
509
|
+ useVideoStream (stream) {
|
|
|
510
|
+ if (localVideo) {
|
|
|
511
|
+ localVideo.stop();
|
|
|
512
|
+ }
|
|
|
513
|
+ localVideo = stream;
|
|
|
514
|
+
|
|
|
515
|
+ if (stream) {
|
|
|
516
|
+ this.videoMuted = stream.isMuted();
|
|
|
517
|
+
|
|
|
518
|
+ APP.UI.addLocalStream(stream);
|
|
|
519
|
+
|
|
|
520
|
+ this.isSharingScreen = stream.videoType === 'desktop';
|
|
|
521
|
+ } else {
|
|
|
522
|
+ this.videoMuted = false;
|
|
|
523
|
+ this.isSharingScreen = false;
|
|
|
524
|
+ }
|
|
|
525
|
+
|
|
|
526
|
+ APP.UI.setVideoMuted(this.localId, this.videoMuted);
|
|
|
527
|
+
|
|
|
528
|
+ APP.UI.updateDesktopSharingButtons();
|
|
|
529
|
+ },
|
|
|
530
|
+
|
|
|
531
|
+ /**
|
|
|
532
|
+ * Start using provided audio stream.
|
|
|
533
|
+ * Stops previous audio stream.
|
|
|
534
|
+ * @param {JitsiLocalTrack} [stream] new stream to use or null
|
|
|
535
|
+ */
|
|
|
536
|
+ useAudioStream (stream) {
|
|
|
537
|
+ if (localAudio) {
|
|
|
538
|
+ localAudio.stop();
|
|
|
539
|
+ }
|
|
|
540
|
+ localAudio = stream;
|
|
|
541
|
+
|
|
|
542
|
+ if (stream) {
|
|
|
543
|
+ this.audioMuted = stream.isMuted();
|
|
|
544
|
+
|
|
|
545
|
+ APP.UI.addLocalStream(stream);
|
|
|
546
|
+ } else {
|
|
|
547
|
+ this.audioMuted = false;
|
|
|
548
|
+ }
|
|
|
549
|
+
|
|
|
550
|
+ APP.UI.setAudioMuted(this.localId, this.audioMuted);
|
|
|
551
|
+ },
|
|
|
552
|
+
|
|
492
|
553
|
videoSwitchInProgress: false,
|
|
493
|
554
|
toggleScreenSharing () {
|
|
494
|
555
|
if (this.videoSwitchInProgress) {
|
|
|
@@ -507,22 +568,13 @@ export default {
|
|
507
|
568
|
createLocalTracks('video').then(function ([stream]) {
|
|
508
|
569
|
return room.addTrack(stream);
|
|
509
|
570
|
}).then((stream) => {
|
|
510
|
|
- if (localVideo) {
|
|
511
|
|
- localVideo.stop();
|
|
512
|
|
- }
|
|
513
|
|
- localVideo = stream;
|
|
514
|
|
- this.videoMuted = stream.isMuted();
|
|
515
|
|
- APP.UI.setVideoMuted(this.localId, this.videoMuted);
|
|
516
|
|
-
|
|
517
|
|
- APP.UI.addLocalStream(stream);
|
|
|
571
|
+ this.useVideoStream(stream);
|
|
|
572
|
+ this.videoSwitchInProgress = false;
|
|
518
|
573
|
console.log('sharing local video');
|
|
519
|
|
- }).catch((err) => {
|
|
520
|
|
- localVideo = null;
|
|
521
|
|
- console.error('failed to share local video', err);
|
|
522
|
|
- }).then(() => {
|
|
|
574
|
+ }).catch(function (err) {
|
|
|
575
|
+ this.useVideoStream(null);
|
|
523
|
576
|
this.videoSwitchInProgress = false;
|
|
524
|
|
- this.isSharingScreen = false;
|
|
525
|
|
- APP.UI.updateDesktopSharingButtons();
|
|
|
577
|
+ console.error('failed to share local video', err);
|
|
526
|
578
|
});
|
|
527
|
579
|
} else {
|
|
528
|
580
|
// stop sharing video and share desktop
|
|
|
@@ -541,19 +593,8 @@ export default {
|
|
541
|
593
|
);
|
|
542
|
594
|
return room.addTrack(stream);
|
|
543
|
595
|
}).then((stream) => {
|
|
544
|
|
- if (localVideo) {
|
|
545
|
|
- localVideo.stop();
|
|
546
|
|
- }
|
|
547
|
|
- localVideo = stream;
|
|
548
|
|
-
|
|
549
|
|
- this.videoMuted = stream.isMuted();
|
|
550
|
|
- APP.UI.setVideoMuted(this.localId, this.videoMuted);
|
|
551
|
|
-
|
|
552
|
|
- APP.UI.addLocalStream(stream);
|
|
553
|
|
-
|
|
|
596
|
+ this.useVideoStream(stream);
|
|
554
|
597
|
this.videoSwitchInProgress = false;
|
|
555
|
|
- this.isSharingScreen = true;
|
|
556
|
|
- APP.UI.updateDesktopSharingButtons();
|
|
557
|
598
|
console.log('sharing local desktop');
|
|
558
|
599
|
}).catch((err) => {
|
|
559
|
600
|
this.videoSwitchInProgress = false;
|
|
|
@@ -907,6 +948,30 @@ export default {
|
|
907
|
948
|
room.pinParticipant(id);
|
|
908
|
949
|
});
|
|
909
|
950
|
|
|
|
951
|
+ APP.UI.addListener(
|
|
|
952
|
+ UIEvents.VIDEO_DEVICE_CHANGED,
|
|
|
953
|
+ (cameraDeviceId) => {
|
|
|
954
|
+ APP.settings.setCameraDeviceId(cameraDeviceId);
|
|
|
955
|
+ createLocalTracks('video').then(([stream]) => {
|
|
|
956
|
+ room.addTrack(stream);
|
|
|
957
|
+ this.useVideoStream(stream);
|
|
|
958
|
+ console.log('switched local video device');
|
|
|
959
|
+ });
|
|
|
960
|
+ }
|
|
|
961
|
+ );
|
|
|
962
|
+
|
|
|
963
|
+ APP.UI.addListener(
|
|
|
964
|
+ UIEvents.AUDIO_DEVICE_CHANGED,
|
|
|
965
|
+ (micDeviceId) => {
|
|
|
966
|
+ APP.settings.setMicDeviceId(micDeviceId);
|
|
|
967
|
+ createLocalTracks('audio').then(([stream]) => {
|
|
|
968
|
+ room.addTrack(stream);
|
|
|
969
|
+ this.useAudioStream(stream);
|
|
|
970
|
+ console.log('switched local audio device');
|
|
|
971
|
+ });
|
|
|
972
|
+ }
|
|
|
973
|
+ );
|
|
|
974
|
+
|
|
910
|
975
|
APP.UI.addListener(
|
|
911
|
976
|
UIEvents.TOGGLE_SCREENSHARING, this.toggleScreenSharing.bind(this)
|
|
912
|
977
|
);
|