Browse Source

Simplify

Simplify the source code (with the idea that source code which does not
exist does not have to be maintained).

Additionally, apply modifications to have the source code comply with the coding
style.

Overall, prepare saghul:audio-mode for merge into jitsi:master.
efficient_tiling
Lyubomir Marinov 8 years ago
parent
commit
3c04634609

+ 0
- 14
ios/app/AudioMode.h View File

1
-#import <AVFoundation/AVFoundation.h>
2
-#import <Foundation/Foundation.h>
3
-
4
-#import "RCTBridgeModule.h"
5
-
6
-
7
-@interface AudioMode : NSObject<RCTBridgeModule>
8
-
9
-@property (nonatomic, readonly) AVAudioSession *session;
10
-@property (nonatomic, readonly) NSString *category;
11
-@property (nonatomic, readonly) NSString *mode;
12
-@property (nonatomic, readonly) BOOL initialized;
13
-
14
-@end

+ 67
- 63
ios/app/AudioMode.m View File

1
-#import "AudioMode.h"
1
+#import "RCTBridgeModule.h"
2
 #import "RCTLog.h"
2
 #import "RCTLog.h"
3
 
3
 
4
+#import <AVFoundation/AVFoundation.h>
4
 
5
 
5
-@implementation AudioMode
6
+@interface AudioMode : NSObject<RCTBridgeModule>
7
+@end
8
+
9
+@implementation AudioMode {
10
+    NSString *_category;
11
+    NSString *_mode;
12
+}
6
 
13
 
7
 RCT_EXPORT_MODULE();
14
 RCT_EXPORT_MODULE();
8
 
15
 
12
     kAudioModeVideoCall
19
     kAudioModeVideoCall
13
 } JitsiMeetAudioMode;
20
 } JitsiMeetAudioMode;
14
 
21
 
15
-- (instancetype)init
16
-{
22
+- (NSDictionary *)constantsToExport {
23
+    return @{
24
+        @"AUDIO_CALL" : [NSNumber numberWithInt: kAudioModeAudioCall],
25
+        @"DEFAULT"    : [NSNumber numberWithInt: kAudioModeDefault],
26
+        @"VIDEO_CALL" : [NSNumber numberWithInt: kAudioModeVideoCall]
27
+    };
28
+};
29
+
30
+- (instancetype)init {
17
     self = [super init];
31
     self = [super init];
18
     if (self) {
32
     if (self) {
19
-        _initialized = NO;
20
         _category = nil;
33
         _category = nil;
21
         _mode = nil;
34
         _mode = nil;
22
-        _session = [AVAudioSession sharedInstance];
23
     }
35
     }
24
     return self;
36
     return self;
25
 }
37
 }
26
 
38
 
27
-- (dispatch_queue_t)methodQueue
28
-{
39
+- (dispatch_queue_t)methodQueue {
29
     // Make sure all our methods run in the main thread.  The route change
40
     // Make sure all our methods run in the main thread.  The route change
30
     // notification runs there so this will make sure it will only be fired
41
     // notification runs there so this will make sure it will only be fired
31
     // after our changes have been applied (when we cause them, that is).
42
     // after our changes have been applied (when we cause them, that is).
33
 }
44
 }
34
 
45
 
