Contributing
Thanks for helping out! Here’s how the project is laid out and how to check your work before you send it.
The layout
Section titled “The layout”| Folder | What’s in it |
|---|---|
crates/nyquist |
The server: ingest, sources and failover, playback, viewer sessions, the REST API, the panel and /metrics. |
crates/nyquist-config |
The nyquist.toml model, its defaults and checks, the settings catalog and edits that keep comments. |
crates/nyquist-core |
Streams, publishers and the stream registry. |
crates/nyquist-rtmp, crates/nyquist-srt |
The RTMP server and client, and the SRT bindings. |
crates/nyquist-mpegts, crates/nyquist-packager, crates/nyquist-codec |
MPEG-TS, HLS, DASH and CMAF packaging, and codec parsing. |
web |
The admin panel, a Svelte app that gets baked into the binary. |
docs |
This website, built with Starlight. |
assets |
The logo and the wordmark. |
Checks
Section titled “Checks”These all have to pass:
cargo fmt --all --checkcargo clippy --workspace --all-targets --locked -- -D warningscargo test --workspace --lockedThe panel and the docs have their own:
cd web && npm ci && npm run check && npm test && npm run build && cd ..cd docs && npm ci && npm run build && cd ..Commits follow Conventional Commits, one line each, like feat(config): add a setting for the thing or docs: explain the thing.
The panel
Section titled “The panel”The panel is a Svelte app in web/. Run npm run dev in there while Nyquist runs and it proxies the API for you. It looks for Nyquist at http://127.0.0.1:8080, so if yours listens somewhere else, point it there with NYQUIST_URL:
NYQUIST_URL=http://127.0.0.1:9090 npm run devThe test pattern
Section titled “The test pattern”fake:// replays crates/nyquist/assets/test-pattern.ts, a loop of 64 frames at 30 fps, 2.13 seconds, which is exactly 100 AAC frames at 48 kHz. It starts on a keyframe and has no B frames, so Nyquist can play it over and over with timestamps that keep counting up. It’s the second half of a two loop encode, which keeps the audio encoder warmed up and the loop seamless, and the tone is 1003.125 Hz so it fits the loop a whole number of times. To make a new one:
ffmpeg -f lavfi -i "testsrc2=size=1280x720:rate=30" -f lavfi -i "sine=frequency=1003.125:sample_rate=48000" \ -t 4.2666667 -c:v libx264 -preset veryslow -profile:v main -pix_fmt yuv420p -bf 0 -g 32 -keyint_min 32 \ -sc_threshold 0 -b:v 700k -maxrate 1000k -bufsize 1400k -c:a aac -b:a 96k -ac 2 -f mpegts two_loops.tsffmpeg -ss 2.1333333 -i two_loops.ts -c copy -f mpegts crates/nyquist/assets/test-pattern.tsThese docs
Section titled “These docs”The docs are a Starlight site in docs/. The pages are Markdown files in docs/src/content/docs, with guides in guides/ and reference pages in reference/. The sidebar lives in docs/astro.config.mjs.
cd docsnpm cinpm run devThat serves the site at http://localhost:4321 and reloads as you type. npm run build makes the static site in docs/dist, the same way the docs host does. The Node version the build needs is in docs/.node-version.
Adding a setting
Section titled “Adding a setting”Every setting has exactly one default, in the Default impl of its section in crates/nyquist-config. To add one:
- Add the field and its default, and check its value in the section’s
validate. - Describe it in the settings catalog,
crates/nyquist-config/src/catalog/entries.rs: a label, a one sentence help text, its kind and limits (use the same constants the check uses), whether it applies live or after a restart, and whether it’s an advanced knob. - Regenerate the config reference (see below) and commit it.
The catalog tests fail until every setting has an entry, every entry points at a real setting and every limit matches what the check accepts, so you can’t forget a step.
The config reference
Section titled “The config reference”The config reference is generated from the settings catalog, so it always matches the code. A test fails when the committed page is out of date. To write it again:
NYQUIST_WRITE_DOCS=1 cargo test -p nyquist-config --test referenceThen commit docs/src/content/docs/reference/config.md along with your change.