peer

package module
v0.0.0-...-bddfc14 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2024 License: MIT Imports: 9 Imported by: 2

README

Simple Peer

tries to match API of javascript version feross/simple-peer.

Documentation

Index

Constants

View Source
const (
	SignalMessageRenegotiate        = "renegotiate"
	SignalMessageTransceiverRequest = "transceiverRequest"
	SignalMessageCandidate          = "candidate"
	SignalMessageAnswer             = "answer"
	SignalMessageOffer              = "offer"
	SignalMessagePRAnswer           = "pranswer"
	SignalMessageRollback           = "rollback"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type OnClose

type OnClose func()

type OnConnect

type OnConnect func()

type OnData

type OnData func(message webrtc.DataChannelMessage)

type OnError

type OnError func(err error)

type OnNegotiated

type OnNegotiated func()

type OnSignal

type OnSignal func(message map[string]interface{}) error

type OnTrack

type OnTrack func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver)

type OnTransceiver

type OnTransceiver func(transceiver *webrtc.RTPTransceiver)

type Peer

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

func NewPeer

func NewPeer(options ...PeerOptions) *Peer

func (*Peer) AddTrack

func (peer *Peer) AddTrack(track webrtc.TrackLocal) (*webrtc.RTPSender, error)

func (*Peer) AddTransceiverFromKind

func (peer *Peer) AddTransceiverFromKind(kind webrtc.RTPCodecType, init ...webrtc.RTPTransceiverInit) (*webrtc.RTPTransceiver, error)

func (*Peer) Channel

func (peer *Peer) Channel() *webrtc.DataChannel

func (*Peer) Close

func (peer *Peer) Close() error

func (*Peer) CloseSignal

func (peer *Peer) CloseSignal() chan bool

func (*Peer) Closed

func (peer *Peer) Closed() bool

func (*Peer) ConnectSignal

func (peer *Peer) ConnectSignal() chan bool

func (*Peer) Connected

func (peer *Peer) Connected() bool

func (*Peer) Connection

func (peer *Peer) Connection() *webrtc.PeerConnection

func (*Peer) Id

func (peer *Peer) Id() string

func (*Peer) Init

func (peer *Peer) Init() error

func (*Peer) Initiator

func (peer *Peer) Initiator() bool

func (*Peer) Negotiate

func (peer *Peer) Negotiate() error

func (*Peer) OffClose

func (peer *Peer) OffClose(fn OnClose)

func (*Peer) OffConnect

func (peer *Peer) OffConnect(fn OnConnect)

func (*Peer) OffData

func (peer *Peer) OffData(fn OnData)

func (*Peer) OffError

func (peer *Peer) OffError(fn OnError)

func (*Peer) OffNegotiated

func (peer *Peer) OffNegotiated(fn OnNegotiated)

func (*Peer) OffTrack

func (peer *Peer) OffTrack(fn OnTrack)

func (*Peer) OffTransceiver

func (peer *Peer) OffTransceiver(fn OnTransceiver)

func (*Peer) OnClose

func (peer *Peer) OnClose(fn OnClose)

func (*Peer) OnConnect

func (peer *Peer) OnConnect(fn OnConnect)

func (*Peer) OnData

func (peer *Peer) OnData(fn OnData)

func (*Peer) OnError

func (peer *Peer) OnError(fn OnError)

func (*Peer) OnNegotiated

func (peer *Peer) OnNegotiated(fn OnNegotiated)

func (*Peer) OnSignal

func (peer *Peer) OnSignal(fn OnSignal)

func (*Peer) OnTrack

func (peer *Peer) OnTrack(fn OnTrack)

func (*Peer) OnTransceiver

func (peer *Peer) OnTransceiver(fn OnTransceiver)

func (*Peer) Reader

func (peer *Peer) Reader() io.ReadCloser

func (*Peer) RemoveTrack

func (peer *Peer) RemoveTrack(sender *webrtc.RTPSender) error

func (*Peer) SDPTransform

func (peer *Peer) SDPTransform(fn SDPTransform)

func (*Peer) Signal

func (peer *Peer) Signal(message map[string]interface{}) error

func (*Peer) Write

func (peer *Peer) Write(bytes []byte) (int, error)

func (*Peer) WriteText

func (peer *Peer) WriteText(text string) (int, error)

type PeerOptions

type PeerOptions struct {
	Id                    string
	ChannelName           string
	ChannelConfig         *webrtc.DataChannelInit
	Tracks                []webrtc.TrackLocal
	Config                *webrtc.Configuration
	OfferConfig           *webrtc.OfferOptions
	AnswerConfig          *webrtc.AnswerOptions
	MaxChannelMessageSize int
	OnSignal              OnSignal
	OnConnect             OnConnect
	OnData                OnData
	OnError               OnError
	OnClose               OnClose
	OnTransceiver         OnTransceiver
	OnTrack               OnTrack
	OnNegotiated          OnNegotiated
	SDPTransform          SDPTransform
}

type SDPTransform

type SDPTransform func(sdp string) string

type SignalMessageTransceiver

type SignalMessageTransceiver struct {
	Kind webrtc.RTPCodecType         `json:"kind"`
	Init []webrtc.RTPTransceiverInit `json:"init"`
}

Jump to

Keyboard shortcuts

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