Переглянути джерело

[RN] Rename createInitialLocalTracks to createLocalTracks

The name better suits its purpose, since it can be called at any time.
master
Saúl Ibarra Corretgé 8 роки тому
джерело
коміт
c42f1704ff

+ 22
- 22
conference.js Переглянути файл

57
     participantUpdated
57
     participantUpdated
58
 } from './react/features/base/participants';
58
 } from './react/features/base/participants';
59
 import {
59
 import {
60
-    createLocalTracks,
60
+    createLocalTracksF,
61
     isLocalTrackMuted,
61
     isLocalTrackMuted,
62
     replaceLocalTrack,
62
     replaceLocalTrack,
63
     trackAdded,
63
     trackAdded,
539
                         return [desktopStream];
539
                         return [desktopStream];
540
                     }
540
                     }
541
 
541
 
542
-                    return createLocalTracks({ devices: ['audio'] }, true)
542
+                    return createLocalTracksF({ devices: ['audio'] }, true)
543
                         .then(([audioStream]) => {
543
                         .then(([audioStream]) => {
544
                             return [desktopStream, audioStream];
544
                             return [desktopStream, audioStream];
545
                         })
545
                         })
551
                     logger.error('Failed to obtain desktop stream', error);
551
                     logger.error('Failed to obtain desktop stream', error);
552
                     screenSharingError = error;
552
                     screenSharingError = error;
553
                     return requestedAudio
553
                     return requestedAudio
554
-                        ? createLocalTracks({ devices: ['audio'] }, true)
554
+                        ? createLocalTracksF({ devices: ['audio'] }, true)
555
                         : [];
555
                         : [];
