Documentation ¶
Index ¶
- Constants
- Variables
- type Buffer
- type BufferOptions
- type Candidates
- type Config
- type ICEServerConfig
- type MediaEngine
- type Peer
- func (p *Peer) Answer(sdp webrtc.SessionDescription) (*webrtc.SessionDescription, error)
- func (p *Peer) Close() error
- func (p *Peer) Join(sid string, sdp webrtc.SessionDescription) (*webrtc.SessionDescription, error)
- func (p *Peer) SetRemoteDescription(sdp webrtc.SessionDescription) error
- func (p *Peer) Trickle(candidate webrtc.ICECandidateInit) error
- type Receiver
- type Router
- type RouterConfig
- type SFU
- type Sender
- type SenderType
- type Session
- type SimpleSender
- func (s *SimpleSender) Close()
- func (s *SimpleSender) CurrentSpatialLayer() uint8
- func (s *SimpleSender) ID() string
- func (s *SimpleSender) Kind() webrtc.RTPCodecType
- func (s *SimpleSender) Mute(val bool)
- func (s *SimpleSender) OnCloseHandler(fn func())
- func (s *SimpleSender) Start()
- func (s *SimpleSender) SwitchSpatialLayer(layer uint8)
- func (s *SimpleSender) SwitchTemporalLayer(layer uint8)
- func (s *SimpleSender) Track() *webrtc.Track
- func (s *SimpleSender) Transceiver() *webrtc.RTPTransceiver
- func (s *SimpleSender) Type() SenderType
- func (s *SimpleSender) WriteRTP(pkt *rtp.Packet)
- type SimulcastConfig
- type SimulcastSender
- func (s *SimulcastSender) Close()
- func (s *SimulcastSender) CurrentSpatialLayer() uint8
- func (s *SimulcastSender) ID() string
- func (s *SimulcastSender) Kind() webrtc.RTPCodecType
- func (s *SimulcastSender) Mute(val bool)
- func (s *SimulcastSender) OnCloseHandler(fn func())
- func (s *SimulcastSender) Start()
- func (s *SimulcastSender) SwitchSpatialLayer(targetLayer uint8)
- func (s *SimulcastSender) SwitchTemporalLayer(layer uint8)
- func (s *SimulcastSender) Track() *webrtc.Track
- func (s *SimulcastSender) Transceiver() *webrtc.RTPTransceiver
- func (s *SimulcastSender) Type() SenderType
- func (s *SimulcastSender) WriteRTP(pkt *rtp.Packet)
- type Transport
- type TransportWideCC
- type VP8Helper
- type WebRTCConfig
- type WebRTCReceiver
- func (w *WebRTCReceiver) AddSender(sender Sender)
- func (w *WebRTCReceiver) DeleteSender(pid string)
- func (w *WebRTCReceiver) OnCloseHandler(fn func())
- func (w *WebRTCReceiver) OnTransportWideCC(fn func(sn uint16, timeNS int64, marker bool))
- func (w *WebRTCReceiver) SendRTCP(p []rtcp.Packet)
- func (w *WebRTCReceiver) SetRTCPCh(ch chan []rtcp.Packet)
- func (w *WebRTCReceiver) SpatialLayer() uint8
- func (w *WebRTCReceiver) Start()
- func (w *WebRTCReceiver) Track() *webrtc.Track
- func (w *WebRTCReceiver) WriteBufferedPacket(sn []uint16, track *webrtc.Track, snOffset uint16, tsOffset, ssrc uint32) error
- type WebRTCTransport
- func (p *WebRTCTransport) AddICECandidate(candidate webrtc.ICECandidateInit) error
- func (p *WebRTCTransport) AddSender(streamID string, sender Sender)
- func (p *WebRTCTransport) Close() error
- func (p *WebRTCTransport) CreateAnswer() (webrtc.SessionDescription, error)
- func (p *WebRTCTransport) CreateOffer() (webrtc.SessionDescription, error)
- func (p *WebRTCTransport) GetRouter() Router
- func (p *WebRTCTransport) GetSenders(streamID string) []Sender
- func (p *WebRTCTransport) ID() string
- func (p *WebRTCTransport) LocalDescription() *webrtc.SessionDescription
- func (p *WebRTCTransport) OnICECandidate(f func(c *webrtc.ICECandidate))
- func (p *WebRTCTransport) OnNegotiationNeeded(f func())
- func (p *WebRTCTransport) OnTrack(f func(*webrtc.Track, *webrtc.RTPReceiver))
- func (p *WebRTCTransport) SetLocalDescription(desc webrtc.SessionDescription) error
- func (p *WebRTCTransport) SetRemoteDescription(desc webrtc.SessionDescription) error
- func (p *WebRTCTransport) SignalingState() webrtc.SignalingState
- type WebRTCTransportConfig
Constants ¶
const ( SimpleReceiver = iota + 1 SimulcastReceiver SVCReceiver )
Variables ¶
var ( // ErrTransportExists join is called after a peerconnection is established ErrTransportExists = errors.New("rtc transport already exists for this connection") // ErrNoTransportEstablished cannot signal before join ErrNoTransportEstablished = errors.New("no rtc transport exists for this Peer") // ErrOfferIgnored if offer received in unstable state ErrOfferIgnored = errors.New("offered ignored") )
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer contains all packets
func NewBuffer ¶
func NewBuffer(track *webrtc.Track, o BufferOptions) *Buffer
NewBuffer constructs a new Buffer
type BufferOptions ¶
BufferOptions provides configuration options for the buffer
type Candidates ¶ added in v1.0.40
type Config ¶
type Config struct { SFU struct { Ballast int64 `mapstructure:"ballast"` } `mapstructure:"sfu"` WebRTC WebRTCConfig `mapstructure:"webrtc"` Log log.Config `mapstructure:"log"` Router RouterConfig `mapstructure:"router"` }
Config for base SFU
type ICEServerConfig ¶
type ICEServerConfig struct { URLs []string `mapstructure:"urls"` Username string `mapstructure:"username"` Credential string `mapstructure:"credential"` }
ICEServerConfig defines parameters for ice servers
type MediaEngine ¶
type MediaEngine struct {
webrtc.MediaEngine
}
MediaEngine handles stream codecs
func (*MediaEngine) PopulateFromSDP ¶
func (e *MediaEngine) PopulateFromSDP(sd webrtc.SessionDescription) error
PopulateFromSDP finds all codecs in sd and adds them to m, using the dynamic payload types and parameters from sd. PopulateFromSDP is intended for use when answering a request. The offerer sets the PayloadTypes for the connection. PopulateFromSDP allows an answerer to properly match the PayloadTypes from the offerer. A MediaEngine populated by PopulateFromSDP should be used only for a single session.
type Peer ¶ added in v1.0.23
type Peer struct { OnIceCandidate func(*webrtc.ICECandidateInit) OnOffer func(*webrtc.SessionDescription) // contains filtered or unexported fields }
Peer represents a single peer signal session
func (*Peer) Close ¶ added in v1.0.23
Close shuts down the peer connection and sends true to the done channel
func (*Peer) Join ¶ added in v1.0.23
Join initializes this peer for a given sessionID (takes an SDPOffer)
func (*Peer) SetRemoteDescription ¶ added in v1.0.23
SetRemoteDescription when receiving an answer from remote
type Receiver ¶
type Receiver interface { Start() Track() *webrtc.Track AddSender(sender Sender) DeleteSender(pid string) SpatialLayer() uint8 OnCloseHandler(fn func()) OnTransportWideCC(fn func(sn uint16, timeNS int64, marker bool)) SendRTCP(p []rtcp.Packet) SetRTCPCh(ch chan []rtcp.Packet) WriteBufferedPacket(sn []uint16, track *webrtc.Track, snOffset uint16, tsOffset, ssrc uint32) error }
Receiver defines a interface for a track receivers
func NewWebRTCReceiver ¶ added in v1.0.16
func NewWebRTCReceiver(receiver *webrtc.RTPReceiver, track *webrtc.Track, config BufferOptions) Receiver
NewWebRTCReceiver creates a new webrtc track receivers
type Router ¶
type Router interface { ID() string Config() RouterConfig AddReceiver(track *webrtc.Track, receiver *webrtc.RTPReceiver) *receiverRouter AddSender(p *WebRTCTransport, rr *receiverRouter) error AddTWCCExt(id string, ext int) SendRTCP(pkts []rtcp.Packet) Stop() }
Router defines a track rtp/rtcp router
type RouterConfig ¶ added in v1.0.15
type RouterConfig struct { MaxBandwidth uint64 `mapstructure:"maxbandwidth"` MaxBufferTime int `mapstructure:"maxbuffertime"` Simulcast SimulcastConfig `mapstructure:"simulcast"` }
RouterConfig defines router configurations
type SFU ¶
type SFU struct {
// contains filtered or unexported fields
}
SFU represents an sfu instance
func (*SFU) NewWebRTCTransport ¶
func (s *SFU) NewWebRTCTransport(sid string, me MediaEngine) (*WebRTCTransport, error)
NewWebRTCTransport creates a new WebRTCTransport that is a member of a session
type Sender ¶
type Sender interface { ID() string Start() Close() Kind() webrtc.RTPCodecType Type() SenderType Track() *webrtc.Track Transceiver() *webrtc.RTPTransceiver Mute(val bool) WriteRTP(*rtp.Packet) CurrentSpatialLayer() uint8 OnCloseHandler(fn func()) // Simulcast/SVC events SwitchSpatialLayer(layer uint8) SwitchTemporalLayer(layer uint8) }
Sender defines a interface for a track receivers
func NewSimpleSender ¶ added in v1.0.23
NewSimpleSender creates a new track sender instance
func NewSimulcastSender ¶ added in v1.0.23
func NewSimulcastSender(id string, router *receiverRouter, transceiver *webrtc.RTPTransceiver, layer uint8, conf SimulcastConfig) Sender
NewSimulcastSender creates a new track sender instance
type SenderType ¶ added in v1.0.26
type SenderType int
SenderType determines the type of a sender
const ( SimpleSenderType SenderType = iota + 1 SimulcastSenderType SVCSenderType )
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session represents a set of transports. Transports inside a session are automatically subscribed to each other.
func (*Session) AddTransport ¶
AddTransport adds a transport to the session
func (*Session) OnClose ¶
func (s *Session) OnClose(f func())
OnClose is called when the session is closed
func (*Session) Publish ¶ added in v1.0.41
Publish will add a Sender to all peers in current Session from given Receiver
func (*Session) RemoveTransport ¶
RemoveTransport removes a transport from the session
func (*Session) Subscribe ¶ added in v1.0.41
func (s *Session) Subscribe(p *WebRTCTransport)
Subscribe will create a Sender for every other Receiver in the session
func (*Session) Transports ¶
Transports returns transports in this session
type SimpleSender ¶ added in v1.0.23
type SimpleSender struct {
// contains filtered or unexported fields
}
SimpleSender represents a Sender which writes RTP to a webrtc track
func (*SimpleSender) CurrentSpatialLayer ¶ added in v1.0.23
func (s *SimpleSender) CurrentSpatialLayer() uint8
func (*SimpleSender) ID ¶ added in v1.0.23
func (s *SimpleSender) ID() string
func (*SimpleSender) Kind ¶ added in v1.0.23
func (s *SimpleSender) Kind() webrtc.RTPCodecType
func (*SimpleSender) Mute ¶ added in v1.0.23
func (s *SimpleSender) Mute(val bool)
func (*SimpleSender) OnCloseHandler ¶ added in v1.0.23
func (s *SimpleSender) OnCloseHandler(fn func())
OnCloseHandler method to be called on remote tracked removed
func (*SimpleSender) Start ¶ added in v1.0.30
func (s *SimpleSender) Start()
func (*SimpleSender) SwitchSpatialLayer ¶ added in v1.0.23
func (s *SimpleSender) SwitchSpatialLayer(layer uint8)
func (*SimpleSender) SwitchTemporalLayer ¶ added in v1.0.23
func (s *SimpleSender) SwitchTemporalLayer(layer uint8)
func (*SimpleSender) Track ¶ added in v1.0.30
func (s *SimpleSender) Track() *webrtc.Track
func (*SimpleSender) Transceiver ¶ added in v1.0.41
func (s *SimpleSender) Transceiver() *webrtc.RTPTransceiver
func (*SimpleSender) Type ¶ added in v1.0.26
func (s *SimpleSender) Type() SenderType
func (*SimpleSender) WriteRTP ¶ added in v1.0.23
func (s *SimpleSender) WriteRTP(pkt *rtp.Packet)
WriteRTP to the track
type SimulcastConfig ¶ added in v1.0.18
type SimulcastSender ¶ added in v1.0.23
type SimulcastSender struct {
// contains filtered or unexported fields
}
SimulcastSender represents a Sender which writes RTP to a webrtc track
func (*SimulcastSender) CurrentSpatialLayer ¶ added in v1.0.23
func (s *SimulcastSender) CurrentSpatialLayer() uint8
func (*SimulcastSender) ID ¶ added in v1.0.23
func (s *SimulcastSender) ID() string
func (*SimulcastSender) Kind ¶ added in v1.0.23
func (s *SimulcastSender) Kind() webrtc.RTPCodecType
func (*SimulcastSender) Mute ¶ added in v1.0.23
func (s *SimulcastSender) Mute(val bool)
func (*SimulcastSender) OnCloseHandler ¶ added in v1.0.23
func (s *SimulcastSender) OnCloseHandler(fn func())
OnCloseHandler method to be called on remote tracked removed
func (*SimulcastSender) Start ¶ added in v1.0.30
func (s *SimulcastSender) Start()
func (*SimulcastSender) SwitchSpatialLayer ¶ added in v1.0.23
func (s *SimulcastSender) SwitchSpatialLayer(targetLayer uint8)
func (*SimulcastSender) SwitchTemporalLayer ¶ added in v1.0.23
func (s *SimulcastSender) SwitchTemporalLayer(layer uint8)
func (*SimulcastSender) Track ¶ added in v1.0.30
func (s *SimulcastSender) Track() *webrtc.Track
func (*SimulcastSender) Transceiver ¶ added in v1.0.41
func (s *SimulcastSender) Transceiver() *webrtc.RTPTransceiver
func (*SimulcastSender) Type ¶ added in v1.0.26
func (s *SimulcastSender) Type() SenderType
func (*SimulcastSender) WriteRTP ¶ added in v1.0.23
func (s *SimulcastSender) WriteRTP(pkt *rtp.Packet)
WriteRTP to the track
type Transport ¶
type Transport interface { ID() string GetRouter() Router AddSender(streamID string, sender Sender) GetSenders(streamID string) []Sender }
Transport represents a transport that media can be sent over
type TransportWideCC ¶ added in v1.0.31
type VP8Helper ¶ added in v1.0.18
type VP8Helper struct { TemporalSupported bool // Optional Header PictureID uint16 /* 8 or 16 bits, picture ID */ TL0PICIDX uint8 /* 8 bits temporal level zero index */ // Optional Header If either of the T or K bits are set to 1, // the TID/Y/KEYIDX extension field MUST be present. TID uint8 /* 2 bits temporal layer idx*/ // IsKeyFrame is a helper to detect if current packet is a keyframe IsKeyFrame bool // contains filtered or unexported fields }
VP8Helper is a helper to get temporal data from VP8 packet header
VP8Helper Payload Descriptor 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ |X|R|N|S|R| PID | (REQUIRED) |X|R|N|S|R| PID | (REQUIRED) +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ X: |I|L|T|K| RSV | (OPTIONAL) X: |I|L|T|K| RSV | (OPTIONAL) +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ I: |M| PictureID | (OPTIONAL) I: |M| PictureID | (OPTIONAL) +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ L: | TL0PICIDX | (OPTIONAL) | PictureID | +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ T/K:|TID|Y| KEYIDX | (OPTIONAL) L: | TL0PICIDX | (OPTIONAL) +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ T/K:|TID|Y| KEYIDX | (OPTIONAL) +-+-+-+-+-+-+-+-+
type WebRTCConfig ¶
type WebRTCConfig struct { ICEPortRange []uint16 `mapstructure:"portrange"` ICEServers []ICEServerConfig `mapstructure:"iceserver"` Candidates Candidates `mapstructure:"candidates"` SDPSemantics string `mapstructure:"sdpsemantics"` }
WebRTCConfig defines parameters for ice
type WebRTCReceiver ¶ added in v1.0.16
WebRTCReceiver receives a video track
func (*WebRTCReceiver) AddSender ¶ added in v1.0.18
func (w *WebRTCReceiver) AddSender(sender Sender)
func (*WebRTCReceiver) DeleteSender ¶ added in v1.0.18
func (w *WebRTCReceiver) DeleteSender(pid string)
DeleteSender removes a Sender from a Receiver
func (*WebRTCReceiver) OnCloseHandler ¶ added in v1.0.16
func (w *WebRTCReceiver) OnCloseHandler(fn func())
OnCloseHandler method to be called on remote tracked removed
func (*WebRTCReceiver) OnTransportWideCC ¶ added in v1.0.31
func (w *WebRTCReceiver) OnTransportWideCC(fn func(sn uint16, timeNS int64, marker bool))
func (*WebRTCReceiver) SendRTCP ¶ added in v1.0.31
func (w *WebRTCReceiver) SendRTCP(p []rtcp.Packet)
func (*WebRTCReceiver) SetRTCPCh ¶ added in v1.0.31
func (w *WebRTCReceiver) SetRTCPCh(ch chan []rtcp.Packet)
func (*WebRTCReceiver) SpatialLayer ¶ added in v1.0.18
func (w *WebRTCReceiver) SpatialLayer() uint8
func (*WebRTCReceiver) Start ¶ added in v1.0.31
func (w *WebRTCReceiver) Start()
func (*WebRTCReceiver) Track ¶ added in v1.0.16
func (w *WebRTCReceiver) Track() *webrtc.Track
Track returns receivers track
func (*WebRTCReceiver) WriteBufferedPacket ¶ added in v1.0.23
func (w *WebRTCReceiver) WriteBufferedPacket(sn []uint16, track *webrtc.Track, snOffset uint16, tsOffset, ssrc uint32) error
WriteBufferedPacket writes buffered packet to track, return error if packet not found
type WebRTCTransport ¶
type WebRTCTransport struct {
// contains filtered or unexported fields
}
WebRTCTransport represents a sfu peer connection
func NewWebRTCTransport ¶
func NewWebRTCTransport(session *Session, me MediaEngine, cfg WebRTCTransportConfig) (*WebRTCTransport, error)
NewWebRTCTransport creates a new WebRTCTransport
func (*WebRTCTransport) AddICECandidate ¶
func (p *WebRTCTransport) AddICECandidate(candidate webrtc.ICECandidateInit) error
AddICECandidate to peer connection
func (*WebRTCTransport) AddSender ¶ added in v1.0.23
func (p *WebRTCTransport) AddSender(streamID string, sender Sender)
func (*WebRTCTransport) CreateAnswer ¶
func (p *WebRTCTransport) CreateAnswer() (webrtc.SessionDescription, error)
CreateAnswer generates the localDescription
func (*WebRTCTransport) CreateOffer ¶
func (p *WebRTCTransport) CreateOffer() (webrtc.SessionDescription, error)
CreateOffer generates the localDescription
func (*WebRTCTransport) GetRouter ¶
func (p *WebRTCTransport) GetRouter() Router
GetRouter returns router with mediaSSRC
func (*WebRTCTransport) GetSenders ¶ added in v1.0.23
func (p *WebRTCTransport) GetSenders(streamID string) []Sender
func (*WebRTCTransport) LocalDescription ¶ added in v1.0.7
func (p *WebRTCTransport) LocalDescription() *webrtc.SessionDescription
LocalDescription returns the peer connection LocalDescription
func (*WebRTCTransport) OnICECandidate ¶
func (p *WebRTCTransport) OnICECandidate(f func(c *webrtc.ICECandidate))
OnICECandidate handler
func (*WebRTCTransport) OnNegotiationNeeded ¶
func (p *WebRTCTransport) OnNegotiationNeeded(f func())
OnNegotiationNeeded handler
func (*WebRTCTransport) OnTrack ¶
func (p *WebRTCTransport) OnTrack(f func(*webrtc.Track, *webrtc.RTPReceiver))
OnTrack handler
func (*WebRTCTransport) SetLocalDescription ¶
func (p *WebRTCTransport) SetLocalDescription(desc webrtc.SessionDescription) error
SetLocalDescription sets the SessionDescription of the remote peer
func (*WebRTCTransport) SetRemoteDescription ¶
func (p *WebRTCTransport) SetRemoteDescription(desc webrtc.SessionDescription) error
SetRemoteDescription sets the SessionDescription of the remote peer
func (*WebRTCTransport) SignalingState ¶ added in v1.0.29
func (p *WebRTCTransport) SignalingState() webrtc.SignalingState
type WebRTCTransportConfig ¶ added in v1.0.3
type WebRTCTransportConfig struct {
// contains filtered or unexported fields
}
WebRTCTransportConfig represents configuration options