Documentation ¶
Overview ¶
Package webrtc contains WebRTC utilities.
Index ¶
- func FromStream(stream *stream.Stream, reader stream.Reader, pc *PeerConnection) error
- func ToStream(pc *PeerConnection, stream **stream.Stream) ([]*description.Media, error)
- func TracksAreValid(medias []*sdp.MediaDescription) error
- type IncomingTrack
- type OutgoingTrack
- type PeerConnection
- func (co *PeerConnection) AddRemoteCandidate(candidate *webrtc.ICECandidateInit) error
- func (co *PeerConnection) BytesReceived() uint64
- func (co *PeerConnection) BytesSent() uint64
- func (co *PeerConnection) Close()
- func (co *PeerConnection) Connected() <-chan struct{}
- func (co *PeerConnection) CreateFullAnswer(ctx context.Context, offer *webrtc.SessionDescription) (*webrtc.SessionDescription, error)
- func (co *PeerConnection) CreatePartialOffer() (*webrtc.SessionDescription, error)
- func (co *PeerConnection) Disconnected() <-chan struct{}
- func (co *PeerConnection) GatherIncomingTracks(ctx context.Context) ([]*IncomingTrack, error)
- func (co *PeerConnection) GatheringDone() <-chan struct{}
- func (co *PeerConnection) LocalCandidate() string
- func (co *PeerConnection) NewLocalCandidate() <-chan *webrtc.ICECandidateInit
- func (co *PeerConnection) RemoteCandidate() string
- func (co *PeerConnection) SetAnswer(answer *webrtc.SessionDescription) error
- func (co *PeerConnection) Start() error
- func (co *PeerConnection) StartReading()
- func (co *PeerConnection) WaitUntilConnected(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromStream ¶ added in v1.9.1
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
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) 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.