35
 - (void)routeChanged:(NSNotification*)notification {
46
 - (void)routeChanged:(NSNotification*)notification {
36
-    NSDictionary *dict = notification.userInfo;
37
-    NSInteger reason = [[dict valueForKey:AVAudioSessionRouteChangeReasonKey]
38
-                        integerValue];
47
+    NSInteger reason
48
+        = [[notification.userInfo
49
+                valueForKey:AVAudioSessionRouteChangeReasonKey]
50
+            integerValue];
51
+
39
     switch (reason) {
52
     switch (reason) {
40
-    case AVAudioSessionRouteChangeReasonCategoryChange: {
41
-        // The category has changed, check if it's the one we want and adjust
42
-        // as needed.
43
-        BOOL success;
44
-        NSError *error;
45
-
46
-        if (_session.category != _category) {
47
-            success = [_session setCategory: _category error: &error];
48
-            if (!success || error) {
49
-                RCTLogInfo(@"Error overriding the desired session category");
50
-            }
51
-        }
52
-
53
-        if (_session.mode != _mode) {
54
-            success = [_session setMode: _mode error: &error];
55
-            if (!success || error) {
56
-                RCTLogInfo(@"Error overriding the desired session mode");
57
-            }
58
-        }
59
-    }
53
+    case AVAudioSessionRouteChangeReasonCategoryChange:
54
+        // The category has changed. Check if it's the one we want and adjust as
55
+        // needed.
56
+        [self setCategory:_category mode:_mode error:nil];
57
+        break;
58
+
60
     default:
59
     default:
61
-        // Do nothing
60
+        // Do nothing.
62
         break;
61
         break;
63
     }
62
     }
64
 }
63
 }
65
 
64
 
66
-- (NSDictionary *)constantsToExport
67
-{
68
-    return @{ @"AUDIO_CALL" : [NSNumber numberWithInt: kAudioModeAudioCall],
69
-              @"VIDEO_CALL" : [NSNumber numberWithInt: kAudioModeVideoCall],
70
-              @"DEFAULT"    : [NSNumber numberWithInt: kAudioModeDefault]
71
-    };
72
-};
65
+- (BOOL)setCategory:(NSString *)category
66
+               mode:(NSString *)mode
67
+              error:(NSError * _Nullable *)outError {
68
+    AVAudioSession *session = [AVAudioSession sharedInstance];
69
+
70
+    if (session.category != category
71
+            && ![session setCategory:category error:outError]) {
72
+        RCTLogError(@"Failed to (re)apply specified AVAudioSession category!");
73
+        return NO;
74
+    }
75
+
76
+    if (session.mode != mode && ![session setMode:mode error:outError]) {
77
+        RCTLogError(@"Failed to (re)apply specified AVAudioSession mode!");
78
+        return NO;
79
+    }
80
+
81
+    return YES;
82
+}
73
 
83
 
74
 RCT_EXPORT_METHOD(setMode:(int)mode
84
 RCT_EXPORT_METHOD(setMode:(int)mode
75
                   resolve:(RCTPromiseResolveBlock)resolve
85
                   resolve:(RCTPromiseResolveBlock)resolve
76
                    reject:(RCTPromiseRejectBlock)reject) {
86
                    reject:(RCTPromiseRejectBlock)reject) {
77
-    NSError *error;
78
-    BOOL success;
79
     NSString *avCategory;
87
     NSString *avCategory;
80
     NSString *avMode;
88
     NSString *avMode;
89
+    NSError *error;
81
 
90
 
82
     switch (mode) {
91
     switch (mode) {
83
     case kAudioModeAudioCall:
92
     case kAudioModeAudioCall:
84
         avCategory = AVAudioSessionCategoryPlayAndRecord;
93
         avCategory = AVAudioSessionCategoryPlayAndRecord;
85
         avMode = AVAudioSessionModeVoiceChat;
94
         avMode = AVAudioSessionModeVoiceChat;
86
         break;
95
         break;
87
-    case kAudioModeVideoCall:
88
-        avCategory = AVAudioSessionCategoryPlayAndRecord;
89
-        avMode = AVAudioSessionModeVideoChat;
90
-        break;
91
     case kAudioModeDefault:
96
     case kAudioModeDefault:
92
         avCategory = AVAudioSessionCategorySoloAmbient;
97
         avCategory = AVAudioSessionCategorySoloAmbient;
93
         avMode = AVAudioSessionModeDefault;
98
         avMode = AVAudioSessionModeDefault;
94
         break;
99
         break;
100
+    case kAudioModeVideoCall:
101
+        avCategory = AVAudioSessionCategoryPlayAndRecord;
102
+        avMode = AVAudioSessionModeVideoChat;
103
+        break;
95
     default:
104
     default:
96
         reject(@"setMode", @"Invalid mode", nil);
105
         reject(@"setMode", @"Invalid mode", nil);
97
         return;
106
         return;
98
     }
107
     }
99
 
108
 
100
-    // Configure AVAudioSession category
101
-    success = [_session setCategory: avCategory error: &error];
102
-    if (!success || error) {
109
+    if (![self setCategory:avCategory mode:avMode error:&error] || error) {
103
         reject(@"setMode", error.localizedDescription, error);
110
         reject(@"setMode", error.localizedDescription, error);
104
         return;
111
         return;
105
     }
112
     }
106
 
113
 
107
-    // Configure AVAudioSession mode
108
-    success = [_session setMode: avMode error: &error];
109
-    if (!success || error) {
110
-        reject(@"setMode", error.localizedDescription, error);
111
-        return;
114
+    // Even though the specified category and mode were successfully set, the
115
+    // AVAudioSession is a singleton and other parts of the application such as
116
+    // WebRTC may undo the settings. Make sure that the settings are reapplied
117
+    // upon undoes.
118
+    if (!_category || !_mode) {
119
+        [[NSNotificationCenter defaultCenter]
120
+            addObserver:self
121
+               selector:@selector(routeChanged:)
122
+                   name:AVAudioSessionRouteChangeNotification
123
+                 object:nil];
112
     }
124
     }
113
 
125
 
114
-    // Save the desired mode and category
126
+    // Save the desired/specified category and mode so that they may be
127
+    // reapplied (upon undoes as described above).
115
     _category = avCategory;
128
     _category = avCategory;
116
     _mode = avMode;
129
     _mode = avMode;
117
 
130
 
118
-    // Initialize audio route changes observer if needed
119
-    if (!_initialized) {
120
-        [[NSNotificationCenter defaultCenter] addObserver: self
121
-            selector: @selector(routeChanged:)
122
-            name: AVAudioSessionRouteChangeNotification
123
-            object: nil];
124
-        _initialized = YES;
125
-    }
126
-
127
     resolve(nil);
131
     resolve(nil);
128
 }
132
 }
