Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add data stream support #361

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

Add data stream support #361

wants to merge 12 commits into from

Conversation

lukasIO
Copy link
Contributor

@lukasIO lukasIO commented Dec 17, 2024

depends on livekit/rust-sdks#533

writing stream:

thoughts about writing: for STT we need a way to optionally also override the chunk index with this API

const greeting = 'Hi this is just a text sample';
  const streamWriter = await room.localParticipant?.streamText({
    destinationIdentities: [recipient.identity],
  });

  for (const c of greeting) {
    await streamWriter.write([c]);
// for overriding the chunk Id, you'd simply have a second value in the array like
//     await streamWriter.write([c, myChunkIndex]);

  }

  await streamWriter?.close();

reading stream:

room.on(RoomEvent.TextStreamReceived, async (reader: TextStreamReader) => 
    for await (const { current } of reader) {
      console.log(current);
    }
    // whole stream content
    console.log(await reader.readAll());
  });

Copy link

changeset-bot bot commented Dec 17, 2024

⚠️ No Changeset found

Latest commit: 957b941

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@lukasIO lukasIO marked this pull request as draft December 17, 2024 14:43
@lukasIO lukasIO changed the title Add data stream receiving Add data stream support Dec 20, 2024
@lukasIO lukasIO marked this pull request as ready for review December 20, 2024 15:17
Copy link
Contributor

@bcherry bcherry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add docstrings to all of the exported classes? There's also at least one error handling TODO left in here still.

Looks good and thank you for including an example!

@lukasIO
Copy link
Contributor Author

lukasIO commented Dec 22, 2024

Can you add docstrings to all of the exported classes?

added some, the annoying thing however is that docstrings don't show up on class instances. And we're only returning class instances to users, so they won't really profit from them.

There's also at least one error handling TODO left in here still

errors are currently being logged to console, the TODO is in there for later improvements around re-requesting missing chunks or similar repair mechanisms. Deleted the TODOs


return new Promise(async (resolve) => {
// FIXME we need an equivalent for this on the rust layer
// await localP.engine.waitForBufferStatusLow(DataPacket_Kind.RELIABLE);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@theomonnom How does Rust currently handle the datachannel buffer? Do we have an event yet and/or a different mechanism for backpressure?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants