webrtc

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2024 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package webrtc contains WebRTC utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ICEFragmentMarshal

func ICEFragmentMarshal(offer string, candidates []*webrtc.ICECandidateInit) ([]byte, error)

ICEFragmentMarshal encodes an ICE fragment.

func ICEFragmentUnmarshal

func ICEFragmentUnmarshal(buf []byte) ([]*webrtc.ICECandidateInit, error)

ICEFragmentUnmarshal decodes an ICE fragment.

func LinkHeaderMarshal

func LinkHeaderMarshal(iceServers []webrtc.ICEServer) []string

LinkHeaderMarshal encodes a link header.

func LinkHeaderUnmarshal

func LinkHeaderUnmarshal(link []string) ([]webrtc.ICEServer, error)

LinkHeaderUnmarshal decodes a link header.

func TracksAreValid added in v1.8.3

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

TracksAreValid checks whether tracks in the SDP are valid

func TracksToMedias added in v1.3.0

func TracksToMedias(tracks []*IncomingTrack) []*description.Media

TracksToMedias converts WebRTC tracks into a media description.

Types

type IncomingTrack

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

IncomingTrack is an incoming track.

func (*IncomingTrack) Format

func (t *IncomingTrack) Format() format.Format

Format returns the track format.

func (*IncomingTrack) ReadRTP

func (t *IncomingTrack) ReadRTP() (*rtp.Packet, error)

ReadRTP reads a RTP packet.

type OutgoingTrack

type OutgoingTrack struct {
	Format format.Format
	// 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) WaitUntilConnected

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

WaitUntilConnected waits until connection is established.

type TrackWrapper added in v1.3.0

type TrackWrapper struct {
	ClockRat int
}

TrackWrapper provides ClockRate() and PTSEqualsDTS() to WebRTC tracks.

func (TrackWrapper) ClockRate added in v1.3.0

func (w TrackWrapper) ClockRate() int

ClockRate returns the clock rate.

func (TrackWrapper) PTSEqualsDTS added in v1.3.0

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

PTSEqualsDTS returns whether PTS equals DTS.

type WHIPClient

type WHIPClient struct {
	HTTPClient *http.Client
	URL        *url.URL
	Log        logger.Writer
	// contains filtered or unexported fields
}

WHIPClient is a WHIP client.

func (*WHIPClient) Close

func (c *WHIPClient) Close() error

Close closes the client.

func (*WHIPClient) Publish

func (c *WHIPClient) Publish(
	ctx context.Context,
	videoTrack format.Format,
	audioTrack format.Format,
) ([]*OutgoingTrack, error)

Publish publishes tracks.

func (*WHIPClient) Read

func (c *WHIPClient) Read(ctx context.Context) ([]*IncomingTrack, error)

Read reads tracks.

func (*WHIPClient) Wait

func (c *WHIPClient) Wait(ctx context.Context) error

Wait waits for client errors.

Jump to

Keyboard shortcuts

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