Datarhei - Dragon Fork: fork of datarhei/core with native WebRTC (WHEP) egress for low-latency streaming. Built with Pion.
Find a file
Zac Gaetano 671f64ca56
Some checks failed
tests / build (push) Failing after 2s
tests / build (pull_request) Failing after 2s
feat(branding): Dragon Fork identity for v0.1.0-dragonfork release
M5 / final M2-stack work. The fork now identifies itself unambiguously
in logs, the API, and the README without changing the Go module path
(internal imports stay at github.com/datarhei/core/v16 — see NOTES.md
for the rationale).

Identity surfaces:

- app/version.go gains Variant ('dragonfork') and Fork ('Datarhei —
  Dragon Fork') as vars (overridable via -ldflags for downstream
  re-packagers).
- api.About + the /api endpoint expose 'variant' and 'fork' fields;
  Swagger docs regenerated.
- Startup banner logs 'variant' + 'fork' alongside the existing
  application + version fields, so a TrueNAS sysadmin tail-following
  /var/log can tell at a glance which fork is running.

Documentation:

- README.md rewritten with a Dragon Fork header and Quick start; the
  upstream feature surface is summarised in 'From upstream Datarhei'
  with a clear additivity statement. Sample process JSON, multi-input
  pipeline guidance, link to the design + testing docs.
- NOTICE: Apache 2.0 §4(d) attribution to upstream datarhei Core,
  Pion, Echo, FFmpeg.
- CREDITS: enumerated dependency list with licenses.
- CHANGELOG.md prepended with a 'Datarhei — Dragon Fork' section
  starting at v0.1.0-dragonfork; upstream's '# Core' history preserved
  below.

