sfu

package
v1.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

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

func (b *Buffer) GetLostRateBandwidth(cycle uint64) (float64, uint64)

GetLostRateBandwidth calc lostRate and bandwidth by cycle

func (*Buffer) GetNackPair

func (b *Buffer) GetNackPair(buffer [65536]*rtp.Packet, begin, end uint16) (rtcp.NackPair, int)

GetNackPair calc nackpair

func (*Buffer) GetPacket

func (b *Buffer) GetPacket(sn uint16) *rtp.Packet

GetPacket get packet by sequence number

func (*Buffer) GetPayloadType

func (b *Buffer) GetPayloadType() uint8

GetPayloadType get payloadtype

func (*Buffer) GetRTCPChan

func (b *Buffer) GetRTCPChan() chan rtcp.Packet

GetRTCPChan return rtcp channel

func (*Buffer) GetSSRC

func (b *Buffer) GetSSRC() uint32

GetSSRC get ssrc

func (*Buffer) Push

func (b *Buffer) Push(p *rtp.Packet)

Push adds a RTP Packet, out of order, new packet may be arrived later

func (*Buffer) Stop

func (b *Buffer) Stop()

Stop buffer

type BufferOptions

type BufferOptions struct {
	BufferTime int
}

type Config

type Config struct {
	WebRTC   WebRTCConfig   `mapstructure:"webrtc"`
	Log      log.Config     `mapstructure:"log"`
	Receiver ReceiverConfig `mapstructure:"receiver"`
}

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 Receiver

type Receiver interface {
	Track() *webrtc.Track
	GetPacket(sn uint16) *rtp.Packet
	ReadRTP() (*rtp.Packet, error)
	ReadRTCP() (rtcp.Packet, error)
	WriteRTCP(rtcp.Packet) error
	Close()
	// contains filtered or unexported methods
}

Receiver defines a interface for a track receiver

type ReceiverConfig

type ReceiverConfig struct {
	Video WebRTCVideoReceiverConfig `mapstructure:"video"`
}

ReceiverConfig defines receiver configurations

type Router

type Router struct {
	// contains filtered or unexported fields
}

Router defines a track rtp/rtcp router

func NewRouter

func NewRouter(tid string, recv Receiver) *Router

NewRouter for routing rtp/rtcp packets

func (*Router) AddSender

func (r *Router) AddSender(pid string, sub Sender)

AddSender to router

func (*Router) Close

func (r *Router) Close()

Close a router

func (*Router) DelSub

func (r *Router) DelSub(pid string)

DelSub to router

func (*Router) Track

func (r *Router) Track() *webrtc.Track

Track returns the router receiver track

type SFU

type SFU struct {
	// contains filtered or unexported fields
}

SFU represents an sfu instance

func NewSFU

func NewSFU(c Config) *SFU

NewSFU creates a new 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 {
	ReadRTCP() (rtcp.Packet, error)
	WriteRTP(*rtp.Packet)

	Close()
	// contains filtered or unexported methods
}

Sender defines a interface for a track receiver

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 NewSession

func NewSession(id string) *Session

NewSession creates a new session

func (*Session) AddRouter

func (r *Session) AddRouter(router *Router)

AddRouter adds a router to transports

func (*Session) AddTransport

func (r *Session) AddTransport(transport Transport)

AddTransport adds a transport to the session

func (*Session) OnClose

func (r *Session) OnClose(f func())

OnClose called when session is closed

func (*Session) RemoveTransport

func (r *Session) RemoveTransport(tid string)

RemoveTransport removes a transport for the session

func (*Session) Transports

func (r *Session) Transports() map[string]Transport

Transports returns transports in this session

type Transport

type Transport interface {
	ID() string
	GetRouter(uint32) *Router
	Routers() map[uint32]*Router
	NewSender(*webrtc.Track) (Sender, error)
	// contains filtered or unexported methods
}

Transport represents a transport that media can be sent over

type WebRTCAudioReceiver

type WebRTCAudioReceiver struct {
	// contains filtered or unexported fields
}

WebRTCAudioReceiver receives a audio track

func NewWebRTCAudioReceiver

func NewWebRTCAudioReceiver(track *webrtc.Track) *WebRTCAudioReceiver

NewWebRTCAudioReceiver creates a new audio track receiver

func (*WebRTCAudioReceiver) Close

func (a *WebRTCAudioReceiver) Close()

