feat(webrtc): add package skeleton and typed errors

This commit is contained in:
Zac Gaetano 2026-04-17 08:43:57 -04:00
parent 651a9a3eb5
commit 7ea1844869
3 changed files with 46 additions and 0 deletions

9
.gitignore vendored
View file

@ -7,6 +7,15 @@
/test/** /test/**
.vscode .vscode
# Dragon Fork additions: source trees under /core/ and /test/ must be tracked.
!/core/
!/core/webrtc/
!/core/webrtc/**
!/test/
!/test/publish.sh
!/test/whep-client/
!/test/whep-client/**
*.ts *.ts
*.ts.tmp *.ts.tmp
*.m3u8 *.m3u8

11
core/webrtc/doc.go Normal file
View file

@ -0,0 +1,11 @@
// Package webrtc implements the Dragon Fork WebRTC egress module.
//
// It exposes a WHEP (WebRTC-HTTP Egress Protocol) HTTP endpoint and serves
// live RTP produced by an FFmpeg process on a local UDP socket to one or
// more WebRTC peer connections built with Pion.
//
// This package is additive: it does not modify existing datarhei ingest,
// transcode, or non-WebRTC output code paths. The only contact with
// existing code is a new URL scheme ("webrtc://") registered with the
// output resolver (done in milestone M2, not here).
package webrtc

26
core/webrtc/errors.go Normal file
View file

@ -0,0 +1,26 @@
package webrtc
import "errors"
// Sentinel errors returned by package functions.
var (
// ErrStreamNotFound indicates a WHEP subscribe referenced a stream_id
// that has no registered source. Maps to HTTP 404.
ErrStreamNotFound = errors.New("webrtc: stream not found")
// ErrPeerCapReached indicates max_peers_total has been exceeded.
// Maps to HTTP 503.
ErrPeerCapReached = errors.New("webrtc: peer capacity reached")
// ErrCodecMismatch indicates the viewer's SDP offer does not include
// a codec the source can serve (expected H.264 + Opus). Maps to HTTP 406.
ErrCodecMismatch = errors.New("webrtc: codec mismatch")
// ErrInvalidSDP indicates the request body was not a parseable SDP offer.
// Maps to HTTP 400.
ErrInvalidSDP = errors.New("webrtc: invalid SDP")
// ErrICETimeout indicates ICE gathering did not complete within the
// configured timeout. Maps to HTTP 500.
ErrICETimeout = errors.New("webrtc: ICE gathering timeout")
)