8000 chore: fix compile error for macos. · doesnotexist/flutter-webrtc@fec62be · GitHub
[go: up one dir, main page]

Skip to content

Commit fec62be

Browse files
committed
chore: fix compile error for macos.
1 parent 9e3c09e commit fec62be

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

common/darwin/Classes/AudioUtils.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
#if TARGET_OS_IPHONE
2+
13
#import <WebRTC/WebRTC.h>
24

35
@interface AudioUtils : NSObject
4-
56
+ (void)ensureAudioSessionWithRecording:(BOOL)recording;
67
// needed for wired headphones to use headphone mic
78
+ (BOOL)selectAudioInput:(AVAudioSessionPort)type;
89
+ (void)setSpeakerphoneOn:(BOOL)enable;
910
+ (void)deactiveRtcAudioSession;
1011
@end
12+
13+
#endif

common/darwin/Classes/AudioUtils.m

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
#import "AudioUtils.h"
2-
31
#if TARGET_OS_IPHONE
2+
#import "AudioUtils.h"
43
#import <AVFoundation/AVFoundation.h>
5-
#endif
64

75
@implementation AudioUtils
86

97
+ (void)ensureAudioSessionWithRecording:(BOOL)recording {
10-
#if TARGET_OS_IPHONE
118
RTCAudioSession *session = [RTCAudioSession sharedInstance];
129
// we also need to set default WebRTC audio configuration, since it may be activated after
1310
// this method is called
@@ -40,11 +37,9 @@ + (void)ensureAudioSessionWithRecording:(BOOL)recording {
4037
[session setMode:config.mode error:nil];
4138
[session unlockForConfiguration];
4239
}
43-
#endif
4440
}
4541

4642
+ (BOOL)selectAudioInput:(AVAudioSessionPort)type {
47-
#if TARGET_OS_IPHONE
4843
RTCAudioSession *rtcSession = [RTCAudioSession sharedInstance];
4944
AVAudioSessionPortDescription *inputPort = nil;
5045
for (AVAudioSessionPortDescription *port in rtcSession.session.availableInputs) {
@@ -63,12 +58,10 @@ + (BOOL)selectAudioInput:(AVAudioSessionPort)type {
6358
}
6459
return YES;
6560
}
66-
#endif
6761
return NO;
6862
}
6963

7064
+ (void)setSpeakerphoneOn:(BOOL)enable {
71-
#if TARGET_OS_IPHONE
7265
RTCAudioSession *session = [RTCAudioSession sharedInstance];
7366
RTCAudioSessionConfiguration *config = [RTCAudioSessionConfiguration webRTCConfiguration];
7467
[session lockForConfiguration];
@@ -92,7 +85,6 @@ + (void)setSpeakerphoneOn:(BOOL)enable {
9285
else NSLog(@"AudioSession override via Loudspeaker is successful ");
9386
}
9487
[session unlockForConfiguration];
95-
#endif
9688
}
9789

9890
+ (void)deactiveRtcAudioSession {
@@ -101,3 +93,4 @@ + (void)deactiveRtcAudioSession {
10193
}
10294

10395
@end
96+
#endif

common/darwin/Classes/FlutterWebRTCPlugin.m

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ - (instancetype)initWithChannel:(FlutterMethodChannel *)channel
6666
_textures = textures;
6767
_messenger = messenger;
6868
_speakerOn = NO;
69-
_preferredInput = AVAudioSessionPortHeadphones;
7069
_eventChannel = eventChannel;
7170
#if TARGET_OS_IPHONE
71+
_preferredInput = AVAudioSessionPortHeadphones;
7272
self.viewController = viewController;
7373
#endif
7474
}
@@ -1076,15 +1076,19 @@ - (BOOL) hasLocalAudioTrack {
10761076
return NO;
10771077
}
10781078

1079-
- (void) ensureAudioSession{
1079+
- (void) ensureAudioSession {
1080+
#if TARGET_OS_IPHONE
10801081
[AudioUtils ensureAudioSessionWithRecording:[self hasLocalAudioTrack]];
10811082
[AudioUtils setSpeakerphoneOn:_speakerOn];
1083+
#endif
10821084
}
10831085

1084-
- (void) deactiveRtcAudioSession{
1086+
- (void) deactiveRtcAudioSession {
1087+
#if TARGET_OS_IPHONE
10851088
if (![self hasLocalAudioTrack] && self.peerConnections.count == 0) {
10861089
[AudioUtils deactiveRtcAudioSession];
10871090
}
1091+
#endif
10881092
}
10891093

10901094
-(void)mediaStreamGetTracks:(NSString*)streamId

0 commit comments

Comments
 (0)
0