package streamallocator import ( "github.com/livekit/protocol/livekit" ) // ------------------------------------------------ type StreamState int const ( StreamStateActive StreamState = iota StreamStatePaused ) func (s StreamState) String() string { switch s { case StreamStateActive: return "active" case StreamStatePaused: return "paused" default: return "unknown" } } // ------------------------------------------------ type StreamStateInfo struct { ParticipantID livekit.ParticipantID TrackID livekit.TrackID State StreamState } type StreamStateUpdate struct { StreamStates []*StreamStateInfo } func NewStreamStateUpdate() *StreamStateUpdate { return &StreamStateUpdate{} } func (s *StreamStateUpdate) HandleStreamingChange(isPaused bool, track *Track) { if isPaused { s.StreamStates = append(s.StreamStates, &StreamStateInfo{ ParticipantID: track.PublisherID(), TrackID: track.ID(), State: StreamStatePaused, }) } else { s.StreamStates = append(s.StreamStates, &StreamStateInfo{ ParticipantID: track.PublisherID(), TrackID: track.ID(), State: StreamStateActive, }) } } func (s *StreamStateUpdate) Empty() bool { return len(s.StreamStates) == 0 } // ------------------------------------------------