[RN] Rename createInitialLocalTracks to createLocalTracks

The name better suits its purpose, since it can be called at any time.
This commit is contained in:
Saúl Ibarra Corretgé 2017-08-14 15:25:37 +02:00 committed by Lyubo Marinov
parent 5358f022ff
commit c42f1704ff
4 changed files with 30 additions and 30 deletions

View File

@ -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 =>

View File

@ -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());
}
}

View File

@ -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

View File

@ -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<JitsiLocalTrack[]>}
*/
export function createLocalTracks(
export function createLocalTracksF(
options,
firePermissionPromptIsShownEvent,
store) {