Skip to content

feat(audio): runtime audio processing options and engine-wide state read-back#1107

Merged
hiroshihorie merged 7 commits into
mainfrom
hiroshi/runtime-audio-options
Jun 12, 2026
Merged

feat(audio): runtime audio processing options and engine-wide state read-back#1107
hiroshihorie merged 7 commits into
mainfrom
hiroshi/runtime-audio-options

Conversation

@hiroshihorie

Copy link
Copy Markdown
Member

What

Runtime control of audio processing (AEC / NS / AGC / HPF) for local audio tracks, plus an engine-wide diagnostic read-back, built on the WebRTC-SDK audio processing options API (webrtc-sdk/webrtc#247 + webrtc-sdk/webrtc#254).

API

SetAudioProcessingOptions with per-component enabled flags and modes (automatic / platform / software), applied either at capture time via AudioCaptureOptions or at runtime:

final result = await localAudioTrack.setAudioProcessingOptions(options);

Caller bugs (invalid combination, remote track) throw AudioProcessingException; legitimate outcomes return a typed AudioProcessingApplyResult (applied / stored / rejections).

Read — the audio processing module is owned by the native peer connection factory and shared engine-wide, so the snapshot lives on AudioManager:

final state = await AudioManager.instance.getAudioProcessingState();

Per component: requested (nullable — null means nothing was ever applied), isSoftwareResolved / isSoftwareActive, isPlatformAvailable / isPlatformResolved / isPlatformActive, and effective as the merged verdict. Same requested → resolved → active → effective vocabulary as the native SDKs.

Commits

Bottom-up, each builds standalone:

  1. chore(deps): WebRTC-SDK pin bump
  2. Dart AudioProcessingOptions for LocalAudioTrack
  3. Routing through the LiveKit native plugin (iOS + Android handlers)
  4. Typed apply results
  5. Engine-wide v2 state read-back on AudioManager

Dependencies / not yet done

@hiroshihorie hiroshihorie force-pushed the hiroshi/runtime-audio-options branch 2 times, most recently from 787a0a3 to 50de779 Compare June 12, 2026 07:02
Introduce AudioProcessingMode and AudioProcessingOptions in track
options, plus LocalAudioTrack.setAudioProcessingOptions() to apply
per-component echo cancellation / noise suppression / auto gain control /
high-pass filter modes at runtime. AudioCaptureOptions now carries these
processing fields and serializes the per-component modes into its capture
constraints.

Updates are currently delegated to flutter_webrtc; a follow-up moves the
implementation into this SDK's own native plugin.
Move setAudioProcessingOptions off flutter_webrtc's Dart API and onto
this SDK's own `livekit_client` method channel. The iOS/macOS and Android
plugins resolve the local track from flutter_webrtc's shared registry and
call the WebRTC AudioEngine setAudioProcessingOptions API directly,
returning {result, code, message}.

This removes the dependency on fork-only flutter_webrtc Dart symbols
(rtc.AudioProcessingOptions / rtc.AudioProcessingMode), so the SDK once
again analyzes cleanly against the published flutter_webrtc package.
LocalAudioTrack.setAudioProcessingOptions returns an
AudioProcessingApplyResult (code + message + isSuccess) for operational
outcomes — applied/stored, and the device-capability rejections
platform-unavailable / apply-failed (inspect isSuccess). It throws
AudioProcessingException only for malformed requests (invalid mode
combination, or a non-local track).

The native plugin handlers return {result, code, message}; the Dart side
maps the code into the result or the exception accordingly.
Surfaces the WebRTC-SDK v2 audio processing state on AudioManager:
the audio processing module is owned by the native peer connection
factory and shared engine-wide, so the snapshot reflects what is
actually applied across the engine rather than any single track.

Dart models follow the v2 contract per component: requested (caller
intent, null when nothing was ever applied) -> software/platform
resolved -> active, with effective as the merged verdict. The iOS and
Android plugins read factory.audioProcessingState and serialize it
over the method channel; Android reaches the factory through the
flutter_webrtc getPeerConnectionFactory accessor.
@hiroshihorie hiroshihorie force-pushed the hiroshi/runtime-audio-options branch from 50de779 to 01354e6 Compare June 12, 2026 09:46
@hiroshihorie hiroshihorie marked this pull request as ready for review June 12, 2026 09:57
@hiroshihorie hiroshihorie merged commit 1c03b55 into main Jun 12, 2026
17 checks passed
@hiroshihorie hiroshihorie deleted the hiroshi/runtime-audio-options branch June 12, 2026 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant