Documentation
¶
Overview ¶
Package peer wraps Pion's RTCPeerConnection with the few extras goloom requires: ICE candidate buffering until remote description is set, and a uniform logging prefix so PUB and SUB events are easy to tell apart.
Index ¶
Constants ¶
const ( // RTCPModeFull: NACK generator + responder, RTCP sender/receiver reports, // receiver-side TWCC feedback. What a real WebRTC client does. RTCPModeFull = "full" // RTCPModeNoFeedback: RTCPModeFull without receiver-side TWCC feedback. RTCPModeNoFeedback = "nofb" // RTCPModeLegacy: no RTCP interceptors (behaviour before 2026-09). RTCPModeLegacy = "legacy" )
RTCP interceptor sets selectable through RTCPMode.
Variables ¶
var RTCPMode = rtcpModeFromEnv()
RTCPMode is read by BuildAPI for every new session. It defaults to $GOLOOM_RTCP_MODE, or RTCPModeNoFeedback when that is unset or unknown.
The default deliberately omits the receiver-side TWCC feedback generator. Measured 2026-07-23: with the phone reporting its (lossy mobile) receive stats, the SFU's send-side estimate for SFU→phone fell toward zero and even the single-packet HELLO stopped arriving. Reports and NACK — the parts the sibling projects identified as load-bearing — are on. Set the env var to "full" to re-test the feedback generator, or on Android call Client.SetRTCPMode before Connect.
Functions ¶
func BuildAPI ¶
BuildAPI constructs a Pion webrtc.API with a minimal MediaEngine matching the codecs Telemost's web client offers in its publisher SDP:
- audio/opus PT=111 with minptime=10;useinbandfec=1, transport-cc + nack
- video/VP8 PT=96 with goog-remb, transport-cc, ccm fir, nack, nack pli
VP9 / H264 / AV1 / RED are intentionally not registered for PoC #1 — one codec per kind keeps SDP and renegotiation simple. The SFU has VP8 in its subscriber answer offerings, so this is enough to receive too.
func KeepICEInterface ¶ added in v1.2.0
KeepICEInterface reports whether ICE may gather host candidates on the named network interface.
func ToConfig ¶
func ToConfig(servers []goloom.ServerICEEntry) webrtc.Configuration
ToConfig converts the goloom-supplied ice_servers list into a Pion webrtc.Configuration with BUNDLE max-bundle (Telemost requires it — its publisher offer always uses a=group:BUNDLE 0 1).
func ValidRTCPMode ¶ added in v1.2.0
ValidRTCPMode reports whether m names an RTCP interceptor set.
Types ¶
type Wrapper ¶
type Wrapper struct {
Name string // "PUB" or "SUB"
PC *webrtc.PeerConnection
Log *log.Logger
// contains filtered or unexported fields
}
Wrapper owns one Pion PeerConnection plus the bits we need around it.
func New ¶
New builds a PeerConnection from the supplied API + Configuration. The caller wires OnICECandidate / OnTrack / OnDataChannel / OnConnectionStateChange before adding tracks or applying SDP.
func (*Wrapper) AddICECandidate ¶
func (w *Wrapper) AddICECandidate(c webrtc.ICECandidateInit) error
AddICECandidate buffers if remote description not yet applied, applies directly otherwise. The double-check pattern avoids losing candidates that arrive concurrently with SetRemoteDescriptionAndFlush.
func (*Wrapper) SetRemoteDescriptionAndFlush ¶
func (w *Wrapper) SetRemoteDescriptionAndFlush(d webrtc.SessionDescription) error
SetRemoteDescriptionAndFlush applies the SDP, marks the remote-set flag, and drains any ICE candidates that arrived before it.