Documentation
¶
Overview ¶
Package webrtc contains WebRTC utilities.
Index ¶
- func FromStream(desc *description.Session, r *stream.Reader, pc *PeerConnection) error
- func ToStream(pc *PeerConnection, pathConf *conf.Path, subStream **stream.SubStream, ...) ([]*description.Media, error)
- func TracksAreValid(medias []*sdp.MediaDescription) error
- type InboundTrack
- type Net
- type OutboundDataChannel
- type OutboundTrack
- type PeerConnection
- func (co *PeerConnection) AddRemoteCandidate(candidate *webrtc.ICECandidateInit) error
- func (co *PeerConnection) Close()
- func (co *PeerConnection) Connected() <-chan struct{}
- func (co *PeerConnection) CreateFullAnswer(offer *webrtc.SessionDescription, restarted bool) (*webrtc.SessionDescription, error)
- func (co *PeerConnection) CreateFullOffer() (*webrtc.SessionDescription, error)
- func (co *PeerConnection) CreatePartialOffer(restart bool) (*webrtc.SessionDescription, error)
- func (co *PeerConnection) Failed() <-chan struct{}
- func (co *PeerConnection) GatherInboundTracks(timeout time.Duration) error
- func (co *PeerConnection) GatheringDone() <-chan struct{}
- func (co *PeerConnection) InboundTracks() []*InboundTrack
- func (co *PeerConnection) LocalCandidate() string
- func (co *PeerConnection) NewLocalCandidate() <-chan *webrtc.ICECandidateInit
- func (co *PeerConnection) RemoteCandidate() string
- func (co *PeerConnection) RemoteDescription() *webrtc.SessionDescription
- func (co *PeerConnection) SetAnswer(answer *webrtc.SessionDescription) error
- func (co *PeerConnection) Start() error
- func (co *PeerConnection) StartReading()
- func (co *PeerConnection) Stats() *Stats
- func (co *PeerConnection) WaitUntilConnected(timeout time.Duration) error
- type Stats
- type TCPMuxWrapper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromStream ¶
func FromStream( desc *description.Session, r *stream.Reader, pc *PeerConnection, ) error
FromStream maps a MediaMTX stream to a WebRTC connection
func ToStream ¶
func ToStream( pc *PeerConnection, pathConf *conf.Path, subStream **stream.SubStream, log logger.Writer, ) ([]*description.Media, error)
ToStream maps a WebRTC connection to a MediaMTX stream.
func TracksAreValid ¶
func TracksAreValid(medias []*sdp.MediaDescription) error
TracksAreValid checks whether tracks in the SDP are valid
Types ¶
type InboundTrack ¶
type InboundTrack struct {
OnPacketRTP func(*rtp.Packet)
// contains filtered or unexported fields
}
InboundTrack is an incoming track.
func (*InboundTrack) ClockRate ¶
func (t *InboundTrack) ClockRate() int
ClockRate returns the clock rate. Needed by rtptime.GlobalDecoder
func (*InboundTrack) Codec ¶
func (t *InboundTrack) Codec() webrtc.RTPCodecParameters
Codec returns the track codec.
func (*InboundTrack) PTSEqualsDTS ¶
func (*InboundTrack) PTSEqualsDTS(*rtp.Packet) bool
PTSEqualsDTS returns whether PTS equals DTS. Needed by rtptime.GlobalDecoder
type Net ¶
Net is stdnet.Net with the following changes: - Interfaces() is overridden to query the OS directly on every call without caching. - ListenUDP() is overridden to apply the configured read buffer size to the returned UDPConn.
func (*Net) InterfaceByIndex ¶
InterfaceByIndex returns the interface specified by index.
func (*Net) InterfaceByName ¶
InterfaceByName returns the interface specified by name.
func (*Net) Interfaces ¶
Interfaces returns the current list of network interfaces by querying the OS on every call, with no caching.
type OutboundDataChannel ¶
type OutboundDataChannel struct {
Label string
// contains filtered or unexported fields
}
OutboundDataChannel is an outgoing data channel.
func (*OutboundDataChannel) Write ¶
func (c *OutboundDataChannel) Write(data []byte)
Write writes data to the channel.
type OutboundTrack ¶
type OutboundTrack struct {
Caps webrtc.RTPCodecCapability
// contains filtered or unexported fields
}
OutboundTrack is an outgoing track.
func (*OutboundTrack) WriteRTP ¶
func (t *OutboundTrack) WriteRTP(pkt *rtp.Packet) error
WriteRTP writes a RTP packet.
func (*OutboundTrack) WriteRTPWithNTP ¶
WriteRTPWithNTP writes a RTP packet.
type PeerConnection ¶
type PeerConnection struct {
Net transport.Net
LocalRandomUDP bool
ICEUDPMux ice.UDPMux
ICETCPMux *TCPMuxWrapper
ICEServers []webrtc.ICEServer
IPsFromInterfaces bool
IPsFromInterfacesList []string
AdditionalHosts []string
STUNGatherTimeout time.Duration
SupportsIPv6 bool
Publish bool
OutboundTracks []*OutboundTrack
OutboundDataChannels []*OutboundDataChannel
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) Connected ¶
func (co *PeerConnection) Connected() <-chan struct{}
Connected returns when connected.
func (*PeerConnection) CreateFullAnswer ¶
func (co *PeerConnection) CreateFullAnswer( offer *webrtc.SessionDescription, restarted bool, ) (*webrtc.SessionDescription, error)
CreateFullAnswer accepts an offer and creates a full answer.
func (*PeerConnection) CreateFullOffer ¶
func (co *PeerConnection) CreateFullOffer() (*webrtc.SessionDescription, error)
CreateFullOffer creates a full offer.
func (*PeerConnection) CreatePartialOffer ¶
func (co *PeerConnection) CreatePartialOffer(restart bool) (*webrtc.SessionDescription, error)
CreatePartialOffer creates a partial offer.
func (*PeerConnection) Failed ¶
func (co *PeerConnection) Failed() <-chan struct{}
Failed returns when failed or closed.
func (*PeerConnection) GatherInboundTracks ¶
func (co *PeerConnection) GatherInboundTracks(timeout time.Duration) error
GatherInboundTracks gathers incoming tracks.
func (*PeerConnection) GatheringDone ¶
func (co *PeerConnection) GatheringDone() <-chan struct{}
GatheringDone returns when candidate gathering is complete.
func (*PeerConnection) InboundTracks ¶
func (co *PeerConnection) InboundTracks() []*InboundTrack
InboundTracks returns incoming tracks.
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) RemoteDescription ¶
func (co *PeerConnection) RemoteDescription() *webrtc.SessionDescription
RemoteDescription returns the current remote description.
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 ¶
func (co *PeerConnection) StartReading()
StartReading starts reading incoming tracks.
func (*PeerConnection) WaitUntilConnected ¶
func (co *PeerConnection) WaitUntilConnected(timeout time.Duration) error
WaitUntilConnected waits until connection is established.