Documentation ¶
Overview ¶
Package webrtc contains WebRTC utilities.
Index ¶
- func ICEFragmentMarshal(offer string, candidates []*webrtc.ICECandidateInit) ([]byte, error)
- func ICEFragmentUnmarshal(buf []byte) ([]*webrtc.ICECandidateInit, error)
- func LinkHeaderMarshal(iceServers []webrtc.ICEServer) []string
- func LinkHeaderUnmarshal(link []string) ([]webrtc.ICEServer, error)
- func NewAPI(cnf APIConf) (*webrtc.API, error)
- func TrackCount(medias []*sdp.MediaDescription) (int, error)
- func TracksToMedias(tracks []*IncomingTrack) []*description.Media
- func WHIPDeleteSession(ctx context.Context, hc *http.Client, ur string) error
- func WHIPOptionsICEServers(ctx context.Context, hc *http.Client, ur string) ([]webrtc.ICEServer, error)
- func WHIPPatchCandidate(ctx context.Context, hc *http.Client, ur string, ...) error
- type APIConf
- 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, count int) ([]*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) SetupOutgoingTracks(videoTrack format.Format, audioTrack format.Format) ([]*OutgoingTrack, error)
- func (co *PeerConnection) Start() error
- func (co *PeerConnection) WaitGatheringDone(ctx context.Context) error
- func (co *PeerConnection) WaitUntilConnected(ctx context.Context) error
- type TrackWrapper
- type WHIPClient
- type WHIPPostOfferResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ICEFragmentMarshal ¶
ICEFragmentMarshal encodes an ICE fragment.
func ICEFragmentUnmarshal ¶
ICEFragmentUnmarshal decodes an ICE fragment.
func LinkHeaderMarshal ¶
func LinkHeaderMarshal(iceServers []webrtc.ICEServer) []string
LinkHeaderMarshal encodes a link header.
func LinkHeaderUnmarshal ¶
LinkHeaderUnmarshal decodes a link header.
func TrackCount ¶
TrackCount returns the track count.
func TracksToMedias ¶
func TracksToMedias(tracks []*IncomingTrack) []*description.Media
TracksToMedias converts WebRTC tracks into a media description.
func WHIPDeleteSession ¶
WHIPDeleteSession deletes a WHIP/WHEP session.
Types ¶
type APIConf ¶
type APIConf struct { ICEUDPMux ice.UDPMux ICETCPMux ice.TCPMux LocalRandomUDP bool IPsFromInterfaces bool IPsFromInterfacesList []string AdditionalHosts []string }
APIConf is the configuration passed to NewAPI().
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.
type OutgoingTrack ¶
type OutgoingTrack struct {
// contains filtered or unexported fields
}
OutgoingTrack is a WebRTC outgoing track
type PeerConnection ¶
type PeerConnection struct { ICEServers []webrtc.ICEServer API *webrtc.API Publish bool 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, count int, ) ([]*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) SetupOutgoingTracks ¶
func (co *PeerConnection) SetupOutgoingTracks( videoTrack format.Format, audioTrack format.Format, ) ([]*OutgoingTrack, error)
SetupOutgoingTracks setups outgoing tracks.
func (*PeerConnection) Start ¶
func (co *PeerConnection) Start() error
Start starts the peer connection.
func (*PeerConnection) WaitGatheringDone ¶
func (co *PeerConnection) WaitGatheringDone(ctx context.Context) error
WaitGatheringDone waits until candidate gathering is complete.
func (*PeerConnection) WaitUntilConnected ¶
func (co *PeerConnection) WaitUntilConnected( ctx context.Context, ) error
WaitUntilConnected waits until connection is established.
type TrackWrapper ¶
type TrackWrapper struct {
ClockRat int
}
TrackWrapper provides ClockRate() and PTSEqualsDTS() to WebRTC tracks.
func (TrackWrapper) ClockRate ¶
func (w TrackWrapper) ClockRate() int
ClockRate returns the clock rate.
func (TrackWrapper) PTSEqualsDTS ¶
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) 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.
type WHIPPostOfferResponse ¶
WHIPPostOfferResponse is the response to a post offer.