Skip to content

Commit 5c0d922

Browse files
committed
feat: port data streams to the livekit-ffi rust implementation
Replaces the hand-rolled Python data streams (client-side header/chunk/trailer framing over SendStreamHeader/Chunk/TrailerRequest) with the FFI's native implementation (data streams v2: single-packet streams + deflate): - Writers open handle-based FFI streams (text/byte_stream_open/write/close); chunking, stream ids, and compression now happen in rust - send_text/send_file are one-shot FFI calls and gain a compress option - Incoming streams arrive via text/byte_stream_opened room events; readers consume per-handle reader events after a read_incremental request, and unhandled topics dispose the owned reader handle - New public API: StreamError (raised when a stream terminates abnormally, previously indistinguishable from clean EOS) and RoomOptions.data_stream/DataStreamOptions.max_payload_byte_length - Drops the use_legacy_client_implementation override, so data streams v2 support is advertised to other clients The consumer-facing API is unchanged. Behavior changes: read errors now raise StreamError, stream ids are rust-generated unless supplied, sender_identity is honored consistently (was ignored for chunks/trailers), and trailers of targeted streams are no longer broadcast room-wide.
1 parent b591881 commit 5c0d922

5 files changed

Lines changed: 900 additions & 278 deletions

File tree

livekit-rtc/livekit/rtc/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
from .room import (
6767
ConnectError,
6868
DataPacket,
69+
DataStreamOptions,
6970
Room,
7071
RoomOptions,
7172
RtcConfiguration,
@@ -123,6 +124,7 @@
123124
TextStreamWriter,
124125
ByteStreamWriter,
125126
ByteStreamReader,
127+
StreamError,
126128
)
127129
from .data_track import (
128130
LocalDataTrack,
@@ -172,6 +174,7 @@
172174
"ConnectError",
173175
"Room",
174176
"RoomOptions",
177+
"DataStreamOptions",
175178
"RtcConfiguration",
176179
"SimulateScenarioKind",
177180
"SipDTMF",
@@ -217,6 +220,7 @@
217220
"TextStreamWriter",
218221
"ByteStreamReader",
219222
"ByteStreamWriter",
223+
"StreamError",
220224
"AudioProcessingModule",
221225
"PlatformAudio",
222226
"PlatformAudioSource",

0 commit comments

Comments
 (0)