registry

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SingleInputBridge

func SingleInputBridge(bridge BridgeFunc) map[string]BridgeFunc

Types

type BaseManifest

type BaseManifest struct {
	Name                 string
	Description          string
	ConfigurationFactory ConfigurationFactory
	// contains filtered or unexported fields
}

func (BaseManifest) ConfigurationType

func (m BaseManifest) ConfigurationType() reflect.Type

func (BaseManifest) Default

func (m BaseManifest) Default() Configuration

Default returns the manifest's default configuration without validating it, so callers that plan to apply further values (e.g. decoding CLI/spec input) can start from it before validation happens once, at the end.

func (BaseManifest) ID

func (m BaseManifest) ID() PluginKey

func (BaseManifest) NewConfiguration

func (m BaseManifest) NewConfiguration() (Configuration, error)

func (BaseManifest) RegistryName

func (m BaseManifest) RegistryName() string

type BridgeFunc

type BridgeFunc func(
	current media.StreamInfo,
	required []manifest.Capability,
) ([]ConversionCandidate, error)

type Bundle

type Bundle struct {
	Muxers               *MuxerRegistry
	Demuxers             *DemuxerRegistry
	Encoders             *EncoderRegistry
	Decoders             *DecoderRegistry
	Filters              *FilterRegistry
	ParameterizedFilters *ParameterizedFilterRegistry
}

func (Bundle) Register

func (b Bundle) Register(manifest Manifest) error

type Configuration

type Configuration interface{}

type ConfigurationFactory

type ConfigurationFactory interface {
	ConfigurationType() reflect.Type
	New() (Configuration, error)

	// Default returns the factory's default field values without applying
	// options or validating the result. It is intended as a starting point
	// for further mutation (e.g. decoding CLI/spec values onto it) that is
	// validated once, after all values are applied — not before.
	Default() Configuration
}

ConfigurationFactory produces a plugin's Configuration. ConfigurationType reports the concrete configuration type without constructing (and therefore without validating) a value, so the registry can derive plugin identity even for configurations with no semantically valid default.

func NewConfigurationFactory

func NewConfigurationFactory[T any, Option any](newConfiguration func(...Option) (T, error)) ConfigurationFactory

func StaticConfigurationFactory

func StaticConfigurationFactory(config Configuration) ConfigurationFactory

StaticConfigurationFactory wraps an already-constructed Configuration value. Intended for tests and other call sites where the value is known upfront rather than produced by an option-pattern constructor. Each call to New or Default returns a fresh copy, matching the option-pattern factory's guarantee that callers never share a mutable instance.

type ConversionCandidate

type ConversionCandidate struct {
	Config Configuration
	Cost   ConversionCost
}

type ConversionCost

type ConversionCost struct {
	QualityLoss uint32
	Work        uint32
}

type DecoderManifest

type DecoderManifest struct {
	TransformManifest
	Factory DecoderFactory
}

func (DecoderManifest) Validate

func (m DecoderManifest) Validate() error

type DecoderRegistry

type DecoderRegistry = Registry[DecoderManifest]

type Defaulter

type Defaulter interface {
	ApplyDefaults()
}

type DemuxerFactory

type DemuxerFactory func(io.Reader, Configuration) (node.Demuxer, error)

type DemuxerManifest

type DemuxerManifest struct {
	BaseManifest
	Probe   manifest.Prober
	Factory DemuxerFactory
}

func (DemuxerManifest) Validate

func (m DemuxerManifest) Validate() error

type DemuxerRegistry

type DemuxerRegistry = Registry[DemuxerManifest]

type EncoderManifest

type EncoderManifest struct {
	TransformManifest
	Codecs  []media.CodecID
	Factory EncoderFactory
}

func (EncoderManifest) Supports

func (m EncoderManifest) Supports(codec media.CodecID) bool

func (EncoderManifest) Validate

func (m EncoderManifest) Validate() error

type EncoderRegistry

type EncoderRegistry = Registry[EncoderManifest]

type FilterFactory

FilterFactory builds a filter node from the resolved stream on each of its input ports, and reports the resolved stream on each of its output ports. Single-port filters normally use SingleFactory instead of implementing this directly.

func SingleFactory

SingleFactory adapts a conventional single "in"->"out" filter factory to the general per-port FilterFactory signature.

type FilterManifest

