Documentation
¶
Overview ¶
Package onair owns owner looks, assets, reels and background master clips.
Index ¶
- Constants
- Variables
- func BackupAssets(ctx context.Context, db *sql.DB) ([]string, error)
- func BoundaryDeadline(ctx context.Context) (time.Time, bool)
- func ServeFont(w http.ResponseWriter, r *http.Request)
- func ServeSystemScreens(w http.ResponseWriter, r *http.Request)
- func WithBoundaryDeadline(ctx context.Context, at time.Time) context.Context
- type Asset
- type AssetKindTotal
- type AssetPassStats
- type Brand
- type Chatter
- type ClipUploadMetadata
- type ImportJob
- type ImportRequest
- type LibraryAsset
- type LibraryUse
- type LinkClipInput
- type Look
- type Member
- type Options
- type Pack
- type PluginContentCache
- type PluginSegment
- type Progress
- type Queryer
- type Reel
- type ReelClip
- type RoleConfig
- type SceneSound
- type SceneVideo
- type Service
- func (s *Service) AddLinkClip(ctx context.Context, reelID string, in LinkClipInput) (ReelClip, error)
- func (s *Service) AssetMetadata(ctx context.Context, digest string) (Asset, error)
- func (s *Service) Assets(ctx context.Context) ([]Asset, error)
- func (s *Service) CachedReelClip(reelID, clipID string) (string, bool)
- func (s *Service) CancelChannel(channelID string)
- func (s *Service) Clip(_ context.Context, r core.ClipRequest) (core.ClipRef, bool)
- func (s *Service) Close()
- func (s *Service) Crossfade(look, moment string) bool
- func (s *Service) DeleteAsset(ctx context.Context, d string) error
- func (s *Service) DeleteClip(ctx context.Context, reel, id string) error
- func (s *Service) DeleteLook(ctx context.Context, id string) error
- func (s *Service) DeleteReel(ctx context.Context, id string) error
- func (s *Service) Downloader() *extras.Downloader
- func (s *Service) DownloaderStatus() extras.DownloaderStatus
- func (s *Service) Draft(ctx context.Context, l Look) (Look, error)
- func (s *Service) Duration(id, m string) (time.Duration, bool)
- func (s *Service) Ensure(_ context.Context, r core.ClipRequest)
- func (s *Service) ExportStylePack(ctx context.Context, id string) ([]byte, []string, error)
- func (s *Service) Generate(ctx context.Context, prompt, summary string, base Look) (Look, error)
- func (s *Service) GenerateScene(ctx context.Context, prompt, summary string, base Look, sceneID string) (Look, error)
- func (s *Service) Handler(resources ...func(chi.Router)) http.Handler
- func (s *Service) Import(ctx context.Context, reel string, in ImportRequest) ([]ImportJob, error)
- func (s *Service) ImportStyleFiles(ctx context.Context, packID string, files map[string][]byte) (Look, error)
- func (s *Service) ImportStylePack(ctx context.Context, raw []byte) (Look, error)
- func (s *Service) InstallDownloader(ctx context.Context, update bool) (extras.DownloaderStatus, error)
- func (s *Service) Library(ctx context.Context) ([]LibraryAsset, error)
- func (s *Service) LibraryRoutes(r chi.Router)
- func (s *Service) LiveStatic(ctx context.Context, r core.ClipRequest) bool
- func (s *Service) Look(ctx context.Context, id string) (Look, error)
- func (s *Service) Looks(ctx context.Context) ([]Look, error)
- func (s *Service) Overlay(ctx context.Context, r core.ClipRequest) (scene.Document, raster.Bindings, bool)
- func (s *Service) PeekCachedReelClip(reelID, clipID string) (string, time.Duration, bool)
- func (s *Service) PokeAssets()
- func (s *Service) Reel(ctx context.Context, id string) (Reel, error)
- func (s *Service) ReelClipPath(ctx context.Context, reelID, clipID string) (string, bool)
- func (s *Service) ReelSnapshot(ctx context.Context, id string) (Reel, error)
- func (s *Service) Reels(ctx context.Context) ([]Reel, error)
- func (s *Service) RenderLead(look, moment string) time.Duration
- func (s *Service) ResolveReelClip(ctx context.Context, reelID, clipID string) (ReelClip, error)
- func (s *Service) SaveLook(ctx context.Context, l Look) (Look, error)
- func (s *Service) SaveReel(ctx context.Context, r Reel) (Reel, error)
- func (s *Service) SegmentInfo(moment string) (name, rating string, ok bool)
- func (s *Service) Start()
- func (s *Service) StudioRoutes(r chi.Router)
- func (s *Service) StyleScreens(id string) *config.LiveTVScreens
- func (s *Service) Template(ctx context.Context, prompt string, base Look) (Look, error)
- func (s *Service) Templates(_ context.Context) ([]TemplateRecord, error)
- func (s *Service) UploadAsset(ctx context.Context, name, kind, license string, r io.Reader) (Asset, error)
- func (s *Service) UploadClip(ctx context.Context, reel, name string, r io.Reader, ...) (ReelClip, error)
- func (s *Service) WakeUpcoming()
- type StyleControl
- type StyleScene
- type TemplateRecord
Constants ¶
const AssetFilesVersion = 1
AssetFilesVersion is advertised in a node's capabilities once it keeps On Air asset bytes in files. Nodes without it read content from the database, so content stays there while any member lacks it.
const StyleDraftGuide = `` /* 1794-byte string literal not displayed */
StyleDraftGuide is the renderer contract shared by generation and live agent drafts.
Variables ¶
var ErrNotFound = errors.New("onair: not found")
var ErrUsed = errors.New("onair: asset is in use")
Functions ¶
func BackupAssets ¶
BackupAssets lists the assets whose bytes live only in files (rows with stored='file' in db, which may be a snapshot copy) and opens each one from this node's blob store, for backup bundles.
func ServeFont ¶
func ServeFont(w http.ResponseWriter, r *http.Request)
MCP exclusion: these owner-authenticated routes supply immutable rendering resources to the console. They do not expose owner records or mutations; fetching binary fonts and bundled scene data has no useful agent tool analogue.
func ServeSystemScreens ¶
func ServeSystemScreens(w http.ResponseWriter, r *http.Request)
Types ¶
type Asset ¶
type Asset struct {
Source string `json:"source,omitempty"`
Attribution string `json:"attribution,omitempty"`
Status string `json:"status,omitempty"`
Progress float64 `json:"progress,omitempty"`
Error string `json:"error,omitempty"`
Digest string `json:"digest"`
Name string `json:"name"`
Kind string `json:"kind"`
Size int64 `json:"size"`
License string `json:"license,omitempty"`
UsedBy []string `json:"usedBy"`
URL string `json:"url,omitempty"`
MIME string `json:"-"`
DurationMS int64 `json:"durationMs,omitempty"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
Link bool `json:"link,omitempty"`
Tags []string `json:"tags,omitempty"`
}
type AssetKindTotal ¶
AssetKindTotal totals the stored assets of one kind.
func AssetKindTotals ¶
func AssetKindTotals(ctx context.Context, q Queryer) ([]AssetKindTotal, error)
AssetKindTotals is the stored assets' bytes by kind, largest first, for support bundles. size precedes the content column, so no blob page is read.
type AssetPassStats ¶
type AssetPassStats struct {
Copied, Emptied, Restored int
// CopiedBytes went from database rows into files; EmptiedBytes left the
// database.
CopiedBytes, EmptiedBytes int64
// LongestWrite is the longest single write statement of the pass (the
// write lock on SQLite).
LongestWrite time.Duration
// Released is the free pages returned to the filesystem afterwards.
Released int64
}
AssetPassStats describes one move-out pass.
type Brand ¶
type Brand struct {
Palette struct {
Background string `json:"background"`
Accent string `json:"accent"`
Text string `json:"text"`
Glow string `json:"glow"`
} `json:"palette"`
Type struct {
Display string `json:"display"`
Body string `json:"body"`
} `json:"type"`
Energy float64 `json:"energy"`
Textures []string `json:"textures"`
Tagline string `json:"tagline"`
Language string `json:"language"`
Logo string `json:"logo,omitempty"`
}
type Chatter ¶
type Chatter interface {
Enabled() bool
Chat(context.Context, []llm.Message, bool) (string, error)
}
Chatter is the owner's configured model. Proposals never save records.
type ClipUploadMetadata ¶
ClipUploadMetadata preserves provenance when a local file is imported into a reel.
type ImportJob ¶
type ImportJob struct {
UseSourceTitle bool `json:"useSourceTitle,omitempty"`
ID string `json:"id"`
Source string `json:"source"`
Attribution string `json:"attribution,omitempty"`
Name string `json:"name"`
Kind string `json:"kind"`
Status string `json:"status"`
Progress float64 `json:"progress"`
Error string `json:"error,omitempty"`
Link bool `json:"link,omitempty"`
}
type ImportRequest ¶
type ImportRequest struct {
URL string `json:"url"`
URLs []string `json:"urls"`
Name string `json:"name"`
Kind string `json:"kind"`
Mode string `json:"mode,omitempty"`
DurationMS int64 `json:"durationMs,omitempty"`
Tags []string `json:"tags,omitempty"`
}
Import jobs share the bounded background queue with look preparation. No network request or media probe runs on the console request goroutine.
type LibraryAsset ¶
type LibraryAsset struct {
Asset
MIME string `json:"mime"`
UsedBy []LibraryUse `json:"usedBy"`
CreatedAt int64 `json:"createdAt"`
}
type LibraryUse ¶
type LinkClipInput ¶
type LinkClipInput struct {
ID string
Name string
Source string
Attribution string
DurationMS int64
Tags []string
}
LinkClipInput describes a dynamic link-backed reel clip stored without media bytes.
type Look ¶
type Look struct {
ID string `json:"id"`
Name string `json:"name"`
Template string `json:"template"`
Brand Brand `json:"brand"`
Roles map[string]RoleConfig `json:"roles"`
Scenes []StyleScene `json:"scenes"`
Controls []StyleControl `json:"controls"`
ChannelIDs []string `json:"channelIds"`
ChannelCount int `json:"channelCount"`
Bug *core.BugSettings `json:"bug,omitempty"`
Screens *config.LiveTVScreens `json:"screens,omitempty"`
Pack *Pack `json:"pack,omitempty"`
Render *Progress `json:"render,omitempty"`
}
type Member ¶
type Member struct {
ID string
// Files is true when the node advertises AssetFilesVersion.
Files bool
}
Member is one node sharing this database.
type Options ¶
type Options struct {
// Showcase adds the decade looks and commercial reels used by the shipped showcase channels.
Showcase bool
// Changed runs after an owner style save has committed and locks are released.
Changed func(context.Context) error
ReelsChanged func(context.Context)
StyleChannels func(context.Context) (map[string][]string, error)
ReelChannels func(context.Context) (map[string][]string, error)
PluginSegment func(string) (PluginSegment, bool)
StaticRequests func(context.Context, string) []core.ClipRequest
DB *sql.DB
Chat Chatter
Dir string
FFmpeg func() string
Probe func(context.Context, string) (*core.MediaInfo, error)
Acquire func(context.Context) (context.Context, func(), error)
Bindings func(context.Context, string, string, time.Time) (any, error)
// Upcoming supplies requests for the next three hours of watched channels.
Upcoming func(context.Context) []core.ClipRequest
Logger *slog.Logger
CacheBytes int64
LinkCacheBytes int64
WorkingSize func() (int, int)
Artwork func(context.Context, string) (image.Image, error)
// Render is a seam for verifying that Ensure never executes work inline.
Render func(context.Context, scene.Document, raster.Bindings, string) error
// NormalizeClip is a seam for normalizing downloaded link media in offline tests.
NormalizeClip func(ctx context.Context, reel Reel, src, out string) (time.Duration, error)
// ValidateURL, ArchiveOrigin, HTTPClient and Now are seams for offline unit tests.
ValidateURL func(context.Context, string) error
ArchiveOrigin string
HTTPClient *http.Client
Now func() time.Time
// AssetDir is the blob store for asset bytes (<data>/onair/assets);
// empty uses Dir/assets.
AssetDir string
// NodeID identifies this node in onair_asset_replicas.
NodeID string
// Members lists every node sharing the database (cluster members seen
// in the last day); nil means this node alone.
Members func(context.Context) ([]Member, error)
// AssetsChanged asks every node to run an asset pass (PokeAssets).
AssetsChanged func(context.Context)
// Downloader resolves and downloads video/audio pages via yt-dlp or the
// owner's configured resolver command.
Downloader *extras.Downloader
}
type PluginContentCache ¶
type PluginContentCache struct {
// contains filtered or unexported fields
}
PluginContentCache connects the host's background publisher to render readers. Values are immutable after publication; the cache owns the map itself.
func NewPluginContentCache ¶
func NewPluginContentCache() *PluginContentCache
func (*PluginContentCache) EnablePlugin ¶
func (c *PluginContentCache) EnablePlugin(plugin string)
func (*PluginContentCache) Lookup ¶
func (c *PluginContentCache) Lookup(id string) (PluginSegment, bool)
func (*PluginContentCache) Publish ¶
func (c *PluginContentCache) Publish(values map[string]PluginSegment)
func (*PluginContentCache) RemovePlugin ¶
func (c *PluginContentCache) RemovePlugin(plugin string)
type PluginSegment ¶
type PluginSegment struct {
Document scene.Document
Slots map[string]string
Images map[string]image.Image
Version string
Expires time.Time
Rating string
Name string
}
PluginSegment is an immutable background-loaded snapshot. Lookup must do no I/O. Expiry gates playback and rendering, never the declared schedule duration.
type Queryer ¶
type Queryer interface {
QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
}
Queryer runs read queries: a *sql.DB, *sql.Conn or *sql.Tx.
type Reel ¶
type Reel struct {
Anchor time.Time `json:"-"`
ID string `json:"id"`
Name string `json:"name"`
Order string `json:"order"`
RepeatHours float64 `json:"repeatHours"`
LoudnessMatch bool `json:"loudnessMatch"`
TrimSilence bool `json:"trimSilence"`
Clips []ReelClip `json:"clips"`
ChannelIDs []string `json:"channelIds"`
}
type ReelClip ¶
type ReelClip struct {
Source string `json:"source,omitempty"`
Attribution string `json:"attribution,omitempty"`
ID string `json:"id"`
Name string `json:"name"`
DurationMS int64 `json:"durationMs"`
SourceDigest string `json:"sourceDigest,omitempty"`
Status string `json:"status"`
Progress float64 `json:"progress,omitempty"`
Size int64 `json:"size,omitempty"`
Preview string `json:"preview,omitempty"`
Error string `json:"error,omitempty"`
Link bool `json:"link,omitempty"`
Cached bool `json:"cached,omitempty"`
Tags []string `json:"tags,omitempty"`
AutoName bool `json:"autoName,omitempty"`
}
type RoleConfig ¶
type RoleConfig struct {
Duration float64 `json:"duration"`
}
type SceneSound ¶
type SceneVideo ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) AddLinkClip ¶
func (s *Service) AddLinkClip(ctx context.Context, reelID string, in LinkClipInput) (ReelClip, error)
AddLinkClip stores a link-backed clip on reelID without downloading media.
func (*Service) AssetMetadata ¶
AssetMetadata reads one asset's stored facts by digest: a single indexed row, with no usage scan, no content read and no probing. Duration is 0 until the asset has been probed.
func (*Service) CachedReelClip ¶
CachedReelClip returns a resolved link clip's local normalized file path from the in-memory LRU index and records its airing time. It never blocks or resolves.
func (*Service) CancelChannel ¶
CancelChannel stops every queued and running render for a channel and releases its pins: the channel was disabled, deleted, or fell out of the requested set. The running render's context is cancelled, which also kills its ffmpeg. Work already in the job channels is dropped by process under the unwanted mark; a later request for the channel clears the mark in enqueue.
func (*Service) Crossfade ¶
Crossfade is read from saved look metadata by the background input planner.
func (*Service) DeleteClip ¶
func (*Service) Downloader ¶
func (s *Service) Downloader() *extras.Downloader
Downloader returns the yt-dlp downloader shared with this service.
func (*Service) DownloaderStatus ¶
func (s *Service) DownloaderStatus() extras.DownloaderStatus
DownloaderStatus returns the active yt-dlp-compatible command status for link imports.
func (*Service) ExportStylePack ¶
ExportStylePack uses the plugin package digest and data runtime; no executable files, credentials, viewers or channel bindings leave this server.
func (*Service) GenerateScene ¶
func (*Service) Handler ¶
Handler must be mounted behind the application's owner authentication and CSRF guard, like livetv.Handler. MCP exclusions: these routes are console designer transport. Binary assets, multipart clips and previews cannot be represented by JSON MCP tools; look/reel transport accompanies the visual stage and explicit Save. Agent look drafts/saves use the separate proposal-backed builtin tools. Bindings is an ephemeral stage preview; it does not mutate server state. ResourceRoutes mounts W6's font and family resource handlers on this router.
func (*Service) ImportStyleFiles ¶
func (s *Service) ImportStyleFiles(ctx context.Context, packID string, files map[string][]byte) (Look, error)
ImportStyleFiles is the plugin install bridge for upload, URL and Marketplace.
func (*Service) ImportStylePack ¶
func (*Service) InstallDownloader ¶
func (s *Service) InstallDownloader(ctx context.Context, update bool) (extras.DownloaderStatus, error)
InstallDownloader installs or updates the managed yt-dlp standalone release binary.
func (*Service) LibraryRoutes ¶
func (*Service) LiveStatic ¶
LiveStatic reports readiness without requiring a rendered clip for a scene whose analogue background is supplied continuously by the Signal engine.
func (*Service) Overlay ¶
func (s *Service) Overlay(ctx context.Context, r core.ClipRequest) (scene.Document, raster.Bindings, bool)
Overlay prepares an immutable scene and decoded resources for the playout background planner. It never renders; frame ticks evaluate the pure renderer.
func (*Service) PeekCachedReelClip ¶
PeekCachedReelClip checks the in-memory link cache without touching LastAired, the database, disk, or network.
func (*Service) PokeAssets ¶
func (s *Service) PokeAssets()
PokeAssets runs a move-out pass soon; the app calls it for peer requests and membership changes.
func (*Service) ReelClipPath ¶
ReelClipPath reads clip metadata and the local master index. A miss is materialized by the background queue, and the caller skips it until a later planning pass.
func (*Service) ReelSnapshot ¶
ReelSnapshot reads the durable owner clip ordering and conversion states.
func (*Service) RenderLead ¶
RenderLead reflects measured 1080p master work, including slot contention. Every channel decodes these same masters; lower-resolution outputs inherit the conservative native-resolution estimate. Cached repeats need no work.
func (*Service) ResolveReelClip ¶
ResolveReelClip triggers an on-demand background resolution for console preview.
func (*Service) SegmentInfo ¶
SegmentInfo supplies immutable policy metadata without accessing the database.
func (*Service) Start ¶
func (s *Service) Start()
Start begins workers after application dependencies have been constructed.
func (*Service) StudioRoutes ¶
func (*Service) StyleScreens ¶
func (s *Service) StyleScreens(id string) *config.LiveTVScreens
StyleScreens reads the cached owner style; it performs no rendering or database work.
func (*Service) Templates ¶
func (s *Service) Templates(_ context.Context) ([]TemplateRecord, error)
func (*Service) UploadAsset ¶
func (*Service) UploadClip ¶
func (*Service) WakeUpcoming ¶
func (s *Service) WakeUpcoming()
WakeUpcoming signals watchUpcoming when viewer demand or look configuration starts.
type StyleControl ¶
type StyleScene ¶
type StyleScene struct {
ID string `json:"id"`
Role string `json:"role"`
Name string `json:"name"`
Enabled bool `json:"enabled"`
Weight int `json:"weight"`
Document scene.Document `json:"document"`
Sounds []SceneSound `json:"sounds"`
Video *SceneVideo `json:"video,omitempty"`
}
func (*StyleScene) UnmarshalJSON ¶
func (s *StyleScene) UnmarshalJSON(b []byte) error
Every owned document goes through the strict, cost-limited scene decoder.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package encode writes content-addressed On Air master clips off request paths.
|
Package encode writes content-addressed On Air master clips off request paths. |
|
Package families embeds the built-in scene documents; families are data.
|
Package families embeds the built-in scene documents; families are data. |
|
Package fonts provides embedded OFL faces.
|
Package fonts provides embedded OFL faces. |
|
Package raster renders scene v1 with no I/O, global mutable state or frame goroutines.
|
Package raster renders scene v1 with no I/O, global mutable state or frame goroutines. |
|
Package scene defines the portable, executable-code-free On Air document v1.
|
Package scene defines the portable, executable-code-free On Air document v1. |
|
Package signal produces live, deterministic signal screens without clip loops or per-tick allocations.
|
Package signal produces live, deterministic signal screens without clip loops or per-tick allocations. |