Skip to content

Add RemoteTrackPublication.setFecProtection - #1334

Draft
cloudwebrtc wants to merge 2 commits into
mainfrom
duan/flexfec-subscribe
Draft

cloudwebrtc wants to merge 2 commits into
mainfrom
duan/flexfec-subscribe

Conversation

@cloudwebrtc

@cloudwebrtc cloudwebrtc commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds subscriber-side FlexFEC control: a subscriber can ask the SFU for FlexFEC repair packets on a subscribed video track, matching RemoteTrackPublication::set_fec_protection in the Rust SDK (livekit/rust-sdks#1668).

  • Protocol updated to v1.55.0, which adds UpdateTrackSettings.fec (FECProtection with a mode and a level).
  • New public FecProtection, FecProtectionMode and FecProtectionLevel, with presets FecProtection.disabled, FecProtection.adaptive, FecProtection.fixed(level) and FecProtection.minimum(level).
  • RemoteTrackPublication.setFecProtection(protection) and the fecProtection getter.
    • Only for video tracks; for any other track it throws UnsupportedError, matching the InvalidRequest the FFI SDKs return (Add an FFI request to set subscriber FEC protection rust-sdks#1765).
    • Can be called before the track is subscribed. The request is kept and sent once the track arrives.
    • The protection is included in every UpdateTrackSettings. The server replaces the other fields on each update but keeps the previous protection when fec is omitted.
    • Sent again whenever a new track is attached (resubscription), with or without adaptive stream. Full reconnects already resend track settings.
    • Until the app calls it, fec is omitted, so the requests the SDK sends are unchanged.

Receiving FlexFEC needs no client option: libwebrtc always offers flexfec-03 as a receive codec. The publisher side (enableFlexFec, per-sender protection) comes in a follow-up, after flutter-webrtc/flutter-webrtc#2304 is released.

The server only sends repair packets when downstream FlexFEC is enabled on it (livekit/livekit#5195); otherwise the request is ignored.

Testing

  • New tests in test/publication/remote_track_publication_test.dart:
    • protection set before subscribing is sent when the track is attached
    • updates are sent, and other settings changes repeat the protection
    • disabled is sent explicitly
    • fec is omitted until requested
    • the protection is sent again on resubscription, with and without adaptive stream
    • audio tracks throw UnsupportedError
  • flutter test (all pass), flutter analyze, dart format, import_sorter.
  • Not yet tested end to end against a FlexFEC-enabled server.

Request FlexFEC repair packets for a subscribed video track through the
new UpdateTrackSettings.fec field (protocol v1.55.0). The requested
protection is kept on the publication and repeated with every settings
update, since the server replaces the other fields on each update, and
sent again when a new track is attached.
@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

This PR bumps

  • livekit_client: minor

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.

1 participant