type FilterManifest struct {
	TransformManifest
	// OutputPorts declares the named outputs produced by Factory. Keeping the
	// topology with the manifest lets callers describe and validate a filter
	// before a stream has been negotiated.
	OutputPorts []string
	Bridge      map[string]BridgeFunc
	Factory     FilterFactory
}

func (FilterManifest) Validate

func (m FilterManifest) Validate() error

func (FilterManifest) ValidateOutputs

func (m FilterManifest) ValidateOutputs(outputs media.StreamSet) error

ValidateOutputs verifies that a factory result matches the manifest's declared topology. Empty declarations are tolerated here for unregistered test manifests; registered manifests are rejected by Validate.

type FilterRegistry

type FilterRegistry = Registry[FilterManifest]

type InputRequirements

type InputRequirements map[string]InputRequirementsFunc

func SingleInputRequirements

func SingleInputRequirements(requirements InputRequirementsFunc) InputRequirements

type InputRequirementsFunc

type InputRequirementsFunc func(target media.CodecID, config Configuration) ([]manifest.Capability, error)

func StaticRequirements

func StaticRequirements(capabilities ...manifest.Capability) InputRequirementsFunc

type Manifest

type Manifest interface {
	ID() PluginKey
	RegistryName() string
	ConfigurationType() reflect.Type
	NewConfiguration() (Configuration, error)
	Default() Configuration
}

type ManifestFactory

type ManifestFactory func(parameters Configuration) (FilterManifest, error)