556
                 }).catch(error => {
556
                 }).catch(error => {
557
                     audioOnlyError = error;
557
                     audioOnlyError = error;
561
             // Resolve with no tracks
561
             // Resolve with no tracks
562
             tryCreateLocalTracks = Promise.resolve([]);
562
             tryCreateLocalTracks = Promise.resolve([]);
563
         } else {
563
         } else {
564
-            tryCreateLocalTracks = createLocalTracks(
564
+            tryCreateLocalTracks = createLocalTracksF(
565
                 { devices: initialDevices }, true)
565
                 { devices: initialDevices }, true)
566
                 .catch(err => {
566
                 .catch(err => {
567
                     if (requestedAudio && requestedVideo) {
567
                     if (requestedAudio && requestedVideo) {
569
                         // Try audio only...
569
                         // Try audio only...
570
                         audioAndVideoError = err;
570
                         audioAndVideoError = err;
571
 
571
 
572
-                        return createLocalTracks({devices: ['audio']}, true);
572
+                        return createLocalTracksF({devices: ['audio']}, true);
573
                     } else if (requestedAudio && !requestedVideo) {
573
                     } else if (requestedAudio && !requestedVideo) {
574
                         audioOnlyError = err;
574
                         audioOnlyError = err;
575
 
575
 
589
 
589
 
590
                     // Try video only...
590
                     // Try video only...
591
                     return requestedVideo
591
                     return requestedVideo
592
-                        ? createLocalTracks({devices: ['video']}, true)
592
+                        ? createLocalTracksF({devices: ['video']}, true)
593
                         : [];
593
                         : [];
594
                 })
594
                 })
595
                 .catch(err => {
595
                 .catch(err => {
781
         }
781
         }
782
 
782
 
783
         if (!this.localAudio && !mute) {
783
         if (!this.localAudio && !mute) {
784
-            createLocalTracks({ devices: ['audio'] }, false)
784
+            const maybeShowErrorDialog = error => {
785
+                showUI && APP.UI.showMicErrorNotification(error);
786
+            };
787
+
788
+            createLocalTracksF({ devices: ['audio'] }, false)
785
                 .then(([audioTrack]) => audioTrack)
789
                 .then(([audioTrack]) => audioTrack)
786
                 .catch(error => {
790
                 .catch(error => {
787
-                    if (showUI) {
788
-                        APP.UI.showMicErrorNotification(error);
789
-                    }
791
+                    maybeShowErrorDialog(error);
790
 
792
 
791
                     // Rollback the audio muted status by using null track
793
                     // Rollback the audio muted status by using null track
792
                     return null;
794
                     return null;
838
             return;
840
             return;
839
         }
841
         }
840
 
842
 
841
-        const maybeShowErrorDialog = (error) => {
842
-            if (showUI) {
843
-                APP.UI.showCameraErrorNotification(error);
844
-            }
845
-        };
846
-
847
         // FIXME it is possible to queue this task twice, but it's not causing
843
         // FIXME it is possible to queue this task twice, but it's not causing
848
         // any issues. Specifically this can happen when the previous
844
         // any issues. Specifically this can happen when the previous
849
         // get user media call is blocked on "ask user for permissions" dialog.
845
         // get user media call is blocked on "ask user for permissions" dialog.
850
         if (!this.localVideo && !mute) {
846
         if (!this.localVideo && !mute) {
847
+            const maybeShowErrorDialog = error => {
848
+                showUI && APP.UI.showCameraErrorNotification(error);
849
+            };
850
+
851
             // Try to create local video if there wasn't any.
851
             // Try to create local video if there wasn't any.
852
             // This handles the case when user joined with no video
852
             // This handles the case when user joined with no video
853
             // (dismissed screen sharing screen or in audio only mode), but
853
             // (dismissed screen sharing screen or in audio only mode), but
856
             //
856
             //
857
             // FIXME when local track creation is moved to react/redux
857
             // FIXME when local track creation is moved to react/redux
858
             // it should take care of the use case described above
858
             // it should take care of the use case described above
859
-            createLocalTracks({ devices: ['video'] }, false)
859
+            createLocalTracksF({ devices: ['video'] }, false)
860
                 .then(([videoTrack]) => videoTrack)
860
                 .then(([videoTrack]) => videoTrack)
861
                 .catch(error => {
861
                 .catch(error => {
862
                     // FIXME should send some feedback to the API on error ?
862
                     // FIXME should send some feedback to the API on error ?
1326
         let promise = null;
1326
         let promise = null;
1327
 
1327
 
1328
         if (didHaveVideo) {
1328
         if (didHaveVideo) {
1329
-            promise = createLocalTracks({ devices: ['video'] })
1329
+            promise = createLocalTracksF({ devices: ['video'] })
1330
                 .then(([stream]) => this.useVideoStream(stream))
1330
                 .then(([stream]) => this.useVideoStream(stream))
1331
                 .then(() => {
1331
                 .then(() => {
1332
                     JitsiMeetJS.analytics.sendEvent(
1332
                     JitsiMeetJS.analytics.sendEvent(
1412
         const didHaveVideo = Boolean(this.localVideo);
1412
         const didHaveVideo = Boolean(this.localVideo);
1413
         const wasVideoMuted = this.isLocalVideoMuted();
1413
         const wasVideoMuted = this.isLocalVideoMuted();
1414
 
1414
 
1415
-        return createLocalTracks({
1415
+        return createLocalTracksF({
1416
             desktopSharingSources: options.desktopSharingSources,
1416
             desktopSharingSources: options.desktopSharingSources,
1417
             devices: ['desktop'],
1417
             devices: ['desktop'],
1418
             desktopSharingExtensionExternalInstallation: {
1418
             desktopSharingExtensionExternalInstallation: {
2021
             UIEvents.VIDEO_DEVICE_CHANGED,
2021
             UIEvents.VIDEO_DEVICE_CHANGED,
2022
             (cameraDeviceId) => {
2022
             (cameraDeviceId) => {
2023
                 JitsiMeetJS.analytics.sendEvent('settings.changeDevice.video');
2023
                 JitsiMeetJS.analytics.sendEvent('settings.changeDevice.video');
2024
-                createLocalTracks({
2024
+                createLocalTracksF({
2025
                     devices: ['video'],
2025
                     devices: ['video'],
2026
                     cameraDeviceId: cameraDeviceId,
2026
                     cameraDeviceId: cameraDeviceId,
2027
                     micDeviceId: null
2027
                     micDeviceId: null
2050
             (micDeviceId) => {
2050
             (micDeviceId) => {
2051
                 JitsiMeetJS.analytics.sendEvent(
2051
                 JitsiMeetJS.analytics.sendEvent(
2052
                     'settings.changeDevice.audioIn');
2052
                     'settings.changeDevice.audioIn');
2053
-                createLocalTracks({
2053
+                createLocalTracksF({
2054
                     devices: ['audio'],
2054
                     devices: ['audio'],
2055
                     cameraDeviceId: null,
2055
                     cameraDeviceId: null,
2056
                     micDeviceId: micDeviceId
2056
                     micDeviceId: micDeviceId
2281
 
2281
 
2282
         promises.push(
2282
         promises.push(
2283
             mediaDeviceHelper.createLocalTracksAfterDeviceListChanged(
2283
             mediaDeviceHelper.createLocalTracksAfterDeviceListChanged(
2284
-                    createLocalTracks,
2284
+                    createLocalTracksF,
2285
                     newDevices.videoinput,
2285
                     newDevices.videoinput,
2286
                     newDevices.audioinput)
2286
                     newDevices.audioinput)
2287
                 .then(tracks =>
2287
                 .then(tracks =>

+ 2
- 2
react/features/app/middleware.js Переглянути файл

5
     SET_LOCATION_URL
5
     SET_LOCATION_URL
6
 } from '../base/connection';
6
 } from '../base/connection';
7
 import { MiddlewareRegistry } from '../base/redux';
7
 import { MiddlewareRegistry } from '../base/redux';
8
-import { createInitialLocalTracks, destroyLocalTracks } from '../base/tracks';
8
+import { createLocalTracksA, destroyLocalTracks } from '../base/tracks';
9
 
9
 
10
 MiddlewareRegistry.register(store => next => action => {
10
 MiddlewareRegistry.register(store => next => action => {
11
     switch (action.type) {
11
     switch (action.type) {
99
         } else {
99
         } else {
100
             // Create the local tracks if they haven't been created yet.
100
             // Create the local tracks if they haven't been created yet.
101
             state['features/base/tracks'].some(t => t.local)
101
             state['features/base/tracks'].some(t => t.local)
102
-                || dispatch(createInitialLocalTracks());
102
+                || dispatch(createLocalTracksA());
103
         }
103
         }
104
     }
104
     }
105
 
105
 

+ 5
- 5
react/features/base/tracks/actions.js Переглянути файл

8
 import { getLocalParticipant } from '../participants';
8
 import { getLocalParticipant } from '../participants';
9
 
9
 
10
 import { TRACK_ADDED, TRACK_REMOVED, TRACK_UPDATED } from './actionTypes';
10
 import { TRACK_ADDED, TRACK_REMOVED, TRACK_UPDATED } from './actionTypes';
11
-import { createLocalTracks } from './functions';
11
+import { createLocalTracksF } from './functions';
12
 
12
 
13
 /**
13
 /**
14
  * Request to start capturing local audio and/or video. By default, the user
14
  * Request to start capturing local audio and/or video. By default, the user
17
  * @param {Object} [options] - For info @see JitsiMeetJS.createLocalTracks.
17
  * @param {Object} [options] - For info @see JitsiMeetJS.createLocalTracks.
18
  * @returns {Function}
18
  * @returns {Function}
19
  */
19
  */
20
-export function createInitialLocalTracks(options = {}) {
20
+export function createLocalTracksA(options = {}) {
21
     return (dispatch, getState) => {
21
     return (dispatch, getState) => {
22
         const devices
22
         const devices
23
             = options.devices || [ MEDIA_TYPE.AUDIO, MEDIA_TYPE.VIDEO ];
23
             = options.devices || [ MEDIA_TYPE.AUDIO, MEDIA_TYPE.VIDEO ];
28
 
28
 
29
         // The following executes on React Native only at the time of this
29
         // The following executes on React Native only at the time of this
30
         // writing. The effort to port Web's createInitialLocalTracksAndConnect
30
         // writing. The effort to port Web's createInitialLocalTracksAndConnect
31
-        // is significant and that's where the function createLocalTracks got
31
+        // is significant and that's where the function createLocalTracksF got
32
         // born. I started with the idea a porting so that we could inherit the
32
         // born. I started with the idea a porting so that we could inherit the
33
         // ability to getUserMedia for audio only or video only if getUserMedia
33
         // ability to getUserMedia for audio only or video only if getUserMedia
34
         // for audio and video fails. Eventually though, I realized that on
34
         // for audio and video fails. Eventually though, I realized that on
37
         // to implement them) and the right thing to do is to ask for each
37
         // to implement them) and the right thing to do is to ask for each
38
         // device separately.
38
         // device separately.
39
         for (const device of devices) {
39
         for (const device of devices) {
40
-            createLocalTracks(
40
+            createLocalTracksF(
41
                 {
41
                 {
42
                     cameraDeviceId: options.cameraDeviceId,
42
                     cameraDeviceId: options.cameraDeviceId,
43
                     devices: [ device ],
43
                     devices: [ device ],
48
                 store)
48
                 store)
49
             .then(localTracks => dispatch(_updateLocalTracks(localTracks)));
49
             .then(localTracks => dispatch(_updateLocalTracks(localTracks)));
50
 
50
 
51
-            // TODO The function createLocalTracks logs the rejection reason of
51
+            // TODO The function createLocalTracksF logs the rejection reason of
52
             // JitsiMeetJS.createLocalTracks so there is no real benefit to
52
             // JitsiMeetJS.createLocalTracks so there is no real benefit to
53
             // logging it here as well. Technically though,
53
             // logging it here as well. Technically though,
54
             // _updateLocalTracks may cause a rejection so it may be nice to log
54
             // _updateLocalTracks may cause a rejection so it may be nice to log

+ 1
- 1
react/features/base/tracks/functions.js Переглянути файл

23
  * is to execute and from which state such as {@code config} is to be retrieved.
23
  * is to execute and from which state such as {@code config} is to be retrieved.
24
  * @returns {Promise<JitsiLocalTrack[]>}
24
  * @returns {Promise<JitsiLocalTrack[]>}
25
  */
25
  */
26
-export function createLocalTracks(
26
+export function createLocalTracksF(
27
         options,
27
         options,
28
         firePermissionPromptIsShownEvent,
28
         firePermissionPromptIsShownEvent,
29
         store) {
29
         store) {

Завантаження…
Відмінити
Зберегти