conversion

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

View Source
const MainInputAlias = routing.MainInputAlias

MainInputAlias is the reserved source alias for the main input's decoded stream (see routing.MainInputAlias).

Variables

This section is empty.

Functions

func Build

func Build(ctx context.Context, inputs InputSet, output io.Writer, spec Spec, observation pipeline.ObservationMode) (*pipeline.Pipeline, error)

func Negotiate

func Negotiate(ctx context.Context, inputs InputSet, output io.Writer, spec Spec) (*pipeline.Geometry, error)

func NewError

func NewError(code Code, message string) error

NewError builds an Error carrying code, for use by callers (such as example/web's HTTP layer) that need the same {code, message} shape for conditions conversion itself never produces (e.g. an unknown job ID).

Types

type AuxInputSpec

type AuxInputSpec struct {
	Demuxer *PluginSpec `json:"demuxer,omitempty"`
	Decoder *PluginSpec `json:"decoder,omitempty"`
}

AuxInputSpec is a named additional source, demuxed and decoded like the main input. It has no filter chain of its own — any processing on the way to a consumer is just an ordinary FilterSpec wired from this alias.

type Code

type Code string
const (
	CodeInvalidSpec       Code = "invalid_spec"
	CodeUnsupportedCodec  Code = "unsupported_codec"
	CodeNegotiationFailed Code = "negotiation_failed"
	CodeBuildFailed       Code = "build_failed"
	CodePipelineFailed    Code = "pipeline_failed"
	CodeCanceled          Code = "canceled"
	CodeNotFound          Code = "not_found"
	CodeNotReady          Code = "not_ready"
	CodePayloadTooLarge   Code = "payload_too_large"
	CodeInternal          Code = "internal"
)

type Error

type Error struct {
	Code    Code   `json:"code"`
	Message string `json:"message"`
	// contains filtered or unexported fields
}

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type FilterSpec

type FilterSpec struct {
	PluginSpec
	Alias      string             `json:"alias,omitempty"`
	Inputs     map[string]PortRef `json:"inputs,omitempty"`
	Parameters map[string]string  `json:"parameters,omitempty"`
}

type InputSet

type InputSet struct {
	Main io.ReadSeeker
	Aux  map[string]io.ReadSeeker
}

type Job

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

Job runs a negotiated conversion in the background and tracks its outcome so progress can be polled independently of the goroutine driving Run. It is the shared state machine behind both the HTTP job store (example/web) and the WASM bindings: only how input/output are wired up and how job IDs are exposed differs between them.

func StartJob

func StartJob(ctx context.Context, inputs InputSet, output io.Writer, spec Spec) (*Job, error)

StartJob negotiates, builds, and runs a conversion in the background. The returned Job stays valid until Close is called; Snapshot and Cancel are safe to call concurrently with the running conversion.

func (*Job) Cancel

func (j *Job) Cancel()

Cancel requests that the job stop. It does not wait for the pipeline to finish; use Done or Close for that.

func (*Job) Close

func (j *Job) Close() error

Close cancels the job if still running, waits for it to finish, and releases pipeline resources. Safe to call multiple times.

func (*Job) Description

func (j *Job) Description() pipeline.Description

func (*Job) Done

func (j *Job) Done() <-chan struct{}

Done is closed once the job's goroutine has finished, after which Snapshot and Err reflect the final outcome.

func (*Job) Err

func (j *Job) Err() error

Err returns the error Run finished with, if any. Only meaningful after Done is closed.

func (*Job) Snapshot

func (j *Job) Snapshot() Progress

Snapshot reports the job's current progress and outcome.

type NodeStatus

type NodeStatus struct {
	ID           string `json:"id"`
	Role         string `json:"role"`
	Plugin       string `json:"plugin"`
	AutoInserted bool   `json:"autoInserted"`
	State        string `json:"state"`
	ElapsedMs    int64  `json:"elapsedMs"`
	Error        string `json:"error,omitempty"`
}

type PluginSpec

type PluginSpec struct {
	Name   string            `json:"name"`
	Values map[string]string `json:"values,omitempty"`
}

type PortRef

type PortRef struct {
	Alias string `json:"alias"`
	Port  string `json:"port,omitempty"`
}

PortRef names one port of one graph node: a filter alias, an auxiliary input name, or MainInputAlias. An empty Port defaults to "out".

type Progress

type Progress struct {
	Status         Status       `json:"status,omitempty"` // set by Job.Snapshot; empty when Snapshot is called directly
	Error          string       `json:"error,omitempty"`  // set by Job.Snapshot when Status is failed
	Percent        float64      `json:"percent"`          // -1 when duration is unknown
	ProcessedMs    int64        `json:"processedMs"`
	TotalMs        int64        `json:"totalMs"`
	ProcessedItems uint64       `json:"processedItems"`
	SpeedRatio     float64      `json:"speedRatio"` // processed media time per wall-clock second
	ElapsedMs      int64        `json:"elapsedMs"`
	EtaMs          int64        `json:"etaMs"`
	Nodes          []NodeStatus `json:"nodes"`
}

func Snapshot

func Snapshot(snapshot pipeline.Snapshot, final bool) Progress

Snapshot summarizes a pipeline.Snapshot for progress reporting. Elapsed time is taken from snapshot.Elapsed (wall-clock time since Pipeline.Run started). Set final to true once the conversion has finished (successfully or not) so the reported percent/duration reflect completion rather than the last observed media time.

type Resolved

type Resolved struct {
	Demuxer      registry.DemuxerManifest
	DemuxConfig  registry.Configuration
	Decoder      registry.DecoderManifest
	DecodeConfig registry.Configuration
	Filters      []routing.FilterSpec
	AuxInputs    map[string]resolvedAuxInput
	Sink         *routing.PortRef
	Encoder      registry.EncoderManifest
	EncodeConfig registry.Configuration
	Muxer        registry.MuxerManifest
	MuxConfig    registry.Configuration
	Codec        media.CodecID
	Resources    registry.ResourceBudget
}

func Resolve

func Resolve(spec Spec) (Resolved, error)

type Spec

type Spec struct {
	Demuxer   *PluginSpec             `json:"demuxer,omitempty"`
	Decoder   *PluginSpec             `json:"decoder,omitempty"`
	Filters   []FilterSpec            `json:"filters,omitempty"`
	AuxInputs map[string]AuxInputSpec `json:"auxInputs,omitempty"`
	// Sink names the port that feeds the encoder. nil resolves to the
	// default: the last filter's "out" port, or (with no filters) the main
	// input directly.
	Sink        *PortRef    `json:"sink,omitempty"`
	Codec       string      `json:"codec,omitempty"`
	Encoder     *PluginSpec `json:"encoder,omitempty"`
	Muxer       PluginSpec  `json:"muxer"`
	Parallelism int         `json:"parallelism,omitempty"`
}

type Status

type Status string
const (
	StatusRunning   Status = "running"
	StatusCompleted Status = "completed"
	StatusFailed    Status = "failed"
	StatusCanceled  Status = "canceled"
)

Jump to

Keyboard shortcuts

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