129
 
133
 

+ 0
- 4
ios/app/POSIX.h View File

1
-#import "RCTBridgeModule.h"
2
-
3
-@interface POSIX : NSObject<RCTBridgeModule>
4
-@end

+ 4
- 1
ios/app/POSIX.m View File

1
-#import "POSIX.h"
1
+#import "RCTBridgeModule.h"
2
 
2
 
3
 #include <arpa/inet.h>
3
 #include <arpa/inet.h>
4
 #include <netdb.h>
4
 #include <netdb.h>
5
 #include <sys/types.h>
5
 #include <sys/types.h>
6
 #include <sys/socket.h>
6
 #include <sys/socket.h>
7
 
7
 
8
+@interface POSIX : NSObject<RCTBridgeModule>
9
+@end
10
+
8
 @implementation POSIX
11
 @implementation POSIX
9
 
12
 
10
 RCT_EXPORT_MODULE();
13
 RCT_EXPORT_MODULE();

+ 1
- 5
ios/jitsi-meet-react.xcodeproj/project.pbxproj View File

206
 		00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTImage.xcodeproj; path = "../node_modules/react-native/Libraries/Image/RCTImage.xcodeproj"; sourceTree = "<group>"; };
206
 		00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTImage.xcodeproj; path = "../node_modules/react-native/Libraries/Image/RCTImage.xcodeproj"; sourceTree = "<group>"; };
207
 		00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTNetwork.xcodeproj; path = "../node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj"; sourceTree = "<group>"; };
207
 		00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTNetwork.xcodeproj; path = "../node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj"; sourceTree = "<group>"; };
208
 		00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTVibration.xcodeproj; path = "../node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj"; sourceTree = "<group>"; };
208
 		00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTVibration.xcodeproj; path = "../node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj"; sourceTree = "<group>"; };
