diff --git a/conference.js b/conference.js index df8add4ef..3a45895f6 100644 --- a/conference.js +++ b/conference.js @@ -57,7 +57,7 @@ import { participantUpdated } from './react/features/base/participants'; import { - createLocalTracks, + createLocalTracksF, isLocalTrackMuted, replaceLocalTrack, trackAdded, @@ -539,7 +539,7 @@ export default { return [desktopStream]; } - return createLocalTracks({ devices: ['audio'] }, true) + return createLocalTracksF({ devices: ['audio'] }, true) .then(([audioStream]) => { return [desktopStream, audioStream]; }) @@ -551,7 +551,7 @@ export default { logger.error('Failed to obtain desktop stream', error); screenSharingError = error; return requestedAudio - ? createLocalTracks({ devices: ['audio'] }, true) + ? createLocalTracksF({ devices: ['audio'] }, true) : []; }).catch(error => { audioOnlyError = error; @@ -561,7 +561,7 @@ export default { // Resolve with no tracks tryCreateLocalTracks = Promise.resolve([]); } else { - tryCreateLocalTracks = createLocalTracks( + tryCreateLocalTracks = createLocalTracksF( { devices: initialDevices }, true) .catch(err => { if (requestedAudio && requestedVideo) { @@ -569,7 +569,7 @@ export default { // Try audio only... audioAndVideoError = err; - return createLocalTracks({devices: ['audio']}, true); + return createLocalTracksF({devices: ['audio']}, true); } else if (requestedAudio && !requestedVideo) { audioOnlyError = err; @@ -589,7 +589,7 @@ export default { // Try video only... return requestedVideo - ? createLocalTracks({devices: ['video']}, true) + ? createLocalTracksF({devices: ['video']}, true) : []; }) .catch(err => { @@ -781,12 +781,14 @@ export default { } if (!this.localAudio && !mute) { - createLocalTracks({ devices: ['audio'] }, false) + const maybeShowErrorDialog = error => { + showUI && APP.UI.showMicErrorNotification(error); + }; + + createLocalTracksF({ devices: ['audio'] }, false) .then(([audioTrack]) => audioTrack) .catch(error => { - if (showUI) { - APP.UI.showMicErrorNotification(error); - } + maybeShowErrorDialog(error); // Rollback the audio muted status by using null track return null; @@ -838,16 +840,14 @@ export default { return; } - const maybeShowErrorDialog = (error) => { - if (showUI) { - APP.UI.showCameraErrorNotification(error); - } - }; - // FIXME it is possible to queue this task twice, but it's not causing // any issues. Specifically this can happen when the previous // get user media call is blocked on "ask user for permissions" dialog. if (!this.localVideo && !mute) { + const maybeShowErrorDialog = error => { + showUI && APP.UI.showCameraErrorNotification(error); + }; + // Try to create local video if there wasn't any. // This handles the case when user joined with no video // (dismissed screen sharing screen or in audio only mode), but @@ -856,7 +856,7 @@ export default { // // FIXME when local track creation is moved to react/redux // it should take care of the use case described above - createLocalTracks({ devices: ['video'] }, false) + createLocalTracksF({ devices: ['video'] }, false) .then(([videoTrack]) => videoTrack) .catch(error => { // FIXME should send some feedback to the API on error ? @@ -1326,7 +1326,7 @@ export default { let promise = null; if (didHaveVideo) { - promise = createLocalTracks({ devices: ['video'] }) + promise = createLocalTracksF({ devices: ['video'] }) .then(([stream]) => this.useVideoStream(stream)) .then(() => { JitsiMeetJS.analytics.sendEvent( @@ -1412,7 +1412,7 @@ export default { const didHaveVideo = Boolean(this.localVideo); const wasVideoMuted = this.isLocalVideoMuted(); - return createLocalTracks({ + return createLocalTracksF({ desktopSharingSources: options.desktopSharingSources, devices: ['desktop'], desktopSharingExtensionExternalInstallation: { @@ -2021,7 +2021,7 @@ export default { UIEvents.VIDEO_DEVICE_CHANGED, (cameraDeviceId) => { JitsiMeetJS.analytics.sendEvent('settings.changeDevice.video'); - createLocalTracks({ + createLocalTracksF({ devices: ['video'], cameraDeviceId: cameraDeviceId, micDeviceId: null @@ -2050,7 +2050,7 @@ export default { (micDeviceId) => { JitsiMeetJS.analytics.sendEvent( 'settings.changeDevice.audioIn'); - createLocalTracks({ + createLocalTracksF({ devices: ['audio'], cameraDeviceId: null, micDeviceId: micDeviceId @@ -2281,7 +2281,7 @@ export default { promises.push( mediaDeviceHelper.createLocalTracksAfterDeviceListChanged( - createLocalTracks, + createLocalTracksF, newDevices.videoinput, newDevices.audioinput) .then(tracks => diff --git a/react/features/app/middleware.js b/react/features/app/middleware.js index 589f2410b..e154bb138 100644 --- a/react/features/app/middleware.js +++ b/react/features/app/middleware.js @@ -5,7 +5,7 @@ import { SET_LOCATION_URL } from '../base/connection'; import { MiddlewareRegistry } from '../base/redux'; -import { createInitialLocalTracks, destroyLocalTracks } from '../base/tracks'; +import { createLocalTracksA, destroyLocalTracks } from '../base/tracks'; MiddlewareRegistry.register(store => next => action => { switch (action.type) { @@ -99,7 +99,7 @@ function _navigate({ dispatch, getState }) { } else { // Create the local tracks if they haven't been created yet. state['features/base/tracks'].some(t => t.local) - || dispatch(createInitialLocalTracks()); + || dispatch(createLocalTracksA()); } } diff --git a/react/features/base/tracks/actions.js b/react/features/base/tracks/actions.js index eabaa57c7..54bd89261 100644 --- a/react/features/base/tracks/actions.js +++ b/react/features/base/tracks/actions.js @@ -8,7 +8,7 @@ import { import { getLocalParticipant } from '../participants'; import { TRACK_ADDED, TRACK_REMOVED, TRACK_UPDATED } from './actionTypes'; -import { createLocalTracks } from './functions'; +import { createLocalTracksF } from './functions'; /** * Request to start capturing local audio and/or video. By default, the user @@ -17,7 +17,7 @@ import { createLocalTracks } from './functions'; * @param {Object} [options] - For info @see JitsiMeetJS.createLocalTracks. * @returns {Function} */ -export function createInitialLocalTracks(options = {}) { +export function createLocalTracksA(options = {}) { return (dispatch, getState) => { const devices = options.devices || [ MEDIA_TYPE.AUDIO, MEDIA_TYPE.VIDEO ]; @@ -28,7 +28,7 @@ export function createInitialLocalTracks(options = {}) { // The following executes on React Native only at the time of this // writing. The effort to port Web's createInitialLocalTracksAndConnect - // is significant and that's where the function createLocalTracks got + // is significant and that's where the function createLocalTracksF got // born. I started with the idea a porting so that we could inherit the // ability to getUserMedia for audio only or video only if getUserMedia // for audio and video fails. Eventually though, I realized that on @@ -37,7 +37,7 @@ export function createInitialLocalTracks(options = {}) { // to implement them) and the right thing to do is to ask for each // device separately. for (const device of devices) { - createLocalTracks( + createLocalTracksF( { cameraDeviceId: options.cameraDeviceId, devices: [ device ], @@ -48,7 +48,7 @@ export function createInitialLocalTracks(options = {}) { store) .then(localTracks => dispatch(_updateLocalTracks(localTracks))); - // TODO The function createLocalTracks logs the rejection reason of + // TODO The function createLocalTracksF logs the rejection reason of // JitsiMeetJS.createLocalTracks so there is no real benefit to // logging it here as well. Technically though, // _updateLocalTracks may cause a rejection so it may be nice to log diff --git a/react/features/base/tracks/functions.js b/react/features/base/tracks/functions.js index 3a44d84b5..925b00500 100644 --- a/react/features/base/tracks/functions.js +++ b/react/features/base/tracks/functions.js @@ -23,7 +23,7 @@ const logger = require('jitsi-meet-logger').getLogger(__filename); * is to execute and from which state such as {@code config} is to be retrieved. * @returns {Promise} */ -export function createLocalTracks( +export function createLocalTracksF( options, firePermissionPromptIsShownEvent, store) {