Repository navigation
Add LocalParticipant.sendBytes - #750
Conversation
Mirrors python-sdks send_bytes: sends a complete in-memory buffer through the FFI StreamSendBytes request so short payloads can be inlined and larger ones compressed, instead of callers going through streamBytes or a temp file with sendFile. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 1b6e3ec The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
5ea52bf to
a5d9c04
Compare
Matches python-sdks send_bytes, which takes no progress callback. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
🔍 Devin Review: 1 flag
Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
| ); | ||
|
|
||
| if (cb.result.case !== 'info') { | ||
| throw new Error(cb.result.case === 'error' ? cb.result.value.description : 'unknown error'); |
There was a problem hiding this comment.
just a sanity check: should every non-info and non-error case throw an unknown error?
There was a problem hiding this comment.
Good point, though I think in practice, info and error are the only two cases: https://github.com/livekit/rust-sdks/blob/524123ee0069e8c01342c90978ad0dd5e4c58275/livekit-ffi/protocol/data_stream.proto#L187-L190
I will clean this up though, on second read this should just be a switch with two cases and a default.
Handle the expected result case, the error case, and any unexpected case explicitly instead of collapsing everything non-success into 'unknown error'. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Adds
LocalParticipant.sendBytes(data, options), the node counterpart of python-sdks'send_bytes(livekit/python-sdks#858).It sends an in-memory
Uint8Arrayas a complete byte stream in a singleStreamSendBytesRequest. WithstreamBytes()every payload costs a header, a chunk and a trailer. Here the whole payload is known up front, so short payloads can go out as a single packet and larger ones can be compressed, as long as every recipient supports it. It returns the resultingByteStreamInfo, just assendTextreturns its info.This replaces the workaround in livekit/agents-js#2769, which wrote each message to a temp file so it could use
sendFile's one-shot path.Options:
topic,name(defaults to"unknown"),mimeType(defaults to"application/octet-stream"),attributes,destinationIdentities,streamId,compress(defaults to true).No bindings bump is needed:
StreamSendBytes*is already in@livekit/rtc-ffi-bindings0.12.73.Testing
sends and receives a small in-memory buffer via sendBytes(port of python'stest_send_bytes_small). It checks the returned info and the round trip.livekit-server --dev, and both passed.🤖 Generated with Claude Code