streamallocator

package
v1.13.7 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: Apache-2.0 Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultStreamAllocatorConfig = StreamAllocatorConfig{
		MinChannelCapacity:               0,
		DisableEstimationUnmanagedTracks: false,

		ProbeMode:       ProbeModePadding,
		ProbeOveragePct: 120,
		ProbeMinBps:     200_000,

		PausedMinWait: 5 * time.Second,
	}
)

Functions

This section is empty.

Types

type AddTrackParams

type AddTrackParams struct {
	Source         livekit.TrackSource
	Priority       uint8
	IsMultiLayered bool
	PublisherID    livekit.ParticipantID
}

type Event

type Event struct {
	*StreamAllocator
	// contains filtered or unexported fields
}

func (Event) String

func (e Event) String() string

type MaxDistanceSorter

type MaxDistanceSorter []*Track

func (MaxDistanceSorter) Len

func (m MaxDistanceSorter) Len() int

func (MaxDistanceSorter) Less

func (m MaxDistanceSorter) Less(i, j int) bool

func (MaxDistanceSorter) Swap

func (m MaxDistanceSorter) Swap(i, j int)

type MinDistanceSorter

type MinDistanceSorter []*Track

func (MinDistanceSorter) Len

func (m MinDistanceSorter) Len() int

func (MinDistanceSorter) Less

func (m MinDistanceSorter) Less(i, j int) bool

func (MinDistanceSorter) Swap

func (m MinDistanceSorter) Swap(i, j int)

type ProbeMode

type ProbeMode string
const (
	ProbeModePadding ProbeMode = "padding"
	ProbeModeMedia   ProbeMode = "media"
)

type StreamAllocator

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

func NewStreamAllocator

func NewStreamAllocator(params StreamAllocatorParams, enabled bool, allowPause bool) *StreamAllocator

func (*StreamAllocator) AddTrack

func (s *StreamAllocator) AddTrack(downTrack *sfu.DownTrack, params AddTrackParams)

func (*StreamAllocator) BWEType

func (s *StreamAllocator) BWEType() bwe.BWEType

func (*StreamAllocator) IsBWEEnabled

func (s *StreamAllocator) IsBWEEnabled(downTrack *sfu.DownTrack) bool

called to check if track should participate in BWE

func (*StreamAllocator) IsSubscribeMutable

func (s *StreamAllocator) IsSubscribeMutable(downTrack *sfu.DownTrack) bool

called to check if track subscription mute can be applied

func (*StreamAllocator) OnAvailableLayersChanged

func (s *StreamAllocator) OnAvailableLayersChanged(downTrack *sfu.DownTrack)

called when feeding track's layer availability changes

func (*StreamAllocator) OnBitrateAvailabilityChanged

func (s *StreamAllocator) OnBitrateAvailabilityChanged(downTrack *sfu.DownTrack)

called when feeding track's bitrate measurement of any layer is available

func (*StreamAllocator) OnCongestionStateChange

func (s *StreamAllocator) OnCongestionStateChange(fromState bwe.CongestionState, toState bwe.CongestionState, estimatedAvailableChannelCapacity int64)

BWEListener implementation

func (*StreamAllocator) OnMaxPublishedSpatialChanged

func (s *StreamAllocator) OnMaxPublishedSpatialChanged(downTrack *sfu.DownTrack)

called when feeding track's max published spatial layer changes

func (*StreamAllocator) OnMaxPublishedTemporalChanged

func (s *StreamAllocator) OnMaxPublishedTemporalChanged(downTrack *sfu.DownTrack)

called when feeding track's max published temporal layer changes

func (*StreamAllocator) OnPacerProbeObserverClusterComplete

func (s *StreamAllocator) OnPacerProbeObserverClusterComplete(probeClusterId ccutils.ProbeClusterId)

called when pacer probe observer observes a cluster completion

func (*StreamAllocator) OnProbeClusterSwitch

func (s *StreamAllocator) OnProbeClusterSwitch(pci ccutils.ProbeClusterInfo)

called when probe cluster changes

func (*StreamAllocator) OnREMB

func (s *StreamAllocator) OnREMB(downTrack *sfu.DownTrack, remb *rtcp.ReceiverEstimatedMaximumBitrate)

called when a new REMB is received (receive side bandwidth estimation)

func (*StreamAllocator) OnResume

func (s *StreamAllocator) OnResume(downTrack *sfu.DownTrack)

called when forwarder resumes a track

func (*StreamAllocator) OnSendProbe

func (s *StreamAllocator) OnSendProbe(bytesToSend int)

called when prober wants to send packet(s)

func (*StreamAllocator) OnStreamStateChange

func (s *StreamAllocator) OnStreamStateChange(f func(update *StreamStateUpdate) error)

func (*StreamAllocator) OnSubscribedLayerChanged

func (s *StreamAllocator) OnSubscribedLayerChanged(downTrack *sfu.DownTrack, layer buffer.VideoLayer)

called when subscribed layer changes (limiting max layer)

func (*StreamAllocator) OnSubscriptionChanged

func (s *StreamAllocator) OnSubscriptionChanged(downTrack *sfu.DownTrack)

called when subscription settings changes (muting/unmuting of track)

func (*StreamAllocator) OnTransportCCFeedback

func (s *StreamAllocator) OnTransportCCFeedback(downTrack *sfu.DownTrack, fb *rtcp.TransportLayerCC)

called when a new transport-cc feedback is received

func (*StreamAllocator) RemoveTrack

func (s *StreamAllocator) RemoveTrack(downTrack *sfu.DownTrack)

func (*StreamAllocator) SetAllowPause

func (s *StreamAllocator) SetAllowPause(allowPause bool)

func (*StreamAllocator) SetChannelCapacity

