engine

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: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEAGAIN = errors.New("resource temporarily unavailable (need more data)")
	ErrEOF    = errors.New("end of file or stream")
)

Functions

func ResolveConfig

func ResolveConfig[T any, C Wrapper[T]](cfg registry.Configuration) (T, error)

ResolveConfig resolves a configuration from the registry. It accepts either a value type T or a pointer type *T.

func WrapDecoder

func WrapDecoder(engine DecoderEngine) node.Decoder

func WrapDemuxer

func WrapDemuxer(engine DemuxerEngine) node.Demuxer

func WrapEncoder

func WrapEncoder(engine EncoderEngine) node.Encoder

func WrapFilter

func WrapFilter(engine FilterEngine, options ...FilterOption) node.Filter

WrapFilter adapts engine to node.Filter. With no options it exposes the conventional single "in" (run-phase) input port and single "out" output port, using only SendFrame/ReceiveFrame/Flush.

func WrapMuxer

func WrapMuxer(engine MuxerEngine) node.Muxer

Types

type AuxInputEngine

type AuxInputEngine interface {
	SendInput(port string, frame *media.Frame) error
	EndInput(port string) error
}

AuxInputEngine is an optional FilterEngine capability, detected via type assertion, needed only when a filter declares more than one run-phase input port and/or any preload input port. SendInput receives a frame for a named port; EndInput marks that port's EOF. The adapter retains and releases frames around both calls.

type DecoderAdapter

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

func (*DecoderAdapter) Close

func (n *DecoderAdapter) Close() error

func (*DecoderAdapter) InputPorts

func (n *DecoderAdapter) InputPorts() map[string]*node.InPort[*media.Packet]

func (*DecoderAdapter) OutputPorts

func (n *DecoderAdapter) OutputPorts() map[string]*node.OutPort[media.Frame]

func (*DecoderAdapter) Prepare

func (n *DecoderAdapter) Prepare(resources registry.ResourceGrant) error

func (*DecoderAdapter) Start

func (n *DecoderAdapter) Start(ctx context.Context) error

type DecoderEngine

type DecoderEngine interface {
	SendPacket(pkt *media.Packet) error
	ReceiveFrame() (media.Frame, error)
	Flush() error
}

type DemuxerAdapter

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

func (*DemuxerAdapter) Close

func (n *DemuxerAdapter) Close() error

func (*DemuxerAdapter) Metadata

func (n *DemuxerAdapter) Metadata() *metadata.Bundle

func (*DemuxerAdapter) OutputPorts

func (n *DemuxerAdapter) OutputPorts() map[string]*node.OutPort[*media.Packet]

func (*DemuxerAdapter) Prepare

func (n *DemuxerAdapter) Prepare(resources registry.ResourceGrant) error

func (*DemuxerAdapter) Start

func (n *DemuxerAdapter) Start(ctx context.Context) error

func (*DemuxerAdapter) Streams

func (n *DemuxerAdapter) Streams() ([]media.StreamInfo, error)

type DemuxerEngine

type DemuxerEngine interface {
	Analyze() (streams []media.StreamInfo, globalMeta metadata.Bundle, err error)
	ReadPacket() (pkt *media.Packet, streamIndex int, err error)
}

type EncoderAdapter

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

func (*EncoderAdapter) Close

func (n *EncoderAdapter) Close() error

func (*EncoderAdapter) InputPorts

func (n *EncoderAdapter) InputPorts() map[string]*node.InPort[media.Frame]

func (*EncoderAdapter) OutputPorts

func (n *EncoderAdapter) OutputPorts() map[string]*node.OutPort[*media.Packet]

func (*EncoderAdapter) Prepare

func (n *EncoderAdapter) Prepare(resources registry.ResourceGrant) error

func (*EncoderAdapter) Start

func (n *EncoderAdapter) Start(ctx context.Context) error

type EncoderEngine

type EncoderEngine interface {
	SendFrame(frame *media.Frame) error
	ReceivePacket() (*media.Packet, error)
	Flush() error
}

type FilterAdapter

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

FilterAdapter adapts a FilterEngine to node.Filter. A single run-phase input and a single output is the smallest possible topology and needs nothing beyond FilterEngine itself; more of either is a difference in degree, not in kind, and is handled by the same adapter type using the optional AuxInputEngine/MultiOutputEngine capabilities.

