Documentation ¶
Index ¶
- Constants
- Variables
- func InitTurnServer(conf TurnConfig, ...) (*turn.Server, error)
- func RelayWithFanOutDataChannels() func(r *relayPeer)
- func RelayWithSenderReports() func(r *relayPeer)
- type AudioObserver
- type Candidates
- type ChannelAPIMessage
- type Config
- type Datachannel
- type DownTrack
- func (d *DownTrack) Bind(t webrtc.TrackLocalContext) (webrtc.RTPCodecParameters, error)
- func (d *DownTrack) Close()
- func (d *DownTrack) Codec() webrtc.RTPCodecCapability
- func (d *DownTrack) CreateSenderReport() *rtcp.SenderReport
- func (d *DownTrack) CreateSourceDescriptionChunks() []rtcp.SourceDescriptionChunk
- func (d *DownTrack) CurrentSpatialLayer() int
- func (d *DownTrack) Enabled() bool
- func (d *DownTrack) ID() string
- func (d *DownTrack) Kind() webrtc.RTPCodecType
- func (d *DownTrack) Mute(val bool)
- func (d *DownTrack) OnBind(fn func())
- func (d *DownTrack) OnCloseHandler(fn func())
- func (d *DownTrack) SetInitialLayers(spatialLayer, temporalLayer int32)
- func (d *DownTrack) SetTransceiver(transceiver *webrtc.RTPTransceiver)
- func (d *DownTrack) Stop() error
- func (d *DownTrack) StreamID() string
- func (d *DownTrack) SwitchSpatialLayer(targetLayer int32, setAsMax bool) error
- func (d *DownTrack) SwitchSpatialLayerDone(layer int32)
- func (d *DownTrack) SwitchTemporalLayer(targetLayer int32, setAsMax bool)
- func (d *DownTrack) Unbind(_ webrtc.TrackLocalContext) error
- func (d *DownTrack) UpdateStats(packetLen uint32)
- func (d *DownTrack) UptrackLayersChange(availableLayers []uint16) (int64, error)
- func (d *DownTrack) WriteRTP(p *buffer.ExtPacket, layer int) error
- type DownTrackType
- type ICEServerConfig
- type JoinConfig
- type MessageProcessor
- type Middlewares
- type Peer
- type PeerLocal
- func (p *PeerLocal) Answer(sdp webrtc.SessionDescription) (*webrtc.SessionDescription, error)
- func (p *PeerLocal) Close() error
- func (p *PeerLocal) ID() string
- func (p *PeerLocal) Join(sid, uid string, config ...JoinConfig) error
- func (p *PeerLocal) Publisher() *Publisher
- func (p *PeerLocal) SendDCMessage(label string, msg []byte) error
- func (p *PeerLocal) Session() Session
- func (p *PeerLocal) SetRemoteDescription(sdp webrtc.SessionDescription) error
- func (p *PeerLocal) Subscriber() *Subscriber
- func (p *PeerLocal) Trickle(candidate webrtc.ICECandidateInit, target int) error
- type ProcessArgs
- type ProcessFunc
- type Publisher
- func (p *Publisher) AddICECandidate(candidate webrtc.ICECandidateInit) error
- func (p *Publisher) AddRelayFanOutDataChannel(label string)
- func (p *Publisher) Answer(offer webrtc.SessionDescription) (webrtc.SessionDescription, error)
- func (p *Publisher) Close()
- func (p *Publisher) GetRelayedDataChannels(label string) []*webrtc.DataChannel
- func (p *Publisher) GetRouter() Router
- func (p *Publisher) OnICECandidate(f func(c *webrtc.ICECandidate))
- func (p *Publisher) OnICEConnectionStateChange(f func(connectionState webrtc.ICEConnectionState))
- func (p *Publisher) OnPublisherTrack(f func(track PublisherTrack))
- func (p *Publisher) PeerConnection() *webrtc.PeerConnection
- func (p *Publisher) PublisherTracks() []PublisherTrack
- func (p *Publisher) Relay(signalFn func(meta relay.PeerMeta, signal []byte) ([]byte, error), ...) (*relay.Peer, error)
- func (p *Publisher) Relayed() bool
- func (p *Publisher) SignalingState() webrtc.SignalingState
- func (p *Publisher) Tracks() []*webrtc.TrackRemote
- type PublisherTrack
- type Receiver
- type RelayPeer
- type Router
- type RouterConfig
- type SFU
- type Session
- type SessionLocal
- func (s *SessionLocal) AddDatachannel(owner string, dc *webrtc.DataChannel)
- func (s *SessionLocal) AddPeer(peer Peer)
- func (s *SessionLocal) AddRelayPeer(peerID string, signalData []byte) ([]byte, error)
- func (s *SessionLocal) AudioObserver() *AudioObserver
- func (s *SessionLocal) Close()
- func (s *SessionLocal) FanOutMessage(origin, label string, msg webrtc.DataChannelMessage)
- func (s *SessionLocal) GetDCMiddlewares() []*Datachannel
- func (s *SessionLocal) GetDataChannels(peerID, label string) []*webrtc.DataChannel
- func (s *SessionLocal) GetFanOutDataChannelLabels() []string
- func (s *SessionLocal) GetPeer(peerID string) Peer
- func (s *SessionLocal) GetRelayPeer(peerID string) *RelayPeer
- func (s *SessionLocal) ID() string
- func (s *SessionLocal) OnClose(f func())
- func (s *SessionLocal) Peers() []Peer
- func (s *SessionLocal) Publish(router Router, r Receiver)
- func (s *SessionLocal) RelayPeers() []*RelayPeer
- func (s *SessionLocal) RemovePeer(p Peer)
- func (s *SessionLocal) Subscribe(peer Peer)
- type SessionProvider
- type SimulcastConfig
- type Subscriber
- func (s *Subscriber) AddDataChannel(label string) (*webrtc.DataChannel, error)
- func (s *Subscriber) AddDatachannel(peer Peer, dc *Datachannel) error
- func (s *Subscriber) AddDownTrack(streamID string, downTrack *DownTrack)
- func (s *Subscriber) AddICECandidate(candidate webrtc.ICECandidateInit) error
- func (s *Subscriber) Close() error
- func (s *Subscriber) CreateOffer() (webrtc.SessionDescription, error)
- func (s *Subscriber) DataChannel(label string) *webrtc.DataChannel
- func (s *Subscriber) DownTracks() []*DownTrack
- func (s *Subscriber) GetDatachannel(label string) *webrtc.DataChannel
- func (s *Subscriber) GetDownTracks(streamID string) []*DownTrack
- func (s *Subscriber) Negotiate()
- func (s *Subscriber) OnICECandidate(f func(c *webrtc.ICECandidate))
- func (s *Subscriber) OnNegotiationNeeded(f func())
- func (s *Subscriber) RegisterDatachannel(label string, dc *webrtc.DataChannel)
- func (s *Subscriber) RemoveDownTrack(streamID string, downTrack *DownTrack)
- func (s *Subscriber) SetRemoteDescription(desc webrtc.SessionDescription) error
- type TurnAuth
- type TurnConfig
- type WebRTCConfig
- type WebRTCReceiver
- func (w *WebRTCReceiver) AddDownTrack(track *DownTrack, bestQualityFirst bool)
- func (w *WebRTCReceiver) AddUpTrack(track *webrtc.TrackRemote, buff *buffer.Buffer, bestQualityFirst bool)
- func (w *WebRTCReceiver) Codec() webrtc.RTPCodecParameters
- func (w *WebRTCReceiver) DeleteDownTrack(layer int, id string)
- func (w *WebRTCReceiver) GetBitrate() [3]uint64
- func (w *WebRTCReceiver) GetMaxTemporalLayer() [3]int32
- func (w *WebRTCReceiver) GetSenderReportTime(layer int) (rtpTS uint32, ntpTS uint64)
- func (w *WebRTCReceiver) Kind() webrtc.RTPCodecType
- func (w *WebRTCReceiver) OnCloseHandler(fn func())
- func (w *WebRTCReceiver) RetransmitPackets(track *DownTrack, packets []packetMeta) error
- func (w *WebRTCReceiver) SSRC(layer int) uint32
- func (w *WebRTCReceiver) SendRTCP(p []rtcp.Packet)
- func (w *WebRTCReceiver) SetRTCPCh(ch chan []rtcp.Packet)
- func (w *WebRTCReceiver) SetTrackMeta(trackID, streamID string)
- func (w *WebRTCReceiver) StreamID() string
- func (w *WebRTCReceiver) SwitchDownTrack(track *DownTrack, layer int) error
- func (w *WebRTCReceiver) TrackID() string
- type WebRTCTimeoutsConfig
- type WebRTCTransportConfig
Constants ¶
const APIChannelLabel = "ion-sfu"
const (
AudioLevelsMethod = "audioLevels"
)
Variables ¶
var ( ErrSpatialNotSupported = errors.New("current track does not support simulcast/SVC") ErrSpatialLayerBusy = errors.New("a spatial layer change is in progress, try latter") )
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") )
var Logger logr.Logger = logr.Discard()
Logger is an implementation of logr.Logger. If is not provided - will be turned off.
Functions ¶
func InitTurnServer ¶ added in v1.8.3
func RelayWithFanOutDataChannels ¶ added in v1.10.9
func RelayWithFanOutDataChannels() func(r *relayPeer)
func RelayWithSenderReports ¶ added in v1.10.9
func RelayWithSenderReports() func(r *relayPeer)
Types ¶
type AudioObserver ¶ added in v1.9.9
func NewAudioObserver ¶ added in v1.9.9
func NewAudioObserver(threshold uint8, interval, filter int) *AudioObserver
func (*AudioObserver) Calc ¶ added in v1.9.9
func (a *AudioObserver) Calc() []string
type Candidates ¶
type ChannelAPIMessage ¶ added in v1.10.3
type ChannelAPIMessage struct { Method string `json:"method"` Params interface{} `json:"params,omitempty"` }
type Config ¶
type Config struct { SFU struct { Ballast int64 `mapstructure:"ballast"` WithStats bool `mapstructure:"withstats"` } `mapstructure:"sfu"` WebRTC WebRTCConfig `mapstructure:"webrtc"` Router RouterConfig `mapstructure:"Router"` Turn TurnConfig `mapstructure:"turn"` BufferFactory *buffer.Factory TurnAuth func(username string, realm string, srcAddr net.Addr) ([]byte, bool) }
Config for base SFU
type Datachannel ¶ added in v1.8.0
type Datachannel struct { Label string // contains filtered or unexported fields }
Datachannel is a wrapper to define middlewares executed on defined label. The datachannels created will be negotiated on join to all peers that joins the SFU.
func (*Datachannel) OnMessage ¶ added in v1.8.0
func (dc *Datachannel) OnMessage(fn func(ctx context.Context, args ProcessArgs))
OnMessage sets the message callback for the datachannel, the event is fired after all the middlewares have processed the message.
func (*Datachannel) Use ¶ added in v1.8.0
func (dc *Datachannel) Use(middlewares ...func(MessageProcessor) MessageProcessor)
Use adds the middlewares to the current Datachannel. The middlewares are going to be executed before the OnMessage event fires.
type DownTrack ¶
type DownTrack struct {
// contains filtered or unexported fields
}
DownTrack implements TrackLocal, is the track used to write packets to SFU Subscriber, the track handle the packets for simple, simulcast and SVC Publisher.
func NewDownTrack ¶
func NewDownTrack(c webrtc.RTPCodecCapability, r Receiver, bf *buffer.Factory, peerID string, mt int) (*DownTrack, error)
NewDownTrack returns a DownTrack.
func (*DownTrack) Bind ¶
Bind is called by the PeerConnection after negotiation is complete This asserts that the code requested is supported by the remote peer. If so it setups all the state (SSRC and PayloadType) to have a call
func (*DownTrack) Codec ¶
func (d *DownTrack) Codec() webrtc.RTPCodecCapability
Codec returns current track codec capability
func (*DownTrack) CreateSenderReport ¶ added in v1.9.0
func (d *DownTrack) CreateSenderReport() *rtcp.SenderReport
func (*DownTrack) CreateSourceDescriptionChunks ¶ added in v1.9.0
func (d *DownTrack) CreateSourceDescriptionChunks() []rtcp.SourceDescriptionChunk
func (*DownTrack) CurrentSpatialLayer ¶ added in v1.10.4
func (*DownTrack) ID ¶
ID is the unique identifier for this Track. This should be unique for the stream, but doesn't have to globally unique. A common example would be 'audio' or 'video' and StreamID would be 'desktop' or 'webcam'
func (*DownTrack) Kind ¶
func (d *DownTrack) Kind() webrtc.RTPCodecType
Kind controls if this TrackLocal is audio or video
func (*DownTrack) OnCloseHandler ¶
func (d *DownTrack) OnCloseHandler(fn func())
OnCloseHandler method to be called on remote tracked removed
func (*DownTrack) SetInitialLayers ¶ added in v1.8.2
func (*DownTrack) SetTransceiver ¶ added in v1.9.0
func (d *DownTrack) SetTransceiver(transceiver *webrtc.RTPTransceiver)
func (*DownTrack) SwitchSpatialLayer ¶
func (*DownTrack) SwitchSpatialLayerDone ¶ added in v1.10.4
func (*DownTrack) SwitchTemporalLayer ¶ added in v1.8.2
func (*DownTrack) Unbind ¶
Unbind implements the teardown logic when the track is no longer needed. This happens because a track has been stopped.
func (*DownTrack) UpdateStats ¶ added in v1.9.1
func (*DownTrack) UptrackLayersChange ¶ added in v1.10.3
type DownTrackType ¶
type DownTrackType int
DownTrackType determines the type of track
const ( SimpleDownTrack DownTrackType = iota + 1 SimulcastDownTrack )
type ICEServerConfig ¶
type ICEServerConfig struct { URLs []string `mapstructure:"urls"` Username string `mapstructure:"username"` Credential string `mapstructure:"credential"` }
ICEServerConfig defines parameters for ice servers
type JoinConfig ¶ added in v1.9.8
type JoinConfig struct { // If true the peer will not be allowed to publish tracks to SessionLocal. NoPublish bool // If true the peer will not be allowed to subscribe to other peers in SessionLocal. NoSubscribe bool // If true the peer will not automatically subscribe all tracks, // and then the peer can use peer.Subscriber().AddDownTrack/RemoveDownTrack // to customize the subscrbe stream combination as needed. // this parameter depends on NoSubscribe=false. NoAutoSubscribe bool }
JoinConfig allow adding more control to the peers joining a SessionLocal.
type MessageProcessor ¶ added in v1.8.0
type MessageProcessor interface {
Process(ctx context.Context, args ProcessArgs)
}
type Middlewares ¶ added in v1.8.0
type Middlewares []func(MessageProcessor) MessageProcessor
func (Middlewares) Process ¶ added in v1.8.0
func (mws Middlewares) Process(h MessageProcessor) MessageProcessor
func (Middlewares) ProcessFunc ¶ added in v1.8.0
func (mws Middlewares) ProcessFunc(h MessageProcessor) MessageProcessor
type PeerLocal ¶ added in v1.9.9
type PeerLocal struct { sync.Mutex OnOffer func(*webrtc.SessionDescription) OnIceCandidate func(*webrtc.ICECandidateInit, int) OnICEConnectionStateChange func(webrtc.ICEConnectionState) // contains filtered or unexported fields }
PeerLocal represents a pair peer connection
func NewPeer ¶
func NewPeer(provider SessionProvider) *PeerLocal
NewPeer creates a new PeerLocal for signaling with the given SFU
func (*PeerLocal) Close ¶ added in v1.9.9
Close shuts down the peer connection and sends true to the done channel
func (*PeerLocal) Join ¶ added in v1.9.9
func (p *PeerLocal) Join(sid, uid string, config ...JoinConfig) error
Join initializes this peer for a given sessionID
func (*PeerLocal) SendDCMessage ¶ added in v1.10.4
func (*PeerLocal) SetRemoteDescription ¶ added in v1.9.9
SetRemoteDescription when receiving an answer from remote
func (*PeerLocal) Subscriber ¶ added in v1.9.9
func (p *PeerLocal) Subscriber() *Subscriber
type ProcessArgs ¶ added in v1.8.0
type ProcessArgs struct { Peer Peer Message webrtc.DataChannelMessage DataChannel *webrtc.DataChannel }
type ProcessFunc ¶ added in v1.8.0
type ProcessFunc func(ctx context.Context, args ProcessArgs)
func (ProcessFunc) Process ¶ added in v1.8.0
func (p ProcessFunc) Process(ctx context.Context, args ProcessArgs)
type Publisher ¶
type Publisher struct {
// contains filtered or unexported fields
}
func NewPublisher ¶
func NewPublisher(id string, session Session, cfg *WebRTCTransportConfig) (*Publisher, error)
NewPublisher creates a new Publisher
func (*Publisher) AddICECandidate ¶
AddICECandidate to peer connection
func (*Publisher) AddRelayFanOutDataChannel ¶ added in v1.10.9
AddRelayFanOutDataChannel adds fan out data channel to relayed peers
func (*Publisher) GetRelayedDataChannels ¶ added in v1.10.9
GetRelayedDataChannels Returns a slice of data channels that belongs to relayed peers
func (*Publisher) OnICECandidate ¶
func (p *Publisher) OnICECandidate(f func(c *webrtc.ICECandidate))
OnICECandidate handler
func (*Publisher) OnICEConnectionStateChange ¶
func (p *Publisher) OnICEConnectionStateChange(f func(connectionState webrtc.ICEConnectionState))
func (*Publisher) OnPublisherTrack ¶ added in v1.10.8
func (p *Publisher) OnPublisherTrack(f func(track PublisherTrack))
func (*Publisher) PeerConnection ¶ added in v1.9.9
func (p *Publisher) PeerConnection() *webrtc.PeerConnection
func (*Publisher) PublisherTracks ¶ added in v1.10.8
func (p *Publisher) PublisherTracks() []PublisherTrack
func (*Publisher) Relay ¶ added in v1.10.4
func (p *Publisher) Relay(signalFn func(meta relay.PeerMeta, signal []byte) ([]byte, error), options ...func(r *relayPeer)) (*relay.Peer, error)
Relay will relay all current and future tracks from current Publisher
func (*Publisher) Relayed ¶ added in v1.10.9
Relayed returns true if the publisher has been relayed at least once
func (*Publisher) SignalingState ¶
func (p *Publisher) SignalingState() webrtc.SignalingState
type PublisherTrack ¶ added in v1.10.8
type PublisherTrack struct { Track *webrtc.TrackRemote Receiver Receiver // contains filtered or unexported fields }
type Receiver ¶
type Receiver interface { TrackID() string StreamID() string Codec() webrtc.RTPCodecParameters Kind() webrtc.RTPCodecType SSRC(layer int) uint32 SetTrackMeta(trackID, streamID string) AddUpTrack(track *webrtc.TrackRemote, buffer *buffer.Buffer, bestQualityFirst bool) AddDownTrack(track *DownTrack, bestQualityFirst bool) SwitchDownTrack(track *DownTrack, layer int) error GetBitrate() [3]uint64 GetMaxTemporalLayer() [3]int32 RetransmitPackets(track *DownTrack, packets []packetMeta) error DeleteDownTrack(layer int, id string) OnCloseHandler(fn func()) SendRTCP(p []rtcp.Packet) SetRTCPCh(ch chan []rtcp.Packet) GetSenderReportTime(layer int) (rtpTS uint32, ntpTS uint64) }
Receiver defines a interface for a track receivers
func NewWebRTCReceiver ¶
func NewWebRTCReceiver(receiver *webrtc.RTPReceiver, track *webrtc.TrackRemote, pid string) Receiver
NewWebRTCReceiver creates a new webrtc track receivers
type RelayPeer ¶ added in v1.10.9
type RelayPeer struct {
// contains filtered or unexported fields
}
func NewRelayPeer ¶ added in v1.10.9
func NewRelayPeer(peer *relay.Peer, session Session, config *WebRTCTransportConfig) *RelayPeer
func (*RelayPeer) DataChannel ¶ added in v1.10.9
type Router ¶
type Router interface { ID() string AddReceiver(receiver *webrtc.RTPReceiver, track *webrtc.TrackRemote, trackID, streamID string) (Receiver, bool) AddDownTracks(s *Subscriber, r Receiver) error SetRTCPWriter(func([]rtcp.Packet) error) AddDownTrack(s *Subscriber, r Receiver) (*DownTrack, error) Stop() }
Router defines a track rtp/rtcp Router
type RouterConfig ¶
type RouterConfig struct { WithStats bool `mapstructure:"withstats"` MaxBandwidth uint64 `mapstructure:"maxbandwidth"` MaxPacketTrack int `mapstructure:"maxpackettrack"` AudioLevelInterval int `mapstructure:"audiolevelinterval"` AudioLevelThreshold uint8 `mapstructure:"audiolevelthreshold"` AudioLevelFilter int `mapstructure:"audiolevelfilter"` Simulcast SimulcastConfig `mapstructure:"simulcast"` }
RouterConfig defines Router configurations
type SFU ¶
SFU represents an sfu instance
func (*SFU) GetSession ¶
func (s *SFU) GetSession(sid string) (Session, WebRTCTransportConfig)
func (*SFU) GetSessions ¶ added in v1.9.1
GetSessions return all sessions
func (*SFU) NewDatachannel ¶ added in v1.8.0
func (s *SFU) NewDatachannel(label string) *Datachannel
type Session ¶
type Session interface { ID() string Publish(router Router, r Receiver) Subscribe(peer Peer) AddPeer(peer Peer) GetPeer(peerID string) Peer RemovePeer(peer Peer) AddRelayPeer(peerID string, signalData []byte) ([]byte, error) AudioObserver() *AudioObserver AddDatachannel(owner string, dc *webrtc.DataChannel) GetDCMiddlewares() []*Datachannel GetFanOutDataChannelLabels() []string GetDataChannels(peerID, label string) (dcs []*webrtc.DataChannel) FanOutMessage(origin, label string, msg webrtc.DataChannelMessage) Peers() []Peer RelayPeers() []*RelayPeer }
Session represents a set of peers. Transports inside a SessionLocal are automatically subscribed to each other.
func NewSession ¶
func NewSession(id string, dcs []*Datachannel, cfg WebRTCTransportConfig) Session
NewSession creates a new SessionLocal
type SessionLocal ¶ added in v1.9.9
type SessionLocal struct {
// contains filtered or unexported fields
}
func (*SessionLocal) AddDatachannel ¶ added in v1.9.9
func (s *SessionLocal) AddDatachannel(owner string, dc *webrtc.DataChannel)
func (*SessionLocal) AddPeer ¶ added in v1.9.9
func (s *SessionLocal) AddPeer(peer Peer)
func (*SessionLocal) AddRelayPeer ¶ added in v1.10.9
func (s *SessionLocal) AddRelayPeer(peerID string, signalData []byte) ([]byte, error)
func (*SessionLocal) AudioObserver ¶ added in v1.9.9
func (s *SessionLocal) AudioObserver() *AudioObserver
func (*SessionLocal) Close ¶ added in v1.10.8
func (s *SessionLocal) Close()
func (*SessionLocal) FanOutMessage ¶ added in v1.10.9
func (s *SessionLocal) FanOutMessage(origin, label string, msg webrtc.DataChannelMessage)
func (*SessionLocal) GetDCMiddlewares ¶ added in v1.9.9
func (s *SessionLocal) GetDCMiddlewares() []*Datachannel
func (*SessionLocal) GetDataChannels ¶ added in v1.9.9
func (s *SessionLocal) GetDataChannels(peerID, label string) []*webrtc.DataChannel
func (*SessionLocal) GetFanOutDataChannelLabels ¶ added in v1.10.9
func (s *SessionLocal) GetFanOutDataChannelLabels() []string
func (*SessionLocal) GetPeer ¶ added in v1.10.9
func (s *SessionLocal) GetPeer(peerID string) Peer
func (*SessionLocal) GetRelayPeer ¶ added in v1.10.9
func (s *SessionLocal) GetRelayPeer(peerID string) *RelayPeer
func (*SessionLocal) ID ¶ added in v1.9.9
func (s *SessionLocal) ID() string
ID return SessionLocal id
func (*SessionLocal) OnClose ¶ added in v1.9.9
func (s *SessionLocal) OnClose(f func())
OnClose is called when the SessionLocal is closed
func (*SessionLocal) Peers ¶ added in v1.9.9
func (s *SessionLocal) Peers() []Peer
Peers returns peers in this SessionLocal
func (*SessionLocal) Publish ¶ added in v1.9.9
func (s *SessionLocal) Publish(router Router, r Receiver)
Publish will add a Sender to all peers in current SessionLocal from given Receiver
func (*SessionLocal) RelayPeers ¶ added in v1.10.9
func (s *SessionLocal) RelayPeers() []*RelayPeer
RelayPeers returns relay peers in this SessionLocal
func (*SessionLocal) RemovePeer ¶ added in v1.9.9
func (s *SessionLocal) RemovePeer(p Peer)
RemovePeer removes Peer from the SessionLocal
func (*SessionLocal) Subscribe ¶ added in v1.9.9
func (s *SessionLocal) Subscribe(peer Peer)
Subscribe will create a Sender for every other Receiver in the SessionLocal
type SessionProvider ¶
type SessionProvider interface {
GetSession(sid string) (Session, WebRTCTransportConfig)
}
SessionProvider provides the SessionLocal to the sfu.Peer This allows the sfu.SFU{} implementation to be customized / wrapped by another package
type SimulcastConfig ¶
type Subscriber ¶
func NewSubscriber ¶
func NewSubscriber(id string, cfg WebRTCTransportConfig) (*Subscriber, error)
NewSubscriber creates a new Subscriber
func (*Subscriber) AddDataChannel ¶
func (s *Subscriber) AddDataChannel(label string) (*webrtc.DataChannel, error)
func (*Subscriber) AddDatachannel ¶ added in v1.8.0
func (s *Subscriber) AddDatachannel(peer Peer, dc *Datachannel) error
func (*Subscriber) AddDownTrack ¶
func (s *Subscriber) AddDownTrack(streamID string, downTrack *DownTrack)
func (*Subscriber) AddICECandidate ¶
func (s *Subscriber) AddICECandidate(candidate webrtc.ICECandidateInit) error
AddICECandidate to peer connection
func (*Subscriber) CreateOffer ¶
func (s *Subscriber) CreateOffer() (webrtc.SessionDescription, error)
func (*Subscriber) DataChannel ¶ added in v1.9.1
func (s *Subscriber) DataChannel(label string) *webrtc.DataChannel
DataChannel returns the channel for a label
func (*Subscriber) DownTracks ¶ added in v1.10.8
func (s *Subscriber) DownTracks() []*DownTrack
func (*Subscriber) GetDatachannel ¶ added in v1.9.9
func (s *Subscriber) GetDatachannel(label string) *webrtc.DataChannel
func (*Subscriber) GetDownTracks ¶
func (s *Subscriber) GetDownTracks(streamID string) []*DownTrack
func (*Subscriber) Negotiate ¶ added in v1.9.9
func (s *Subscriber) Negotiate()
Negotiate fires a debounced negotiation request
func (*Subscriber) OnICECandidate ¶
func (s *Subscriber) OnICECandidate(f func(c *webrtc.ICECandidate))
OnICECandidate handler
func (*Subscriber) OnNegotiationNeeded ¶
func (s *Subscriber) OnNegotiationNeeded(f func())
func (*Subscriber) RegisterDatachannel ¶ added in v1.9.9
func (s *Subscriber) RegisterDatachannel(label string, dc *webrtc.DataChannel)
func (*Subscriber) RemoveDownTrack ¶ added in v1.7.5
func (s *Subscriber) RemoveDownTrack(streamID string, downTrack *DownTrack)
func (*Subscriber) SetRemoteDescription ¶
func (s *Subscriber) SetRemoteDescription(desc webrtc.SessionDescription) error
SetRemoteDescription sets the SessionDescription of the remote peer
type TurnConfig ¶ added in v1.7.4
type TurnConfig struct { Enabled bool `mapstructure:"enabled"` Realm string `mapstructure:"realm"` Address string `mapstructure:"address"` Cert string `mapstructure:"cert"` Key string `mapstructure:"key"` Auth TurnAuth `mapstructure:"auth"` PortRange []uint16 `mapstructure:"portrange"` }
WebRTCConfig defines parameters for ice
type WebRTCConfig ¶
type WebRTCConfig struct { ICESinglePort int `mapstructure:"singleport"` ICEPortRange []uint16 `mapstructure:"portrange"` ICEServers []ICEServerConfig `mapstructure:"iceserver"` Candidates Candidates `mapstructure:"candidates"` SDPSemantics string `mapstructure:"sdpsemantics"` MDNS bool `mapstructure:"mdns"` Timeouts WebRTCTimeoutsConfig `mapstructure:"timeouts"` }
WebRTCConfig defines parameters for ice
type WebRTCReceiver ¶
WebRTCReceiver receives a video track
func (*WebRTCReceiver) AddDownTrack ¶
func (w *WebRTCReceiver) AddDownTrack(track *DownTrack, bestQualityFirst bool)
func (*WebRTCReceiver) AddUpTrack ¶
func (w *WebRTCReceiver) AddUpTrack(track *webrtc.TrackRemote, buff *buffer.Buffer, bestQualityFirst bool)
func (*WebRTCReceiver) Codec ¶
func (w *WebRTCReceiver) Codec() webrtc.RTPCodecParameters
func (*WebRTCReceiver) DeleteDownTrack ¶
func (w *WebRTCReceiver) DeleteDownTrack(layer int, id string)
DeleteDownTrack removes a DownTrack from a Receiver
func (*WebRTCReceiver) GetBitrate ¶ added in v1.8.2
func (w *WebRTCReceiver) GetBitrate() [3]uint64
func (*WebRTCReceiver) GetMaxTemporalLayer ¶ added in v1.8.2
func (w *WebRTCReceiver) GetMaxTemporalLayer() [3]int32
func (*WebRTCReceiver) GetSenderReportTime ¶ added in v1.10.9
func (w *WebRTCReceiver) GetSenderReportTime(layer int) (rtpTS uint32, ntpTS uint64)
func (*WebRTCReceiver) Kind ¶
func (w *WebRTCReceiver) Kind() webrtc.RTPCodecType
func (*WebRTCReceiver) OnCloseHandler ¶
func (w *WebRTCReceiver) OnCloseHandler(fn func())
OnCloseHandler method to be called on remote tracked removed
func (*WebRTCReceiver) RetransmitPackets ¶ added in v1.7.0
func (w *WebRTCReceiver) RetransmitPackets(track *DownTrack, packets []packetMeta) error
func (*WebRTCReceiver) SSRC ¶
func (w *WebRTCReceiver) SSRC(layer int) uint32
func (*WebRTCReceiver) SendRTCP ¶
func (w *WebRTCReceiver) SendRTCP(p []rtcp.Packet)
func (*WebRTCReceiver) SetRTCPCh ¶
func (w *WebRTCReceiver) SetRTCPCh(ch chan []rtcp.Packet)
func (*WebRTCReceiver) SetTrackMeta ¶ added in v1.10.9
func (w *WebRTCReceiver) SetTrackMeta(trackID, streamID string)
func (*WebRTCReceiver) StreamID ¶
func (w *WebRTCReceiver) StreamID() string
func (*WebRTCReceiver) SwitchDownTrack ¶ added in v1.9.8
func (w *WebRTCReceiver) SwitchDownTrack(track *DownTrack, layer int) error
func (*WebRTCReceiver) TrackID ¶
func (w *WebRTCReceiver) TrackID() string
type WebRTCTimeoutsConfig ¶ added in v1.10.4
type WebRTCTransportConfig ¶
type WebRTCTransportConfig struct { Configuration webrtc.Configuration Setting webrtc.SettingEngine Router RouterConfig BufferFactory *buffer.Factory }
WebRTCTransportConfig represents Configuration options
func NewWebRTCTransportConfig ¶
func NewWebRTCTransportConfig(c Config) WebRTCTransportConfig
NewWebRTCTransportConfig parses our settings and returns a usable WebRTCTransportConfig for creating PeerConnections