peer

package
v0.0.0-...-3f3c78e Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCantCreatePeerConnection   = errors.New("can't create peer connection")
	ErrCantSetRemoteDescription   = errors.New("can't set remote description")
	ErrCantCreateAnswer           = errors.New("can't create answer")
	ErrCantSetLocalDescription    = errors.New("can't set local description")
	ErrCantCreateLocalDescription = errors.New("can't create local description")
	ErrDataChannelNotAvailable    = errors.New("data channel is not available")
	ErrDataChannelNotReady        = errors.New("data channel is not ready")
	ErrCantSubscribeToTrack       = errors.New("can't subscribe to track")
)

Functions

This section is empty.

Types

type DataChannelAvailable

type DataChannelAvailable struct{}

type DataChannelMessage

type DataChannelMessage struct {
	Message string
}

type ICEGatheringComplete

type ICEGatheringComplete struct{}

type JoinedTheCall

type JoinedTheCall struct{}

type LeftTheCall

type LeftTheCall struct {
	Reason event.CallHangupReason
}

type MessageContent

type MessageContent = interface{}

Due to the limitation of Go, we're using the `interface{}` to be able to use switch the actual type of the message on runtime. The underlying types do not necessary need to be structures.

type NewICECandidate

type NewICECandidate struct {
	Candidate *webrtc.ICECandidate
}

type NewTrackPublished

type NewTrackPublished struct {
	// Remote track that has been published.
	RemoteTrack *webrtc.TrackRemote
}

type Peer

type Peer[ID comparable] struct {
	// contains filtered or unexported fields
}

A wrapped representation of the peer connection (single peer in the call). The peer gets information about the things happening outside via public methods and informs the outside world about the things happening inside the peer by posting the messages to the channel.

func NewPeer

func NewPeer[ID comparable](
	connectionFactory *webrtc_ext.PeerConnectionFactory,
	sdpOffer string,
	sink *channel.SinkWithSender[ID, MessageContent],
	logger *logrus.Entry,
) (*Peer[ID], *webrtc.SessionDescription, error)

Instantiates a new peer with a given SDP offer and returns a peer and the SDP answer if everything is ok.

func (*Peer[ID]) AddTrack

func (p *Peer[ID]) AddTrack(track *webrtc.TrackLocalStaticRTP) (*webrtc.RTPSender, error)

Implementation of the `SubscriptionController` interface.

func (*Peer[ID]) ProcessNewRemoteCandidates

func (p *Peer[ID]) ProcessNewRemoteCandidates(candidates []webrtc.ICECandidateInit)

Processes the remote ICE candidates.

func (*Peer[ID]) ProcessSDPAnswer

func (p *Peer[ID]) ProcessSDPAnswer(sdpAnswer string) error

Processes the SDP answer received from the remote peer.

func (*Peer[ID]) ProcessSDPOffer

func (p *Peer[ID]) ProcessSDPOffer(sdpOffer string) (*webrtc.SessionDescription, error)

Applies the sdp offer received from the remote peer and generates an SDP answer.

func (*Peer[ID]) RemoveTrack

func (p *Peer[ID]) RemoveTrack(sender *webrtc.RTPSender) error

Implementation of the `SubscriptionController` interface.

func (*Peer[ID]) RequestKeyFrame

func (p *Peer[ID]) RequestKeyFrame(track *webrtc.TrackRemote) error

Request a key frame from the peer connection.

func (*Peer[ID]) SendOverDataChannel

func (p *Peer[ID]) SendOverDataChannel(json string) error

Tries to send the given message to the remote counterpart of our peer.

func (*Peer[ID]) Terminate

func (p *Peer[ID]) Terminate()

Closes peer connection. From this moment on, no new messages will be sent from the peer.

type RenegotiationRequired

type RenegotiationRequired struct {
	Offer *webrtc.SessionDescription
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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