|
@@ -27,8 +27,6 @@ let room, connection, localAudio, localVideo, roomLocker;
|
27
|
27
|
|
28
|
28
|
import {VIDEO_CONTAINER_TYPE} from "./modules/UI/videolayout/LargeVideo";
|
29
|
29
|
|
30
|
|
-const USER_MEDIA_PERMISSIONS_GUIDANCE_OVERLAY_TIMEOUT = 500;
|
31
|
|
-
|
32
|
30
|
/**
|
33
|
31
|
* Known custom conference commands.
|
34
|
32
|
*/
|
|
@@ -68,32 +66,26 @@ function connect(roomName) {
|
68
|
66
|
*/
|
69
|
67
|
function createInitialLocalTracksAndConnect(roomName) {
|
70
|
68
|
let audioAndVideoError,
|
71
|
|
- audioOnlyError,
|
72
|
|
- tracksCreated;
|
|
69
|
+ audioOnlyError;
|
|
70
|
+
|
|
71
|
+ JitsiMeetJS.mediaDevices.addEventListener(
|
|
72
|
+ JitsiMeetJS.events.mediaDevices.PERMISSION_PROMPT_IS_SHOWN,
|
|
73
|
+ browser => APP.UI.showUserMediaPermissionsGuidanceOverlay(browser));
|
73
|
74
|
|
74
|
75
|
// First try to retrieve both audio and video.
|
75
|
|
- let tryCreateLocalTracks = createLocalTracks(['audio', 'video'])
|
|
76
|
+ let tryCreateLocalTracks = createLocalTracks(
|
|
77
|
+ { devices: ['audio', 'video'] }, true)
|
76
|
78
|
.catch(err => {
|
77
|
79
|
// If failed then try to retrieve only audio.
|
78
|
80
|
audioAndVideoError = err;
|
79
|
|
- return createLocalTracks(['audio']);
|
|
81
|
+ return createLocalTracks({ devices: ['audio'] }, true);
|
80
|
82
|
})
|
81
|
83
|
.catch(err => {
|
82
|
84
|
// If audio failed too then just return empty array for tracks.
|
83
|
85
|
audioOnlyError = err;
|
84
|
86
|
return [];
|
85
|
|
- })
|
86
|
|
- .then(tracks => {
|
87
|
|
- tracksCreated = true;
|
88
|
|
- return tracks;
|
89
|
87
|
});
|
90
|
88
|
|
91
|
|
- window.setTimeout(() => {
|
92
|
|
- if (!audioAndVideoError && !audioOnlyError && !tracksCreated) {
|
93
|
|
- APP.UI.showUserMediaPermissionsGuidanceOverlay();
|
94
|
|
- }
|
95
|
|
- }, USER_MEDIA_PERMISSIONS_GUIDANCE_OVERLAY_TIMEOUT);
|
96
|
|
-
|
97
|
89
|
return Promise.all([ tryCreateLocalTracks, connect(roomName) ])
|
98
|
90
|
.then(([tracks, con]) => {
|
99
|
91
|
APP.UI.hideUserMediaPermissionsGuidanceOverlay();
|
|
@@ -245,32 +237,42 @@ function hangup (requestFeedback = false) {
|
245
|
237
|
|
246
|
238
|
/**
|
247
|
239
|
* Create local tracks of specified types.
|
248
|
|
- * @param {string[]} devices - required track types ('audio', 'video' etc.)
|
249
|
|
- * @param {string|null} [cameraDeviceId] - camera device id, if undefined - one
|
250
|
|
- * from settings will be used
|
251
|
|
- * @param {string|null} [micDeviceId] - microphone device id, if undefined - one
|
252
|
|
- * from settings will be used
|
|
240
|
+ * @param {Object} options
|
|
241
|
+ * @param {string[]} options.devices - required track types
|
|
242
|
+ * ('audio', 'video' etc.)
|
|
243
|
+ * @param {string|null} (options.cameraDeviceId) - camera device id, if
|
|
244
|
+ * undefined - one from settings will be used
|
|
245
|
+ * @param {string|null} (options.micDeviceId) - microphone device id, if
|
|
246
|
+ * undefined - one from settings will be used
|
|
247
|
+ * @param {boolean} (checkForPermissionPrompt) - if lib-jitsi-meet should check
|
|
248
|
+ * for gUM permission prompt
|
253
|
249
|
* @returns {Promise<JitsiLocalTrack[]>}
|
254
|
250
|
*/
|
255
|
|
-function createLocalTracks (devices, cameraDeviceId, micDeviceId) {
|
256
|
|
- return JitsiMeetJS.createLocalTracks({
|
257
|
|
- // copy array to avoid mutations inside library
|
258
|
|
- devices: devices.slice(0),
|
259
|
|
- resolution: config.resolution,
|
260
|
|
- cameraDeviceId: typeof cameraDeviceId === 'undefined'
|
261
|
|
- || cameraDeviceId === null
|
|
251
|
+function createLocalTracks (options, checkForPermissionPrompt) {
|
|
252
|
+ options || (options = {});
|
|
253
|
+
|
|
254
|
+ return JitsiMeetJS
|
|
255
|
+ .createLocalTracks({
|
|
256
|
+ // copy array to avoid mutations inside library
|
|
257
|
+ devices: options.devices.slice(0),
|
|
258
|
+ resolution: config.resolution,
|
|
259
|
+ cameraDeviceId: typeof options.cameraDeviceId === 'undefined' ||
|
|
260
|
+ options.cameraDeviceId === null
|
262
|
261
|
? APP.settings.getCameraDeviceId()
|
263
|
|
- : cameraDeviceId,
|
264
|
|
- micDeviceId: typeof micDeviceId === 'undefined' || micDeviceId === null
|
265
|
|
- ? APP.settings.getMicDeviceId()
|
266
|
|
- : micDeviceId,
|
267
|
|
- // adds any ff fake device settings if any
|
268
|
|
- firefox_fake_device: config.firefox_fake_device
|
269
|
|
- }).catch(function (err) {
|
270
|
|
- console.error('failed to create local tracks', ...devices, err);
|
271
|
|
- return Promise.reject(err);
|
272
|
|
- });
|
273
|
|
-}
|
|
262
|
+ : options.cameraDeviceId,
|
|
263
|
+ micDeviceId: typeof options.micDeviceId === 'undefined' ||
|
|
264
|
+ options.micDeviceId === null
|
|
265
|
+ ? APP.settings.getMicDeviceId()
|
|
266
|
+ : options.micDeviceId,
|
|
267
|
+ // adds any ff fake device settings if any
|
|
268
|
+ firefox_fake_device: config.firefox_fake_device
|
|
269
|
+ }, checkForPermissionPrompt)
|
|
270
|
+ .catch(function (err) {
|
|
271
|
+ console.error(
|
|
272
|
+ 'failed to create local tracks', options.devices, err);
|
|
273
|
+ return Promise.reject(err);
|
|
274
|
+ });
|
|
275
|
+ }
|
274
|
276
|
|
275
|
277
|
/**
|
276
|
278
|
* Changes the email for the local user
|
|
@@ -861,7 +863,7 @@ export default {
|
861
|
863
|
this.videoSwitchInProgress = true;
|
862
|
864
|
|
863
|
865
|
if (shareScreen) {
|
864
|
|
- createLocalTracks(['desktop']).then(([stream]) => {
|
|
866
|
+ createLocalTracks({ devices: ['desktop'] }).then(([stream]) => {
|
865
|
867
|
stream.on(
|
866
|
868
|
TrackEvents.LOCAL_TRACK_STOPPED,
|
867
|
869
|
() => {
|
|
@@ -918,7 +920,7 @@ export default {
|
918
|
920
|
APP.UI.messageHandler.openDialog(dialogTitle, dialogTxt, false);
|
919
|
921
|
});
|
920
|
922
|
} else {
|
921
|
|
- createLocalTracks(['video']).then(
|
|
923
|
+ createLocalTracks({ devices: ['video'] }).then(
|
922
|
924
|
([stream]) => this.useVideoStream(stream)
|
923
|
925
|
).then(() => {
|
924
|
926
|
this.videoSwitchInProgress = false;
|
|
@@ -1260,32 +1262,40 @@ export default {
|
1260
|
1262
|
APP.UI.addListener(
|
1261
|
1263
|
UIEvents.VIDEO_DEVICE_CHANGED,
|
1262
|
1264
|
(cameraDeviceId) => {
|
1263
|
|
- createLocalTracks(['video'], cameraDeviceId, null)
|
1264
|
|
- .then(([stream]) => {
|
1265
|
|
- this.useVideoStream(stream);
|
1266
|
|
- console.log('switched local video device');
|
1267
|
|
- APP.settings.setCameraDeviceId(cameraDeviceId);
|
1268
|
|
- })
|
1269
|
|
- .catch((err) => {
|
1270
|
|
- APP.UI.showDeviceErrorDialog(null, err);
|
1271
|
|
- APP.UI.setSelectedCameraFromSettings();
|
1272
|
|
- });
|
|
1265
|
+ createLocalTracks({
|
|
1266
|
+ devices: ['video'],
|
|
1267
|
+ cameraDeviceId: cameraDeviceId,
|
|
1268
|
+ micDeviceId: null
|
|
1269
|
+ })
|
|
1270
|
+ .then(([stream]) => {
|
|
1271
|
+ this.useVideoStream(stream);
|
|
1272
|
+ console.log('switched local video device');
|
|
1273
|
+ APP.settings.setCameraDeviceId(cameraDeviceId);
|
|
1274
|
+ })
|
|
1275
|
+ .catch((err) => {
|
|
1276
|
+ APP.UI.showDeviceErrorDialog(null, err);
|
|
1277
|
+ APP.UI.setSelectedCameraFromSettings();
|
|
1278
|
+ });
|
1273
|
1279
|
}
|
1274
|
1280
|
);
|
1275
|
1281
|
|
1276
|
1282
|
APP.UI.addListener(
|
1277
|
1283
|
UIEvents.AUDIO_DEVICE_CHANGED,
|
1278
|
1284
|
(micDeviceId) => {
|
1279
|
|
- createLocalTracks(['audio'], null, micDeviceId)
|
1280
|
|
- .then(([stream]) => {
|
1281
|
|
- this.useAudioStream(stream);
|
1282
|
|
- console.log('switched local audio device');
|
1283
|
|
- APP.settings.setMicDeviceId(micDeviceId);
|
1284
|
|
- })
|
1285
|
|
- .catch((err) => {
|
1286
|
|
- APP.UI.showDeviceErrorDialog(err, null);
|
1287
|
|
- APP.UI.setSelectedMicFromSettings();
|
1288
|
|
- });
|
|
1285
|
+ createLocalTracks({
|
|
1286
|
+ devices: ['audio'],
|
|
1287
|
+ cameraDeviceId: null,
|
|
1288
|
+ micDeviceId: micDeviceId
|
|
1289
|
+ })
|
|
1290
|
+ .then(([stream]) => {
|
|
1291
|
+ this.useAudioStream(stream);
|
|
1292
|
+ console.log('switched local audio device');
|
|
1293
|
+ APP.settings.setMicDeviceId(micDeviceId);
|
|
1294
|
+ })
|
|
1295
|
+ .catch((err) => {
|
|
1296
|
+ APP.UI.showDeviceErrorDialog(err, null);
|
|
1297
|
+ APP.UI.setSelectedMicFromSettings();
|
|
1298
|
+ });
|
1289
|
1299
|
}
|
1290
|
1300
|
);
|
1291
|
1301
|
|