Repository navigation
feat(rtc): prepare audio sources natively during connect - #963
Draft
xianshijing-lk wants to merge 5 commits into
Draft
xianshijing-lk wants to merge 5 commits into
xianshijing-lk wants to merge 5 commits into
Conversation
Contributor
|
👋 This PR has no changeset. If it should be released, add a markdown file under ---
"livekit-rtc": patch
---
Short description of the change, used in the release notes.
If this change doesn't need a release (docs, CI, tests), you can ignore this comment. |
This was referenced Nov 23, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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