peer

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: Apache-2.0 Imports: 6 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

This section is empty.

Variables

This section is empty.

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

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