setEngineAvailability method
- AudioEngineAvailability availability
Sets whether the WebRTC audio engine is allowed to run.
This is the highest-priority gate over anything that may start the engine (enabling the microphone, remote audio playback). Requests made while unavailable are honored as soon as availability allows, so it is safe to connect a room and publish the microphone while the engine is still gated off.
This is the core of CallKit coordination on iOS: set
AudioEngineAvailability.none before connecting, then flip to
AudioEngineAvailability.defaultAvailability in CallKit's
provider(didActivate:) and back to none in didDeactivate. Combine
with AudioSessionManagementMode.externalCallSystem so LiveKit never
activates the session itself.
iOS/macOS only. A no-op elsewhere, so it is always safe to call from cross-platform code.
Throws if the native side rejects the change, so callers never assume the engine is gated when it is not.
Experimental: this API may change in a future release.
Implementation
@experimental
Future<void> setEngineAvailability(AudioEngineAvailability availability) async {
if (!lkPlatformIsApple()) return;
await Native.setEngineAvailability(
isInputAvailable: availability.isInputAvailable,
isOutputAvailable: availability.isOutputAvailable,
);
}