From 80128b551c0c4007271471d59ee9936faaa5c96b Mon Sep 17 00:00:00 2001 From: shijing xian Date: Tue, 30 Jun 2026 13:35:18 +0800 Subject: [PATCH 1/3] chore: update rust-sdks to livekit-ffi v0.12.68 Updates rust-sdks submodule to include: - Add MaintainFramerateAndResolution to DegradationPreference enum (aligns with WebRTC M144) - DISABLED is deprecated, use MAINTAIN_FRAMERATE_AND_RESOLUTION instead Co-Authored-By: Claude Opus 4.5 --- client-sdk-rust | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client-sdk-rust b/client-sdk-rust index 8e551062..dad794d4 160000 --- a/client-sdk-rust +++ b/client-sdk-rust @@ -1 +1 @@ -Subproject commit 8e551062c59f912159b8cebac44b2cdcce0024ef +Subproject commit dad794d414fda9e8c1de83af1c0f190506a15f8f From d0a4d243d7d9abf62ad7b746837573eb2a612d7c Mon Sep 17 00:00:00 2001 From: shijing xian Date: Tue, 30 Jun 2026 14:14:30 +0800 Subject: [PATCH 2/3] feat: add DegradationPreference enum with MaintainFramerateAndResolution Add DegradationPreference enum and field to TrackPublishOptions to allow controlling encoder behavior when bandwidth is constrained: - Balanced: Balance between framerate and resolution degradation - MaintainFramerate: Degrade framerate to maintain resolution - MaintainResolution: Degrade resolution to maintain framerate - Disabled (deprecated): Use MaintainFramerateAndResolution instead - MaintainFramerateAndResolution: Maintain both, drop frames before encoding Co-Authored-By: Claude Opus 4.5 --- include/livekit/room_event_types.h | 17 +++++++++++++++++ src/room_proto_converter.cpp | 6 ++++++ 2 files changed, 23 insertions(+) diff --git a/include/livekit/room_event_types.h b/include/livekit/room_event_types.h index cb55f7b0..20e26a19 100644 --- a/include/livekit/room_event_types.h +++ b/include/livekit/room_event_types.h @@ -273,6 +273,19 @@ struct AudioEncodingOptions { std::uint64_t max_bitrate = 0; }; +/// Controls how the encoder degrades quality when bandwidth is constrained. +enum class DegradationPreference { + /// Balance between framerate and resolution degradation. + Balanced = 0, + /// Degrade framerate to maintain resolution. + MaintainFramerate = 1, + /// Degrade resolution to maintain framerate (drop frames to keep clarity). + MaintainResolution = 2, + /// Maintain both framerate and resolution. Frames may be dropped before + /// encoding if necessary to avoid overusing network and encoder resources. + MaintainFramerateAndResolution = 4, +}; + /// Optional RTP packet-trailer features for published video tracks. struct PacketTrailerFeatures { /// Embed a user-supplied wall-clock timestamp. @@ -313,6 +326,10 @@ struct TrackPublishOptions { /// Optional packet-trailer features to enable for published video. PacketTrailerFeatures packet_trailer_features{}; + + /// Controls how the encoder trades off between resolution and framerate + /// when bandwidth is constrained. Default is MaintainResolution. + std::optional degradation_preference; }; // --------------------------------------------------------- diff --git a/src/room_proto_converter.cpp b/src/room_proto_converter.cpp index 53b49c59..15661cc2 100644 --- a/src/room_proto_converter.cpp +++ b/src/room_proto_converter.cpp @@ -505,6 +505,9 @@ proto::TrackPublishOptions toProto(const TrackPublishOptions& in) { for (const proto::PacketTrailerFeature feature : toProto(in.packet_trailer_features)) { msg.add_packet_trailer_features(feature); } + if (in.degradation_preference) { + msg.set_degradation_preference(static_cast(*in.degradation_preference)); + } return msg; } @@ -538,6 +541,9 @@ TrackPublishOptions fromProto(const proto::TrackPublishOptions& in) { out.preconnect_buffer = in.preconnect_buffer(); } out.packet_trailer_features = fromProto(in.packet_trailer_features()); + if (in.has_degradation_preference()) { + out.degradation_preference = static_cast(in.degradation_preference()); + } return out; } From 7244d40a8855decab607df1372ea11ff1633b04f Mon Sep 17 00:00:00 2001 From: shijing xian Date: Tue, 30 Jun 2026 16:26:55 +0800 Subject: [PATCH 3/3] fix: correct DegradationPreference docstrings to match WebRTC semantics The docstrings for MaintainFramerate and MaintainResolution were swapped. Per the W3C WebRTC spec: - MaintainFramerate: Degrade resolution to maintain framerate (prioritize smooth motion) - MaintainResolution: Degrade framerate to maintain resolution (prioritize image clarity) Co-Authored-By: Claude Opus 4.5 --- include/livekit/room_event_types.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/livekit/room_event_types.h b/include/livekit/room_event_types.h index 20e26a19..a55b7687 100644 --- a/include/livekit/room_event_types.h +++ b/include/livekit/room_event_types.h @@ -277,9 +277,9 @@ struct AudioEncodingOptions { enum class DegradationPreference { /// Balance between framerate and resolution degradation. Balanced = 0, - /// Degrade framerate to maintain resolution. + /// Degrade resolution to maintain framerate (prioritize smooth motion). MaintainFramerate = 1, - /// Degrade resolution to maintain framerate (drop frames to keep clarity). + /// Degrade framerate to maintain resolution (prioritize image clarity). MaintainResolution = 2, /// Maintain both framerate and resolution. Frames may be dropped before /// encoding if necessary to avoid overusing network and encoder resources.