feat(srt): add SRT statistics for inputs and outputs - #564
Merged
Conversation
Adds on-demand SRT statistics for all four SRT block types
(efpsrt_input/output, mpegtssrt_input/output). Backend scans the
pipeline for srtsrc/srtsink elements, reads their libsrt stats
GstStructure (handling caller-mode top-level, listener-mode
GValueArray, and gst::Array variants across plugin versions), and
exposes them via GET /api/flows/{id}/srt-stats.
API design:
- SrtStats keyed by element name (`{block_id}:srtsink`)
- SrtConnectionStats with typed SrtRole / SrtMode enums
- SrtCallerStats splits sender vs receiver counters
(packets_sent_lost / packets_received_lost, etc.) so the
semantics of each counter is unambiguous
- Peer address parsed from GInetSocketAddress, formatted as ip:port
Frontend mirrors the WebRTC stats pattern:
- SrtStatsStore polls every 1s while the selected flow is running
and the flow has at least one SRT block
- Compact inline view in the graph node: peer count, RTT, recent
loss %
- Detailed property-inspector view with per-caller sections,
separating NAK'd-then-retransmitted (recovered, green) from
TLPKTDROP / TSBPD (actual data loss, red)
- Per-second deltas computed against the previous poll so loss /
packet / byte counters show both lifetime totals and current
rate ("134k (450/s)") — keeps the figures meaningful on
long-running streams
Tested with caller-mode receivers, listener-mode senders with
multiple peers, and unit tests covering the parser fixtures.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Code review follow-ups: - Promote `gio` from a backend-only direct dep to the workspace dep table so it stays version-aligned with the gstreamer/glib 0.22 pins. Backend now references `gio.workspace = true`. - Add unit tests for `caller_is_active` and `has_any_data` — both back the `connected` flag and the single-caller fall-through in `collect_element_stats`, so they deserve explicit coverage. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Adds on-demand SRT statistics for all four SRT block types (
efpsrt_input,efpsrt_output,mpegtssrt_input,mpegtssrt_output), mirroring the existing WebRTC stats pattern.srtsrc/srtsinkelements and reads their libsrtstatsGstStructure. Handles caller-mode top-level, listener-modeGValueArray, andgst::Array/gst::Listvariants across gst-plugins-bad versions. Exposed viaGET /api/flows/{id}/srt-stats.SrtRole/SrtModeenums and splits sender vs receiver counters (packets_sent_lost/packets_received_lostetc.) so the semantics of each counter is unambiguous. Peer address parsed fromGInetSocketAddressand formatted asip:port.134k (450/s)), keeping the figures meaningful on long-running streams. Recent-interval loss fraction drives both the compact loss reading and a per-caller "Recent loss" row.connected-flag heuristics).Test plan
cargo checkpasses on backend + frontend (native + WASM)cargo test --lib pipeline::srt— 8/8 passcargo test --test openapi_test— snapshot updated and cleanRetransmitted: 678 (100% recovered)) rather than red, while TLPKTDROP would display red🤖 Generated with Claude Code