feat(liveion): source quality tiers and manual bitrate switching - #437
Open
a-wing wants to merge 1 commit into
Open
feat(liveion): source quality tiers and manual bitrate switching#437a-wing wants to merge 1 commit into
a-wing wants to merge 1 commit into
Conversation
Build on the AIMD adaptive-bitrate loop (issue #409): - livehal: implement runtime setBitrate for the v4l2-m2m encoder via VIDIOC_S_CTRL V4L2_CID_MPEG_VIDEO_BITRATE (rkmpp already had it) - config: named quality tiers at source level ([[stream.<name>.sources.tiers]], bitrate-only presets; reserved width/height/fps fields are rejected until the encoder rebuild path lands). The AIMD floor defaults to the lowest tier when tiers are declared; explicit min_bitrate still wins - api: GET/POST/DELETE /api/sources/{stream}/bitrate — query the drive mode (adaptive/manual/fixed), switch by raw bitrate or tier name, clear the override. A per-stream BitrateControl (now created for every native source) suspends the AIMD controller on manual sets - webui: per-stream Bitrate dialog with tier buttons, raw bps input and resume/clear actions Docs (EN/ZH), conf example and tests updated.
Codecov Report❌ Patch coverage is
... and 3 files with indirect coverage changes 🚀 New features to boost your workflow:
|
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.
Background
Main already has the network-driven adaptive bitrate loop (issue #409): WHEP subscriber RTCP feedback (TWCC / RR loss) is sampled per subscriber, and a per-stream AIMD controller retunes the shared hardware encoder through
StreamSource::set_bitrate→ livehalEncoderBackend::setBitrate. Until now only therkmppbackend implemented runtime retuning, and there was no way to drive the encoder bitrate by hand.What this PR adds
livehal: v4l2-m2m runtime retune
V4l2M2mEncoder::setBitrate()—VIDIOC_S_CTRL / V4L2_CID_MPEG_VIDEO_BITRATEon the running device, joining rkmpp. RDK X5 stays unsupported (needs on-device verification).Config: named quality tiers at source level
capture/encoder(not inside the encoder block) because a quality tier spans both:bitrateretunes the encoder, while resolution/framerate tiers would also reconfigure the capture (livehal has no scaler stage). Reserved per-tierwidth/height/fpsfields exist in the schema but are rejected by validation until the encoder-rebuild path lands — today tiers are bitrate-only presets, validated unique, non-zero, and ≤encoder.bitrate.min_bitratestill wins). Old configs are unaffected.API:
/api/sources/{stream}/bitrateGET— drive mode (adaptive/manual/fixed), current bitrate, active override and tier match, configured tiers.POST—{ "tier": "mid" }or{ "bitrate": 1500000 }(exactly one; 400 on both/neither/unknown tier, 404 without a source, 409 when the backend cannot retune).DELETE— clears the manual override; the AIMD controller resumes from the held value, fixed sources just drop the marker.BitrateControlis now created for every native source (not only adaptive ones) so manual/auto coordination and state reporting behave uniformly.WebUI
/api/sources).Test plan
cargo fmt --all -- --checkcargo clippy --all-targets --features source-all,webui,net4mqtt,recorder,cascade,whepwright,rtsp,target-whip,native-source,capture-v4l2,encoder-v4l2-m2m -- -D warningscargo test -p liveion ... --lib— 216 passed (11 new: tier validation, TOML tiers roundtrip, tier resolution, bitrate-info modes)cargo test --features source --test tests— incl. extended bitrate-API smoke test (400/404 paths)pnpm run lint,pnpm run typecheck,pnpm -r build