Documentation
¶
Overview ¶
Package forwarding adapts mature RTP forwarding components without owning room authority, capture or a second congestion controller.
Index ¶
- func PublicationRID(layer, count int) string
- type EgressStats
- type EncodedSource
- type LayerFormat
- type Output
- func (output *Output) BeginFrame()
- func (output *Output) Close()
- func (output *Output) ReceiverRestart(receiver sfu.TrackReceiver)
- func (output *Output) Reconcile()
- func (output *Output) Resync()
- func (output *Output) SetBudget(budget int64)
- func (output *Output) SetMaxSpatialLayer(layer int32)
- func (output *Output) SetMaxTemporalLayer(layer int32)
- func (output *Output) State() Snapshot
- func (output *Output) UpTrackBitrateAvailabilityChange()
- func (output *Output) UpTrackBitrateReport(layers []int32, rates sfu.Bitrates)
- func (output *Output) UpTrackLayersChange()
- func (output *Output) UpTrackMaxPublishedLayerChange(layer int32)
- func (output *Output) UpTrackMaxTemporalLayerSeenChange(layer int32)
- func (output *Output) WriteRTP(packet *buffer.ExtPacket, layer int32) int32
- type Publication
- func (publication *Publication) Close() error
- func (publication *Publication) Counters() PublicationCounters
- func (publication *Publication) CurrentSource() *Source
- func (publication *Publication) LowestLayerBudget() int64
- func (*Publication) OnBindAndConnected()
- func (*Publication) OnCodecNegotiated(webrtc.RTPCodecCapability)
- func (*Publication) OnDownTrackClose(bool)
- func (*Publication) OnMaxSubscribedLayerChanged(int32)
- func (publication *Publication) OnRttUpdate(rtt uint32)
- func (publication *Publication) OnStatsUpdate(stats *livekit.AnalyticsStat)
- func (*Publication) OnStreamStarted(time.Duration)
- func (publication *Publication) ReplaceSource(next *Source) error
- func (publication *Publication) RequiredActiveCount() int
- func (publication *Publication) SetActiveCount(count int) error
- func (publication *Publication) SetAudioBitrate(bitrate uint32)
- func (publication *Publication) SetConnected() error
- func (publication *Publication) VideoBudget() int64
- type PublicationCounters
- type Snapshot
- type Source
- func (source *Source) BindLayer(layer int, ssrc uint32, parameters webrtc.RTPParameters) error
- func (source *Source) Close()
- func (source *Source) RateControlled(layer int32) bool
- func (source *Source) ReferenceTime(layer int, timestamp uint32) (time.Time, bool)
- func (source *Source) SenderReport(layer int, report *rtcp.SenderReport) error
- func (source *Source) SetCorrelation(layer int, correlation *livekit.RTCPSenderReportState) error
- func (source *Source) SetLowestLayerRateControlled(controlled bool)
- func (source *Source) TrackInfo() *livekit.TrackInfo
- func (source *Source) UpdateDimensions(layer int, width, height uint32) error
- func (source *Source) UpdateFormats(formats []LayerFormat) error
- func (source *Source) WriteRTP(layer int, packet *rtp.Packet) error
- type SourceOptions
- type Transport
- func (*Transport) BWEType() bwe.BWEType
- func (transport *Transport) Close() error
- func (transport *Transport) CurrentSource() *Source
- func (transport *Transport) Egress() EgressStats
- func (*Transport) IsBWEEnabled(*sfu.DownTrack) bool
- func (*Transport) IsSubscribeMutable(*sfu.DownTrack) bool
- func (*Transport) OnAvailableLayersChanged(*sfu.DownTrack)
- func (*Transport) OnBindAndConnected()
- func (*Transport) OnBitrateAvailabilityChanged(*sfu.DownTrack)
- func (*Transport) OnCodecNegotiated(webrtc.RTPCodecCapability)
- func (transport *Transport) OnCongestionStateChange(_, _ bwe.CongestionState, capacity int64)
- func (*Transport) OnDownTrackClose(bool)
- func (*Transport) OnMaxPublishedSpatialChanged(*sfu.DownTrack)
- func (*Transport) OnMaxPublishedTemporalChanged(*sfu.DownTrack)
- func (*Transport) OnMaxSubscribedLayerChanged(int32)
- func (transport *Transport) OnPacerProbeObserverClusterComplete(id ccutils.ProbeClusterId)
- func (*Transport) OnProbeClusterSwitch(ccutils.ProbeClusterInfo)
- func (*Transport) OnREMB(*sfu.DownTrack, *rtcp.ReceiverEstimatedMaximumBitrate)
- func (*Transport) OnResume(*sfu.DownTrack)
- func (transport *Transport) OnRttUpdate(rtt uint32)
- func (transport *Transport) OnSendProbe(bytesToSend int)
- func (transport *Transport) OnStatsUpdate(stats *livekit.AnalyticsStat)
- func (*Transport) OnStreamStarted(time.Duration)
- func (*Transport) OnSubscribedLayerChanged(*sfu.DownTrack, buffer.VideoLayer)
- func (transport *Transport) OnSubscriptionChanged(*sfu.DownTrack)
- func (transport *Transport) OnTransportCCFeedback(_ *sfu.DownTrack, packet *rtcp.TransportLayerCC)
- func (transport *Transport) ReplaceSource(next *Source) error
- func (transport *Transport) RequiredActiveCount() int
- func (transport *Transport) SetAudioBitrate(bitrate uint32)
- func (transport *Transport) SetConnected() error
- func (transport *Transport) TargetBitrate() (int, bool)
- type TransportOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PublicationRID ¶
Types ¶
type EgressStats ¶
type EgressStats struct {
// Drops include canceled probe padding and queued packets retired at close.
Packets, RTPBytes, DroppedPackets uint64
}
type EncodedSource ¶
type EncodedSource struct {
*Source
// contains filtered or unexported fields
}
EncodedSource feeds complete codec outputs into the same forwarding buffers used for received RTP. Its capture/decoder owner serializes calls and fences replacement input; no network, capture or wall-clock scheduler lives here.
func NewEncodedSource ¶
func NewEncodedSource(options SourceOptions) (*EncodedSource, error)
func (*EncodedSource) BeginFrame ¶
func (*EncodedSource) BeginGeneration ¶
func (input *EncodedSource) BeginGeneration()
func (*EncodedSource) CodecBudget ¶
func (input *EncodedSource) CodecBudget(layer int, rtpBudget int64) int64
CodecBudget converts source-RTP allocation units to encoder AU-payload units. Actual packetization includes codec descriptors; bitrate comes from the existing tracker window so dormant time does not dilute the overhead rate. Downstream extensions and SRTP/UDP overhead are outside this source measure.
func (*EncodedSource) WriteFrame ¶
func (input *EncodedSource) WriteFrame(layer int, frame encoded.Frame) error
type LayerFormat ¶
type LayerFormat struct {
Width, Height, Bitrate uint32
}
type Output ¶
Output owns allocation for one video stream on one child connection. Its physical owner closes it; budget changes and upstream events do not create another scheduler. Do not attach a StreamAllocator to the same DownTrack.
func (*Output) BeginFrame ¶
func (output *Output) BeginFrame()
BeginFrame fences a controlled Native input before any of its outputs arrive. Raw RTP has no such boundary and keeps DownTrack's ordinary switching path.
func (*Output) ReceiverRestart ¶
func (output *Output) ReceiverRestart(receiver sfu.TrackReceiver)
func (*Output) SetMaxSpatialLayer ¶
func (*Output) SetMaxTemporalLayer ¶
func (*Output) UpTrackBitrateAvailabilityChange ¶
func (output *Output) UpTrackBitrateAvailabilityChange()
func (*Output) UpTrackBitrateReport ¶
func (*Output) UpTrackLayersChange ¶
func (output *Output) UpTrackLayersChange()
func (*Output) UpTrackMaxPublishedLayerChange ¶
func (*Output) UpTrackMaxTemporalLayerSeenChange ¶
type Publication ¶
type Publication struct {
PC *webrtc.PeerConnection
// contains filtered or unexported fields
}
Publication sends existing representations over one simulcast connection. LiveKit's allocator owns all track allocations and probes on the shared BWE.
func NewPublication ¶
func NewPublication(options TransportOptions) (_ *Publication, err error)
func (*Publication) Close ¶
func (publication *Publication) Close() error
func (*Publication) Counters ¶
func (publication *Publication) Counters() PublicationCounters
func (*Publication) CurrentSource ¶
func (publication *Publication) CurrentSource() *Source
func (*Publication) LowestLayerBudget ¶
func (publication *Publication) LowestLayerBudget() int64
func (*Publication) OnBindAndConnected ¶
func (*Publication) OnBindAndConnected()
func (*Publication) OnCodecNegotiated ¶
func (*Publication) OnCodecNegotiated(webrtc.RTPCodecCapability)
func (*Publication) OnDownTrackClose ¶
func (*Publication) OnDownTrackClose(bool)
func (*Publication) OnMaxSubscribedLayerChanged ¶
func (*Publication) OnMaxSubscribedLayerChanged(int32)
func (*Publication) OnRttUpdate ¶
func (publication *Publication) OnRttUpdate(rtt uint32)
func (*Publication) OnStatsUpdate ¶
func (publication *Publication) OnStatsUpdate(stats *livekit.AnalyticsStat)
func (*Publication) OnStreamStarted ¶
func (*Publication) OnStreamStarted(time.Duration)
func (*Publication) ReplaceSource ¶
func (publication *Publication) ReplaceSource(next *Source) error
ReplaceSource keeps every RID, allocator, counter and sender on this PC.
func (*Publication) RequiredActiveCount ¶
func (publication *Publication) RequiredActiveCount() int
func (*Publication) SetActiveCount ¶
func (publication *Publication) SetActiveCount(count int) error
func (*Publication) SetAudioBitrate ¶
func (publication *Publication) SetAudioBitrate(bitrate uint32)
func (*Publication) SetConnected ¶
func (publication *Publication) SetConnected() error
func (*Publication) VideoBudget ¶
func (publication *Publication) VideoBudget() int64
type PublicationCounters ¶
type Snapshot ¶
type Snapshot struct {
Prepare, Target, Requested, Current int32
Paused bool
// VideoBudget is the current connection estimate after audio reservation.
// It is codec input, not a claim that this bitrate is available or delivered.
VideoBudget int64
}
Snapshot is read by the parent at its input-frame boundary. Current means accepted for forwarding, not remotely decoded. Prepare admits codec work, not network delivery, from the latest supplied budget (initial or observed). Its caller gates observed-only decisions with Transport.TargetBitrate. -1 means no selected layer.
type Source ¶
type Source struct {
*sfu.ReceiverBase
// contains filtered or unexported fields
}
Source owns finite RTP layers and their mature forwarding buffers. The caller owns input generations, codec clocks and PeerConnections. Feedback callbacks run without Source's mutex and may retire the source.
func NewSource ¶
func NewSource(options SourceOptions) (*Source, error)
func (*Source) BindLayer ¶
BindLayer installs a single source identity. A different SSRC requires the caller's source-generation replacement, not silent buffer reuse.
func (*Source) RateControlled ¶
func (*Source) ReferenceTime ¶
ReferenceTime keeps derived outputs on the received source's RTP/NTP clock. The bounded input history makes the nearest 32-bit timestamp delta unambiguous.
func (*Source) SenderReport ¶
func (source *Source) SenderReport(layer int, report *rtcp.SenderReport) error
func (*Source) SetCorrelation ¶
func (source *Source) SetCorrelation(layer int, correlation *livekit.RTCPSenderReportState) error
SetCorrelation receives the local source owner's RTP/NTP mapping unchanged. The layer must already have received RTP; the media core owns report ordering.
func (*Source) SetLowestLayerRateControlled ¶
The live codec owner sets this after startup and clears it at retirement.
func (*Source) UpdateDimensions ¶
UpdateDimensions publishes actual encoder dimensions without UpdateTrackInfo's mute propagation, which resets every active layer's tracker and bitrate.
func (*Source) UpdateFormats ¶
func (source *Source) UpdateFormats(formats []LayerFormat) error
UpdateFormats changes one source owner's declared layer metadata without replacing its buffers or packet identities. Zero values remain unknown. The caller serializes updates with its capture/source generation changes.
type SourceOptions ¶
type SourceOptions struct {
ID, StreamID string
Codec webrtc.RTPCodecParameters
Formats []LayerFormat
HeaderExtensions []webrtc.RTPHeaderExtensionParameter
MaxPackets int
OnRTCP func(layer int, packets []rtcp.Packet)
}
type Transport ¶
type Transport struct {
PC *webrtc.PeerConnection
Output *Output
VideoSender *webrtc.RTPSender
AudioSender *webrtc.RTPSender
// contains filtered or unexported fields
}
Transport is outgoing-only. Its caller owns signaling, ICE events and the shared UDP mux. Video RTCP is callback-driven; never read VideoSender's RTCP.
func NewTransport ¶
func NewTransport(options TransportOptions) (_ *Transport, err error)
func (*Transport) CurrentSource ¶
func (*Transport) Egress ¶
func (transport *Transport) Egress() EgressStats
Egress counts successful RTP writes, including headers but excluding SRTP/UDP overhead. It is local delivery to Pion, not proof of remote receipt or decode.
func (*Transport) OnAvailableLayersChanged ¶
func (*Transport) OnBindAndConnected ¶
func (*Transport) OnBindAndConnected()
func (*Transport) OnBitrateAvailabilityChanged ¶
func (*Transport) OnCodecNegotiated ¶
func (*Transport) OnCodecNegotiated(webrtc.RTPCodecCapability)
func (*Transport) OnCongestionStateChange ¶
func (transport *Transport) OnCongestionStateChange(_, _ bwe.CongestionState, capacity int64)
HandleTWCCFeedback invokes this synchronously under the transport's event lock. Store the framework result without reentering that lock.
func (*Transport) OnDownTrackClose ¶
func (*Transport) OnMaxPublishedSpatialChanged ¶
func (*Transport) OnMaxPublishedTemporalChanged ¶
func (*Transport) OnMaxSubscribedLayerChanged ¶
func (*Transport) OnPacerProbeObserverClusterComplete ¶
func (transport *Transport) OnPacerProbeObserverClusterComplete(id ccutils.ProbeClusterId)
func (*Transport) OnProbeClusterSwitch ¶
func (*Transport) OnProbeClusterSwitch(ccutils.ProbeClusterInfo)
AddCluster returns the exact cluster synchronously. Initializing it there avoids reentering the Prober while its own cluster-start mutex is held.
func (*Transport) OnREMB ¶
func (*Transport) OnREMB(*sfu.DownTrack, *rtcp.ReceiverEstimatedMaximumBitrate)
func (*Transport) OnRttUpdate ¶
func (*Transport) OnSendProbe ¶
func (*Transport) OnStatsUpdate ¶
func (transport *Transport) OnStatsUpdate(stats *livekit.AnalyticsStat)
func (*Transport) OnStreamStarted ¶
func (*Transport) OnSubscribedLayerChanged ¶
func (*Transport) OnSubscribedLayerChanged(*sfu.DownTrack, buffer.VideoLayer)
func (*Transport) OnSubscriptionChanged ¶
func (*Transport) OnTransportCCFeedback ¶
func (transport *Transport) OnTransportCCFeedback(_ *sfu.DownTrack, packet *rtcp.TransportLayerCC)
LiveKit delivers feedback without a ReadRTCP loop on its callback reader.
func (*Transport) ReplaceSource ¶
ReplaceSource retains the connection and its congestion state. The caller prepares recovery in next and serializes group lifetime with this handoff.
func (*Transport) RequiredActiveCount ¶
func (*Transport) SetAudioBitrate ¶
SetAudioBitrate reserves the current audio owner's contribution to this PC's shared estimate. Zero means no audio demand; the transport invents no profile.
func (*Transport) SetConnected ¶
func (*Transport) TargetBitrate ¶
type TransportOptions ¶
type TransportOptions struct {
Source *Source
Settings webrtc.SettingEngine
ConnectionID string
InitialBitrate int
Audio webrtc.TrackLocal
// OnDemandChanged must only signal its owner without blocking or reentering
// Transport. Callers can coalesce signals in their existing bounded owner.
OnDemandChanged func()
}