vnettest

package
v1.13.6 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package vnettest sets up real pion peer connections on an in-memory virtual network, for integration tests that exercise media paths without a server.

It depends only on pion, so it can be imported both by tests inside pkg/... and by the top level test package.

Index

Constants

View Source
const (
	VP8PayloadType  = 96
	RTXPayloadType  = VP8PayloadType + 1
	OpusPayloadType = 111
)

Variables

This section is empty.

Functions

func GatheredOffer

func GatheredOffer(t *testing.T, pc *webrtc.PeerConnection) webrtc.SessionDescription

GatheredOffer creates an offer and waits for gathering, so the SDP carries every candidate and the caller needs no trickle.

func NewMediaEngine

func NewMediaEngine(t *testing.T, cfg MediaEngineConfig) *webrtc.MediaEngine

func NewPeerConnection

func NewPeerConnection(t *testing.T, cfg PCConfig) *webrtc.PeerConnection

NewPeerConnection builds a peer connection on the virtual network with no interceptors, so nothing rewrites what a test puts on the wire.

func NewSettingEngine

func NewSettingEngine(net *vnet.Net) webrtc.SettingEngine

NewSettingEngine returns a setting engine bound to net, with ICE timeouts short enough to keep tests quick.

func SignalPair

func SignalPair(t *testing.T, offerer, answerer *webrtc.PeerConnection)

SignalPair performs a full offer/answer exchange between two peer connections and waits for both to connect.

func UntilConnected

func UntilConnected(pcs ...*webrtc.PeerConnection) <-chan struct{}

UntilConnected closes the returned channel once every peer connection is connected.

func VideoRTCPFeedback

func VideoRTCPFeedback() []webrtc.RTCPFeedback

Types

type Hosts

type Hosts struct {
	OfferNet  *vnet.Net
	AnswerNet *vnet.Net
}

Hosts are the two ends of a started virtual network.

func NewHosts

func NewHosts(t *testing.T) *Hosts

NewHosts returns two hosts on a started virtual network, torn down with the test.

type MediaEngineConfig

type MediaEngineConfig struct {
	Video               bool // VP8 and its RTX codec; otherwise opus
	HeaderExtensions    bool // abs-send-time + transport-cc
	SimulcastExtensions bool // mid + rid + rsid
}

MediaEngineConfig describes what to register on a media engine.

type PCConfig

type PCConfig struct {
	Net         *vnet.Net
	MediaEngine MediaEngineConfig

	// BufferFactory is SettingEngine.BufferFactory, e. g. buffer.Factory.GetOrNew.
	// Optional.
	BufferFactory func(packetType packetio.BufferPacketType, ssrc uint32) io.ReadWriteCloser
}

PCConfig describes a peer connection on the virtual network.

Jump to

Keyboard shortcuts

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