OTAudioSessionManager
Defines an audio session manager for use with calling services like CallKit. Implementation of this protocol is optional. Custom audio devices can implement these methods to manage the AVAudioSession. The default audio device in the SDK provides a working implementation.
For more information, see this documentation.
Methods
| Name | Description |
|---|---|
enableCallingServicesMode() |
Enables manual activation for the AVAudioSession. |
preconfigureAudioSessionForCallWithMode:(mode) |
Configures the audio session with the appropriate settings for a CallKit-based call. |
audioSessionDidActivate:(session) |
Notifies the SDK that the audio session has been activated. |
audioSessionDidDeactivate:(session) |
Notifies the SDK that the audio session has been deactivated. |
enableCallingServicesMode()
Enables manual activation for the AVAudioSession.
This method prepares the SDK for integration with calling services like CallKit, enabling proper audio routing and session management.
The SDK manages the AVAudioSession configuration, while the application or CallKit is responsible for activating the session.
Note: Call this early in the app lifecycle, typically at launch or before starting any calls.
preconfigureAudioSessionForCallWithMode:(mode)
Configures the audio session with the appropriate settings for a CallKit-based call.
This method sets up the AVAudioSession with settings optimized for the specified mode, including audio category, mode, and routing configuration. However, it does not activate the session. The session is configured in advance so it can be activated correctly when triggered by a CallKit action.
Note: This method should be called prior to activating the session, typically in response to CallKit's CXAnswerCallAction or CXStartCallAction. This ensures proper configuration for later activation by the system. See Apple Developer Forum for more details.
Parameters:
| Name | Type | Description |
|---|---|---|
mode |
AVAudioSessionMode | The AVAudioSessionMode to apply during configuration. In general, AVAudioSessionModeVoiceChat should be used for VoIP calls to optimize audio performance. If a custom mode is provided for use by a non-default audio device, that mode will be used; otherwise, AVAudioSessionModeVoiceChat will be used as the default. |
audioSessionDidActivate:(session)
Notifies the SDK that the audio session has been activated.
This method should be called when the system (for example, via CallKit) has activated the audio session. It informs the SDK that audio is now ready to be used and that the session is active.
Note: This method is only relevant when using OTAudioSessionManagerModeCallingServices. If called in other modes, such as OTAudioSessionManagerModeVideoChat, it will be ignored since the SDK handles audio session activation automatically.
Parameters:
| Name | Type | Description |
|---|---|---|
session |
AVAudioSession * | The active AVAudioSession instance that was activated by the system. |
audioSessionDidDeactivate:(session)
Notifies the SDK that the audio session has been deactivated.
This method should be called when the system (for example, CallKit) has deactivated the audio session. It signals the SDK to release audio resources or update its internal state accordingly.
Note: This method is only relevant when using OTAudioSessionManagerModeCallingServices. In modes such as OTAudioSessionManagerModeVideoChat, this call will be ignored, as the SDK automatically manages the audio session lifecycle.
Parameters:
| Name | Type | Description |
|---|---|---|
session |
AVAudioSession * | The AVAudioSession instance that has been deactivated. |