-
Notifications
You must be signed in to change notification settings - Fork 156
Data tracks integration #863
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
Open
ladvoc
wants to merge
129
commits into
main
Choose a base branch
from
ladvoc/data-tracks-integration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
129 commits
Select commit
Hold shift + click to select a range
16d0294
Upgrade protocol to v1.44.0
ladvoc cb8f8a8
Integrate
ladvoc ca66c69
generated protobuf
github-actions[bot] 2ccb534
Data tracks core module
ladvoc fd1a92e
Merge remote-tracking branch 'origin/main' into ladvoc/data-tracks-core
ladvoc 7a90118
Use workspace dependencies
ladvoc afc10b4
Add to workspace
ladvoc c320670
Format
ladvoc ab8bb25
Add release-plz configuration
ladvoc d7b07a5
Used checked add
ladvoc 7fb9c8f
Fix naming typo
ladvoc e951f4a
Fix inverted logic
ladvoc 9452218
Fix potential integer overflow
ladvoc 5bca4c6
Data tracks integration with livekit crate
ladvoc b4f2303
Data tracks example
ladvoc 1347840
Add crate as workspace dependency
ladvoc fae05c9
Merge branch 'ladvoc/data-tracks-core' into ladvoc/data-tracks-integr…
ladvoc da85847
Fix typo
ladvoc 8239631
Apply Clippy suggestions
ladvoc 39808fe
Merge branch 'ladvoc/data-tracks-core' into ladvoc/data-tracks-integr…
ladvoc 861755c
Integrate
ladvoc af1781b
Add example to workspace
ladvoc d2d9817
Handle DC back pressure
ladvoc f612712
Document DC sender
ladvoc 63f7ed6
Clippy
ladvoc 9e1b6c7
Detect duplicate packets
ladvoc b4862cf
Compare with >=
ladvoc 5ec6439
Calculate payload length during finalize
ladvoc 01c550a
Cast earlier in expression
ladvoc 8d65bbe
Handle edge case in packet reassembly
ladvoc c117c1c
Format
ladvoc b920d42
Refactor extension deserialization
ladvoc 301aedf
Use wrapping add in tests
ladvoc d2afd21
Merge remote-tracking branch 'origin/main' into ladvoc/data-tracks-core
ladvoc 8e4f0bc
generated protobuf
github-actions[bot] d1444af
Merge remote-tracking branch 'origin/main' into ladvoc/data-tracks-in…
ladvoc 8745150
Merge branch 'ladvoc/data-tracks-core' into ladvoc/data-tracks-integr…
ladvoc 0bf2ee0
generated protobuf
github-actions[bot] ca40c9f
Address comment
ladvoc 037fafc
Add packet specification
ladvoc cf1f9be
Format
ladvoc 1438639
Implement drop for manager input
ladvoc 2d7d219
Increment frame number after fallible ops
ladvoc ddbe67a
Merge remote-tracking branch 'origin/ladvoc/data-tracks-core' into la…
ladvoc ccdc012
Handle publisher side full reconnect
ladvoc 1522a52
Merge remote-tracking branch 'origin/ladvoc/data-tracks-core' into la…
ladvoc 7e314a8
Test publisher side full reconnect
ladvoc ad94670
Merge remote-tracking branch 'origin/main' into ladvoc/data-tracks-core
ladvoc 15f3359
Update protobuf
ladvoc 1ce2601
generated protobuf
github-actions[bot] d0e7498
Merge remote-tracking branch 'origin/ladvoc/data-tracks-core' into la…
ladvoc e86ba41
Fix protocol
ladvoc e2583ab
Add missing clone derive
ladvoc cc4f741
Rename error reason case
ladvoc ba3636b
Unpublish on unknown handle
ladvoc 3432333
Update protocol
ladvoc 586dc9d
Format
ladvoc 8529950
generated protobuf
github-actions[bot] 9923c14
Add missing await
ladvoc e5d9549
Drop guard for manager input
ladvoc fc7e146
Remove timeout
ladvoc 86924dd
Add doc comment
ladvoc 38eba78
Avoid hardcoded constants
ladvoc 0aa9412
Increase buffer counts
ladvoc 9a85e8a
Merge remote-tracking branch 'origin/ladvoc/data-tracks-core' into la…
ladvoc d932ff2
Clarify intent
ladvoc c952b3e
Use workspace deps for example
ladvoc 0cca8ec
Fix typo
ladvoc e2f3167
Format
ladvoc 39b6bc8
Use workspace deps
ladvoc 45531ef
Merge remote-tracking branch 'origin' into ladvoc/data-tracks-core
ladvoc dac3f02
Add invalid name error case
ladvoc ac7b3f8
Ignore extensions with unknown length
ladvoc bef4a10
Format
ladvoc 211313e
Merge remote-tracking branch 'origin/main' into ladvoc/data-tracks-core
ladvoc 20439ea
Add knope configuration
ladvoc 6d136bc
Merge remote-tracking branch 'origin/ladvoc/data-tracks-core' into la…
ladvoc e5be06c
Fix doc
ladvoc 6811877
Use constant
ladvoc d5fd25d
Remove future deprecation note
ladvoc cca6bd1
Compatible format with JS example
ladvoc a2cd198
Visualization on subscriber side
ladvoc c130668
Fill entire tile area
ladvoc 7d83908
Label point
ladvoc d604d50
Graph on both sides
ladvoc fee0ac7
Interactive graph on publisher side
ladvoc 1452856
UI tweaks
ladvoc cba9e40
Reverse orientation
ladvoc 93159dd
Hint when no points
ladvoc 7efd0a8
Two byte TLV packet format
ladvoc 296bfbe
Merge remote-tracking branch 'origin/main' into ladvoc/data-tracks-core
ladvoc c513c70
Add changeset
ladvoc eb1d7d8
Remove comment
ladvoc 920544c
Use workspace props, add description
ladvoc 0784fe8
Merge remote-tracking branch 'origin/ladvoc/data-tracks-core' into la…
ladvoc 4337555
Use actual bytes for extension TLV encoding
ladvoc 0faf7c3
Skip extra bytes for future extension versions
ladvoc 5ba7822
User customizable frame buffer size for subscriptions
ladvoc 61f8f29
Format
ladvoc a7181f3
Add new method
ladvoc 41b25dd
Additional unit tests for track managers
ladvoc 37030fe
Fix publish/unpublish detection
ladvoc de06a2d
Concrete stream type for subscription
ladvoc 7fa0bc6
Consistent public type prefixing
ladvoc 66ff49f
Assert key index remains the same
ladvoc 00d1d2b
Changeset
ladvoc d5339be
Avoid intermediate collect
ladvoc f615772
Format
ladvoc fff3d9d
Rename event
ladvoc ab51dc5
Add track unpublished event
ladvoc 7b07b1d
Test track unpublished event
ladvoc af97e55
Merge remote-tracking branch 'origin/ladvoc/data-tracks-core' into la…
ladvoc 15a8e53
Integrate core changes
ladvoc b4550df
Expose data track unpublished event
ladvoc fc69292
Drop prefix from event names
ladvoc 41edcb2
Expose additional types in prelude
ladvoc bb358f3
Clamp invalid buffer size instead of panic
ladvoc 0035a09
Merge remote-tracking branch 'origin/ladvoc/data-tracks-core' into la…
ladvoc 49ed111
Do not consume track on unpublish
ladvoc 8aa877e
Merge remote-tracking branch 'origin/ladvoc/data-tracks-core' into la…
ladvoc 1f8c0da
Integrate changes
ladvoc 79d8ae5
Merge remote-tracking branch 'origin/main' into ladvoc/data-tracks-in…
ladvoc be26a5c
Format
ladvoc 181a933
Merge remote-tracking branch 'origin/main' into ladvoc/data-tracks-in…
ladvoc 519d782
Document timeout error reason
ladvoc 00305b8
Rename
ladvoc acd4486
Handle incoming packets in single PC path
ladvoc ea8dc8c
Integrate with testing util changes
ladvoc 5a7bc95
Rename type
ladvoc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| livekit: minor | ||
| --- | ||
|
|
||
| # Initial support for data tracks |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| livekit-datatrack: patch | ||
| --- | ||
|
|
||
| # Rename type to DataTrackStream |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| [package] | ||
| name = "basic_data_track" | ||
| version = "0.1.0" | ||
| edition = "2021" | ||
| publish = false | ||
|
|
||
| [dependencies] | ||
| tokio = { workspace = true, features = ["full"] } | ||
| livekit = { workspace = true, features = ["rustls-tls-native-roots"] } | ||
| futures-util = { workspace = true, default-features = false, features = ["sink"] } | ||
| anyhow = { workspace = true } | ||
| log = { workspace = true } | ||
| env_logger = { workspace = true } | ||
|
|
||
| [[bin]] | ||
| name = "publisher" | ||
| path = "src/publisher.rs" | ||
|
|
||
| [[bin]] | ||
| name = "subscriber" | ||
| path = "src/subscriber.rs" |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # Basic Data Track | ||
|
|
||
| Simple example of publishing and subscribing to a data track. | ||
|
|
||
| ## Usage | ||
|
|
||
| 1. Run the publisher: | ||
|
|
||
| ```sh | ||
| export LIVEKIT_URL="..." | ||
| export LIVEKIT_TOKEN="<first participant token>" | ||
| cargo run --bin publisher | ||
| ``` | ||
|
|
||
| 2. In a second terminal, run the subscriber: | ||
|
|
||
| ```sh | ||
| export LIVEKIT_URL="..." | ||
| export LIVEKIT_TOKEN="<second participant token>" | ||
| cargo run --bin subscriber | ||
| ``` |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| use anyhow::Result; | ||
| use livekit::prelude::*; | ||
| use std::{env, time::Duration}; | ||
| use tokio::{signal, time}; | ||
|
|
||
| #[tokio::main] | ||
| async fn main() -> Result<()> { | ||
| env_logger::init(); | ||
|
|
||
| let url = env::var("LIVEKIT_URL").expect("LIVEKIT_URL is not set"); | ||
| let token = env::var("LIVEKIT_TOKEN").expect("LIVEKIT_TOKEN is not set"); | ||
|
|
||
| let (room, _) = Room::connect(&url, &token, RoomOptions::default()).await?; | ||
|
|
||
| let track = room.local_participant().publish_data_track("my_sensor_data").await?; | ||
|
|
||
| tokio::select! { | ||
| _ = push_frames(track) => {} | ||
| _ = signal::ctrl_c() => {} | ||
| } | ||
| Ok(()) | ||
| } | ||
|
|
||
| async fn read_sensor() -> Vec<u8> { | ||
| // Dynamically read some sensor data... | ||
| vec![0xFA; 256] | ||
| } | ||
|
|
||
| async fn push_frames(track: LocalDataTrack) { | ||
| loop { | ||
| log::info!("Pushing frame"); | ||
|
|
||
| let reading = read_sensor().await; | ||
| let frame = DataTrackFrame::new(reading).with_user_timestamp_now(); | ||
|
|
||
| track.try_push(frame).inspect_err(|err| println!("Failed to push frame: {}", err)).ok(); | ||
| time::sleep(Duration::from_millis(500)).await | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| use anyhow::Result; | ||
| use futures_util::StreamExt; | ||
| use livekit::prelude::*; | ||
| use std::env; | ||
| use tokio::{signal, sync::mpsc::UnboundedReceiver}; | ||
|
|
||
| #[tokio::main] | ||
| async fn main() -> Result<()> { | ||
| env_logger::init(); | ||
|
|
||
| let url = env::var("LIVEKIT_URL").expect("LIVEKIT_URL is not set"); | ||
| let token = env::var("LIVEKIT_TOKEN").expect("LIVEKIT_TOKEN is not set"); | ||
|
|
||
| let (_, rx) = Room::connect(&url, &token, RoomOptions::default()).await?; | ||
|
|
||
| tokio::select! { | ||
| _ = handle_publications(rx) => {} | ||
| _ = signal::ctrl_c() => {} | ||
| } | ||
| Ok(()) | ||
| } | ||
|
|
||
| /// Subscribes to any published data tracks. | ||
| async fn handle_publications(mut rx: UnboundedReceiver<RoomEvent>) -> Result<()> { | ||
| while let Some(event) = rx.recv().await { | ||
| let RoomEvent::DataTrackPublished(track) = event else { | ||
| continue; | ||
| }; | ||
| subscribe(track).await? | ||
| } | ||
| Ok(()) | ||
| } | ||
|
|
||
| /// Subscribes to the given data track and logs received frames. | ||
| async fn subscribe(track: RemoteDataTrack) -> Result<()> { | ||
| log::info!( | ||
| "Subscribing to '{}' published by '{}'", | ||
| track.info().name(), | ||
| track.publisher_identity() | ||
| ); | ||
| let mut subscription = track.subscribe().await?; | ||
| while let Some(frame) = subscription.next().await { | ||
| log::info!("Received frame ({} bytes)", frame.payload().len()); | ||
|
|
||
| if let Some(duration) = frame.duration_since_timestamp() { | ||
| log::info!("Latency: {:?}", duration); | ||
| } | ||
| } | ||
| log::info!("Unsubscribed"); | ||
| Ok(()) | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Add the another example we had discussed called like
data_track_signalor something like that which shows a number changing on an ascii art graph and which uses the same protocol (ascii packed number) as the one I added in the web implementation.