Browse Source

feat(iOS) expose activating/deactivating audio session functionality

master
Alex Bumbu 3 years ago
parent
commit
81dfbaeb81
No account linked to committer's email address

+ 10
- 0
ios/sdk/sdk.xcodeproj/project.pbxproj View File

@@ -24,6 +24,8 @@
24 24
 		0BD906EA1EC0C00300C8C18E /* JitsiMeet.h in Headers */ = {isa = PBXBuildFile; fileRef = 0BD906E81EC0C00300C8C18E /* JitsiMeet.h */; settings = {ATTRIBUTES = (Public, ); }; };
25 25
 		4E51B76425E5345E0038575A /* ScheenshareEventEmiter.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E51B76225E5345E0038575A /* ScheenshareEventEmiter.h */; };
26 26
 		4E51B76525E5345E0038575A /* ScheenshareEventEmiter.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E51B76325E5345E0038575A /* ScheenshareEventEmiter.m */; };
27
+		4ED4FFF32721B9B90074E620 /* JitsiAudioSession.h in Headers */ = {isa = PBXBuildFile; fileRef = 4ED4FFF12721B9B90074E620 /* JitsiAudioSession.h */; settings = {ATTRIBUTES = (Public, ); }; };
28
+		4ED4FFF42721B9B90074E620 /* JitsiAudioSession.m in Sources */ = {isa = PBXBuildFile; fileRef = 4ED4FFF22721B9B90074E620 /* JitsiAudioSession.m */; };
27 29
 		6F08DF7D4458EE3CF3F36F6D /* libPods-JitsiMeetSDK.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E4376CA6886DE68FD7A4294B /* libPods-JitsiMeetSDK.a */; };
28 30
 		A4A934E9212F3ADB001E9388 /* Dropbox.m in Sources */ = {isa = PBXBuildFile; fileRef = A4A934E8212F3ADB001E9388 /* Dropbox.m */; };
29 31
 		C6245F5D2053091D0040BE68 /* image-resize@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = C6245F5B2053091D0040BE68 /* image-resize@2x.png */; };
@@ -77,6 +79,9 @@
77 79
 		0BD906E91EC0C00300C8C18E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
78 80
 		4E51B76225E5345E0038575A /* ScheenshareEventEmiter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScheenshareEventEmiter.h; sourceTree = "<group>"; };
79 81
 		4E51B76325E5345E0038575A /* ScheenshareEventEmiter.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ScheenshareEventEmiter.m; sourceTree = "<group>"; };
82
+		4ED4FFF12721B9B90074E620 /* JitsiAudioSession.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JitsiAudioSession.h; sourceTree = "<group>"; };
83
+		4ED4FFF22721B9B90074E620 /* JitsiAudioSession.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = JitsiAudioSession.m; sourceTree = "<group>"; };
84
+		4ED4FFF52721BAE10074E620 /* JitsiAudioSession+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "JitsiAudioSession+Private.h"; sourceTree = "<group>"; };
80 85
 		891FE43DAD30BC8976683100 /* Pods-JitsiMeetSDK.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-JitsiMeetSDK.release.xcconfig"; path = "../Pods/Target Support Files/Pods-JitsiMeetSDK/Pods-JitsiMeetSDK.release.xcconfig"; sourceTree = "<group>"; };
81 86
 		98E09B5C73D9036B4ED252FC /* Pods-JitsiMeet.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-JitsiMeet.debug.xcconfig"; path = "../Pods/Target Support Files/Pods-JitsiMeet/Pods-JitsiMeet.debug.xcconfig"; sourceTree = "<group>"; };
82 87
 		9C77CA3CC919B081F1A52982 /* Pods-JitsiMeet.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-JitsiMeet.release.xcconfig"; path = "../Pods/Target Support Files/Pods-JitsiMeet/Pods-JitsiMeet.release.xcconfig"; sourceTree = "<group>"; };
@@ -174,6 +179,9 @@
174 179
 				DEFE535821FB311F00011A3A /* JitsiMeet+Private.h */,
175 180
 				DEA9F283258A5D9900D4CD74 /* JitsiMeetSDK.h */,
176 181
 				DEFE535321FB1BF800011A3A /* JitsiMeet.m */,
182
+				4ED4FFF12721B9B90074E620 /* JitsiAudioSession.h */,
183
+				4ED4FFF52721BAE10074E620 /* JitsiAudioSession+Private.h */,
184
+				4ED4FFF22721B9B90074E620 /* JitsiAudioSession.m */,
177 185
 				DEAD3224220C497000E93636 /* JitsiMeetConferenceOptions.h */,
178 186
 				DEAD3228220C734300E93636 /* JitsiMeetConferenceOptions+Private.h */,
179 187
 				DEAD3225220C497000E93636 /* JitsiMeetConferenceOptions.m */,
@@ -277,6 +285,7 @@
277 285
 				4E51B76425E5345E0038575A /* ScheenshareEventEmiter.h in Headers */,
278 286
 				DE65AACC2318028300290BEC /* JitsiMeetBaseLogHandler+Private.h in Headers */,
279 287
 				0B412F221EDEF6EA00B1A0A6 /* JitsiMeetViewDelegate.h in Headers */,
288
+				4ED4FFF32721B9B90074E620 /* JitsiAudioSession.h in Headers */,
280 289
 				0BD906EA1EC0C00300C8C18E /* JitsiMeet.h in Headers */,
281 290
 				DE81A2D42316AC4D00AE1940 /* JitsiMeetLogger.h in Headers */,
282 291
 				DE65AACA2317FFCD00290BEC /* LogUtils.h in Headers */,
@@ -438,6 +447,7 @@
438 447
 			files = (
439 448
 				0BB9AD7B1F5EC8F4001C08DB /* CallKit.m in Sources */,
440 449
 				DE81A2DF2317ED5400AE1940 /* JitsiMeetBaseLogHandler.m in Sources */,
450
+				4ED4FFF42721B9B90074E620 /* JitsiAudioSession.m in Sources */,
441 451
 				0BB9AD7D1F60356D001C08DB /* AppInfo.m in Sources */,
442 452
 				DE81A2D92316AC7600AE1940 /* LogBridge.m in Sources */,
443 453
 				DEAFA779229EAD520033A7FA /* RNRootView.m in Sources */,

+ 6
- 5
ios/sdk/src/AudioMode.m View File

@@ -20,6 +20,7 @@
20 20
 #import <React/RCTLog.h>
21 21
 #import <WebRTC/WebRTC.h>
22 22
 
23
+#import "JitsiAudioSession+Private.h"
23 24
 #import "LogUtils.h"
24 25
 
25 26
 
@@ -113,7 +114,7 @@ RCT_EXPORT_MODULE();
113 114
         isSpeakerOn = NO;
114 115
         isEarpieceOn = NO;
115 116
 
116
-        RTCAudioSession *session = [RTCAudioSession sharedInstance];
117
+        RTCAudioSession *session = JitsiAudioSession.rtcAudioSession;
117 118
         [session addDelegate:self];
118 119
     }
119 120
 
@@ -127,7 +128,7 @@ RCT_EXPORT_MODULE();
127 128
 
128 129
 - (BOOL)setConfigWithoutLock:(RTCAudioSessionConfiguration *)config
129 130
                        error:(NSError * _Nullable *)outError {
130
-    RTCAudioSession *session = [RTCAudioSession sharedInstance];
131
+    RTCAudioSession *session = JitsiAudioSession.rtcAudioSession;
131 132
 
132 133
     return [session setConfiguration:config error:outError];
133 134
 }
@@ -135,7 +136,7 @@ RCT_EXPORT_MODULE();
135 136
 - (BOOL)setConfig:(RTCAudioSessionConfiguration *)config
136 137
             error:(NSError * _Nullable *)outError {
137 138
 
138
-    RTCAudioSession *session = [RTCAudioSession sharedInstance];
139
+    RTCAudioSession *session = JitsiAudioSession.rtcAudioSession;
139 140
     [session lockForConfiguration];
140 141
     BOOL success = [self setConfigWithoutLock:config error:outError];
141 142
     [session unlockForConfiguration];
@@ -178,7 +179,7 @@ RCT_EXPORT_METHOD(setAudioDevice:(NSString *)device
178 179
                   reject:(RCTPromiseRejectBlock)reject) {
179 180
     DDLogInfo(@"[AudioMode] Selected device: %@", device);
180 181
     
181
-    RTCAudioSession *session = [RTCAudioSession sharedInstance];
182
+    RTCAudioSession *session = JitsiAudioSession.rtcAudioSession;
182 183
     [session lockForConfiguration];
183 184
     BOOL success;
184 185
     NSError *error = nil;
@@ -273,7 +274,7 @@ RCT_EXPORT_METHOD(updateDeviceList) {
273 274
             RTCAudioSessionConfiguration *config = [self configForMode:self->activeMode];
274 275
             [self setConfig:config error:nil];
275 276
             if (self->forceSpeaker && !self->isSpeakerOn) {
276
-                RTCAudioSession *session = [RTCAudioSession sharedInstance];
277
+                RTCAudioSession *session = JitsiAudioSession.rtcAudioSession;
277 278
                 [session lockForConfiguration];
278 279
                 [session overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:nil];
279 280
                 [session unlockForConfiguration];

+ 23
- 0
ios/sdk/src/JitsiAudioSession+Private.h View File

@@ -0,0 +1,23 @@
1
+/*
2
+ * Copyright @ 2017-present 8x8, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ *     http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+#import "JitsiAudioSession.h"
18
+
19
+@interface JitsiAudioSession (Private)
20
+
21
++ (RTCAudioSession *)rtcAudioSession;
22
+
23
+@end

+ 26
- 0
ios/sdk/src/JitsiAudioSession.h View File

@@ -0,0 +1,26 @@
1
+/*
2
+ * Copyright @ 2017-present 8x8, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ *     http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+#import <Foundation/Foundation.h>
18
+
19
+@class AVAudioSession;
20
+
21
+@interface JitsiAudioSession : NSObject
22
+
23
++ (void)activateWithAudioSession:(AVAudioSession *)session;
24
++ (void)deactivateWithAudioSession:(AVAudioSession *)session;
25
+
26
+@end

+ 35
- 0
ios/sdk/src/JitsiAudioSession.m View File

@@ -0,0 +1,35 @@
1
+/*
2
+ * Copyright @ 2017-present 8x8, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ *     http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+#import "JitsiAudioSession.h"
18
+#import "JitsiAudioSession+Private.h"
19
+#import <WebRTC/WebRTC.h>
20
+
21
+@implementation JitsiAudioSession
22
+
23
++ (RTCAudioSession *)rtcAudioSession {
24
+    return [RTCAudioSession sharedInstance];
25
+}
26
+
27
++ (void)activateWithAudioSession:(AVAudioSession *)session {
28
+    [self.rtcAudioSession audioSessionDidActivate:session];
29
+}
30
+
31
++ (void)deactivateWithAudioSession:(AVAudioSession *)session {
32
+    [self.rtcAudioSession audioSessionDidDeactivate:session];
33
+}
34
+
35
+@end

+ 1
- 0
ios/sdk/src/JitsiMeetSDK.h View File

@@ -20,4 +20,5 @@
20 20
 #import <JitsiMeetSDK/JitsiMeetConferenceOptions.h>
21 21
 #import <JitsiMeetSDK/JitsiMeetLogger.h>
22 22
 #import <JitsiMeetSDK/JitsiMeetBaseLogHandler.h>
23
+#import <JitsiMeetSDK/JitsiAudioSession.h>
23 24
 #import <JitsiMeetSDK/InfoPlistUtil.h>

+ 3
- 2
ios/sdk/src/callkit/CallKit.m View File

@@ -31,6 +31,7 @@
31 31
 #import <JitsiMeetSDK/JitsiMeetSDK-Swift.h>
32 32
 
33 33
 #import "../LogUtils.h"
34
+#import "JitsiAudioSession.h"
34 35
 
35 36
 
36 37
 // The events emitted/supported by RNCallKit:
@@ -319,13 +320,13 @@ RCT_EXPORT_METHOD(updateCall:(NSString *)callUUID
319 320
 - (void) providerDidActivateAudioSessionWithSession:(AVAudioSession *)session {
320 321
     DDLogInfo(@"[RNCallKit][CXProviderDelegate][provider:didActivateAudioSession:]");
321 322
 
322
-    [[RTCAudioSession sharedInstance] audioSessionDidActivate:session];
323
+    [JitsiAudioSession activateWithAudioSession:session];
323 324
 }
324 325
 
325 326
 - (void) providerDidDeactivateAudioSessionWithSession:(AVAudioSession *)session {
326 327
     DDLogInfo(@"[RNCallKit][CXProviderDelegate][provider:didDeactivateAudioSession:]");
327 328
 
328
-    [[RTCAudioSession sharedInstance] audioSessionDidDeactivate:session];
329
+    [JitsiAudioSession deactivateWithAudioSession:session];
329 330
 }
330 331
 
331 332
 - (void) providerTimedOutPerformingActionWithAction:(CXAction *)action {

Loading…
Cancel
Save