Runtime bitrate endpoint + ABR capability negotiation (Foundation/Moonlight V+ compatible)#273
Open
AsafMah wants to merge 1 commit into
Open
Runtime bitrate endpoint + ABR capability negotiation (Foundation/Moonlight V+ compatible)#273AsafMah wants to merge 1 commit into
AsafMah wants to merge 1 commit into
Conversation
Lets Foundation/Moonlight V+ clients change the encoder bitrate mid-stream
without reconnecting.
Endpoints (HTTPS, paired client, View permission):
- GET /bitrate?bitrate=<kbps> apply a new encoder bitrate to the caller's
active session. Clamped to config max_bitrate and an absolute 500 Mbps ceiling.
Returns <root status_code=200><bitrate>N</bitrate></root> (0 = failure), the
shape V+ NvHTTP.setBitrate() parses (and verifyResponseStatus requires the
status_code attribute).
- GET /api/abr/capabilities reports {supported:false,...}; verified against
AdaptiveBitrateService.kt this makes V+ run its local ABR controller, which
drives the host via /bitrate. Server-side ABR decisioning (/api/abr,
/feedback) is intentionally out of scope.
Apply path: a per-session mail event (dynamic_bitrate), coalesced to the latest
value on the encode thread. NVENC reconfigures the live encoder via
nvEncReconfigureEncoder (no hitch; ported from foundation-sunshine, adapted to
Vibepollo's runtime-versioned NVENC structs). avcodec encoders (AMD/Intel/
software) report set_bitrate()==false and fall back to an encode-session rebuild
via the existing reinit path -- correct, but produces a brief hitch per change.
Not yet compiled (needs the MSYS2/MinGW toolchain); review/runtime test pending.
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.
Implements #272 — runtime (mid-stream) bitrate changes so Foundation / Moonlight V+ clients can adjust encoder bitrate without reconnecting.
Endpoints (HTTPS, paired client, View permission)
GET /bitrate?bitrate=<kbps>— apply a new encoder bitrate to the caller's active session. Clamped tomax_bitrateand an absolute 500 Mbps ceiling. Returns<root status_code=200><bitrate>N</bitrate></root>(0= failure) — the exact shapeNvHTTP.setBitrate()parses (and itsverifyResponseStatusrequires thestatus_codeattribute).GET /api/abr/capabilities— returns{"supported":false,"version":1,"features":["runtime_bitrate"]}. Verified againstAdaptiveBitrateService.kt:supported:falsemakes V+ run its local ABR controller, which drives the host through/bitrate. So both the manual slider and adaptive mode work. Server-side ABR decisioning (POST /api/abr,/feedback) is intentionally out of scope.Apply mechanism
A per-session mail event (
dynamic_bitrate), coalesced to the latest value on the encode thread:nvEncReconfigureEncoderusing saved init params (ported from foundation-sunshine, adapted to Vibepollo's runtime-versioned NVENC structs /api::reconfigure_params_version). Seamless, no hitch.set_bitrate()==falseand fall back to an encode-session rebuild via the existing reinit path. Correct, but a brief hitch per change. Backend-native AMF/QSV reconfigure is a possible follow-up (mirrors foundation staging NVENC first, AMF later).Clamping/overflow: rejects
<=0, clamps tomax_bitrate(when set) and an absolute ceiling;set_bitrate()also rejects>800000 kbpssokbps*1000cannot overflow the 32-bit rate-control fields.Files
globals.h(event),stream.{h,cpp}(set_bitrate_for_sessions, per-session event),video.{h,cpp}(encode_session_t::set_bitrate, NVENC override, both encode paths),nvenc/nvenc_base.{h,cpp}(set_bitratelive reconfigure),nvhttp.cpp(routes).Verification
ninja sunshine→sunshine.exelinks cleanly (no undefined symbols from the new functions). NVENC reconfigure struct fields/version confirmed against the bundledffnvcodec/nvEncodeAPI.h.NvHTTP/AdaptiveBitrateServicesource.Client reference:
qiin2333/moonlight-vplus(NvHTTP.setBitrate,getAbrCapabilities,AdaptiveBitrateService). Server reference:AlkaidLab/foundation-sunshine(#193/bitrate+ NVENC reconfigure, #571/api/abr/*, ClassicOldSong#690max_bitrateclamp).