Screen share: the LiveKit SDK publishes stream audio as mono (no stereo publish option) #223

Closed
opened 2026-11-12 05:47:38 +00:00 by charles · 1 comment
Owner

Found while implementing Screen share 17 (#164).

What the spec asks: stream audio published as 48 kHz stereo, 128 kbit/s, RED on, DTX off (spec §3.3, §7.3; facts §3: the original publishes screen_share_audio stereo).

What the pinned SDK does: livekit 0.10.1 never marks a published audio track as stereo. LocalParticipant::publish_track builds the AddTrackRequest without stereo: true and without AudioTrackFeature::TfStereo (livekit-0.10.1/src/room/participant/local_participant.rs:414-429; only TfPreconnectBuffer is ever pushed), and TrackPublishOptions has no field for it. The server's answer therefore carries no stereo=1 for Opus, and libwebrtc's Opus encoder downmixes. (The single-PC munge_stereo_for_audio only touches our own offer, i.e. what we receive; receiving stereo from the Electron client works.)

Measured (crates/fluxer-voice/tests/livekit_interop.rs::screen_audio_tone_arrives_stereo, livekit-server 1.12.0 --dev): a 2-channel NativeAudioSource fed 440 Hz left / 1000 Hz right arrives at the viewer as two identical channels, each 50 % 440 Hz + 50 % 1000 Hz. The track is published and plays; it is just mono.

What the branch does now: publishes the track as the spec says otherwise (2-channel source, 128 kbit/s, RED, no DTX); the interop test asserts what is true today (two channels arrive, both tones in each) and names this issue.

Options:

  1. Accept mono stream audio for now (a follow-up to revisit when the SDK grows a stereo publish option). Nothing else changes.
  2. Patch livekit (a [patch.crates-io] fork that sets stereo/TfStereo when the source has 2 channels, ~5 lines) and try to upstream it.
  3. Ask upstream first and wait.

Recommendation: 1 now, 2 if stereo matters before upstream moves (game/music sharing is where it shows).

Found while implementing Screen share 17 (#164). **What the spec asks:** stream audio published as 48 kHz **stereo**, 128 kbit/s, RED on, DTX off (spec §3.3, §7.3; facts §3: the original publishes `screen_share_audio` stereo). **What the pinned SDK does:** `livekit` 0.10.1 never marks a published audio track as stereo. `LocalParticipant::publish_track` builds the `AddTrackRequest` without `stereo: true` and without `AudioTrackFeature::TfStereo` (`livekit-0.10.1/src/room/participant/local_participant.rs:414-429`; only `TfPreconnectBuffer` is ever pushed), and `TrackPublishOptions` has no field for it. The server's answer therefore carries no `stereo=1` for Opus, and libwebrtc's Opus encoder downmixes. (The single-PC `munge_stereo_for_audio` only touches our own offer, i.e. what we *receive*; receiving stereo from the Electron client works.) **Measured** (`crates/fluxer-voice/tests/livekit_interop.rs::screen_audio_tone_arrives_stereo`, livekit-server 1.12.0 `--dev`): a 2-channel `NativeAudioSource` fed 440 Hz left / 1000 Hz right arrives at the viewer as two identical channels, each 50 % 440 Hz + 50 % 1000 Hz. The track is published and plays; it is just mono. **What the branch does now:** publishes the track as the spec says otherwise (2-channel source, 128 kbit/s, RED, no DTX); the interop test asserts what is true today (two channels arrive, both tones in each) and names this issue. **Options:** 1. Accept mono stream audio for now (a `follow-up` to revisit when the SDK grows a stereo publish option). Nothing else changes. 2. Patch `livekit` (a `[patch.crates-io]` fork that sets `stereo`/`TfStereo` when the source has 2 channels, ~5 lines) and try to upstream it. 3. Ask upstream first and wait. Recommendation: 1 now, 2 if stereo matters before upstream moves (game/music sharing is where it shows).
Author
Owner

Done on textchat (c24495a): stereo publish patch in third_party/livekit (PATCHES.md:9-40, Text chat 54). Leftovers are #359/#360

Closed during the 2026-11-14 issue triage.

🤖 Generated with Claude Code

Done on `textchat` (c24495a): stereo publish patch in `third_party/livekit` (`PATCHES.md:9-40`, Text chat 54). Leftovers are #359/#360 Closed during the 2026-11-14 issue triage. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
charles/fluxer-native#223
No description provided.