src.nth.io/

summaryrefslogtreecommitdiff
path: root/main/state_machine.h
diff options
context:
space:
mode:
authorLuke Hoersten <[email protected]>2026-06-19 19:40:00 -0500
committerLuke Hoersten <[email protected]>2026-06-19 19:40:00 -0500
commitbccf0fa25e59f4fa9df9d0b3a129aeb369f17a87 (patch)
tree8a9e937860f50f87275d6306a99c8025fdbc8328 /main/state_machine.h
parent30a317dcb6dd40d2eca64aa09fdbe9031c37996f (diff)
scrypted: HTTP keep-alive via node:http Agent + bump JPEG quality 2→1
Two changes in one commit because the keep-alive refactor reshapes the fetch surface and the quality bump piggybacks naturally on it. #1 — Keep-alive ScryptedViewportProvider now uses node:http (always available, no require sandbox dance like undici) with a per-host Agent: keepAlive: true, keepAliveMsecs: 30s, maxSockets: 2. Pool size 2 matches the firmware's two-socket pipelining capacity so frame N+1 can begin uploading on socket B while frame N is still being decoded on socket A. Reusing the socket skips the SYN+SYN-ACK+ ACK round-trip on every POST — on a quiet LAN that's ~1ms saved per frame, and far more on the p95 tail where TCP slow-start was driving 26-35ms net_up spikes in the measured data. httpRequest() wraps http.request to expose tHeaders + tDone (so we keep the existing per-stage script-side timing intact) and returns { status, headers, tHeaders, tDone }. Both pushStreamFrame and postJSON migrated. The remaining fetch() calls (GET /state, GET /config from the UI, and the one-shot snapshot POST) are non-hot paths — left as fetch for now. #2 — JPEG quality ffmpeg -q:v 2 was the de facto "visually lossless" setting in earlier notes; bumping to -q:v 1 squeezes one more notch of quality out of the mjpeg encoder. JPEG size grows ~10-15%; with NODELAY landed and fw_recv at ~22ms for 128KB we have plenty of headroom for the bigger bodies. Applied to both the live-stream encoder and the one-shot snapshot encoder.
Diffstat (limited to 'main/state_machine.h')
0 files changed, 0 insertions, 0 deletions