You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description:
There is an inconsistency in chunk indexing between ByteStreamWriter and TextStreamWriter in livekit/rtc/data_stream.py. The ByteStreamWriter.write method incorrectly increments the _next_chunk_index before using it for the chunk_index field in the proto_DataStream.Chunk message. This results in the first chunk being sent with index 1.
Problem:
Most stream consumers, including the LiveKit Unity SDK (ByteStreamReader), expect the first chunk index of a stream to be 0.
When receiving a chunk with index 1 without seeing index 0 first, the client raises an error, typically like "expected chunk index to be exactly one more than the previous". This prevents byte streams from working correctly with such clients.
Text streams work correctly because TextStreamWriter uses the current _next_chunk_index(which starts at 0) before incrementing it.
Proposed Solution:
Modify ByteStreamWriter.write to use _next_chunk_index for the chunk_index before incrementing it, consistent with TextStreamWriter.
The text was updated successfully, but these errors were encountered:
Description:
There is an inconsistency in chunk indexing between
ByteStreamWriter
andTextStreamWriter
in livekit/rtc/data_stream.py. TheByteStreamWriter.write
method incorrectly increments the_next_chunk_index
before using it for the chunk_index field in theproto_DataStream.Chunk
message. This results in the first chunk being sent with index 1.Code References:
Incorrect ByteStreamWriter logic:
python-sdks/livekit-rtc/livekit/rtc/data_stream.py
Lines 342 to 348 in ea42eb8
Correct TextStreamWriter logic:
python-sdks/livekit-rtc/livekit/rtc/data_stream.py
Lines 286 to 294 in ea42eb8
Problem:
Most stream consumers, including the LiveKit Unity SDK (
ByteStreamReader
), expect the first chunk index of a stream to be 0.When receiving a chunk with index 1 without seeing index 0 first, the client raises an error, typically like "expected chunk index to be exactly one more than the previous". This prevents byte streams from working correctly with such clients.
Text streams work correctly because
TextStreamWriter
uses the current_next_chunk_index
(which starts at 0) before incrementing it.Proposed Solution:
Modify
ByteStreamWriter.write
to use_next_chunk_index
for thechunk_index
before incrementing it, consistent withTextStreamWriter
.The text was updated successfully, but these errors were encountered: