peer

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

View Source
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

func BuildAPI() (*webrtc.API, error)

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

func KeepICEInterface(name string) bool

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

func ValidRTCPMode(m string) bool

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

func New(name string, api *webrtc.API, cfg webrtc.Configuration, lg *log.Logger) (*Wrapper, error)

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) Close

func (w *Wrapper) Close() error

Close shuts the underlying PC. Safe to call once.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL