Skip to content

feat(rtc): prepare audio sources natively during connect - #963

Draft
xianshijing-lk wants to merge 5 commits into
mainfrom
sxian/CLT-3610/fast-track-publication-session-api
Draft

xianshijing-lk wants to merge 5 commits into
mainfrom
sxian/CLT-3610/fast-track-publication-session-api

Conversation

@xianshijing-lk

@xianshijing-lk xianshijing-lk commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Audio publications can be described before connection without constructing a native track on the Python event loop. Add AudioTrackToPublish(source, name, options) and RoomOptions.publish_audio_tracks; Rust creates the track during async connect and returns the track/publication before room events begin. After success, the descriptor's track property exposes the returned LocalAudioTrack. Existing RoomOptions.publish_tracks remains supported.

This keeps all native setup in Rust while preserving complete publication options. Single-PC/supporting servers use existing publish-on-join; other configurations use the native fallback. Publications are installed without duplicate publish calls. Cancellation waits for the native callback and releases any unclaimed room, publication and newly created track, while retaining caller ownership of sources. README includes the source-based API and lifetime requirements.

Native dependency: livekit/rust-sdks#1732 (gitlink pinned to cfafe39e). Agents companion: livekit/agents#8746. No breaking API changes.

Validation: 23 focused tests passed; 15 staging integration tests passed with real non-silent audio, single/dual PC, ordinary/existing-track/source and mixed-input publication, repeated destruction, rejection, partial invalid input and cancelled successful/failed connects. Generated protobuf bindings use the CI toolchain. Agents: 160 focused tests passed.

Staging benchmark against the previous synchronous-preparation implementation: 24 measured sessions, six excluded warmups, median ICE RTT 62 ms, all with audio and message acknowledgements. Activity-start delay: 102.1 to 3.8 ms. First audible audio: 1,929 to 1,808 ms with delayed activity, 1,909 to 1,808 ms with delayed PCM; immediate startup remains unchanged at about 1,302 ms. Both arms use publish-on-join. This demonstrates removal of the preparation regression, not a two-RTT audible saving or production LLM/TTS timing.

Full evidence: https://github.com/livekit/agents/tree/sxian/CLT-3610/fast-track-publication-session-api/examples/startup_tracing/native-preparation-reports

@github-actions

Copy link
Copy Markdown
Contributor

👋 This PR has no changeset. If it should be released, add a markdown file under .changeset/ (any name, e.g. .changeset/fix-token-parsing.md):

---
"livekit-rtc": patch
---

Short description of the change, used in the release notes.
  • Packages: livekit-rtc, livekit-api, livekit-protocol (one line per package)
  • Types: patch, minor, major, patch-rc, minor-rc, major-rc, next-rc, promote

If this change doesn't need a release (docs, CI, tests), you can ignore this comment.

@xianshijing-lk xianshijing-lk changed the title feat(rtc): publish prepared tracks during connect feat(rtc): prepare audio sources natively during connect Nov 24, 2026

This branch has not been deployed

No deployments
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