webrtc

package
v0.0.0-...-8016b3b Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AACTranscodingAvailable

func AACTranscodingAvailable() bool

AACTranscodingAvailable reports whether AAC→PCMU transcoding is available in the current runtime.

func GetActivePeerConnectionCount

func GetActivePeerConnectionCount() int64

GetActivePeerConnectionCount returns the current number of connected WebRTC readers.

func InitializeWebRTCConnection

func InitializeWebRTCConnection(configuration *models.Configuration, communication *models.Communication, mqttClient mqtt.Client, videoBroadcaster *TrackBroadcaster, audioBroadcaster *TrackBroadcaster, handshake models.LiveHDHandshake)

func NewAudioTrack

func NewAudioTrack(streams []packets.Stream) *pionWebRTC.TrackLocalStaticSample

func NewVideoTrack

func NewVideoTrack(streams []packets.Stream) *pionWebRTC.TrackLocalStaticSample

func RegisterCandidates

func RegisterCandidates(key string, candidate models.ReceiveHDCandidatesPayload)

func RegisterDefaultInterceptors

func RegisterDefaultInterceptors(mediaEngine *pionWebRTC.MediaEngine, interceptorRegistry *interceptor.Registry) error

func WriteToTrack

func WriteToTrack(livestreamCursor *packets.QueueCursor, configuration *models.Configuration, communication *models.Communication, mqttClient mqtt.Client, videoBroadcaster *TrackBroadcaster, audioBroadcaster *TrackBroadcaster, rtspClient capture.RTSPClient)

Types

type AACTranscoder

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

AACTranscoder uses an ffmpeg subprocess to convert ADTS AAC to raw PCMU.

func NewAACTranscoder

func NewAACTranscoder() (*AACTranscoder, error)

NewAACTranscoder creates a runtime ffmpeg-based transcoder.

func (*AACTranscoder) Close

func (t *AACTranscoder) Close()

Close stops the ffmpeg subprocess.

func (*AACTranscoder) Transcode

func (t *AACTranscoder) Transcode(adtsData []byte) ([]byte, error)

Transcode writes ADTS AAC to ffmpeg and returns any PCMU bytes produced.

type ConnectionManager

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

ConnectionManager manages WebRTC peer connections in a thread-safe manner

func NewConnectionManager

func NewConnectionManager() *ConnectionManager

NewConnectionManager creates a new connection manager

func (*ConnectionManager) AddPeerConnection

func (cm *ConnectionManager) AddPeerConnection(sessionKey string, wrapper *peerConnectionWrapper)

AddPeerConnection adds a peer connection to the manager

func (*ConnectionManager) CloseCandidateChannel

func (cm *ConnectionManager) CloseCandidateChannel(sessionKey string)

CloseCandidateChannel safely closes and removes a candidate channel

func (*ConnectionManager) CloseExistingPeerConnection

func (cm *ConnectionManager) CloseExistingPeerConnection(sessionKey string) bool

CloseExistingPeerConnection closes and removes any peer connection currently registered under sessionKey. Returns true if one was found. This is used to reset state cleanly when a new request-hd-stream arrives for a session id that the agent thinks is still active (for example after a viewer reload where the previous PC hasn't yet been timed out by ICE).

func (*ConnectionManager) DecrementPeerCount

func (cm *ConnectionManager) DecrementPeerCount() int64

DecrementPeerCount atomically decrements the peer connection count

func (*ConnectionManager) GetOrCreateCandidateChannel

func (cm *ConnectionManager) GetOrCreateCandidateChannel(sessionKey string) chan string

GetOrCreateCandidateChannel gets or creates a candidate channel for a session

func (*ConnectionManager) GetPeerConnectionCount

func (cm *ConnectionManager) GetPeerConnectionCount() int64

GetPeerConnectionCount returns the current count of active peer connections

func (*ConnectionManager) IncrementPeerCount

func (cm *ConnectionManager) IncrementPeerCount() int64

IncrementPeerCount atomically increments the peer connection count

func (*ConnectionManager) QueueCandidate

func (cm *ConnectionManager) QueueCandidate(sessionKey string, candidate string) bool

QueueCandidate safely queues a candidate for a session without racing with channel closure.

func (*ConnectionManager) RemovePeerConnection

func (cm *ConnectionManager) RemovePeerConnection(sessionKey string)

RemovePeerConnection removes a peer connection from the manager

type TrackBroadcaster

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

TrackBroadcaster fans out media samples to multiple peer-specific tracks without blocking. Each peer gets its own TrackLocalStaticSample and a goroutine that drains samples independently, so a slow/congested peer cannot stall the others.

func NewAudioBroadcaster

func NewAudioBroadcaster(streams []packets.Stream) *TrackBroadcaster

func NewTrackBroadcaster

func NewTrackBroadcaster(mimeType string, id string, streamID string) *TrackBroadcaster

NewTrackBroadcaster creates a new broadcaster for either video or audio.

func NewVideoBroadcaster

func NewVideoBroadcaster(streams []packets.Stream) *TrackBroadcaster

func (*TrackBroadcaster) AddPeer

func (b *TrackBroadcaster) AddPeer(sessionKey string) (*pionWebRTC.TrackLocalStaticSample, error)

AddPeer creates a new per-peer track and starts a writer goroutine. Returns the track to be added to the PeerConnection via AddTrack().

func (*TrackBroadcaster) Close

func (b *TrackBroadcaster) Close()

Close removes all peers and stops all writer goroutines.

func (*TrackBroadcaster) PeerCount

func (b *TrackBroadcaster) PeerCount() int

PeerCount returns the current number of connected peers.

func (*TrackBroadcaster) RemovePeer

func (b *TrackBroadcaster) RemovePeer(sessionKey string)

RemovePeer stops the writer goroutine and removes the peer.

func (*TrackBroadcaster) WriteSample

func (b *TrackBroadcaster) WriteSample(sample pionMedia.Sample)

WriteSample fans out a sample to all connected peers without blocking. If a peer's buffer is full (slow consumer), the sample is dropped for that peer only — other peers are unaffected.

type WebRTC

type WebRTC struct {
	Name                  string
	StunServers           []string
	TurnServers           []string
	TurnServersUsername   string
	TurnServersCredential string
	Timer                 *time.Timer
	PacketsCount          chan int
}

func CreateWebRTC

func CreateWebRTC(name string, stunServers []string, turnServers []string, turnServersUsername string, turnServersCredential string) *WebRTC

func (WebRTC) CreateOffer

func (w WebRTC) CreateOffer(sd []byte) pionWebRTC.SessionDescription

func (WebRTC) DecodeSessionDescription

func (w WebRTC) DecodeSessionDescription(data string) ([]byte, error)

Jump to

Keyboard shortcuts

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