feat(stream): export per-session FEC metrics to CSV#5094
Draft
cesarpmorais wants to merge 6 commits into
Draft
Conversation
|
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.



Description
Adds an opt-in mechanism to export per-session network metrics to CSV. When
metrics_pathis configured, Sunshine writes one CSV row perSS_FRAME_FEC_STATUS(0x5502) message received from the client, capturing FEC packet counts, missing-packet counts, and accumulated IDR requests.Context
This is the first of two PRs working toward server-side adaptive bitrate for Sunshine. The current behavior — fixed bitrate negotiated once at RTSP handshake — has no feedback loop when network conditions degrade mid-session. The client-side "slow connection" toast in Moonlight is informational only; it doesn't trigger any server response.
To build a server-side controller, the server first needs observable signal about what the client is experiencing. This PR fills that gap by surfacing the existing
SS_FRAME_FEC_STATUSstream (currently dropped by Sunshine) as a CSV-exportable feed. A follow-up PR will propose a controller that consumes this signal to adjust bitrate dynamically.Motivation
Sunshine receives
SS_FRAME_FEC_STATUSfrom Moonlight clients but silently drops it today — the packet type has no registered handler and the message hits thetype [Unknown]branch instream.cpp. This is the richest per-frame loss signal in the protocol; exposing it gives operators and developers a concrete view of network conditions experienced by the client, regardless of whether they care about adaptive bitrate.Changes
metrics_path(string, default empty = disabled)SS_FRAME_FEC_PTYPE(0x5502) incontrolBroadcastThreadSS_FRAME_FEC_STATUSstd::ofstream— no file is created until the first event arrivesIDR_FRAMEhandler increments a counter that is flushed on each rowdocs/configuration.mdBehavior
SS_FRAME_FEC_STATUSwhen there is FEC recovery activity or a frame drop (seemoonlight-common-c/src/RtpVideoQueue.c:reportFinalFrameFecStatus). A lossless LAN session produces an emptymetrics_pathdirectory.sunshine_metrics_<session_id>_<unix_ms>.csvper session, one row per FEC event with the schema documented indocs/configuration.md.Test plan
MetricsCsvTests.*— 5 tests)tc netem loss 5%on the server interface produced 155 events. Loss patterns correlate with IDR clusters; FEC field values match the wire format spec.Screenshot
N/A (no UI changes)
Issues Fixed or Closed
N/A
Roadmap Issues
N/A
Type of Change
Checklist
AI Usage