Repository navigation
Conversation
…Bytes TextStreamWriter / ByteStreamWriter now open an FFI writer (text/byte_stream_open) and send through text/byte_stream_write and *_stream_close instead of hand-built header/chunk/trailer packets. Rust does the chunking and UTF-8 splitting. - LocalParticipant::streamText / streamBytes return an already-open writer (blocking until the open callback, throwing DataStreamError on failure), taking the same StreamTextOptions / StreamByteOptions as the one-shot sends, including the text operation type, version and generated flag. The public writer constructors keep working but are deprecated; they open lazily on the first write or close, as the header did before. - write() and close() share one mutex and each waits for its FFI callback, so a close never overtakes an in-flight write (python-sdks#879); this also fixes close() not taking the write lock. - A LocalParticipant tracks its writers in a registry shared with them. On disconnect (or participant destruction) every writer is closed and its handle dropped, so later write/close throw DataStreamError instead of reaching an FFI session that would panic. - A writer destroyed without close() sends a non-waiting FFI close. Rust's writer only sends its drop-time trailer from a Tokio thread, so a plain handle drop from C++ left receivers waiting forever. - kStreamChunkSize and the protected ensureHeaderSent / sendChunk / sendTrailer helpers are deprecated and reimplemented on the new path. - Removed FfiClient::sendStream*Async, splitUtf8 and the now-unused header/chunk/trailer converters. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ports the Rust outgoing-manager tests that streamText / streamBytes can reproduce, checking the raw packets the receiving room gets: each write is sent as it happens, writers never compress or inline, multi-write streams split at the 15000-byte MTU and text on UTF-8 boundaries, close attributes and reasons reach the trailer, oversized attributes throw, a destroyed writer still sends its trailer, and packets are attributed to the sender. Also covers targeted destinations and the sender_identity option across one-shot sends and writers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 30, 2026
Author
|
CI for this branch (manually dispatched, since |
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.
Part 5 of 5 of the data streams v2 stack. Merge in order; each part is mergeable on its own.
sendText/sendBytes/sendFileByteStreamReader::writeToFileand a receive size limitstreamText/streamBytes👈 this PRThis stack replaces #321, #322 and #325 (same code, reordered so each step stands on its own).
Moves
TextStreamWriter/ByteStreamWriteronto the FFI's writer handles, and addsLocalParticipant::streamText/streamBytes. The old way of making writers (public constructors) keeps working but is deprecated.Changes
text/byte_stream_open) and send through*_stream_write/*_stream_close, instead of hand-building header / chunk / trailer packets. The Rust core does chunking and UTF-8 splitting.streamText/streamBytesreturn an already-open writer and throwDataStreamErrorif the open fails. They take the same options as the one-shot sends, including the text header fields from part 3.[[deprecated]]attribute and@deprecateddoc. They now open lazily on the first write or close.kStreamChunkSizeand the protectedensureHeaderSent/sendChunk/sendTrailer, which are reimplemented on the new path.write()/close()ordering: they share one mutex and each waits for its FFI callback, soclose()never overtakes an in-flight write (the fix(rtc): synchronize stream writer aclose with in-flight writes python-sdks#879 fix). It also fixesclose()not taking the write lock.LocalParticipanttracks its writers in a shared registry. On disconnect, or when the participant is destroyed, every writer is closed, and later calls throwDataStreamErrorinstead of reaching an FFI session that would panic.close(): it sends a non-waiting close. The Rust writer only sends its drop-time trailer from a Tokio thread, so dropping the handle from C++ left receivers waiting forever.FfiClient::sendStream*Async,splitUtf8and the now-unused header / chunk / trailer converters, which were all internal.Nothing gets more broken: writers now send what other SDKs' writers send (never inline, never compressed), and the C++ receive path from part 2 reads it.
Tests
test_data_stream_conformance_send.cppsender_identityacross all send APIstest_data_stream_conformance_text_header.cppstreamTexttest_data_streams.cppclose()waiting for a write, write after close/disconnect throws, destroyed writer ends the stream, deprecated constructors still work; existing tests switched tostreamText/streamBytestest_data_stream.cpp,test_ffi_client.cpp(unit)Rust
outgoing/manager.rstests covered hereDataStreamSendConformanceTest.*)LIVEKIT_TOKEN_C)The
sender_identitytests are partial because the SFU attributes every packet to the authenticated sender unless its token allows impersonation, which the test tokens don't. So the test checks that the option is accepted and the stream delivered.The 4 Rust
utf8_chunk.rstests cover an internal helper. The C++ SDK no longer chunks text itself;StreamTextSplitsOnUtf8BoundariesAtMtuandV2CompressedTextReframesMultibyteUtf8(part 2) check that behaviour end to end.After this stack
All 124 Rust
livekit-data-streamtests are either ported (fully or partly) or not testable from C++. The ones that aren't testable fall in these groups, and the crate's own tests cover them:Verification (local, macOS arm64,
livekit-server --dev)livekit1.3.0, both directions, 3/3 runs intact:sendText,streamText(40 KB in two writes) andstreamBytes(100 KB) → Python.CloseWaitsForInFlightWrite(a 2 MB write racingclose()) timed out once at 30 s in a filtered run. It passed 3/3 on its own and in the full suite. Worth watching in CI.DataTrackE2ETestschema tests (DefineAndGetSchema,DefineAndGetCustomSchemaEncoding,DefineDuplicateSchemaFails). They fail onmainon this machine too, and the 1 skip is the token-server test.🤖 Generated with Claude Code