209
-		0B42DFAC1E2FD90700111B12 /* AudioMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AudioMode.h; path = app/AudioMode.h; sourceTree = "<group>"; };
210
 		0B42DFAD1E2FD90700111B12 /* AudioMode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AudioMode.m; path = app/AudioMode.m; sourceTree = "<group>"; };
209
 		0B42DFAD1E2FD90700111B12 /* AudioMode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AudioMode.m; path = app/AudioMode.m; sourceTree = "<group>"; };
211
 		0EA8C046B2BF46279796F07D /* libKCKeepAwake.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libKCKeepAwake.a; sourceTree = "<group>"; };
210
 		0EA8C046B2BF46279796F07D /* libKCKeepAwake.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libKCKeepAwake.a; sourceTree = "<group>"; };
212
 		139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTSettings.xcodeproj; path = "../node_modules/react-native/Libraries/Settings/RCTSettings.xcodeproj"; sourceTree = "<group>"; };
211
 		139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTSettings.xcodeproj; path = "../node_modules/react-native/Libraries/Settings/RCTSettings.xcodeproj"; sourceTree = "<group>"; };
226
 		821D8ABD506944B4BDBB069B /* libRNVectorIcons.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNVectorIcons.a; sourceTree = "<group>"; };
225
 		821D8ABD506944B4BDBB069B /* libRNVectorIcons.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNVectorIcons.a; sourceTree = "<group>"; };
227
 		832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = "<group>"; };
226
 		832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = "<group>"; };
228
 		B30EF2301DC0ED7C00690F45 /* WebRTC.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebRTC.framework; path = "../node_modules/react-native-webrtc/ios/WebRTC.framework"; sourceTree = "<group>"; };
227
 		B30EF2301DC0ED7C00690F45 /* WebRTC.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebRTC.framework; path = "../node_modules/react-native-webrtc/ios/WebRTC.framework"; sourceTree = "<group>"; };
229
-		B3A9D0231E0481E10009343D /* POSIX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = POSIX.h; path = app/POSIX.h; sourceTree = "<group>"; };
230
 		B3A9D0241E0481E10009343D /* POSIX.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = POSIX.m; path = app/POSIX.m; sourceTree = "<group>"; };
228
 		B3A9D0241E0481E10009343D /* POSIX.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = POSIX.m; path = app/POSIX.m; sourceTree = "<group>"; };
231
 		B3B083EB1D4955FF0069CEE7 /* jitsi-meet-react.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = "jitsi-meet-react.entitlements"; sourceTree = "<group>"; };
229
 		B3B083EB1D4955FF0069CEE7 /* jitsi-meet-react.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = "jitsi-meet-react.entitlements"; sourceTree = "<group>"; };
232
 		B96AF9B6FBC0453798399985 /* FontAwesome.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = FontAwesome.ttf; path = "../node_modules/react-native-vector-icons/Fonts/FontAwesome.ttf"; sourceTree = "<group>"; };
230
 		B96AF9B6FBC0453798399985 /* FontAwesome.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = FontAwesome.ttf; path = "../node_modules/react-native-vector-icons/Fonts/FontAwesome.ttf"; sourceTree = "<group>"; };
351
 			children = (
349
 			children = (
352
 				13B07FAF1A68108700A75B9A /* AppDelegate.h */,
350
 				13B07FAF1A68108700A75B9A /* AppDelegate.h */,
353
 				13B07FB01A68108700A75B9A /* AppDelegate.m */,
351
 				13B07FB01A68108700A75B9A /* AppDelegate.m */,
354
-				0B42DFAC1E2FD90700111B12 /* AudioMode.h */,
355
 				0B42DFAD1E2FD90700111B12 /* AudioMode.m */,
352
 				0B42DFAD1E2FD90700111B12 /* AudioMode.m */,
356
 				13B07FB51A68108700A75B9A /* Images.xcassets */,
353
 				13B07FB51A68108700A75B9A /* Images.xcassets */,
357
 				13B07FB61A68108700A75B9A /* Info.plist */,
354
 				13B07FB61A68108700A75B9A /* Info.plist */,
358
 				13B07FB11A68108700A75B9A /* LaunchScreen.xib */,
355
 				13B07FB11A68108700A75B9A /* LaunchScreen.xib */,
359
 				008F07F21AC5B25A0029DE68 /* main.jsbundle */,
356
 				008F07F21AC5B25A0029DE68 /* main.jsbundle */,
360
 				13B07FB71A68108700A75B9A /* main.m */,
357
 				13B07FB71A68108700A75B9A /* main.m */,
361
-				B3A9D0231E0481E10009343D /* POSIX.h */,
362
 				B3A9D0241E0481E10009343D /* POSIX.m */,
358
 				B3A9D0241E0481E10009343D /* POSIX.m */,
363
 			);
359
 			);
364
 			name = app;
360
 			name = app;
402
 		832341AE1AAA6A7D00B99B32 /* Libraries */ = {
398
 		832341AE1AAA6A7D00B99B32 /* Libraries */ = {
403
 			isa = PBXGroup;
399
 			isa = PBXGroup;
404
 			children = (
400
 			children = (
401
+				5B09C20C78C74A548AAAC1FA /* KCKeepAwake.xcodeproj */,
405
 				BF96438F1C34FBEB00B0BBDF /* libc.tbd */,
402
 				BF96438F1C34FBEB00B0BBDF /* libc.tbd */,
406
 				BF9643911C34FBF100B0BBDF /* libsqlite3.tbd */,
403
 				BF9643911C34FBF100B0BBDF /* libsqlite3.tbd */,
407
 				BF9643931C34FBF900B0BBDF /* libstdc++.tbd */,
404
 				BF9643931C34FBF900B0BBDF /* libstdc++.tbd */,
417
 				139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */,
414
 				139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */,
418
 				146833FF1AC3E56700842450 /* React.xcodeproj */,
415
 				146833FF1AC3E56700842450 /* React.xcodeproj */,
419
 				22418656B14845609F953A42 /* RNVectorIcons.xcodeproj */,
416
 				22418656B14845609F953A42 /* RNVectorIcons.xcodeproj */,
420
-				5B09C20C78C74A548AAAC1FA /* KCKeepAwake.xcodeproj */,
421
 			);
417
 			);
422
 			name = Libraries;
418
 			name = Libraries;
423
 			sourceTree = "<group>";
419
 			sourceTree = "<group>";

+ 35
- 34
react/features/audio-mode/middleware.js View File

1
-import { AudioMode } from '../base/react-native';
1
+import { NativeModules } from 'react-native';
2
 
2
 
3
 import { APP_WILL_MOUNT } from '../app';
3
 import { APP_WILL_MOUNT } from '../app';
4
 import {
4
 import {
6
     CONFERENCE_LEFT,
6
     CONFERENCE_LEFT,
7
     CONFERENCE_WILL_JOIN
7
     CONFERENCE_WILL_JOIN
8
 } from '../base/conference';
8
 } from '../base/conference';
9
-
10
 import { MiddlewareRegistry } from '../base/redux';
9
 import { MiddlewareRegistry } from '../base/redux';
11
 
10
 
12
 /**
11
 /**
13
- * Middleware that captures conference actions and sets the correct audio
14
- * mode based on the type of conference.  Audio-only conferences don't
15
- * use the speaker by default, and video conferences do.
12
+ * Middleware that captures conference actions and sets the correct audio mode
13
+ * based on the type of conference. Audio-only conferences don't use the speaker
14
+ * by default, and video conferences do.
16
  *
15
  *
17
  * @param {Store} store - Redux store.
16
  * @param {Store} store - Redux store.
18
  * @returns {Function}
17
  * @returns {Function}
19
  */
18
  */
20
 MiddlewareRegistry.register(store => next => action => {
19
 MiddlewareRegistry.register(store => next => action => {
21
-    switch (action.type) {
22
-    case APP_WILL_MOUNT: {
23
-        AudioMode.setMode(AudioMode.DEFAULT)
24
-            .catch(err => {
25
-                console.warn(`Error setting audio mode: ${err}`);
26
-            });
27
-        break;
28
-    }
29
-    case CONFERENCE_WILL_JOIN: {
30
-        let mode;
31
-        const state = store.getState()['features/base/conference'];
32
-
33
-        if (state.audioOnly) {
34
-            // TODO(saghul): Implement audio-only mode
35
-            mode = AudioMode.AUDIO_CALL;
36
-        } else {
37
-            mode = AudioMode.VIDEO_CALL;
20
+    const AudioMode = NativeModules.AudioMode;
21
+
22
+    // The react-native module AudioMode is implemented on iOS at the time of
23
+    // this writing.
24
+    if (AudioMode) {
25
+        let audioMode;
26
+
27
+        switch (action.type) {
28
+        case APP_WILL_MOUNT:
29
+        case CONFERENCE_FAILED:
30
+        case CONFERENCE_LEFT:
31
+            audioMode = AudioMode.DEFAULT;
32
+            break;
33
+
34
+        case CONFERENCE_WILL_JOIN: {
35
+            const conference = store.getState()['features/base/conference'];
36
+
37
+            audioMode
38
+                = conference.audioOnly
39
+                    ? AudioMode.AUDIO_CALL
40
+                    : AudioMode.VIDEO_CALL;
41
+            break;
38
         }
42
         }
39
 
43
 
40
-        AudioMode.setMode(mode)
41
-            .catch(err => {
42
-                console.warn(`Error setting audio mode: ${err}`);
43
-            });
44
-        break;
45
-    }
46
-    case CONFERENCE_FAILED:
47
-    case CONFERENCE_LEFT:
48
-        AudioMode.setMode(AudioMode.DEFAULT)
49
-            .catch(err => {
50
-                console.warn(`Error setting audio mode: ${err}`);
44
+        default:
45
+            audioMode = null;
46
+            break;
47
+        }
48
+
49
+        if (audioMode !== null) {
50
+            AudioMode.setMode(audioMode).catch(err => {
51
+                console.error(`Failed to set audio mode ${audioMode}: ${err}`);
51
             });
52
             });
52
-        break;
53
+        }
53
     }
54
     }
54
 
55
 
55
     return next(action);
56
     return next(action);

+ 10
- 10
react/features/base/conference/actionTypes.js View File

24
 export const CONFERENCE_JOINED = Symbol('CONFERENCE_JOINED');
24
 export const CONFERENCE_JOINED = Symbol('CONFERENCE_JOINED');
25
 
25
 
26
 /**
26
 /**
27
- * The type of the Redux action which signals that a specific conference will be
28
- * joined.
27
+ * The type of the Redux action which signals that a specific conference has
28
+ * been left.
29
  *
29
  *
30
  * {
30
  * {
31
- *     type: CONFERENCE_WILL_JOIN,
32
- *     room: string
31
+ *     type: CONFERENCE_LEFT,
32
+ *     conference: JitsiConference
33
  * }
33
  * }
34
  */
34
  */
35
-export const CONFERENCE_WILL_JOIN = Symbol('CONFERENCE_WILL_JOIN');
35
+export const CONFERENCE_LEFT = Symbol('CONFERENCE_LEFT');
36
 
36
 
37
 /**
37
 /**
38
- * The type of the Redux action which signals that a specific conference has
39
- * been left.
38
+ * The type of the Redux action which signals that a specific conference will be
39
+ * joined.
40
  *
40
  *
41
  * {
41
  * {
42
- *     type: CONFERENCE_LEFT,
43
- *     conference: JitsiConference
42
+ *     type: CONFERENCE_WILL_JOIN,
43
+ *     room: string
44
  * }
44
  * }
45
  */
45
  */
46
-export const CONFERENCE_LEFT = Symbol('CONFERENCE_LEFT');
46
+export const CONFERENCE_WILL_JOIN = Symbol('CONFERENCE_WILL_JOIN');
47
 
47
 
48
 /**
48
 /**
49
  * The type of the Redux action which signals that a specific conference will be
49
  * The type of the Redux action which signals that a specific conference will be

+ 22
- 24
react/features/base/conference/actions.js View File

125
 }
125
 }
126
 
126
 
127
 /**
127
 /**
128
- * Signals the intention of the application to have the local participant leave
129
- * a specific conference. Similar in fashion to CONFERENCE_LEFT. Contrary to it
130
- * though, it's not guaranteed because CONFERENCE_LEFT may be triggered by
131
- * lib-jitsi-meet and not the application.
128
+ * Signals that a specific conference has been left.
132
  *
129
  *
133
- * @param {string} room - The JitsiConference instance which will
134
- * be left by the local participant.
130
+ * @param {JitsiConference} conference - The JitsiConference instance which was
131
+ * left by the local participant.
135
  * @returns {{
132
  * @returns {{
136
- *      type: CONFERENCE_WILL_JOIN,
137
- *      room: string
133
+ *      type: CONFERENCE_LEFT,
134
+ *      conference: JitsiConference
138
  *  }}
135
  *  }}
139
  */
136
  */
140
-function _conferenceWillJoin(room) {
137
+function _conferenceLeft(conference) {
141
     return {
138
     return {
142
-        type: CONFERENCE_WILL_JOIN,
143
-        room
139
+        type: CONFERENCE_LEFT,
140
+        conference
144
     };
141
     };
145
 }
142
 }
146
 
143
 
147
 /**
144
 /**
148
- * Signals that a specific conference has been left.
145
+ * Signals the intention of the application to have the local participant join a
146
+ * conference with a specific room (name). Similar in fashion
147
+ * to CONFERENCE_JOINED.
149
  *
148
  *
150
- * @param {JitsiConference} conference - The JitsiConference instance which was
151
- * left by the local participant.
149
+ * @param {string} room - The room (name) which identifies the conference the
150
+ * local participant will (try to) join.
152
  * @returns {{
151
  * @returns {{
153
- *      type: CONFERENCE_LEFT,
154
- *      conference: JitsiConference
152
+ *      type: CONFERENCE_WILL_JOIN,
153
+ *      room: string
155
  *  }}
154
  *  }}
156
  */
155
  */
157
-function _conferenceLeft(conference) {
156
+function _conferenceWillJoin(room) {
158
     return {
157
     return {
159
-        type: CONFERENCE_LEFT,
160
-        conference
158
+        type: CONFERENCE_WILL_JOIN,
159
+        room
161
     };
160
     };
162
 }
161
 }
163
 
162
 
201
             throw new Error('Cannot join conference without room name');
200
             throw new Error('Cannot join conference without room name');
202
         }
201
         }
203
 
202
 
204
-        // XXX Lib-jitsi-meet does not accept uppercase letters.
205
-        const _room = room.toLowerCase();
206
-
207
-        dispatch(_conferenceWillJoin(_room));
203
+        dispatch(_conferenceWillJoin(room));
208
 
204
 
209
         // TODO Take options from config.
205
         // TODO Take options from config.
210
         const conference
206
         const conference
211
             = connection.initJitsiConference(
207
             = connection.initJitsiConference(
212
-                    _room,
208
+
209
+                    // XXX Lib-jitsi-meet does not accept uppercase letters.
210
+                    room.toLowerCase(),
213
                     { openSctp: true });
211
                     { openSctp: true });
214
 
212
 
215
         _addConferenceListeners(conference, dispatch);
213
         _addConferenceListeners(conference, dispatch);

+ 0
- 20
react/features/base/react-native/AudioMode.js View File

1
-import { NativeModules } from 'react-native';
2
-import { Platform } from '../react';
3
-
4
-let AudioMode;
5
-
6
-if (Platform.OS === 'ios') {
7
-    AudioMode = NativeModules.AudioMode;
8
-} else {
9
-    // TODO(saghul): Implement for Android
10
-    AudioMode = {
11
-        DEFAULT: 0,
12
-        AUDIO_CALL: 1,
13
-        VIDEO_CALL: 2,
14
-        setMode() {
15
-            return Promise.resolve(null);
16
-        }
17
-    };
18
-}
19
-
20
-export default AudioMode;

+ 0
- 1
react/features/base/react-native/index.js View File

1
-export { default as AudioMode } from './AudioMode';
2
 export { default as POSIX } from './POSIX';
1
 export { default as POSIX } from './POSIX';

Loading…
Cancel
Save