mirror of
https://github.com/games-on-whales/wolf.git
synced 2026-10-15 21:12:08 +00:00
[PR #368] [MERGED] fix: add VBV buffer constraints and improve UDP streaming #427
Labels
No labels
🧠 1 - 🤖 999
AMD
bug
bug
cannot reproduce
documentation
duplicate
easy
enhancement
enhancement
enhancement
fixed?
fixed?
good first issue
hard
help wanted
Intel
invalid
LXC
medium
moonlight-protocol
Multi GPU
nixos
not a bug
nvidia
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
games-on-whales/wolf#427
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/games-on-whales/wolf/pull/368
Author: @Baz00k
Created: 3/13/2026
Status: ✅ Merged
Merged: 4/9/2026
Merged by: @ABeltramo
Base:
stable← Head:fix/streaming-improvements📝 Commits (10+)
68fc791feat: implement Apollo-style batched UDP send for video streaming9f80199feat: add packet pacing to prevent client buffer overflow0bf85cbfix: add VBV buffer constraints to prevent frame size spikes0157c58refactor: move batched_send to src/core platform abstraction layerac5d357fix: add config v7 with VBV encoder constraints and revert v3-v6c0fc08aCommitting clang-format changesed2b0aachore: add comments explaining values9f373b6feat: add env config for pacing5dacc0bfeat: add migration to v7 config91ed52frefactor: consolidate config migrations📊 Changes
15 files changed (+1170 additions, -79 deletions)
View changed files
📝
src/core/CMakeLists.txt(+2 -0)➕
src/core/src/core/batched_send.hpp(+104 -0)➕
src/core/src/platforms/linux/batched_send/batched_send.cpp(+233 -0)➕
src/core/src/platforms/unknown/batched_send.cpp(+19 -0)📝
src/moonlight-server/CMakeLists.txt(+1 -1)📝
src/moonlight-server/gst-plugin/gstrtpmoonlightpay_video.cpp(+2 -2)📝
src/moonlight-server/rtsp/commands.hpp(+4 -2)📝
src/moonlight-server/state/configTOML.cpp(+20 -16)📝
src/moonlight-server/state/default/config.include.toml(+15 -12)➕
src/moonlight-server/state/default/config.v7.toml(+562 -0)📝
src/moonlight-server/state/serialised_config.hpp(+1 -1)📝
src/moonlight-server/streaming/streaming.cpp(+160 -43)📝
tests/CMakeLists.txt(+2 -1)📝
tests/assets/config.test.toml(+1 -1)➕
tests/testBatchedSend.cpp(+44 -0)📄 Description
Summary
Fix streaming instability on clients with limited receive buffers (e.g. Moonlight-TV on embedded devices) and Wolf ignoring client bitrate settings.
Changes in this PR allowed me to go from unstable 12mbit stream with significant packet loss to full, stable 35mbit on my TV. This should also stabilize streaming over Wi-Fi.
Root cause: Missing VBV (Video Buffering Verifier) buffer constraints on all hardware encoder pipelines. Without VBV, CBR mode allows individual frames — especially IDR frames and complex game scenes — to spike 2-5x the per-frame bitrate budget, overwhelming client receive buffers.
Most of this code is just reimplementation of what alredy exists in Sunshine/Apollo.
Changes
1. Apollo-style batched UDP send
async_send_to()calls with synchronous batched sends usingsendmmsg()batched_send.hpp/cpp) with Linux implementation2. Packet pacing
3. VBV buffer constraints for all encoders
vbv-buffer-sizeto allnvh265enc,nvh264enc,nvav1encpipelines (config v3-v6 + include)rate-controlfromcqp(Constant QP — ignores bitrate entirely) tocbr, and fixcpb-sizefrom{bitrate}(1-second buffer) to single-frame bufferbitrate_kbps / refreshRate(one frame's worth), matching Sunshine/Apollo's approachRelated issues
Fixes #332
Testing
Tested on Moonlight-TV at 35 Mbps AV1 with stable streaming (previously broke above 12 Mbps).
Streaming still works on original Moonlight and Artemis clients (tested on S23 Ultra and M1 Mac).
Files Changed
streaming/streaming.cpp— Batched send, pacing, VBV format argplatform/batched_send.{hpp,cpp}— New batched send abstractionplatform/linux/batched_send.cpp— Linux sendmmsg implementationgstrtpmoonlightpay_video.cpp,rtsp/commands.hpp— Packet sizeconfig.include.toml,config.v3-v6.toml— Encoder pipeline fixes🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.