From 4da02213bff4d9d47309df10a0d98f6a68fe59aa Mon Sep 17 00:00:00 2001 From: Jacob Gelman <3182119+ladvoc@users.noreply.github.com> Date: Mon, 29 Jun 2026 14:19:48 -0700 Subject: [PATCH] Expose data track pipeline options --- include/livekit/remote_data_track.h | 25 +++++++++++++++++++++++++ src/remote_data_track.cpp | 16 ++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/include/livekit/remote_data_track.h b/include/livekit/remote_data_track.h index e74fd936..faa650d1 100644 --- a/include/livekit/remote_data_track.h +++ b/include/livekit/remote_data_track.h @@ -16,7 +16,9 @@ #pragma once +#include #include +#include #include #include "livekit/data_track_error.h" @@ -65,6 +67,29 @@ class RemoteDataTrack { /// Whether the track is still published by the remote participant. LIVEKIT_API bool isPublished() const; + /// Track-level options that configure how the incoming-frame pipeline + /// reassembles packets for this remote data track. + /// + /// Applied via setPipelineOptions(). + struct PipelineOptions { + /// Maximum number of partial frames the depacketizer will track + /// concurrently for this track. + /// + /// Defaults to 1. Higher values give more out-of-order tolerance for + /// high-frequency senders at the cost of additional buffering. Zero is + /// not a valid value; if a value of zero is provided, it will be + /// clamped to one. Leave unset to keep the current value. + std::optional max_partial_frames{std::nullopt}; + }; + + /// Configures options for the pipeline handling incoming packets for this + /// track. + /// + /// These options apply to all current and future subscriptions of this + /// track, and may be set at any time. New options take effect with the + /// next received packet. + LIVEKIT_API void setPipelineOptions(const PipelineOptions& options); + #ifdef LIVEKIT_TEST_ACCESS /// Test-only accessor for exercising lower-level FFI subscription paths. uintptr_t testFfiHandleId() const noexcept { return ffiHandleId(); } diff --git a/src/remote_data_track.cpp b/src/remote_data_track.cpp index 7c48c560..dcaadb76 100644 --- a/src/remote_data_track.cpp +++ b/src/remote_data_track.cpp @@ -46,6 +46,22 @@ bool RemoteDataTrack::isPublished() const { return resp.remote_data_track_is_published().is_published(); } +void RemoteDataTrack::setPipelineOptions(const PipelineOptions& options) { + if (!handle_.valid()) { + return; + } + + proto::FfiRequest req; + auto* msg = req.mutable_remote_data_track_set_pipeline_options(); + msg->set_track_handle(static_cast(handle_.get())); + auto* opts = msg->mutable_options(); + if (options.max_partial_frames) { + opts->set_max_partial_frames(*options.max_partial_frames); + } + + FfiClient::instance().sendRequest(req); +} + Result, SubscribeDataTrackError> RemoteDataTrack::subscribe( const DataTrackStream::Options& options) { if (!handle_.valid()) {