datarhei-dragonfork-core/core/webrtc
Zac Gaetano 9d38e9ccdb feat(webrtc): add app/webrtc subsystem + lifecycle hooks
Introduces the subsystem layer that sits alongside api.API and wires
the M1 core/webrtc primitives into the per-process restream lifecycle.

app/webrtc/subsystem.go:
  - Subsystem struct holding the global WebRTC config, core PeerFactory,
    per-process stream map, and logger
  - New(config.DataWebRTC, logger) constructor
  - Enabled(), Hooks(), Close(), lookup() methods

app/webrtc/lifecycle.go:
  - onProcessStart: allocates an adjacent UDP port pair, binds two
    Pion Sources (video on V, audio on V+1), registers them under the
    process id, and returns the two RTP output legs to append to the
    FFmpeg command.
  - onProcessStop: tears down the pair.
  - allocAdjacentPair: retries up to 10 times to find a free (V, V+1)
    pair since the kernel's ephemeral picker can hand us an odd port.
  - splitRTPLegs: converts BuildArgs' flat []string into two ConfigIO
    entries by splitting on the second -map token.

core/webrtc/peer.go + forward.go:
  - Adds PeerFactory.CreatePeerFromSources for the M2 two-source
    forwarding mode (video and audio on separate UDP ports, no
    payload-type sniffing). Leaves CreatePeer intact for the M1 PoC.
  - Adds forwardRTPSplit companion goroutine.

config/data.go:
  - Promote anonymous WebRTC struct to named type DataWebRTC so
    app/webrtc can accept it by value.
2026-04-17 10:02:00 -04:00
..
config.go feat(webrtc): add Config with defaults and validation 2026-04-17 08:44:30 -04:00
config_test.go feat(webrtc): add Config with defaults and validation 2026-04-17 08:44:30 -04:00
doc.go feat(webrtc): add package skeleton and typed errors 2026-04-17 08:43:57 -04:00
errors.go feat(webrtc): add package skeleton and typed errors 2026-04-17 08:43:57 -04:00
forward.go feat(webrtc): add app/webrtc subsystem + lifecycle hooks 2026-04-17 10:02:00 -04:00
ice.go feat(webrtc): add ICE config helper (Configuration + SettingEngine) 2026-04-17 08:46:27 -04:00
ice_test.go feat(webrtc): add ICE config helper (Configuration + SettingEngine) 2026-04-17 08:46:27 -04:00
peer.go feat(webrtc): add app/webrtc subsystem + lifecycle hooks 2026-04-17 10:02:00 -04:00
peer_test.go feat(webrtc): add PeerFactory, Peer, and RTP forwarder 2026-04-17 08:47:27 -04:00
registry.go feat(webrtc): add thread-safe Registry for stream_id -> SourceHandle 2026-04-17 08:44:59 -04:00
registry_test.go feat(webrtc): add thread-safe Registry for stream_id -> SourceHandle 2026-04-17 08:44:59 -04:00
source.go feat(webrtc): add -rtp-host flag + TrueNAS Docker deploy 2026-04-17 09:05:37 -04:00
source_test.go feat(webrtc): add Source with UDP RTP reader and subscriber fan-out 2026-04-17 08:45:48 -04:00
whep.go feat(webrtc): add WHEP POST handler (happy path) 2026-04-17 08:48:06 -04:00
whep_test.go feat(webrtc): add WHEP POST handler (happy path) 2026-04-17 08:48:06 -04:00