Documentation
¶
Index ¶
- Constants
- Variables
- type Addr
- type Config
- type Conn
- func (c *Conn) Close() error
- func (c *Conn) LocalAddr() net.Addr
- func (c *Conn) Read(p []byte) (n int, err error)
- func (c *Conn) RemoteAddr() net.Addr
- func (c *Conn) SetDeadline(t time.Time) error
- func (c *Conn) SetReadDeadline(t time.Time) error
- func (c *Conn) SetWriteDeadline(t time.Time) error
- func (c *Conn) Write(p []byte) (n int, err error)
- type DTLSRole
- type DebugSignal
- type Dialer
- func (d *Dialer) Close() error
- func (d *Dialer) Dial(label string) (net.Conn, error)
- func (d *Dialer) DialContext(ctx context.Context, label string) (net.Conn, error)
- func (d *Dialer) SendOffer(ctx context.Context) (uint64, error)
- func (d *Dialer) SetAnswer(ctx context.Context, offerID uint64) error
- type Listener
- type ListenerRunningStatus
- type NAT1To1IPs
- type PortRange
- type Signal
Constants ¶
const ( MTU_DEFAULT = 1024 MAX_RECV_TIMEOUT_DEFAULT = time.Second * 10 )
const ( CONN_DEFAULT_MTU = 65536 CONN_IDLE_TIMEOUT = 30 * time.Second CONN_DEFAULT_CONCURRENCY = 4 )
const (
DEFAULT_ACCEPT_TIMEOUT = 10 * time.Second
)
Variables ¶
var ( // ErrOfferNotReady is returned by ReadOffer when no offer is available. ErrOfferNotReady = errors.New("offer not ready") // ErrInvalidOfferID is returned by Answer/ReadAnswer when the offer ID is invalid. ErrInvalidOfferID = errors.New("invalid offer ID") // ErrAnswerNotReady is returned by ReadAnswer when the offerID is valid but // an associated answer is not received yet. ErrAnswerNotReady = errors.New("answer not ready") )
var (
ErrBrokenDialer = errors.New("dialer need to be recreated")
)
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // CandidateNetworkTypes restricts ICE agent to gather // on only selected types of networks. CandidateNetworkTypes []webrtc.NetworkType // InterfaceFilter restricts ICE agent to gather ICE candidates // on only selected interfaces. InterfaceFilter func(interfaceName string) (allowed bool) // IPs includes a slice of IP addresses and one single ICE Candidate Type. // If set, will add these IPs as ICE Candidates IPs *NAT1To1IPs // ListenerDTLSRole defines the DTLS role when Listening. // MUST be either DTLSRoleClient or DTLSRoleServer, as defined in RFC4347 // DTLSRoleClient will send the ClientHello and start the handshake. // DTLSRoleServer will wait for the ClientHello. ListenerDTLSRole DTLSRole Logger logging.Logger // PortRange is the range of ports to use for the DataChannel. PortRange *PortRange // ReusePeerConnection indicates whether to reuse the same PeerConnection // if possible, when Dialer dials multiple times. // // If set to true, Dialer.Dial() creates a new DataChannel on the same PeerConnection. // Otherwise, Dialer.Dial() negotiates for a new PeerConnection and creates a new DataChannel on it. ReusePeerConnection bool // Signal offers the automatic signaling when establishing the DataChannel. Signal Signal Timeout time.Duration // UDPMux allows serving multiple DataChannels over the one or more pre-established UDP socket. UDPMux ice.UDPMux // WebRTCConfiguration is the configuration for the underlying WebRTC PeerConnection. WebRTCConfiguration webrtc.Configuration }
Config is the configuration for the Dialer and Listener.
func (*Config) BuildSettingEngine ¶
BuildSettingEngine builds a SettingEngine from the configuration.
func (*Config) NewListener ¶
NewListener creates a new Listener from the given configuration.
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn defines a connection based on a dedicated datachannel. Conn interfaces net.Conn.
func NewConn ¶ added in v0.3.2
func NewConn(dataChannel io.ReadWriteCloser, maxConcurrency int) *Conn
BuildConningle builds a Conningle from an existing datachannel.
func (*Conn) LocalAddr ¶
LocalAddr returns the address of Local ICE Candidate selected for the datachannel
func (*Conn) Read ¶
Read reads data from the connection (underlying datachannel). It blocks until read deadline is reached, data is received in read buffer or error occurs.
func (*Conn) RemoteAddr ¶
RemoteAddr returns the address of Remote ICE Candidate selected for the datachannel
func (*Conn) SetDeadline ¶
SetDeadline sets the deadline for future Read and Write calls.
func (*Conn) SetReadDeadline ¶
SetReadDeadline sets the deadline for future Read calls.
func (*Conn) SetWriteDeadline ¶
SetWriteDeadline sets the deadline for future Write calls.
type DTLSRole ¶
type DTLSRole = webrtc.DTLSRole
const ( // DTLSRoleAuto defines the DTLS role is determined based on // the resolved ICE role: the ICE controlled role acts as the DTLS // client and the ICE controlling role acts as the DTLS server. DTLSRoleAuto DTLSRole = iota + 1 // DTLSRoleClient defines the DTLS client role. DTLSRoleClient // DTLSRoleServer defines the DTLS server role. DTLSRoleServer )
From pion/webrtc
type DebugSignal ¶
type DebugSignal struct {
// contains filtered or unexported fields
}
DebugSignal implements a minimalistic signaling method used for debugging purposes.
func NewDebugSignal ¶
func NewDebugSignal(bufferSize int) *DebugSignal
NewDebugSignal creates a new DebugSignal.
func (*DebugSignal) Answer ¶
func (ds *DebugSignal) Answer(offerID uint64, answer []byte) error
Answer implements Signal.Answer. It writes the SDP answer to answers channel.
func (*DebugSignal) Offer ¶ added in v0.3.2
func (ds *DebugSignal) Offer(offerBody []byte) (uint64, error)
Offer implements Signal.Offer. It writes the SDP offer to offers channel.
func (*DebugSignal) ReadAnswer ¶ added in v0.3.2
func (ds *DebugSignal) ReadAnswer(offerID uint64) ([]byte, error)
ReadAnswer implements Signal.ReadAnswer It reads the SDP answer from answers channel.
type Dialer ¶
type Dialer struct {
// contains filtered or unexported fields
}
Dialer can dial a remote peer.
If the SignalMethod is set, the Offer/Answer exchange per new PeerConnection will be done automatically.
func (*Dialer) Close ¶
Close closes the WebRTC PeerConnection and with it all the WebRTC DataChannels under it.
SHOULD be called when done using the transport.
func (*Dialer) Dial ¶
Dial connects to a remote peer with SDP-based negotiation.
Internally calls DialContext with context.Background().
The returned connection is backed by a DataChannel created by the caller with the SDP role as OFFERER as defined in RFC3264. If SignalMethod is set, the Offer/Answer exchange per new PeerConnection will be done automatically. Otherwise, it is recommended to call NewPeerConnection and exchange the SDP offer/answer manually before dialing.
func (*Dialer) DialContext ¶
DialContext connects to a remote peer with SDP-based negotiation using the provided context.
The provided Context must be non-nil. If the context expires before the connection is complete, an error is returned. Once successfully connected, any expiration of the context will not affect the connection.
The returned connection is backed by a DataChannel created by the caller with the SDP role as OFFERER as defined in RFC3264. If SignalMethod is set, the Offer/Answer exchange per new PeerConnection will be done automatically. Otherwise, it is recommended to call NewPeerConnection and exchange the SDP offer/answer manually before dialing.
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener listens for new PeerConnections and saves all incoming datachannel from peers for later use.
func (*Listener) Accept ¶
Accept accepts a new connection from the listener.
It does not establish new connections. These connections are from the pool filled automatically by acceptLoop.
type ListenerRunningStatus ¶
type ListenerRunningStatus = uint32
const ( LISTENER_NEW ListenerRunningStatus = iota LISTENER_RUNNING LISTENER_SUSPENDED LISTENER_STOPPED )
type NAT1To1IPs ¶
type NAT1To1IPs struct { IPs []string Type webrtc.ICECandidateType }
NAT1To1IPs consists of a slice of IP addresses and one single ICE Candidate Type. Use this struct to set the IPs to be used as ICE Candidates.
type Signal ¶ added in v0.3.2
type Signal interface { // Offer submits a SDP offer generated by offerer to be read by the answerer. // // The caller is expected to keep the offerID for as a reference to the offer // when retrieving the answer later. Offer(offer []byte) (offerID uint64, err error) // ReadOffer reads the next SDP offer from the answerer. // // If no offer is available, ReadOffer may block until an offer is available // or return ErrOfferNotReady. ReadOffer() (offerID uint64, offer []byte, err error) // Answer submits a SDP answer generated by answerer to be read by the offerer. // // The caller is expected to provide the offerID returned by ReadOffer in order to // associate the answer with a previously submitted offer. Answer(offerID uint64, answer []byte) error // ReadAnswer reads the answer associated with the offerID. // // If an associated answer is not available, ReadAnswer may block until an answer // is available or return ErrAnswerNotReady. ReadAnswer(offerID uint64) ([]byte, error) }
Signal defines the interface for signalling, i.e., exchanging SDP offers and answers between two peers.