func (s *StreamAllocator) SetChannelCapacity(channelCapacity int64)

func (*StreamAllocator) SetSendSideBWEInterceptor

func (s *StreamAllocator) SetSendSideBWEInterceptor(sendSideBWEInterceptor cc.BandwidthEstimator)

func (*StreamAllocator) SetTrackPriority

func (s *StreamAllocator) SetTrackPriority(downTrack *sfu.DownTrack, priority uint8)

func (*StreamAllocator) Start

func (s *StreamAllocator) Start()

func (*StreamAllocator) Stop

func (s *StreamAllocator) Stop()

type StreamAllocatorConfig

type StreamAllocatorConfig struct {
	MinChannelCapacity               int64 `yaml:"min_channel_capacity,omitempty"`
	DisableEstimationUnmanagedTracks bool  `yaml:"disable_etimation_unmanaged_tracks,omitempty"`

	ProbeMode       ProbeMode `yaml:"probe_mode,omitempty"`
	ProbeOveragePct int64     `yaml:"probe_overage_pct,omitempty"`
	ProbeMinBps     int64     `yaml:"probe_min_bps,omitempty"`

	PausedMinWait time.Duration `yaml:"paused_min_wait,omitempty"`
}

type StreamAllocatorParams

type StreamAllocatorParams struct {
	Config    StreamAllocatorConfig
	BWE       bwe.BWE
	Pacer     pacer.Pacer
	RTTGetter func() (float64, bool)
	Logger    logger.Logger
}

type StreamState

type StreamState int
const (
	StreamStateInactive StreamState = iota
	StreamStateActive
	StreamStatePaused
)

func (StreamState) String

func (s StreamState) String() string

type StreamStateInfo

type StreamStateInfo struct {
	ParticipantID livekit.ParticipantID
	TrackID       livekit.TrackID
	State         StreamState
}

type StreamStateUpdate

type StreamStateUpdate struct {
	StreamStates []*StreamStateInfo
}

func NewStreamStateUpdate

func NewStreamStateUpdate() *StreamStateUpdate

func (*StreamStateUpdate) Empty

func (s *StreamStateUpdate) Empty() bool

func (*StreamStateUpdate) HandleStreamingChange

func (s *StreamStateUpdate) HandleStreamingChange(track *Track, streamState StreamState)

type Track

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

func NewTrack

func NewTrack(
	downTrack *sfu.DownTrack,
	source livekit.TrackSource,
	isMultiLayered bool,
	publisherID livekit.ParticipantID,
	logger logger.Logger,
) *Track

func (*Track) AllocateNextHigher

func (t *Track) AllocateNextHigher(availableChannelCapacity int64, allowOvershoot bool) (sfu.VideoAllocation, bool)

func (*Track) AllocateOptimal

func (t *Track) AllocateOptimal(allowOvershoot bool, hold bool) sfu.VideoAllocation

func (*Track) BandwidthRequested

func (t *Track) BandwidthRequested() int64

func (*Track) DistanceToDesired

func (t *Track) DistanceToDesired() float64

func (*Track) DownTrack

func (t *Track) DownTrack() *sfu.DownTrack

func (*Track) GetNackDelta

func (t *Track) GetNackDelta() (uint32, uint32)

func (*Track) GetNextHigherTransition

func (t *Track) GetNextHigherTransition(allowOvershoot bool) (sfu.VideoTransition, bool)

func (*Track) ID

func (t *Track) ID() livekit.TrackID

func (*Track) IsDeficient

func (t *Track) IsDeficient() bool

func (*Track) IsManaged

func (t *Track) IsManaged() bool

func (*Track) IsSubscribeMutable

func (t *Track) IsSubscribeMutable() bool

func (*Track) Pause

func (t *Track) Pause() sfu.VideoAllocation

func (*Track) Priority

func (t *Track) Priority() uint8

func (*Track) ProvisionalAllocate

func (t *Track) ProvisionalAllocate(availableChannelCapacity int64, layer buffer.VideoLayer, allowPause bool, allowOvershoot bool) (bool, int64)

func (*Track) ProvisionalAllocateCommit

func (t *Track) ProvisionalAllocateCommit() sfu.VideoAllocation

func (*Track) ProvisionalAllocateGetBestWeightedTransition

func (t *Track) ProvisionalAllocateGetBestWeightedTransition() sfu.VideoTransition

func (*Track) ProvisionalAllocateGetCooperativeTransition

func (t *Track) ProvisionalAllocateGetCooperativeTransition(allowOvershoot bool) sfu.VideoTransition

func (*Track) ProvisionalAllocatePrepare

func (t *Track) ProvisionalAllocatePrepare()

func (*Track) ProvisionalAllocateReset

func (t *Track) ProvisionalAllocateReset()

func (*Track) PublisherID

func (t *Track) PublisherID() livekit.ParticipantID

func (*Track) SetDirty

func (t *Track) SetDirty(isDirty bool) bool

func (*Track) SetMaxLayer

func (t *Track) SetMaxLayer(layer buffer.VideoLayer) bool

func (*Track) SetPriority

func (t *Track) SetPriority(priority uint8) bool

func (*Track) SetStreamState

func (t *Track) SetStreamState(streamState StreamState) bool

func (*Track) WritePaddingRTP

func (t *Track) WritePaddingRTP(bytesToSend int) int

func (*Track) WriteProbePackets

func (t *Track) WriteProbePackets(bytesToSend int) int

type TrackSorter

type TrackSorter []*Track

func (TrackSorter) Len

func (t TrackSorter) Len() int

func (TrackSorter) Less

func (t TrackSorter) Less(i, j int) bool

func (TrackSorter) Swap

func (t TrackSorter) Swap(i, j int)

Jump to

Keyboard shortcuts

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