Module path stays github.com/datarhei/core/v16 by design — the fork is
distinguished by repo location and branch history, not import path.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-03 12:22:25 +00:00
.github Add linux/arm/v8 build 2026-03-16 09:28:04 +01:00
app feat(branding): Dragon Fork identity for v0.1.0-dragonfork release 2026-05-03 12:22:25 +00:00
cmd/webrtc-poc feat(webrtc): add -rtp-host flag + TrueNAS Docker deploy 2026-04-17 09:05:37 -04:00
config fix(config): preserve WebRTC section in Config.Clone() 2026-04-17 15:26:11 -04:00
core/webrtc feat(webrtc): add app/webrtc subsystem + lifecycle hooks 2026-04-17 10:02:00 -04:00
deploy deploy(truenas): Core image + compose for M2 WebRTC rollout 2026-04-17 14:59:49 -04:00
docs feat(branding): Dragon Fork identity for v0.1.0-dragonfork release 2026-05-03 12:22:25 +00:00
encoding/json Add v16.7.2 2022-05-13 19:26:45 +02:00
ffmpeg Add looping_runtime to avstream status 2023-05-05 12:03:48 +02:00
glob Fix memfs concurrent read and write performance 2024-03-15 15:25:25 +01:00
http feat(branding): Dragon Fork identity for v0.1.0-dragonfork release 2026-05-03 12:22:25 +00:00
internal Update dependencies 2024-01-12 12:35:07 +01:00
io Fix memfs concurrent read and write performance 2024-03-15 15:25:25 +01:00
log Add WithLevel() to Logger interface 2024-05-29 15:51:51 +02:00
math/rand Fix concurrent accesses 2024-03-15 11:45:50 +01:00
monitor Fix typo in test name 2024-03-14 12:03:38 +01:00
net Fix tests 2023-04-26 09:50:09 +02:00
playout Add v16.7.2 2022-05-13 19:26:45 +02:00
process Fix race condition 2024-01-15 10:42:08 +01:00
prometheus Add GoSRT & improvements (repo-merge) 2022-06-23 22:13:58 +02:00
psutil Fix #10 2023-04-11 15:04:31 +02:00
restream feat(restream): add ProcessHooks for WebRTC subsystem integration 2026-04-17 09:57:14 -04:00
rtmp Don't report EOF as error in RTMP server, update dependency 2024-05-29 16:33:32 +02:00
service Add logging for service 2022-12-27 09:47:59 +01:00
session Fix require positive persist interval 2024-01-12 15:37:51 +01:00
srt Add support for SRTv4 clients 2024-01-12 15:38:32 +01:00
test test(whep-client): add -token flag for JWT-gated /api/v3/whep endpoints 2026-05-03 04:59:08 +00:00
update Don't use deprecated functions from io/ioutil 2022-08-18 10:27:33 +03:00
vendor feat(webrtc): add ICE config helper (Configuration + SettingEngine) 2026-04-17 08:46:27 -04:00
.dockerignore Add v16.8.0 2022-06-03 17:21:52 +02:00
.editorconfig Add v16.7.2 2022-05-13 19:26:45 +02:00
.gitignore feat(webrtc): add package skeleton and typed errors 2026-04-17 08:43:57 -04:00
build.sh Add v16.7.2 2022-05-13 19:26:45 +02:00
CHANGELOG.md feat(branding): Dragon Fork identity for v0.1.0-dragonfork release 2026-05-03 12:22:25 +00:00
CREDITS feat(branding): Dragon Fork identity for v0.1.0-dragonfork release 2026-05-03 12:22:25 +00:00
Dockerfile Add ubuntu build for vod branch 2024-09-24 11:47:25 +02:00
Dockerfile.bundle Mod exposes ports 2022-09-29 10:10:05 +02:00
Dockerfile.test Mod updates build-files 2023-02-23 10:17:39 +01:00
go.mod feat(webrtc): add ICE config helper (Configuration + SettingEngine) 2026-04-17 08:46:27 -04:00
go.sum feat(webrtc): add ICE config helper (Configuration + SettingEngine) 2026-04-17 08:46:27 -04:00
LICENSE Add v16.8.0 2022-06-03 17:21:52 +02:00
main.go Use config locations for import and ffmigrage 2023-01-03 11:45:10 +01:00
Makefile Bump version to 16.15.0, update changelog 2024-04-03 14:27:58 +02:00
mime.types Add v16.7.2 2022-05-13 19:26:45 +02:00
NOTES.md docs: add Dragon Fork WebRTC egress design spec and M1 plan 2026-04-17 08:40:05 -04:00
NOTICE feat(branding): Dragon Fork identity for v0.1.0-dragonfork release 2026-05-03 12:22:25 +00:00
README.md feat(branding): Dragon Fork identity for v0.1.0-dragonfork release 2026-05-03 12:22:25 +00:00
run.sh Add test if import and migrate script exist 2024-04-04 11:10:10 +02:00
SECURITY.md Create SECURITY.md 2022-06-01 22:48:21 +02:00

Datarhei — Dragon Fork

A fork of datarhei/core that adds a native WebRTC (WHEP) egress path. Everything upstream Datarhei already does — RTMP / SRT / RTSP ingest, FFmpeg process orchestration, HLS / DASH outputs, S3 mounts, the HTTP API and Swagger UI — works unchanged. WebRTC sits alongside as another output type, opt-in per process.

publisher (OBS / FFmpeg / SRT) ──▶  datarhei Core  ──▶  WebRTC peers
            │                            │   (15 viewers per stream)
            │                            ├──▶ HLS / DASH (existing)
            │                            ├──▶ RTMP relay (existing)
            └──▶ ingest (RTMP / SRT / …) └──▶ recording (existing)

Sub-second glass-to-glass on a LAN over WHEP, no SFU dependencies, single binary, single Docker image.

Status: M1M4 complete, M5 (release) in flight. Live deploy running on TrueNAS since 2026-04-17.

What this fork adds

  • webrtc.* config block alongside rtmp.* and srt.*, with the same CORE_* env-var binding pattern.
  • Per-process webrtc.enabled toggle on the existing process config. Once true, Core auto-injects two RTP output legs (video + audio), allocates UDP ports, and the WHEP endpoint is live.
  • POST /api/v3/whep/{processID} — WebRTC-HTTP Egress Protocol subscribe; SDP offer in, SDP answer out. JWT-protected by the existing Core auth.
  • DELETE /api/v3/whep/{processID}/{resourceID} — idempotent teardown.
  • PATCH …/{resourceID} — trickle ICE.
  • Browser-side smoke player at test/whep-player.html — zero-dependency WHEP subscriber, ICE/codec/bitrate stats, JWT field, shareable ?url=&token= URLs.
  • Multi-viewer correctness: per-stream peer cap, ICE-failure auto-cleanup, process-stop broadcast tear-down.
  • Error matrix per the design spec: 406 on codec mismatch, 504 on ICE timeout, 503 on cap, 204 on idempotent DELETE, CORS preflights on every WHEP route.

The existing upstream Datarhei feature set is intact — see "From upstream Datarhei" below.

Quick start

Docker (TrueNAS / any host with Docker + LAN-reachable IP)

git clone https://forge.wilddragon.net/zgaetano/datarhei-dragonfork-core.git
cd datarhei-dragonfork-core/deploy/truenas/core

cat > .env <<EOF
PUBLIC_IP=10.0.0.25
CORE_HTTP_PORT=8080
API_AUTH_USERNAME=admin
API_AUTH_PASSWORD=$(openssl rand -base64 24)
API_AUTH_JWT_SECRET=$(openssl rand -base64 48)
EOF

docker compose up -d --build

Then:

  • Swagger UI: http://<host>:8080/api/swagger/index.html
  • WHEP smoke player: open test/whep-player.html in a browser

Sample process JSON

{
  "id": "live",
  "input": [
    { "address": "{rtmp,name=live.stream}", "options": [] }
  ],
  "output": [],
  "webrtc": { "enabled": true }
}

That's it. No webrtc:// URL scheme to learn — the toggle on config.webrtc.enabled is the entire surface. The resolver allocates ports, injects -f rtp udp://… legs into the FFmpeg command, and the WHEP endpoint at /api/v3/whep/live becomes live the moment the process starts.

For multi-input pipelines (lavfi test sources, multi-camera switches, SDI + file audio), use the video_map and audio_map fields:

"webrtc": {
  "enabled": true,
  "video_map": "0:v:0",
  "audio_map": "1:a:0",
  "force_transcode": true
}

Documentation

Topic Where
Design spec docs/design/2026-04-16-datarhei-dragon-fork-webrtc-design.md
M1 (PoC) plan docs/design/2026-04-16-datarhei-dragon-fork-m1-webrtc-poc.md
M2 (Core integration) spec docs/design/2026-04-17-datarhei-dragon-fork-m2-webrtc-core-integration.md
Testing test/TESTING.md
Changelog (Dragon Fork) CHANGELOG.md
Upstream Datarhei docs docs.datarhei.com/core

Building from source

Go 1.24 required (vendored).

make release   # cross-compiles linux/amd64 to ./core/core
make test      # full suite, race detector
go test -tags latency -timeout 90s -count=1 \
  -run TestLatencyServerHop ./app/webrtc/...   # latency p95 gate

From upstream Datarhei

This fork preserves everything upstream Datarhei Core does — Dragon Fork is purely additive. If a feature isn't WebRTC-related, the behaviour is unchanged from upstream and the upstream documentation applies as-is.

Subsystem Upstream feature set
Process management API-driven FFmpeg, error detection / recovery, log history, resource limits, statistics, FFprobe input verification, process metadata
Media delivery HTTP/S, RTMP/S, SRT services with Let's Encrypt, configurable file systems (in-memory / disk / S3), HLS/DASH session limits, viewer session API
Misc HTTP REST + GraphQL, Swagger, Prometheus metrics, multi-arch Docker images

Attribution

Dragon Fork is built on:

  • datarhei Core — Apache 2.0, © datarhei. The base repository this fork tracks. See NOTICE for the required attribution.
  • Pion WebRTC — MIT. The Go WebRTC stack the egress path is built on.
  • FFmpeg — LGPL / GPL (build-flag dependent). Used as a subprocess for transcoding and RTP packetisation; Dragon Fork doesn't link against it.

Full third-party credits in CREDITS.

License

Apache License 2.0 — same as upstream. See LICENSE.