relay

package
v1.10.8 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRelayPeerNotReady     = errors.New("relay Peer is not ready")
	ErrRelayPeerSignalDone   = errors.New("relay Peer signal already called")
	ErrRelaySignalDCNotReady = errors.New("relay Peer data channel is not ready")
)

Functions

This section is empty.

Types

type Message

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

func (*Message) Payload

func (m *Message) Payload() []byte

func (*Message) Reply

func (m *Message) Reply(msg []byte) error

type Peer

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

func NewPeer

func NewPeer(meta PeerMeta, conf *PeerConfig) (*Peer, error)

func (*Peer) AddTrack

func (p *Peer) AddTrack(receiver *webrtc.RTPReceiver, remoteTrack *webrtc.TrackRemote,
	localTrack webrtc.TrackLocal) (*webrtc.RTPSender, error)

AddTrack is used to negotiate a track to the remote peer

func (*Peer) Answer

func (p *Peer) Answer(request []byte) ([]byte, error)

Answer answers the remote Peer signal signalRequest

func (*Peer) Close

func (p *Peer) Close() error

Close ends the relay Peer

func (*Peer) CreateDataChannel

func (p *Peer) CreateDataChannel(label string) (*webrtc.DataChannel, error)

CreateDataChannel creates a new DataChannel object with the given label

func (*Peer) Emit

func (p *Peer) Emit(event string, data []byte) error

Emit emits the data argument to remote peer.

func (*Peer) LocalTracks

func (p *Peer) LocalTracks() []webrtc.TrackLocal

func (*Peer) Offer

func (p *Peer) Offer(signalFn func(meta PeerMeta, signal []byte) ([]byte, error)) error

Offer is used for establish the connection of the local relay Peer with the remote relay Peer.

If connection is successful OnReady handler will be called

func (*Peer) OnDataChannel

func (p *Peer) OnDataChannel(f func(channel *webrtc.DataChannel))

OnDataChannel sets an event handler which is invoked when a data channel message arrives from a remote Peer.

func (*Peer) OnReady

func (p *Peer) OnReady(f func())

OnReady calls the callback when relay Peer is ready to start sending/receiving and creating DC

func (*Peer) OnRequest

func (p *Peer) OnRequest(f func(event string, msg Message))

OnRequest calls the callback when Peer gets a request message from remote Peer

func (*Peer) OnTrack

func (p *Peer) OnTrack(f func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver, meta *TrackMeta))

OnTrack sets an event handler which is called when remote track arrives from a remote Peer

func (*Peer) Request

func (p *Peer) Request(ctx context.Context, event string, data []byte) ([]byte, error)

func (*Peer) WriteRTCP

func (p *Peer) WriteRTCP(pkts []rtcp.Packet) error

WriteRTCP sends a user provided RTCP packet to the connected Peer. If no Peer is connected the packet is discarded. It also runs any configured interceptors.

type PeerConfig

type PeerConfig struct {
	SettingEngine webrtc.SettingEngine
	ICEServers    []webrtc.ICEServer
	Logger        logr.Logger
}

type PeerMeta

type PeerMeta struct {
	PeerID    string `json:"peerId"`
	SessionID string `json:"sessionId"`
}

type TrackMeta

type TrackMeta struct {
	StreamID        string                     `json:"streamId"`
	TrackID         string                     `json:"trackId"`
	CodecParameters *webrtc.RTPCodecParameters `json:"codecParameters,omitempty"`
}

Jump to

Keyboard shortcuts

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