func (*FilterAdapter) Close

func (n *FilterAdapter) Close() error

func (*FilterAdapter) InputPhases

func (n *FilterAdapter) InputPhases() map[string]node.InputPhase

func (*FilterAdapter) InputPorts

func (n *FilterAdapter) InputPorts() map[string]*node.InPort[media.Frame]

func (*FilterAdapter) OutputPorts

func (n *FilterAdapter) OutputPorts() map[string]*node.OutPort[media.Frame]

func (*FilterAdapter) Preload

func (n *FilterAdapter) Preload(ctx context.Context) error

Preload drains every declared preload-phase port to EOF, before Start (and thus the rest of the pipeline's run) ever begins.

func (*FilterAdapter) Prepare

func (n *FilterAdapter) Prepare(resources registry.ResourceGrant) error

func (*FilterAdapter) Process

func (n *FilterAdapter) Process(ctx context.Context) error

func (*FilterAdapter) Start

func (n *FilterAdapter) Start(ctx context.Context) error

type FilterEngine

type FilterEngine interface {
	SendFrame(frame *media.Frame) error
	ReceiveFrame() (media.Frame, error)
	Flush() error
}

FilterEngine is the only interface a filter engine must implement. Exactly one run-phase input port and one output port need nothing more than this; declaring additional ports (see FilterInput, WithInputs, WithOutputs) requires the engine to also implement AuxInputEngine and/or MultiOutputEngine below. Those are optional, type-asserted capabilities, not part of this base contract, so a plain single-port engine never needs to know about them.

type FilterInput

type FilterInput struct {
	ID    string
	Phase node.InputPhase
}

FilterInput names one input port and declares when it is consumed: Run ports are pulled during the pipeline's normal run; Preload ports are drained to completion before the run begins (see node.StagedInput).

type FilterOption

type FilterOption func(*filterOptions)

FilterOption configures WrapFilter's port topology. Callers that need only the conventional single "in"/"out" ports pass no options.

func WithInputs

func WithInputs(inputs ...FilterInput) FilterOption

WithInputs declares this filter's input ports, replacing the default single run-phase "in" port. Declaring more than one run-phase port, or any preload port, requires the engine to also implement AuxInputEngine.

func WithOutputs

func WithOutputs(outputs ...string) FilterOption

WithOutputs names this filter's output ports, replacing the default single "out" port. Declaring more than one requires the engine to also implement MultiOutputEngine.

type MultiOutputEngine

type MultiOutputEngine interface {
	ReceiveOutput() (port string, frame media.Frame, err error)
}

MultiOutputEngine is an optional FilterEngine capability, detected via type assertion, needed only when a filter declares more than one output port. ReceiveOutput behaves like ReceiveFrame but also names which output port the frame belongs to.

type MuxerAdapter

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

func (*MuxerAdapter) AddStream

func (n *MuxerAdapter) AddStream(info media.StreamInfo) (int, error)

func (*MuxerAdapter) Close

func (n *MuxerAdapter) Close() error

func (*MuxerAdapter) InputPorts

func (n *MuxerAdapter) InputPorts() map[string]*node.InPort[*media.Packet]

func (*MuxerAdapter) SetMetadata

func (n *MuxerAdapter) SetMetadata(meta *metadata.Bundle) error

func (*MuxerAdapter) Start

func (n *MuxerAdapter) Start(ctx context.Context) error

type MuxerEngine

type MuxerEngine interface {
	AddStream(info media.StreamInfo) (streamIndex int, err error)
	SetMetadata(meta metadata.Bundle) error

	WriteHeader() error
	WriteTrailer() error

	WritePacket(streamIndex int, pkt *media.Packet) error
}

type SeekableDemuxerAdapter

type SeekableDemuxerAdapter struct {
	*DemuxerAdapter
	// contains filtered or unexported fields
}

func (*SeekableDemuxerAdapter) Seek

func (n *SeekableDemuxerAdapter) Seek(offset time.Duration) error

type SeekerEngine

type SeekerEngine interface {
	Seek(offset time.Duration) error
}

type Validateable

type Validateable interface {
	Validate() error
}

type Wrapper

type Wrapper[T any] interface {
	registry.Configuration
	Resolve() T
	ResolveDefault() T
}

Jump to

Keyboard shortcuts

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