Screen share 11: stream settings and encode parameters (#158) #228
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "screenshare-11-core-stream-params"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Stacked on: screenshare-10-core-go-live
What
Task 11 of the screen-share plan: stream settings and encode parameters in
fluxer-core(spec §3.3, §6.3 "Encode parameters", §10 stream settings menu, §11 settings).voice::stream::params:encode_params(&App, source_w, source_h, codec) -> EncodeParamsandcapture_target(&App) -> CaptureTarget, ported from the fork'sScreenShareOptions.ts. Covers presets as pixel budgets (aspect kept, even sides), effective fps 15/30/60, the mode presets with and without the entitlement, the free-tier clamp, the bitrate table and formula with ceiling scaling, the user bitrate (entitled only), the rung of a smaller source, the degradation rule, L1T3/L1T1 for AV1/VP9,EncoderBackendfromencoder_mode, and the software-H.264 720p30 clamp.stream_settings_model(&App)follows the fork'sStreamSettingsMenuContent/StreamSettingsMenuContentStateMachine: it gives the modes with their two-line descriptions per entitlement, the offered resolutions and frame rates, the premium badge, andQualityPick::{None, Premium, Write}.voice::stream::entitlement:entitlement(&App) -> QualityEntitlement { higher_quality, bitrate_ceiling, premium_exists }. It reads the discovery limits (feature_higher_video_quality> 0;max_screen_share_bitratefloored, fallback 9 000 000, clamped to 1–50 Mbit/s).premium_existsis the fork'sshouldShowPremiumFeatures.VideoSettingsgains the §11 fields:show_my_own_screen_share,pause_own_preview_on_unfocus,disable_pip_popout,content_hint,encoder_mode,scalability_mode,audio_source_mode, plus the include/exclude lists.VoiceSettingChangegains a variant for every screen-share field. Old settings files keep loading, and the retiredlow_240pbecomeslow_480p.golive.rs): the capture start usescapture_targetand the publication usesencode_params. While live,SetVoiceSettingemitsCaptureCommand::Updatewhen the target changed andUpdateScreenShareEncodingwhen the params changed. ACaptureEvent::Startedwith a new size updates the encoder.Tests
crates/fluxer-core/tests/stream_params.rshas 18 tests. They include all 13 the plan names (preset_dimensions_keep_aspect_and_even…old_settings_files_load) plus entitlement/ceiling, encoder backend, start, no-op-when-not-live and menu-model tests. There are also unit tests inparams.rs.FLUXER_SCREENSHOT_TESTS=1 cargo xtask ciis green locally. No capture or hardware tests apply to this task.Deviations / notes for review
CaptureEvent::Startedreports the size the capture delivers, which is already scaled into the target box. It is not the source size. A frame that fills the box on one side therefore keeps the preset's bitrate rung, and only a frame smaller than the box on both sides counts as a "smaller source". Without this, a 16:10 screen at 1080p would get the 720p bitrate.EncodeParamsdocuments even sides.session.rskeepslimitsandpremium_featuresfrom discovery. Nothing stored them before.app.rspasses the entitlement intoreduce_streams.Streams.codecs: Option<LocalCodecs>storesVoiceEvent::CodecCapabilities. It is taken inreduce_settings, logged in or not, and kept across logout. The software-H.264 clamp needs it, and Screen share 12 can reuse it.UserPrivatedoes not modeltraitsyet. Guild features come from the selected channel's guild, as inLimitContext.current(). P2P is never true, because this client never joins peer-to-peer.name=valueby U+001F). This avoids a change tofluxer-platform'sStoredValue.disable_stream_previews(privacy) is left to Screen share 13, which lists that switch. The codec is still provisional until Screen share 12.persist.rsneeded no change, becauseSetVoiceSettingis already saved.Closes #158
🤖 Generated with Claude Code
Independent review: Screen share 11 (stream settings and encode parameters)
Reviewed
git diff 32d0267ab..origin/screenshare-11-core-stream-params(one commit,f88c516) cold, against plan Task 11, spec §3.3/§6.3/§10/§11 and the fork (ScreenShareOptions.ts,VideoQualityEntitlement.ts,StreamSettingsMenuContent*.ts,PremiumUtils.ts,LimitConstants.ts).1. Tests the plan names
All 13 are in
crates/fluxer-core/tests/stream_params.rsand assert the spec values: presets 426×240 … 3840×2160, pixel budget with even sides; effective fps 15/30/60; Screen share 1080p30 / Gaming 1440p60, both 720p30 without the entitlement; free tier 480p/720p at 30 FPS or less; the full floor table (15/30/60) with 720p30 → 3 000 000, 1080p60 → 6 000 000 (floor above the formula), 4K60 formula cut at 9 000 000, ceiling scaling above 9 Mbit/s exactly as the fork'scomputeScreenShareBitrateBps; user bitrate only when entitled; smaller source takes a lower rung; degradation order (source rung / text-detail hint / < 500 000); L1T3/L1T1 for AV1/VP9 only; software H.264 held to 720p30; 240p → 480p; live change →CaptureCommand::UpdatethenUpdateScreenShareEncoding; old settings files load and the new fields round-trip. There are five more: ceiling clamp 1–50 Mbit/s with fallbacks, encoder backend, start uses the settings, no effects when not live, and the menu model.2. Interfaces
encode_params(&App, source_w, source_h, codec) -> EncodeParams,capture_target(&App) -> CaptureTarget,entitlement(&App) -> QualityEntitlement { higher_quality, bitrate_ceiling, premium_exists }(fromWellKnown.limitskept inSession::limits),stream_settings_model(&App), the §11VideoSettingsfields and theVoiceSettingChangevariants all exist and are re-exported fromvoice::stream/voice.EncodeParamsfollows the mergedport.rs(nocodec_preference), as it should. Nothing that Tasks 12, 13, 25 or 28 consume is broken.Streams::codecs(LocalCodecs) is a reasonable place for Task 12 to read the capabilities from.3. Invariants
fluxer-coregains no dependency (Cargo.toml unchanged) and sees no pixels. Server data cannot panic it: limit values are filtered (non-finite or negative values take the fallback), floored and clamped before the cast;fit_to_presetuses u128/isqrt and saturating adds (tested with 0×0, 1×1 and u32::MAX). There are no secrets, and the fixtures use the existingexample.comlogin. The stored source lists (U+001E/U+001F) go through TOML strings with escapes; unreadable entries are dropped.4. Review Focus
None of the seven items belongs to Task 11.
Findings (all minor, none blocking)
max_width × max_height), while the fork scales to the preset's pixel budget with the aspect ratio kept. A non-16:9 source therefore comes out smaller than in the original. Under 1080p, a 3440×1440 ultrawide is sent at about 1920×804 (fork: 2224×930), and a tall 800×2000 window at about 432×1080 (fork: 800×2000, within budget). Worth a follow-up issue: the capture box could be derived fromfit_to_presetonce the source size is known, or the target could become a pixel budget.fills_boxheuristic lifts any frame that touches the box on one side to the preset's rung. A thin 1920×200 window under 1080p30 gets 4 500 000 bit/s, where the fork (240p rung) gives 500 000. That is acceptable given that the capture reports scaled frames, but it is a divergence and should be listed under spec §14.refresh_sharesendsCaptureCommand::Updateonly when the target changes. ChangingAudioSourceMode, the include/exclude lists or the app/desktop audio switches while live therefore never reaches the capture, even thoughUpdatecarriesaudio. Either sendUpdatewhen the audio rule changes too, or document that audio changes apply from the next share.LimitContext.current()), and is re-applied to a running share only on a settings change. If the user navigates to another guild with different limit rules while live,encode_params(&app, …)/capture_target(&app)change without the share being updated. Low impact; consider resolving it for the voice connection's guild while a share runs.stream_settings_modelcomputes its selected values without the software-H.264 clamp. The fork's menu readstarget, which includes the clamp, so with a software-only H.264 share the menu shows 1080p/60 selected while 720p30 is sent. This is cosmetic until Task 12 picks H.264.persist.rsis in the plan's Files list but was not touched. That is fine, becauseSetVoiceSettingalready persistsvoice_settingsand the platform stores names generically. The commit trailer is Opus 5.5 rather than the CLAUDE.md line, which is consistent with Task 10.5. CI
FLUXER_SCREENSHOT_TESTS=1 cargo xtask ciin a fresh review worktree: green ("all steps passed"; the stream_params suite ran 18/18; livekit-interop skipped without FLUXER_LIVEKIT_TESTS, as usual).Verdict: approve. No blocking findings and CI is green; the minor items can become follow-up issues.