Clamp lower-layer encoding against the top layer#1001
Merged
Conversation
Contributor
Author
|
Note on the bitrate clamp — stricter than the JS / Android SDKs. Both peer SDKs only clamp
This PR additionally clamps Worth porting upstream into the Rust SDK too ( |
The middle simulcast layer was emitted with the raw preset's maxFps and maxBitrate, allowing it to exceed the user-configured top layer when a high-fps/high-bitrate preset (e.g. presetH720_169 at 30 fps / 1.7 Mbps) was used alongside a more conservative top encoding (e.g. 24 fps / 1.5 Mbps at the same 1280x720 resolution). Lower layers (q, h) are now clamped against the top encoding: maxFps unconditionally, and maxBitrate when scaleDownBy <= 1.0 so a same-resolution layer cannot outspend the top. Refs #1000
00f1993 to
9a7752b
Compare
hiroshihorie
approved these changes
May 14, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
q,h) are now clamped against the user-configured top encoding:maxFpsunconditionally, andmaxBitratewhenscaleDownBy <= 1.0. A same-resolution lower layer can no longer outspend the top.computeVideoEncodingsand a new pure helpercomputeSimulcastPresetsintoSources/LiveKit/Support/Utils+VideoEncodings.swiftso the preset-resolution logic is testable fromLiveKitCoreTests(the WebRTC-typed return ofcomputeVideoEncodingsis not reachable via@testable import).Fixes #1000.
Test plan
xcodebuild test -scheme LiveKit -only-testing LiveKitCoreTests/SimulcastPresetsTests -destination 'platform=macOS'— 7 new tests pass.simulcastLayers: [.presetH720_169, .presetH360_169]no longer emits a 30 fps / 1.7 Mbpshlayer.