- 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
68 lines
2.1 KiB
Markdown
68 lines
2.1 KiB
Markdown
# agent
|
|
|
|
Always-on credentials refresher, hosted by the single binary as `drm agent`.
|
|
|
|
```text
|
|
apps/agent/
|
|
agentcmd/ the command body, imported by apps/cli
|
|
internal/ poller, durable queue, device pool, worker, ws client
|
|
agent.yaml config
|
|
```
|
|
|
|
## What it does
|
|
|
|
1. Polls streamd (`GET /api/streams`)
|
|
2. When an **enabled** stream is down/errored or missing `mpd`/`key`, enqueues a job
|
|
in a durable SQLite queue under `data_dir`
|
|
3. Claims a free ADB device that **already has** the app installed — it never installs
|
|
4. Runs a phone capture through the stream's app module
|
|
5. `POST /api/streams/:id/credentials`
|
|
6. Force-stops the app and clears the device proxy so the phone is free
|
|
|
|
It never runs a downloader. Claims are kept alive by a websocket heartbeat, so they
|
|
expire by themselves if the agent dies.
|
|
|
|
## Run
|
|
|
|
```bash
|
|
# terminal 1 — control plane
|
|
./bin/drm serve --bind 127.0.0.1:8083 --data .cache/streamd
|
|
|
|
# terminal 2 — agent (operator API key from streamd Settings → API keys)
|
|
export STREAMD_API_KEY=ndk_…
|
|
# or legacy: export STREAMD_TOKEN=…
|
|
./bin/drm agent run --config apps/agent/agent.yaml
|
|
```
|
|
|
|
```bash
|
|
./bin/drm agent status
|
|
./bin/drm agent devices
|
|
./bin/drm agent enqueue --stream tg4-ioi --reason manual
|
|
./bin/drm agent cancel --job 3
|
|
```
|
|
|
|
App modules are discovered under `modules/`. The agent drives whichever module a
|
|
stream names and contains no provider logic.
|
|
|
|
## Config
|
|
|
|
`agent.yaml` — `streamd_url`, **`api_key`** (preferred) or `token` (alias), or
|
|
env `STREAMD_API_KEY` / `STREAMD_TOKEN`. Also: `poll_interval_sec`, `workers`,
|
|
`max_attempts`, `capture_wait_sec`, `devices` (empty = any authorised device),
|
|
`wvd`, `user_agent`, `agent_id`, `data_dir`.
|
|
|
|
Create the key in the streamd dashboard (role **operator**). The legacy shared
|
|
`--token` / `STREAMD_TOKEN` still works but is meant for migration only.
|
|
|
|
`wvd` must be set or key fetches fail.
|
|
|
|
## Build
|
|
|
|
```bash
|
|
go -C apps/cli build -o ../../bin/drm .
|
|
|
|
# cross-compile
|
|
GOOS=darwin GOARCH=arm64 go -C apps/cli build -o ../../bin/drm .
|
|
```
|
|
|
|
**Full guide: [docs/streamd.md](../../docs/streamd.md)**
|