ManifestFactory builds the concrete FilterManifest for one resolved set of parameters. It runs once per resolution (e.g. once per CLI --filter invocation), after Parameters is decoded but before the regular per-instance Configuration is decoded — the returned manifest's own ConfigurationFactory determines that Configuration's type, and may itself depend on the parameters (e.g. a mixer's input/output port count determining how many named input ports its InputRequirements declares).

type MuxerFactory

type MuxerFactory func(io.Writer, Configuration) (node.Muxer, error)

type MuxerManifest

type MuxerManifest struct {
	BaseManifest
	Extensions   []string
	Codecs       []media.CodecID
	DefaultCodec media.CodecID
	Factory      MuxerFactory
}

func (MuxerManifest) Supports

func (m MuxerManifest) Supports(codec media.CodecID) bool

func (MuxerManifest) Validate

func (m MuxerManifest) Validate() error

type MuxerRegistry

type MuxerRegistry = Registry[MuxerManifest]

type ParameterizedFilterManifest

type ParameterizedFilterManifest struct {
	BaseManifest
	NewManifest ManifestFactory
}

ParameterizedFilterManifest is a higher-order filter registration: its registered identity (via BaseManifest.ConfigurationFactory) is a *parameters* type, not the eventual per-instance Configuration type. NewManifest is called with the resolved parameters to produce the concrete FilterManifest used for one invocation; that manifest is never itself added to a Registry[FilterManifest] — it is used directly and discarded once the invocation finishes.

This lets a single registered name (e.g. "mixer") support a family of topologies chosen at resolution time (e.g. an arbitrary input/output port count), without pre-registering one manifest per shape, and without capping how many ports a shape may have.

Parameters is deliberately not named "Shape": a future parameterized manifest may need structural choices that aren't port counts at all, so nothing here assumes the parameters are about topology specifically.

func (ParameterizedFilterManifest) Validate

func (m ParameterizedFilterManifest) Validate() error

type ParameterizedFilterRegistry

type ParameterizedFilterRegistry = Registry[ParameterizedFilterManifest]

type PluginKey

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

PluginKey is the registry-assigned identity of a plugin implementation. Its fields are intentionally private: plugins identify themselves only by registering a named configuration type for a manifest role.

func (PluginKey) ConfigurationType

func (k PluginKey) ConfigurationType() reflect.Type

func (PluginKey) Role

func (k PluginKey) Role() manifest.NodeType

func (PluginKey) String

func (k PluginKey) String() string

type Preparer

type Preparer interface {
	Prepare(ResourceGrant) error
}

Preparer is an optional node capability for resource-dependent setup. It is called after routing and linking, before the pipeline starts processing.

type ProfileRequirements

type ProfileRequirements map[string]ProfileRequirementsFunc

type ProfileRequirementsFunc

type ProfileRequirementsFunc func(inputs media.StreamSet, target media.CodecID, config Configuration) ([]manifest.Capability, error)

ProfileRequirements can refine a port's requirements using the profiles of the streams already connected to the transform. A profile requirement takes precedence over the static requirement for the same port.

type Registry

type Registry[V Manifest] struct {
	// contains filtered or unexported fields
}

func NewRegistry

func NewRegistry[V Manifest]() *Registry[V]

func (*Registry[V]) Enumerate

func (r *Registry[V]) Enumerate() iter.Seq[V]

func (*Registry[V]) Get

func (r *Registry[V]) Get(key PluginKey) (V, error)

func (*Registry[V]) Key

func (r *Registry[V]) Key(config Configuration) (PluginKey, error)

func (*Registry[V]) Lookup

func (r *Registry[V]) Lookup(name string) (V, error)

func (*Registry[V]) Names

func (r *Registry[V]) Names() []string

func (*Registry[V]) Register

func (r *Registry[V]) Register(manifest V) error

type ResourceBudget

type ResourceBudget struct {
	Parallelism int
}

ResourceBudget is the total execution budget requested for a conversion.

type ResourceGrant

type ResourceGrant struct {
	Pool *WorkerPool
}

ResourceGrant is what one transform instance actually receives after negotiation. Pool is nil when the transform did not request Parallelism; otherwise it is a shared handle also held by every other parallel-eligible stage in the same conversion, so capacity moves to whichever stage has runnable work instead of being split evenly up front.

func (ResourceGrant) Parallelism

func (g ResourceGrant) Parallelism() int

Parallelism reports the shared pool's total worker count, or 0 if Pool is nil. This is informational: unlike a per-stage exclusive share, it is the same value for every stage granted the same pool.

type ResourceRequest

type ResourceRequest struct {
	Parallelism bool
}

ResourceRequest declares execution resources a transform can use. It is deliberately independent from Configuration: resources affect scheduling, not the semantic output of a plugin.

type Task

type Task interface {
	Run()
}

Task is a unit of work submitted to a WorkerPool. Callers that already hold a heap-allocated job struct (as every current caller does, since the job must outlive the submitting call to be picked up by another goroutine) can implement Run directly on it to submit the job itself, avoiding the extra closure allocation that wrapping it in a func() would cost.

type TaskFunc

type TaskFunc func()

TaskFunc adapts a plain func() to a Task, for callers where an extra closure allocation per submission isn't a concern (tests, cold paths).

func (TaskFunc) Run

func (f TaskFunc) Run()

type TransformFactoryOptions

type TransformFactoryOptions struct {
	Config Configuration
}

type TransformManifest

type TransformManifest struct {
	BaseManifest
	InputRequirements   InputRequirements
	ProfileRequirements ProfileRequirements
	Resources           ResourceRequest
}

func (TransformManifest) Accept

func (m TransformManifest) Accept(port string, stream media.StreamInfo, target media.CodecID, config Configuration) (bool, error)

func (TransformManifest) Requirements

func (m TransformManifest) Requirements(port string, target media.CodecID, config Configuration) ([]manifest.Capability, error)

func (TransformManifest) RequirementsFor

func (m TransformManifest) RequirementsFor(port string, inputs media.StreamSet, target media.CodecID, config Configuration) ([]manifest.Capability, error)

type Validator

type Validator interface {
	Validate() error
}

type WorkerPool

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

WorkerPool is a bounded set of goroutines shared by every pipeline stage in a single conversion run that requested Parallelism. Capacity flows to whichever stage currently has runnable work: Submit blocks once the queue and all workers are busy, so a stage sitting idle never holds capacity that a busy stage could use instead.

func NewWorkerPool

func NewWorkerPool(size int) *WorkerPool

NewWorkerPool starts size goroutines draining a shared task queue. size is clamped to at least 1.

func (*WorkerPool) Close

func (p *WorkerPool) Close() error

Close stops accepting new work and waits for in-flight tasks to finish. Callers must ensure every stage sharing this pool has stopped submitting before calling Close. Safe to call more than once, and from more than one of a stage's teardown hooks (e.g. both a normal end-of-stream flush and a later unconditional close).

func (*WorkerPool) Size

func (p *WorkerPool) Size() int

Size reports the number of worker goroutines backing the pool.

func (*WorkerPool) Submit

func (p *WorkerPool) Submit(task Task)

Submit runs task on a pool worker, blocking until a worker or queue slot is free.

Jump to

Keyboard shortcuts

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