3.2 KiB
3.2 KiB
T5.5 — 3-layer simulcast at sender
Status: Pending Review
Agent: Kimi Code CLI
Started: 2026-05-12T18:15Z
Completed: 2026-05-12T18:45Z
Commit: 2f1a9f7
PRD: ../PRD-video-simulcast.md
What I changed
crates/wzp-video/src/simulcast.rs— New file.SimulcastEncoder<E: VideoEncoder>driving three layers:LayerConfig { stream_id, width, height, target_bitrate_kbps, target_fps }SimulcastLayer { config, encoder, active }encode()producesVec<LayerPacket>with per-layer payloadsrequest_keyframe()propagates to all active layersset_layer_mask()enables/disables layers dynamically
crates/wzp-video/src/controller.rs:150-220— Addedtick_simulcast(now_ms) -> Vec<LayerTarget>:- Low layer: 150 kbps, 320×180 @ 15 fps
- Mid layer: 600 kbps, 640×360 @ 24 fps
- High layer: 2500 kbps, 1280×720 @ 30 fps
- Drops layers when BWE is insufficient
crates/wzp-video/src/lib.rs— Re-exportedSimulcastEncoder,SimulcastLayer,LayerTarget,LayerPacket.
Why these choices
Three layers is the WebRTC default (low/mid/high). Budget allocation is hard-coded rather than configurable because the PRD specifies a v1 table; future work can make it dynamic. The stream_id field in LayerConfig maps directly to RTP stream IDs so the SFU can filter by layer without parsing codec headers.
Deviations from the task spec
None.
Verification output
$ cargo test -p wzp-video -- simulcast
Compiling wzp-video v0.1.0
Finished `test` profile [unoptimized + debuginfo] target(s) in 2.29s
Running unittests src/lib.rs (target/debug/deps/wzp_video-...)
running 10 tests
test simulcast::tests::simulcast_all_layers_ordered ... ok
test simulcast::tests::simulcast_layer_total_bitrate ... ok
test simulcast::tests::simulcast_encoder_creates_three_layers ... ok
test simulcast::tests::simulcast_encode_produces_three_packets ... ok
test simulcast::tests::simulcast_request_keyframe_propagates ... ok
test simulcast::tests::simulcast_layer_mask_disables_layers ... ok
test controller::tests::simulcast_all_layers_at_4mbps ... ok
test controller::tests::simulcast_low_mid_only_at_1mbps ... ok
test controller::tests::simulcast_low_only_at_200kbps ... ok
test controller::tests::simulcast_no_video_at_20kbps ... ok
test result: ok. 10 passed; 0 failed; 0 ignored; 0 measured; 51 filtered out
$ cargo fmt --all -- --check
# pass
$ cargo clippy -p wzp-video --all-targets -- -D warnings
# pass
Test summary
- Tests added: 10
- Tests modified: 0
- Workspace test count before: 61 / after: 71 (wzp-video)
cargo clippy -p wzp-video --all-targets -- -D warnings: passcargo fmt --all -- --check: pass
Risks / follow-ups
- Simulcast does not yet wire into Android/Desktop engines — The encoder exists but no caller creates a
SimulcastEncoderat runtime. Integration is T6.x scope. - Layer targets are static — BWE changes only enable/disable layers; resolution/fps within a layer are fixed. Future work: adaptive per-layer quality.
Reviewer checklist (filled in by reviewer)
- Code matches PRD intent
- Verification output is real (re-run if suspicious)
- No backward-incompat surprises
- Tests cover the new behavior
- Approved