Skip to content

Clamp simulcast layers#1084

Open
hiroshihorie wants to merge 7 commits into
mainfrom
hiroshi/clamp-simulcast-layers
Open

Clamp simulcast layers#1084
hiroshihorie wants to merge 7 commits into
mainfrom
hiroshi/clamp-simulcast-layers

Conversation

@hiroshihorie
Copy link
Copy Markdown
Member

@hiroshihorie hiroshihorie commented May 15, 2026

Summary

  • Port Swift SDK simulcast lower-layer clamping behavior to Flutter.
  • Clamp lower-layer max framerate so it does not exceed the configured top layer.
  • Clamp lower-layer bitrate only when the layer does not actually downscale resolution.
  • Use the larger output dimension when computing simulcast scale-down values.
  • Add coverage for clamp behavior, ladder length, unchanged presets, priority preservation, and computed encodings.

Testing

  • git diff --check main...HEAD
  • flutter test test/utils_test.dart
  • flutter analyze --no-pub lib/src/utils.dart test/utils_test.dart

Ports the four SimulcastPresetsTests cases that were missing from the
initial port: same-resolution full clamp, parameterized ladder length
over the < 480 / [480, 960) / >= 960 cutoffs, no-overshoot pass-through,
and priority forwarding through the clamp.
Mirrors the Swift guard let lowPreset = presets.first else { return
[baseParameters] } fallback. Unreachable from current call sites since
both default ladders return >= 1 entry, but keeps the function safe
against future callers passing an empty requestedPresets with a default
that could collapse to empty.
Use max/max (preset's larger dimension vs output's larger dimension) to
match the Swift Dimensions.encodings(from:) helper and the new
_clampSimulcastPreset's scaleDownBy calculation. Equivalent for
matching-aspect presets, only differs when a caller mixes a
non-matching-aspect preset with the output dimensions.
@hiroshihorie hiroshihorie changed the title Hiroshi/clamp simulcast layers Clamp simulcast layers May 18, 2026
@hiroshihorie hiroshihorie marked this pull request as ready for review May 19, 2026 10:49
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