streamd: preview quality picker, dashboard polish, C4 wrap keys
All checks were successful
release / build-and-upload (push) Successful in 6m18s
modules-release / build-and-upload (push) Successful in 5m18s

- Preview player can select FHD/HD/SD (or ABR master) from publish links
- Embed dashboard screenshots in README; Linux streamd+agent setup guide
- C4 Widevine wrap license mode + require --wvd; prefer Widevine PSSH
- Channel 4 and My5 modules; streamd auth, variants, schedules, HLS gate
This commit is contained in:
404errordeveloper 2026-10-09 20:57:43 +02:00
parent b3955bd81e
commit 066e018749
113 changed files with 19002 additions and 1541 deletions

View file

@ -7,61 +7,67 @@ single binary as `drm serve`.
apps/streamd/
servecmd/ the command body, imported by apps/cli
internal/api HTTP handlers
internal/auth sessions, API keys, roles
internal/db SQLite store
internal/ui dashboard (index.html, app.js, app.css)
internal/ui dashboard
internal/supervisor downloader + ffmpeg supervision
internal/ws agent heartbeat
internal/ws agent + dashboard websockets
```
## Run
```bash
./bin/drm serve --bind 127.0.0.1:8083 --data .cache/streamd --token SECRET
./bin/drm serve --bind 127.0.0.1:8083 --data .cache/streamd
```
Port 8083 by default, to stay clear of anything already on 8080/8081. On start,
missing media tools are downloaded into `bin/` (ffmpeg, N_m3u8DL-RE, mp4decrypt)
unless you pass `--skip-deps`. Flags / env still win when set.
`--bind` defaults to **`127.0.0.1:8083`** (loopback). Binding `0.0.0.0` (or any
non-loopback address) logs a startup warning — put TLS in front, or keep loopback
and reverse-proxy. Port 8083 stays clear of anything already on 8080/8081.
Open `http://HOST:8083/` and put the token in the header box for mutating actions.
Add a stream with an `.mpd` URL; Widevine keys are optional for clear content.
Optional per-stream SOCKS5/HTTP `proxy` routes origin fetches (geo egress).
On start, missing media tools are downloaded into `bin/` (ffmpeg, N_m3u8DL-RE,
mp4decrypt) unless you pass `--skip-deps`.
## API
### Auth
The old shared bearer token is optional and discouraged. Prefer:
1. First-run setup creates an **admin** account (or `--admin-user` / `--admin-pass`).
2. Sign in at the dashboard (session cookie + CSRF).
3. Create **API keys** (Settings → API keys) for agents and scripts — roles
`admin` / `operator` / `viewer`.
Legacy `--token` / `STREAMD_TOKEN` still works as an admin API key and logs a
warning so you can migrate.
`GET /api/health` stays readable without a principal (liveness only). Stream list,
credentials, and mutations need a session or API key.
## API (short)
| Method | Path | Notes |
|---|---|---|
| GET | `/api/health` | liveness + uptime |
| GET | `/api/apps` | modules/<name>/ providers, channels, registered rewriters |
| GET | `/api/streams` | list + runtime (the agent polls this) |
| POST | `/api/streams` | create |
| GET | `/api/health` | liveness (+ deps when authenticated) |
| GET | `/api/apps` | modules, channels, rewriters |
| GET | `/api/streams` | list + runtime (agent polls this) |
| POST | `/api/streams` | create (`enabled` defaults false unless set; use the form checkbox) |
| GET/PATCH/DELETE | `/api/streams/:id` | detail / edit / delete |
| POST | `/api/streams/:id/start\|stop\|restart` | desired state |
| POST | `/api/streams/:id/credentials` | `{mpd,key?,pssh?,auth?,pid?}` — key optional; restarts if enabled |
| POST | `/api/streams/:id/claim` | agent lease (`agent_id`, TTL ~3m) |
| POST | `/api/streams/:id/claim/release` | release lease |
| POST | `/api/streams/:id/capture` | ask connected agents to refresh credentials now |
| POST | `/api/streams/:id/credentials` | `{mpd,key?,…}` — restarts if enabled |
| POST | `/api/streams/:id/claim` | agent lease |
Mutating routes need `Authorization: Bearer TOKEN` (or `X-Streamd-Token`, or
`?token=`). HLS output is served from `--data/www` at `/hls/<name>/index.m3u8`.
HLS output is served from `--data/www` at `/hls/<name>/index.m3u8`.
Installation-wide settings (`idle_timeout_s`, `default_on_demand`,
`default_outputs`, packager knobs) apply when creating a stream that omits those
fields, or at the next media start for packager knobs.
## No provider knowledge
The schema has no provider defaults, and the dashboard's app/channel pickers come
from `/api/apps`. Per-stream downloader settings resolve at start time:
App/channel pickers come from `/api/apps`. Downloader settings resolve at start:
```text
stored row -> the stream's app module (app.StreamDefaults) -> neutral defaults
stored row -> app module (StreamDefaults) -> installation settings -> neutral defaults
```
The manifest rewriter is a registry lookup on the stream's `rewriter` column, and
HLS is detected from the manifest shape — not from an app or stream name.
## Status
| Area | State |
|---|---|
| serve + SQLite + CRUD UI + claims + credentials | done |
| `/api/apps` + module-driven defaults | done |
| Real downloader/ffmpeg workers + playlist health | partial — least exercised path |
**Full guide: [docs/streamd.md](../../docs/streamd.md)**