Documentation
¶
Overview ¶
Package ice implements ice-lite both server and client side.
The ice-lite is a lite version of ice, it only supports host type candidate. The Server could be used in SFU, MCU, or other server side. The Client could be used in P2P or other client side.
Index ¶
Constants ¶
const ( Host = "host" CandidateFoundationUDP = "udpcandidate" CandidateFoundationTCP = "tcpcandidate" RoleControlled = "controlled" RoleControlling = "controlling" UDP = "udp" TCP = "tcp" )
Constants for default ICE candidate priority, type preference, and component
Variables ¶
var ( ErrUnknownIP = errors.New("unknown ip") // ErrUnknownIP will raise if a given listen ip not in local interfaces. ErrTransportNotExist = errors.New("transport not exist") // ErrTransportNotExist will raise if transport not exist. ErrNoAvailablePort = errors.New("no available port") // ErrNoAvailablePort will raise if no available port. ErrNoStunMessage = errors.New("no stun message") // ErrNoStunMessage will raise if no stun message. ErrUnsupportedStun = errors.New("unsupported stun type received") // ErrUnsupportedStun will raise if unsupported stun type received. ErrInvalidStun = errors.New("invalid stun message received") // ErrInvalidStun will raise if invalid stun message received. ErrStunRoleConflict = errors.New("stun role conflict") // ErrStunRoleConflict will raise if stun role conflict. ErrNoAvailableIP = errors.New("no available ip") // ErrNoAvailableIP will raise if no available ip. ErrNoUDPAddr = errors.New("not a udp addr") // ErrNoUDPAddr will raise if not a udp addr. ErrNoTCPAddr = errors.New("not a tcp addr") // ErrNoTCPAddr will raise if not a tcp addr. ErrUnknownProtocol = errors.New("unknown protocol") // ErrUnknownProtocol will raise if unknown protocol. ErrServerClosed = errors.New("server has closed") // ErrServerClosed will raise if server has closed. ErrTransportExist = errors.New("transport already exist") // ErrTransportExist will raise if transport already exist. ErrInvalidState = errors.New("transport state is invalid") // ErrInvalidState will raise if transport state is invalid. ErrTCPReadTimeout = errors.New("tcp conn read timeout") // ErrTCPReadTimeout will raise if tcp conn read timeout. )
Functions ¶
This section is empty.
Types ¶
type Candidate ¶
type Candidate struct {
Type string
Protocol string
IP string
Port uint16
Priority int
Foundation string
}
Candidate represents an ICE candidate
type Connection ¶
type Connection interface {
Write(data []byte) (int, error)
Protocol() string
RemoteAddr() net.Addr
Close() error
// contains filtered or unexported methods
}
Connection represents a connection between two peers.
type ConnectionState ¶
type ConnectionState int32
ConnectionState represents the state of the ICE connection See https://w3c.github.io/webrtc-pc/#dom-rtciceconnectionstate We simplify the state for our use case.
const ( ConnectionNew ConnectionState = iota // ConnectionNew indicates new connection ConnectionConnected // ConnectionConnected indicates connection connected ConnectionCompleted // ConnectionCompleted indicates connection completed ConnectionDisconnected // ConnectionDisconnected indicates connection disconnected ConnectionFailed // ConnectionFailed indicates connection failed )
func (ConnectionState) String ¶
func (c ConnectionState) String() string
type Option ¶
type Option struct {
MinPort uint16
MaxPort uint16
// MuxPort uint16 // we do not support udp port mux for now, using a turn server instead
EnableIPV6 bool // we do not support ipv6 yet.
EnableTCP bool // default disable
TCPPort uint16
DisableUDP bool // default enable
IPs []string // listen ips, if empty or nil, will use all ips available
FailTimeout int64 // how many seconds will a transport wait before transaction to fail, default is 30s.
DisconnectTimeout int64 // how many seconds will a transport wait before transaction to disconnected, default is 5s.
}
Option is the option for create ice server.
type Parameters ¶
type Parameters struct {
UsernameFragment string
Password string
Candidates []Candidate
Role string
Lite bool
}
Parameters only used for return ice info to generate sdp.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is ice server side, could be used as HOST type candidate
type Transport ¶
type Transport interface {
Write(data []byte) (int, error)
Close()
State() ConnectionState
Parameters() Parameters
}
Transport is the interface for ICE transport.