Close track

func (*WebRTCAudioReceiver) GetPacket

func (a *WebRTCAudioReceiver) GetPacket(sn uint16) *rtp.Packet

GetPacket returns nil since audio isn't buffered (uses fec)

func (*WebRTCAudioReceiver) ReadRTCP

func (a *WebRTCAudioReceiver) ReadRTCP() (rtcp.Packet, error)

ReadRTCP read rtcp packet

func (*WebRTCAudioReceiver) ReadRTP

func (a *WebRTCAudioReceiver) ReadRTP() (*rtp.Packet, error)

ReadRTP read rtp packet

func (*WebRTCAudioReceiver) Track

func (a *WebRTCAudioReceiver) Track() *webrtc.Track

Track returns receiver track

func (*WebRTCAudioReceiver) WriteRTCP

func (a *WebRTCAudioReceiver) WriteRTCP(pkt rtcp.Packet) error

WriteRTCP write rtcp packet

type WebRTCConfig

type WebRTCConfig struct {
	ICEPortRange []uint16          `mapstructure:"portrange"`
	ICEServers   []ICEServerConfig `mapstructure:"iceserver"`
}

WebRTCConfig defines parameters for ice

type WebRTCSender

type WebRTCSender struct {
	// contains filtered or unexported fields
}

WebRTCSender represents a Sender which writes RTP to a webrtc track

func NewWebRTCSender

func NewWebRTCSender(track *webrtc.Track, sender *webrtc.RTPSender) *WebRTCSender

NewWebRTCSender creates a new track sender instance

func (*WebRTCSender) Close

func (s *WebRTCSender) Close()

Close track

func (*WebRTCSender) OnClose added in v1.0.5

func (s *WebRTCSender) OnClose(f func())

OnClose is called when the sender is closed

func (*WebRTCSender) ReadRTCP

func (s *WebRTCSender) ReadRTCP() (rtcp.Packet, error)

ReadRTCP read rtp packet

func (*WebRTCSender) WriteRTP

func (s *WebRTCSender) 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(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) 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) Close

func (p *WebRTCTransport) Close() error

Close peer

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(ssrc uint32) *Router

GetRouter returns router with ssrc

func (*WebRTCTransport) ID

func (p *WebRTCTransport) ID() string

ID of peer

func (*WebRTCTransport) NewSender

func (p *WebRTCTransport) NewSender(intrack *webrtc.Track) (Sender, error)

NewSender for peer

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[uint32]*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

type WebRTCVideoReceiver

type WebRTCVideoReceiver struct {
	// contains filtered or unexported fields
}

WebRTCVideoReceiver receives a video track

func NewWebRTCVideoReceiver

func NewWebRTCVideoReceiver(config WebRTCVideoReceiverConfig, track *webrtc.Track) *WebRTCVideoReceiver

NewWebRTCVideoReceiver creates a new video track receiver

func (*WebRTCVideoReceiver) Close

func (v *WebRTCVideoReceiver) Close()

Close track

func (*WebRTCVideoReceiver) GetPacket

func (v *WebRTCVideoReceiver) GetPacket(sn uint16) *rtp.Packet

GetPacket get a buffered packet if we have one

func (*WebRTCVideoReceiver) ReadRTCP

func (v *WebRTCVideoReceiver) ReadRTCP() (rtcp.Packet, error)

ReadRTCP read rtcp packets

func (*WebRTCVideoReceiver) ReadRTP

func (v *WebRTCVideoReceiver) ReadRTP() (*rtp.Packet, error)

ReadRTP read rtp packets

func (*WebRTCVideoReceiver) Track

func (v *WebRTCVideoReceiver) Track() *webrtc.Track

Track returns receiver track

func (*WebRTCVideoReceiver) WriteRTCP

func (v *WebRTCVideoReceiver) WriteRTCP(pkt rtcp.Packet) error

WriteRTCP write rtcp packet

type WebRTCVideoReceiverConfig

type WebRTCVideoReceiverConfig struct {
	REMBCycle     int `mapstructure:"rembcycle"`
	PLICycle      int `mapstructure:"plicycle"`
	TCCCycle      int `mapstructure:"tcccycle"`
	MaxBandwidth  int `mapstructure:"maxbandwidth"`
	MaxBufferTime int `mapstructure:"maxbuffertime"`
}

WebRTCVideoReceiverConfig .

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL