3.4 KiB
3.4 KiB
T5.2 — VideoQualityController with per-mode allocation gates
Status: Approved
Agent: Kimi Code CLI
Started: 2026-05-12T17:25Z
Completed: 2026-05-12T18:00Z
Commit: 2e0bdc5
PRD: ../PRD-video-quality-priority.md
What I changed
crates/wzp-video/Cargo.toml:12— Addedwzp-protodependency so the controller can useBandwidthEstimatorandPriorityMode.crates/wzp-video/src/controller.rs— New file.VideoQualityControllerwith:VideoTargetstruct:{ bitrate_kbps, fps, width, height }allocate()— per-mode budget split:AudioFirst(24 kbps floor),VideoFirst(video floor first),ScreenShare(16 kbps audio clamp),Balanced(15/85 split)derive_target()— static step table mapping budget → resolution/fps (8 steps from 1280×720@30 down to 240×180@5)smooth()— clamps bitrate changes to 2× per secondtick(now_ms)— allocates, derives, smooths, returns targetset_mode()/update_network()— thread-safe atomic settersset_target()default no-op added toVideoEncodertrait
crates/wzp-video/src/encoder.rs:43-46— Addedset_target(&mut self, _target: &VideoTarget)default method toVideoEncodertrait.crates/wzp-video/src/lib.rs:9-17— Addedpub mod controller;and re-exportedVideoQualityController,VideoTarget.- Tests: 8 new tests covering all 4 allocation modes, step table, smoothing, and mode roundtrip.
Deviations from the task spec
Skeleton task. Followed PRD-video-quality-priority.md sections "Allocation gates" and "VideoQualityController". The PRD pseudocode shows encoder.set_target(target) inside tick(); the actual implementation returns VideoTarget from tick() and provides set_target() on the encoder trait so callers apply it. This keeps the controller testable without a real encoder.
Verification output
$ cargo test -p wzp-video --lib
test result: ok. 40 passed; 0 failed; 0 ignored
$ cargo build -p wzp-video -p wzp-proto -p wzp-relay -p wzp-client -p wzp-android -p wzp-codec -p wzp-desktop
# Finished successfully (59.82s)
$ cargo fmt --all -- --check
# pass
Test summary
- Tests added: 8 (
audio_first_reserves_floor,audio_first_floor_not_below_bwe,screen_share_clamps_audio,balanced_split,derive_target_disabled_below_floor,derive_target_lowest_step,derive_target_highest_step,smoothing_limits_jump,mode_roundtrip) - Tests modified: 0
cargo clippy -p wzp-video --all-targets -- -D warnings: passcargo fmt --all -- --check: pass
Risks / follow-ups
VideoEncoder::set_target()is a no-op default — Platform encoders (VideoToolbox, MediaCodec) need to override this to actually reconfigure bitrate/resolution/fps.- Step table is H.264-only — When H.265/AV1 land (T5.4+), the step table may need different thresholds per codec.
- ScreenShare slide fallback not yet implemented — T5.3 will add
EncoderMode::SlideFallbacktriggered when video budget < 150 kbps. - Controller not yet wired into call engine —
SetPriorityModesignal (T5.1) andVideoQualityController::tick()need to be plumbed intowzp-client/src/call.rsand the Android/desktop engines.
Reviewer checklist (filled in by reviewer)
- Code matches PRD intent
- Verification output is real
- No backward-incompat surprises
- Tests cover the new behavior
- Approved