ice

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFailed = errors.New("ice: connection failed")
)

Functions

func NewPacketConn

func NewPacketConn(c *pionice.Conn) (net.PacketConn, net.Addr, error)

NewPacketConn 从 ICE 连接构造 PacketConn 与对端地址。

Types

type CandidatePairInfo

type CandidatePairInfo struct {
	LocalType  string
	RemoteType string
	LocalAddr  string
	RemoteAddr string
}

CandidatePairInfo ICE 选路摘要。

func SelectedPairInfo

func SelectedPairInfo(agent *pionice.Agent) (CandidatePairInfo, bool)

SelectedPairInfo 从 agent 读取选路摘要。

type Config

type Config struct {
	STUNURLs   []string
	TURNURL    string
	TURNUser   string
	TURNPass   string
	ICETimeout time.Duration
	AuthToken  string
}

Config ICE 客户端配置。

type Connection

type Connection struct {
	ICE             *pionice.Conn
	Agent           *pionice.Agent
	RemotePeerID    string
	ConnectDuration time.Duration
}

Connection ICE 协商结果(保留 Agent 以便读取选路与关闭资源)。

func Connect

func Connect(
	ctx context.Context,
	cfg Config,
	broker signaling.Broker,
	selfID, peerID string,
	role Role,
) (*Connection, error)

Connect 通过信令 Broker 与对端完成 ICE 协商,返回已建立的 ICE 连接。

type LivePairStats

type LivePairStats struct {
	Pair      CandidatePairInfo
	RTTMs     float64
	PairState string
	Nominated bool
}

LivePairStats 从仍存活的 ICE Agent 读取选路与 RTT(供 debug / metrics)。

func LivePairStatsFromAgent

func LivePairStatsFromAgent(agent *pionice.Agent) (LivePairStats, bool)

LivePairStatsFromAgent 读取当前选中候选对的实时统计;agent 为 nil 或无选路时返回 false。

type Role

type Role int

Role ICE 协商角色。

const (
	RoleDialer Role = iota
	RoleListener
)

Jump to

Keyboard shortcuts

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