Skip to content

data tracks: add a priority option to publishing - #1734

Draft
jtestard wants to merge 2 commits into
mainfrom
jtestard/data-track-priority
Draft

jtestard wants to merge 2 commits into
mainfrom
jtestard/data-track-priority

Conversation

@jtestard

Copy link
Copy Markdown

What

A publisher can give a data track a network priority when it publishes it:

use livekit::data_track::{DataTrackOptions, TrackPriority};

let track = participant
    .local_participant()
    .publish_data_track(DataTrackOptions::new("telemetry").with_priority(TrackPriority::HIGH))
    .await?;
  • TrackPriority: a number ordered the way firewall rules are, where a lower value is more important.
    • Named values: HIGH (64), MEDIUM (128), LOW (192), VERY_LOW (254).
    • Values below HIGH are reserved; TrackPriority::new raises them to HIGH.
  • Unset by default: without with_priority, the request carries no priority and the server decides.
  • On the wire: the priority goes in PublishDataTrackRequest.priority.
  • Kept for republishing: it's also kept in the track info, so a republish after a reconnect sends it again.

Notes

  • Depends on Add priority to track and data track publish requests protocol#2015 for the priority fields.
    • livekit-protocol/src has only those four fields added. The generated code matches generate_proto.sh output for them.
    • The protocol submodule isn't bumped here. That can follow once #2015 is merged.
  • Rust API only. Media tracks and the FFI bindings aren't covered yet.

Testing

  • cargo test -p livekit-datatrack passes, including new tests for the request field and the value range.
  • cargo check -p livekit -p livekit-ffi passes.

🤖 Generated with Claude Code

`DataTrackOptions::with_priority(TrackPriority)` sends the track's network
priority to the server in `PublishDataTrackRequest.priority`, and keeps it in
the track info so that a republish sends it again. `TrackPriority` is ordered
the way firewall rules are: a lower value is more important; values below
`TrackPriority::HIGH` (64) are reserved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Changeset incomplete

This PR's changeset is missing version bumps for packages that are affected by the change. The following packages still require a bump:

  • livekit
  • livekit-api
  • livekit-capture
  • livekit-common
  • livekit-data-stream
  • livekit-ffi
  • livekit-rpc
  • livekit-signaling
  • livekit-telemetry
  • livekit-token

Already covered:

  • livekit-datatrack (minor)
  • livekit-protocol (minor)

A package must be bumped when its own files change, and whenever a package it depends on is bumped (so downstream consumers get a matching release).

Click here to create a changeset for the missing packages

The link pre-populates a changeset file with patch bumps for the missing packages. You can also add them to your existing changeset. Edit the bump types as needed before committing.

If this change doesn't require a version bump, add the internal label to this PR.

///
/// Ordered the way firewall rules are: a lower value is more important. Values below
/// [`TrackPriority::HIGH`] are reserved, and [`TrackPriority::new`] raises them to it.
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue: Relying on the derived implementation for Ord in this case produces comparisons that are not semantically valid:

assert!(TrackPriority::LOW < TrackPriority::HIGH) // fails

This branch has not been deployed

No deployments
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