Documentation
¶
Index ¶
- type ArtNetConfig
- type ArtNetListener
- type ArtNetListenerConfig
- type ArtNetTransport
- type FrameHandler
- type IDFromFilename
- type Library
- func (l *Library) Get(id int) (*ShowInfo, bool)
- func (l *Library) GetByName(name string) (*ShowInfo, bool)
- func (l *Library) IsShowPlaying(id int) bool
- func (l *Library) List() []ShowInfo
- func (l *Library) Play(id int) (ShowHandle, error)
- func (l *Library) RunningShows() map[int]*PlayInfo
- func (l *Library) Stop(id int) (wasPlaying bool)
- func (l *Library) StopAll()
- type LibraryConfig
- type LibraryEvent
- type LibraryEventReason
- type LibraryEventType
- type Listener
- type MergeMode
- type PlayInfo
- type Player
- func (e *Player) Close() error
- func (e *Player) IsPlaying(h ShowHandle) bool
- func (e *Player) ListPlaying() []PlayingShow
- func (e *Player) OnShowExited(cb func(ShowHandle))
- func (e *Player) Play(ctx context.Context, show *olashow.OlaShow) ShowHandle
- func (e *Player) Stop(h ShowHandle)
- func (e *Player) StopAll()
- type PlayerConfig
- type PlayingShow
- type Recorder
- type ShowHandle
- type ShowInfo
- type Transport
- type Universe
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArtNetConfig ¶
type ArtNetConfig struct {
// DstIP is the destination IP for UDP unicast Art-Net traffic.
DstIP net.IP
// SrcIP is the optional local bind IP (nil = OS default).
SrcIP net.IP
// SubUni is the Art-Net SubUni (0..255) field used in ArtDMX packets.
SubUni uint8
// Net is the Art-Net Net (0..127) field used in ArtDMX packets.
Net uint8
}
ArtNetConfig configures an ArtNetTransport.
The transport sends Art-Net ArtDMX packets via UDP unicast to DstIP:6454. Net and SubUni select the target Art-Net universe (as defined by the Art-Net specification).
If SrcIP is provided, the UDP socket is bound to SrcIP:6454 (useful on multi-homed hosts). If SrcIP is nil, the OS default routing and an ephemeral source port are used.
type ArtNetListener ¶
type ArtNetListener struct {
// contains filtered or unexported fields
}
ArtNetListener listens for Art-Net ArtDMX packets over UDP and emits frames.
func NewArtNetListener ¶
func NewArtNetListener(cfg ArtNetListenerConfig) (*ArtNetListener, error)
NewArtNetListener binds UDP/6454 and returns an ArtNetListener.
func (*ArtNetListener) Run ¶
func (l *ArtNetListener) Run(ctx context.Context, h FrameHandler) error
Run reads ArtDMX packets until ctx is done and calls h for each received packet.
type ArtNetListenerConfig ¶
type ArtNetListenerConfig struct {
// BindIP is the optional local bind IP. Nil means all interfaces.
BindIP net.IP
// ReadBuffer sets the UDP socket read buffer (0 = OS default).
ReadBuffer int
}
ArtNetListenerConfig configures ArtNetListener.
type ArtNetTransport ¶
type ArtNetTransport struct {
// contains filtered or unexported fields
}
ArtNetTransport sends DMX frames as Art-Net ArtDMX packets over UDP.
func NewArtNetTransport ¶
func NewArtNetTransport(cfg *ArtNetConfig) (*ArtNetTransport, error)
NewArtNetTransport creates a UDP unicast Art-Net sender.
The returned transport maintains an internal ArtDMX sequence counter that increments on each Send. Sequence 0 is skipped (wraps from 255 back to 1).
func (*ArtNetTransport) Close ¶
func (t *ArtNetTransport) Close() error
Close closes the underlying UDP socket.
func (*ArtNetTransport) Send ¶
func (t *ArtNetTransport) Send(dmx [512]byte) error
Send encodes the given DMX frame as an Art-Net ArtDMX packet and sends it via UDP.
type FrameHandler ¶
FrameHandler is a transport-agnostic callback for timestamped DMX frames.
type IDFromFilename ¶
IDFromFilename extracts a show ID and a default name from a filename.
It must return ok=false for filenames that are not shows.
type Library ¶
type Library struct {
// contains filtered or unexported fields
}
Library loads OLA show files from a folder and controls playback via Player.
func NewLibrary ¶
func NewLibrary(player *Player, cfg *LibraryConfig) (*Library, error)
NewLibrary loads shows from cfg.Path and wires the library to player.
func (*Library) IsShowPlaying ¶
IsShowPlaying reports whether the given show ID is currently playing.
func (*Library) Play ¶
func (l *Library) Play(id int) (ShowHandle, error)
Play starts playing a show by ID.
If the show is already running, Play stops the current instance and starts it again.
func (*Library) RunningShows ¶
RunningShows currently running shows, returns a map show ID -> PlayInfo.
type LibraryConfig ¶
type LibraryConfig struct {
// Path is the folder containing show files.
Path string
// IDFromFilename extracts (id, nameFromFile) from the filename.
// If nil, it defaults to parsing "<id>.<name>.show".
IDFromFilename IDFromFilename
// OnEvent is an optional callback invoked when the library state changes.
// It is intended to be set once during initialization.
OnEvent func(LibraryEvent)
}
LibraryConfig configures a Library instance.
type LibraryEvent ¶
type LibraryEvent struct {
// Type is the event category (currently only LibraryStateChanged).
Type LibraryEventType
// At is the time the event was created.
At time.Time
// Reason explains why the state changed.
Reason LibraryEventReason
// Show is the show related to this event when applicable.
// It is nil for events that don't target a single show (e.g. stopall).
Show *ShowInfo
// Running is a snapshot of all currently running shows after the change.
Running []PlayInfo
}
LibraryEvent is emitted when the library state changes.
type LibraryEventReason ¶
type LibraryEventReason string
LibraryEventReason explains why the state changed.
const ( // PlayLibraryEvent a show started PlayLibraryEvent LibraryEventReason = "play" // RestartLibraryEvent a show was restarted RestartLibraryEvent LibraryEventReason = "restart" // StopLibraryEvent a show was stopped StopLibraryEvent LibraryEventReason = "stop" // StopAllLibraryEvent all shows were stopped StopAllLibraryEvent LibraryEventReason = "stopall" // FinishedLibraryEvent a show ended naturally FinishedLibraryEvent LibraryEventReason = "finished" )
type LibraryEventType ¶
type LibraryEventType int
LibraryEventType identifies the kind of library event.
const ( // LibraryStateChanged is emitted when the running set changes. LibraryStateChanged LibraryEventType = iota )
type Listener ¶
type Listener interface {
Run(ctx context.Context, h FrameHandler) error
Close() error
}
Listener is a source of timestamped DMX frames. Implementations should stop when ctx is done and return nil in that case.
type MergeMode ¶
type MergeMode int
MergeMode defines how multiple shows are combined into a single DMX output.
type PlayInfo ¶
type PlayInfo struct {
PlayingShow
// HandleID is the player handle ID for this run.
HandleID int
// ShowID is the numeric show ID.
ShowID int
}
PlayInfo describes a running show instance.
type Player ¶
type Player struct {
// contains filtered or unexported fields
}
Player mixes multiple shows and outputs merged DMX through a Transport.
func NewPlayer ¶
func NewPlayer(tx Transport, cfg *PlayerConfig) *Player
NewPlayer creates a Player that merges concurrent shows and sends the result through tx.
func (*Player) Close ¶
Close stops all running shows, waits for internal goroutines to exit, and closes the underlying Transport.
func (*Player) IsPlaying ¶
func (e *Player) IsPlaying(h ShowHandle) bool
IsPlaying reports whether the show identified by h is currently running.
func (*Player) ListPlaying ¶
func (e *Player) ListPlaying() []PlayingShow
ListPlaying returns a snapshot of currently running shows.
The returned slice is a point-in-time view; shows may start/stop concurrently.
func (*Player) OnShowExited ¶
func (e *Player) OnShowExited(cb func(ShowHandle))
OnShowExited sets a callback invoked when a show goroutine exits and is removed from the player or ctx cancel).
func (*Player) Play ¶
Play starts playing show until it finishes, ctx is cancelled, or Stop is called.
The OLA frame Universe field is ignored. All frames contribute to the single merged output routed by the Transport.
If show.Exclusive is true, the player stops all other running shows before starting playback of this one.
func (*Player) Stop ¶
func (e *Player) Stop(h ShowHandle)
Stop requests the show identified by h to stop.
Stop is asynchronous: it signals the show goroutine, which will exit shortly after (immediately for zero-delay frames, or after the current frame delay). Calling Stop for an unknown handle is a no-op.
type PlayerConfig ¶
type PlayerConfig struct {
// Mode selects the merge method used when multiple shows are playing.
Mode MergeMode
// FlushInterval is the period between output frames.
// If zero, it defaults to 44 Hz (time.Second/44).
FlushInterval time.Duration
}
PlayerConfig configures a Player/Engine instance.
Mode selects how multiple concurrent shows are merged (HTP or LTP). FlushInterval controls the output refresh period.
type PlayingShow ¶
PlayingShow describes a currently running show.
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder consumes DMX frames from a Listener and writes an OLA Show to an io.Writer.
It records using the same timing strategy as OLA's ola_recorder:
- Each received frame becomes one OLA show frame.
- The delay line is written when the *next* frame arrives (ms, truncated).
- The output ends with a frame line (no trailing delay line).
func NewRecorder ¶
NewRecorder creates a Recorder bound to a listener.
type ShowHandle ¶
type ShowHandle struct {
// contains filtered or unexported fields
}
func (ShowHandle) ID ¶
func (h ShowHandle) ID() uint64
ID returns the unique identifier of the handle.
type ShowInfo ¶
type ShowInfo struct {
olashow.OlaShow
// ID is the numeric identifier extracted from the filename.
ID int
// FileName is the show filename (e.g. "001.alpha.show").
FileName string
// Playing is the current runtime information, if the show is running.
Playing *PlayInfo
// contains filtered or unexported fields
}
ShowInfo describes a show discovered on disk plus its runtime state.
type Universe ¶
type Universe struct {
// contains filtered or unexported fields
}
Universe stores the latest DMX buffer per source and can merge them on demand.
func NewUniverse ¶
NewUniverse creates a Universe using the given merge mode.
func (*Universe) Apply ¶
Apply stores the latest DMX for showID. seq must be monotonic across all shows (engine-global).
func (*Universe) SourcesCount ¶
SourcesCount returns the number of sources (useful for tests/metrics).
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
api
command
cmd/server/main.go
|
cmd/server/main.go |
|
ola_player
command
|
|
|
ola_recorder
command
|
|