webrtc

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 License: MIT Imports: 29 Imported by: 0

Documentation

Overview

Package webrtc contains WebRTC utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromStream added in v1.9.1

func FromStream(
	stream *stream.Stream,
	reader stream.Reader,
	pc *PeerConnection,
) error

FromStream maps a MediaMTX stream to a WebRTC connection

func ToStream added in v1.9.1

func ToStream(
	pc *PeerConnection,
	stream **stream.Stream,
) ([]*description.Media, error)

ToStream maps a WebRTC connection to a MediaMTX stream.

func TracksAreValid added in v1.8.3

func TracksAreValid(medias []*sdp.MediaDescription) error

TracksAreValid checks whether tracks in the SDP are valid

Types

type IncomingTrack

type IncomingTrack struct {
	OnPacketRTP func(*rtp.Packet)
	// contains filtered or unexported fields
}

IncomingTrack is an incoming track.

func (*IncomingTrack) ClockRate added in v1.9.1

func (t *IncomingTrack) ClockRate() int

ClockRate returns the clock rate. Needed by rtptime.GlobalDecoder

func (*IncomingTrack) PTSEqualsDTS added in v1.9.1

func (*IncomingTrack) PTSEqualsDTS(*rtp.Packet) bool

PTSEqualsDTS returns whether PTS equals DTS. Needed by rtptime.GlobalDecoder

type OutgoingTrack

type OutgoingTrack struct {
	Caps webrtc.RTPCodecCapability
	// contains filtered or unexported fields
}

OutgoingTrack is a WebRTC outgoing track

func (*OutgoingTrack) WriteRTP

func (t *OutgoingTrack) WriteRTP(pkt *rtp.Packet) error

WriteRTP writes a RTP packet.

type PeerConnection

type PeerConnection struct {
	ICEServers            []webrtc.ICEServer
	ICEUDPMux             ice.UDPMux
	ICETCPMux             ice.TCPMux
	HandshakeTimeout      conf.StringDuration
	TrackGatherTimeout    conf.StringDuration
	LocalRandomUDP        bool
	IPsFromInterfaces     bool
	IPsFromInterfacesList []string
	AdditionalHosts       []string
	Publish               bool
	OutgoingTracks        []*OutgoingTrack
	Log                   logger.Writer
	// contains filtered or unexported fields
}

PeerConnection is a wrapper around webrtc.PeerConnection.

func (*PeerConnection) AddRemoteCandidate

func (co *PeerConnection) AddRemoteCandidate(candidate *webrtc.ICECandidateInit) error

AddRemoteCandidate adds a remote candidate.

func (*PeerConnection) BytesReceived

func (co *PeerConnection) BytesReceived() uint64

BytesReceived returns received bytes.

func (*PeerConnection) BytesSent

func (co *PeerConnection) BytesSent() uint64

BytesSent returns sent bytes.

func (*PeerConnection) Close

func (co *PeerConnection) Close()

Close closes the connection.

func (*PeerConnection) Connected

func (co *PeerConnection) Connected() <-chan struct{}

Connected returns when connected.

func (*PeerConnection) CreateFullAnswer

func (co *PeerConnection) CreateFullAnswer(
	ctx context.Context,
	offer *webrtc.SessionDescription,
) (*webrtc.SessionDescription, error)

CreateFullAnswer creates a full answer.

func (*PeerConnection) CreatePartialOffer

func (co *PeerConnection) CreatePartialOffer() (*webrtc.SessionDescription, error)

CreatePartialOffer creates a partial offer.

func (*PeerConnection) Disconnected

func (co *PeerConnection) Disconnected() <-chan struct{}

Disconnected returns when disconnected.

func (*PeerConnection) GatherIncomingTracks

func (co *PeerConnection) GatherIncomingTracks(ctx context.Context) ([]*IncomingTrack, error)

GatherIncomingTracks gathers incoming tracks.

func (*PeerConnection) GatheringDone

func (co *PeerConnection) GatheringDone() <-chan struct{}

GatheringDone returns when candidate gathering is complete.

func (*PeerConnection) LocalCandidate

func (co *PeerConnection) LocalCandidate() string

LocalCandidate returns the local candidate.

func (*PeerConnection) NewLocalCandidate

func (co *PeerConnection) NewLocalCandidate() <-chan *webrtc.ICECandidateInit

NewLocalCandidate returns when there's a new local candidate.

func (*PeerConnection) RemoteCandidate

func (co *PeerConnection) RemoteCandidate() string

RemoteCandidate returns the remote candidate.

func (*PeerConnection) SetAnswer

func (co *PeerConnection) SetAnswer(answer *webrtc.SessionDescription) error

SetAnswer sets the answer.

func (*PeerConnection) Start

func (co *PeerConnection) Start() error

Start starts the peer connection.

func (*PeerConnection) StartReading added in v1.9.1

func (co *PeerConnection) StartReading()

StartReading starts reading all incoming tracks.

func (*PeerConnection) WaitUntilConnected

func (co *PeerConnection) WaitUntilConnected(
	ctx context.Context,
) error

WaitUntilConnected waits until connection is established.

Jump to

Keyboard shortcuts

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