Created
December 13, 2023 09:04
-
-
Save pixlhero/3d370dcdbcfaefa4df12138161307da4 to your computer and use it in GitHub Desktop.
Echo cancellation workaround iOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Runtime.InteropServices; | |
using UnityEngine; | |
public static class AVAudioSession | |
{ | |
[DllImport("__Internal")] | |
private static extern void _SetupAudioModeForVideoCall(); | |
public static void SetupAudioModeForVideoCall() | |
{ | |
if (UnityEngine.Application.platform == RuntimePlatform.IPhonePlayer) | |
{ | |
_SetupAudioModeForVideoCall(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <AVFAudio/AVAudioSession.h> | |
extern "C" void _SetupAudioModeForVideoCall(){ | |
// Retrieve the shared audio session | |
AVAudioSession *audioSession = [AVAudioSession sharedInstance]; | |
NSError *error = nil; | |
// Set the audio session category and mode | |
[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord mode:AVAudioSessionModeVideoChat options:0 error:&error]; | |
if (error) { | |
NSLog(@"Failed to set the audio session configuration: %@", error); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment