@@ -168,7 +168,7 @@ type StreamAllocator struct {
|
||||
|
||||
state streamAllocatorState
|
||||
|
||||
eventsQueue *utils.OpsQueue
|
||||
eventsQueue *utils.TypedOpsQueue[Event]
|
||||
|
||||
isStopped atomic.Bool
|
||||
}
|
||||
@@ -182,7 +182,7 @@ func NewStreamAllocator(params StreamAllocatorParams) *StreamAllocator {
|
||||
}),
|
||||
// STREAM-ALLOCATOR-DATA rateMonitor: NewRateMonitor(),
|
||||
videoTracks: make(map[livekit.TrackID]*Track),
|
||||
eventsQueue: utils.NewOpsQueue(utils.OpsQueueParams{
|
||||
eventsQueue: utils.NewTypedOpsQueue[Event](utils.OpsQueueParams{
|
||||
Name: "stream-allocator",
|
||||
MinSize: 64,
|
||||
Logger: params.Logger,
|
||||
@@ -559,9 +559,7 @@ func (s *StreamAllocator) maybePostEventAllocateTrack(downTrack *sfu.DownTrack)
|
||||
}
|
||||
|
||||
func (s *StreamAllocator) postEvent(event Event) {
|
||||
s.eventsQueue.Enqueue(func() {
|
||||
s.handleEvent(&event)
|
||||
})
|
||||
s.eventsQueue.Enqueue(s.handleEvent, event)
|
||||
}
|
||||
|
||||
func (s *StreamAllocator) ping() {
|
||||
@@ -580,7 +578,7 @@ func (s *StreamAllocator) ping() {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *StreamAllocator) handleEvent(event *Event) {
|
||||
func (s *StreamAllocator) handleEvent(event Event) {
|
||||
switch event.Signal {
|
||||
case streamAllocatorSignalAllocateTrack:
|
||||
s.handleSignalAllocateTrack(event)
|
||||
@@ -611,7 +609,7 @@ func (s *StreamAllocator) handleEvent(event *Event) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *StreamAllocator) handleSignalAllocateTrack(event *Event) {
|
||||
func (s *StreamAllocator) handleSignalAllocateTrack(event Event) {
|
||||
s.videoTracksMu.Lock()
|
||||
track := s.videoTracks[event.TrackID]
|
||||
if track != nil {
|
||||
@@ -624,7 +622,7 @@ func (s *StreamAllocator) handleSignalAllocateTrack(event *Event) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *StreamAllocator) handleSignalAllocateAllTracks(event *Event) {
|
||||
func (s *StreamAllocator) handleSignalAllocateAllTracks(Event) {
|
||||
s.videoTracksMu.Lock()
|
||||
s.isAllocateAllPending = false
|
||||
s.videoTracksMu.Unlock()
|
||||
@@ -634,11 +632,11 @@ func (s *StreamAllocator) handleSignalAllocateAllTracks(event *Event) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *StreamAllocator) handleSignalAdjustState(event *Event) {
|
||||
func (s *StreamAllocator) handleSignalAdjustState(Event) {
|
||||
s.adjustState()
|
||||
}
|
||||
|
||||
func (s *StreamAllocator) handleSignalEstimate(event *Event) {
|
||||
func (s *StreamAllocator) handleSignalEstimate(event Event) {
|
||||
receivedEstimate, _ := event.Data.(int64)
|
||||
s.lastReceivedEstimate = receivedEstimate
|
||||
// s.monitorRate(receivedEstimate)
|
||||
@@ -651,7 +649,7 @@ func (s *StreamAllocator) handleSignalEstimate(event *Event) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *StreamAllocator) handleSignalPeriodicPing(event *Event) {
|
||||
func (s *StreamAllocator) handleSignalPeriodicPing(Event) {
|
||||
// finalize probe if necessary
|
||||
trend, _ := s.channelObserver.GetTrend()
|
||||
isHandled, isNotFailing, isGoalReached := s.probeController.MaybeFinalizeProbe(
|
||||
@@ -671,7 +669,7 @@ func (s *StreamAllocator) handleSignalPeriodicPing(event *Event) {
|
||||
// s.updateTracksHistory()
|
||||
}
|
||||
|
||||
func (s *StreamAllocator) handleSignalSendProbe(event *Event) {
|
||||
func (s *StreamAllocator) handleSignalSendProbe(event Event) {
|
||||
bytesToSend := event.Data.(int)
|
||||
if bytesToSend <= 0 {
|
||||
return
|
||||
@@ -692,12 +690,12 @@ func (s *StreamAllocator) handleSignalSendProbe(event *Event) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *StreamAllocator) handleSignalProbeClusterDone(event *Event) {
|
||||
func (s *StreamAllocator) handleSignalProbeClusterDone(event Event) {
|
||||
info, _ := event.Data.(ProbeClusterInfo)
|
||||
s.probeController.ProbeClusterDone(info)
|
||||
}
|
||||
|
||||
func (s *StreamAllocator) handleSignalResume(event *Event) {
|
||||
func (s *StreamAllocator) handleSignalResume(event Event) {
|
||||
s.videoTracksMu.Lock()
|
||||
track := s.videoTracks[event.TrackID]
|
||||
s.videoTracksMu.Unlock()
|
||||
@@ -711,11 +709,11 @@ func (s *StreamAllocator) handleSignalResume(event *Event) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *StreamAllocator) handleSignalSetAllowPause(event *Event) {
|
||||
func (s *StreamAllocator) handleSignalSetAllowPause(event Event) {
|
||||
s.allowPause = event.Data.(bool)
|
||||
}
|
||||
|
||||
func (s *StreamAllocator) handleSignalSetChannelCapacity(event *Event) {
|
||||
func (s *StreamAllocator) handleSignalSetChannelCapacity(event Event) {
|
||||
s.overriddenChannelCapacity = event.Data.(int64)
|
||||
if s.overriddenChannelCapacity > 0 {
|
||||
s.params.Logger.Infow("allocating on override channel capacity", "override", s.overriddenChannelCapacity)
|
||||
@@ -726,7 +724,7 @@ func (s *StreamAllocator) handleSignalSetChannelCapacity(event *Event) {
|
||||
}
|
||||
|
||||
/* STREAM-ALLOCATOR-DATA
|
||||
func (s *StreamAllocator) handleSignalNACK(event *Event) {
|
||||
func (s *StreamAllocator) handleSignalNACK(event Event) {
|
||||
nackInfos := event.Data.([]sfu.NackInfo)
|
||||
|
||||
s.videoTracksMu.Lock()
|
||||
@@ -738,7 +736,7 @@ func (s *StreamAllocator) handleSignalNACK(event *Event) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *StreamAllocator) handleSignalRTCPReceiverReport(event *Event) {
|
||||
func (s *StreamAllocator) handleSignalRTCPReceiverReport(event Event) {
|
||||
rr := event.Data.(rtcp.ReceptionReport)
|
||||
|
||||
s.videoTracksMu.Lock()
|
||||
|
||||
Reference in New Issue
Block a user