Documentation ¶
Index ¶
- Constants
- type Buffer
- func (b *Buffer) GetLostRateBandwidth(cycle uint64) (float64, uint64)
- func (b *Buffer) GetNackPair(buffer [65536]*rtp.Packet, begin, end uint16) (rtcp.NackPair, int)
- func (b *Buffer) GetPacket(sn uint16) *rtp.Packet
- func (b *Buffer) GetPayloadType() uint8
- func (b *Buffer) GetRTCPChan() chan rtcp.Packet
- func (b *Buffer) GetSSRC() uint32
- func (b *Buffer) Push(p *rtp.Packet)
- func (b *Buffer) Stop()
- type BufferOptions
- type Config
- type ICEServerConfig
- type Receiver
- type Router
- type RouterConfig
- type SFU
- type Sender
- type Session
- type SimulcastConfig
- type Transport
- type VP8Helper
- type WebRTCConfig
- type WebRTCReceiver
- func (w *WebRTCReceiver) AddSender(sender Sender)
- func (w *WebRTCReceiver) Close()
- func (w *WebRTCReceiver) DeleteSender(pid string)
- func (w *WebRTCReceiver) GetPacket(sn uint16) *rtp.Packet
- func (w *WebRTCReceiver) OnCloseHandler(fn func())
- func (w *WebRTCReceiver) ReadRTCP() chan rtcp.Packet
- func (w *WebRTCReceiver) SpatialLayer() uint8
- func (w *WebRTCReceiver) Track() *webrtc.Track
- func (w *WebRTCReceiver) WriteRTCP(pkt rtcp.Packet) error
- type WebRTCSender
- func (s *WebRTCSender) Close()
- func (s *WebRTCSender) CurrentSpatialLayer() uint8
- func (s *WebRTCSender) ID() string
- func (s *WebRTCSender) OnCloseHandler(fn func())
- func (s *WebRTCSender) SwitchSpatialLayer(layer uint8)
- func (s *WebRTCSender) SwitchTemporalLayer(layer uint8)
- func (s *WebRTCSender) WriteRTP(pkt *rtp.Packet)
- type WebRTCSimulcastSender
- func (s *WebRTCSimulcastSender) Close()
- func (s *WebRTCSimulcastSender) CurrentSpatialLayer() uint8
- func (s *WebRTCSimulcastSender) ID() string
- func (s *WebRTCSimulcastSender) OnCloseHandler(fn func())
- func (s *WebRTCSimulcastSender) SwitchSpatialLayer(targetLayer uint8)
- func (s *WebRTCSimulcastSender) SwitchTemporalLayer(layer uint8)
- func (s *WebRTCSimulcastSender) WriteRTP(pkt *rtp.Packet)
- type WebRTCTransport
- func (p *WebRTCTransport) AddICECandidate(candidate webrtc.ICECandidateInit) error
- func (p *WebRTCTransport) AddTransceiverFromKind(kind webrtc.RTPCodecType, init ...webrtc.RtpTransceiverInit) (*webrtc.RTPTransceiver, error)
- func (p *WebRTCTransport) Close() error
- func (p *WebRTCTransport) CreateAnswer() (webrtc.SessionDescription, error)
- func (p *WebRTCTransport) CreateOffer() (webrtc.SessionDescription, error)
- func (p *WebRTCTransport) GetRouter(trackID string) Router
- func (p *WebRTCTransport) ID() string
- func (p *WebRTCTransport) LocalDescription() *webrtc.SessionDescription
- func (p *WebRTCTransport) OnConnectionStateChange(f func(webrtc.PeerConnectionState))
- func (p *WebRTCTransport) OnDataChannel(f func(*webrtc.DataChannel))
- 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) Routers() map[string]Router
- func (p *WebRTCTransport) SetLocalDescription(desc webrtc.SessionDescription) error
- func (p *WebRTCTransport) SetRemoteDescription(desc webrtc.SessionDescription) error
- type WebRTCTransportConfig
- type WebRTCVideoReceiverConfig
Constants ¶
const ( SimpleRouter = iota + 1 SimulcastRouter SVCRouter )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer contains all packets
func NewBuffer ¶
func NewBuffer(ssrc uint32, pt uint8, o BufferOptions) *Buffer
NewBuffer constructs a new Buffer
func (*Buffer) GetLostRateBandwidth ¶
GetLostRateBandwidth calc lostRate and bandwidth by cycle
func (*Buffer) GetNackPair ¶
GetNackPair calc nackpair
func (*Buffer) GetPayloadType ¶
GetPayloadType get payloadtype
func (*Buffer) GetRTCPChan ¶
GetRTCPChan return rtcp channel
type BufferOptions ¶
type BufferOptions struct {
BufferTime int
}
BufferOptions provides configuration options for the buffer
type Config ¶
type Config struct { 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 Receiver ¶
type Receiver interface { Track() *webrtc.Track AddSender(sender Sender) DeleteSender(pid string) GetPacket(sn uint16) *rtp.Packet ReadRTCP() chan rtcp.Packet WriteRTCP(rtcp.Packet) error OnCloseHandler(fn func()) SpatialLayer() uint8 Close() // contains filtered or unexported methods }
Receiver defines a interface for a track receivers
func NewWebRTCReceiver ¶ added in v1.0.16
func NewWebRTCReceiver(ctx context.Context, track *webrtc.Track, config RouterConfig) Receiver
NewWebRTCReceiver creates a new webrtc track receivers
type Router ¶
type Router interface { ID() string AddReceiver(recv Receiver) GetReceiver(layer uint8) Receiver AddSender(p *WebRTCTransport) error SwitchSpatialLayer(currentLayer, targetLayer uint8, sub Sender) bool }
Router defines a track rtp/rtcp router
type RouterConfig ¶ added in v1.0.15
type RouterConfig struct { REMBFeedback bool `mapstructure:"subrembfeedback"` MaxBandwidth uint64 `mapstructure:"maxbandwidth"` MaxNackTime int64 `mapstructure:"maxnacktime"` Video WebRTCVideoReceiverConfig `mapstructure:"video"` 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 webrtc.MediaEngine) (*WebRTCTransport, error)
NewWebRTCTransport creates a new WebRTCTransport that is a member of a session
type Sender ¶
type Sender interface { ID() string WriteRTP(*rtp.Packet) CurrentSpatialLayer() uint8 OnCloseHandler(fn func()) Close() // Simulcast/SVC events SwitchSpatialLayer(layer uint8) SwitchTemporalLayer(layer uint8) // contains filtered or unexported methods }
Sender defines a interface for a track receivers
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) RemoveTransport ¶
RemoveTransport removes a transport for the session
func (*Session) Transports ¶
Transports returns transports in this session
type SimulcastConfig ¶ added in v1.0.18
type SimulcastConfig struct {
BestQualityFirst bool `mapstructure:"bestqualityfirst"`
}
type Transport ¶
type Transport interface { ID() string GetRouter(string) Router Routers() map[string]Router // contains filtered or unexported methods }
Transport represents a transport that media can be sent over
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"` NAT1To1IPs []string `mapstructure:"nat1to1"` }
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) Close ¶ added in v1.0.16
func (w *WebRTCReceiver) Close()
Close gracefully close the track
func (*WebRTCReceiver) DeleteSender ¶ added in v1.0.18
func (w *WebRTCReceiver) DeleteSender(pid string)
DeleteSender removes a Sender from a Receiver
func (*WebRTCReceiver) GetPacket ¶ added in v1.0.16
func (w *WebRTCReceiver) GetPacket(sn uint16) *rtp.Packet
GetPacket get a buffered packet if we have one
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) ReadRTCP ¶ added in v1.0.16
func (w *WebRTCReceiver) ReadRTCP() chan rtcp.Packet
ReadRTCP read rtcp packets
func (*WebRTCReceiver) SpatialLayer ¶ added in v1.0.18
func (w *WebRTCReceiver) SpatialLayer() uint8
func (*WebRTCReceiver) Track ¶ added in v1.0.16
func (w *WebRTCReceiver) Track() *webrtc.Track
Track returns receivers track
type WebRTCSender ¶
type WebRTCSender struct {
// contains filtered or unexported fields
}
WebRTCSender represents a Sender which writes RTP to a webrtc track
func (*WebRTCSender) CurrentSpatialLayer ¶ added in v1.0.18
func (s *WebRTCSender) CurrentSpatialLayer() uint8
func (*WebRTCSender) ID ¶ added in v1.0.18
func (s *WebRTCSender) ID() string
func (*WebRTCSender) OnCloseHandler ¶ added in v1.0.16
func (s *WebRTCSender) OnCloseHandler(fn func())
OnCloseHandler method to be called on remote tracked removed
func (*WebRTCSender) SwitchSpatialLayer ¶ added in v1.0.18
func (s *WebRTCSender) SwitchSpatialLayer(layer uint8)
func (*WebRTCSender) SwitchTemporalLayer ¶ added in v1.0.18
func (s *WebRTCSender) SwitchTemporalLayer(layer uint8)
func (*WebRTCSender) WriteRTP ¶
func (s *WebRTCSender) WriteRTP(pkt *rtp.Packet)
WriteRTP to the track
type WebRTCSimulcastSender ¶ added in v1.0.18
type WebRTCSimulcastSender struct {
// contains filtered or unexported fields
}
WebRTCSimulcastSender represents a Sender which writes RTP to a webrtc track
func (*WebRTCSimulcastSender) Close ¶ added in v1.0.18
func (s *WebRTCSimulcastSender) Close()
Close track
func (*WebRTCSimulcastSender) CurrentSpatialLayer ¶ added in v1.0.18
func (s *WebRTCSimulcastSender) CurrentSpatialLayer() uint8
func (*WebRTCSimulcastSender) ID ¶ added in v1.0.18
func (s *WebRTCSimulcastSender) ID() string
func (*WebRTCSimulcastSender) OnCloseHandler ¶ added in v1.0.18
func (s *WebRTCSimulcastSender) OnCloseHandler(fn func())
OnCloseHandler method to be called on remote tracked removed
func (*WebRTCSimulcastSender) SwitchSpatialLayer ¶ added in v1.0.18
func (s *WebRTCSimulcastSender) SwitchSpatialLayer(targetLayer uint8)
func (*WebRTCSimulcastSender) SwitchTemporalLayer ¶ added in v1.0.18
func (s *WebRTCSimulcastSender) SwitchTemporalLayer(layer uint8)
func (*WebRTCSimulcastSender) WriteRTP ¶ added in v1.0.18
func (s *WebRTCSimulcastSender) WriteRTP(pkt *rtp.Packet)
WriteRTP to the track
type WebRTCTransport ¶
type WebRTCTransport struct {
// contains filtered or unexported fields
}
WebRTCTransport represents a sfu peer connection
func NewWebRTCTransport ¶
func NewWebRTCTransport(ctx context.Context, session *Session, me webrtc.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) AddTransceiverFromKind ¶ added in v1.0.5
func (p *WebRTCTransport) AddTransceiverFromKind(kind webrtc.RTPCodecType, init ...webrtc.RtpTransceiverInit) (*webrtc.RTPTransceiver, error)
AddTransceiverFromKind adds RtpTransceiver on WebRTC Transport
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(trackID string) Router
GetRouter returns router with ssrc
func (*WebRTCTransport) LocalDescription ¶ added in v1.0.7
func (p *WebRTCTransport) LocalDescription() *webrtc.SessionDescription
LocalDescription returns the peer connection LocalDescription
func (*WebRTCTransport) OnConnectionStateChange ¶
func (p *WebRTCTransport) OnConnectionStateChange(f func(webrtc.PeerConnectionState))
OnConnectionStateChange handler
func (*WebRTCTransport) OnDataChannel ¶ added in v1.0.4
func (p *WebRTCTransport) OnDataChannel(f func(*webrtc.DataChannel))
OnDataChannel handler
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) Routers ¶
func (p *WebRTCTransport) Routers() map[string]Router
Routers returns routers for this peer
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
type WebRTCTransportConfig ¶ added in v1.0.3
type WebRTCTransportConfig struct {
// contains filtered or unexported fields
}
WebRTCTransportConfig represents configuration options