Documentation
¶
Overview ¶
Package shape holds the media-format descriptor vocabulary used across goav to describe the shape of a stream at a point in a pipeline: its domain, media kind, codec, geometry, and audio layout. It keeps the goav root grammar clean while letting callers reach for descriptors as shape.Spec, shape.Set, and the shape.Frame/Packet/Event constructors.
Index ¶
- type Contract
- type MediaDomain
- type Option
- func Audio(sampleRate int, channels int, sampleFormat av.SampleFormat) Option
- func Codec(codec av.CodecID) Option
- func Domain(domain MediaDomain) Option
- func Format(format av.FormatID) Option
- func Media(media av.MediaType) Option
- func Realtime(realtime bool) Option
- func Stream(stream av.StreamID) Option
- func Video(width int, height int, pixelFormat av.PixelFormat) Option
- type Policy
- func (p Policy) AllowsConvert() bool
- func (p Policy) AllowsResample() bool
- func (p Policy) AllowsResize() bool
- func (p Policy) Constructors() []string
- func (p Policy) Covers(needed Policy) bool
- func (p Policy) Empty() bool
- func (p Policy) Missing(needed Policy) Policy
- func (p Policy) String() string
- func (p Policy) Union(other Policy) Policy
- type Set
- type Spec
- func Event(options ...Option) Spec
- func Frame(media av.MediaType, options ...Option) Spec
- func FromCodecParameters(parameters av.CodecParameters) Spec
- func FromStream(stream av.Stream, domain MediaDomain) Spec
- func Merge(base Spec, next Spec) Spec
- func New(options ...Option) Spec
- func Packet(media av.MediaType, codec av.CodecID, options ...Option) Spec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Contract ¶
Contract describes a stage that maps an input Spec to a Set of output Specs and advertises the Set of inputs it accepts.
type MediaDomain ¶
type MediaDomain string
MediaDomain names which representation a Spec describes: packets, frames, or out-of-band events.
const ( DomainPacket MediaDomain = "packet" DomainFrame MediaDomain = "frame" DomainEvent MediaDomain = "event" )
The media domains: encoded packets, decoded frames, or event-only flow.
type Option ¶
type Option func(*Spec)
Option mutates a Spec under construction.
func Audio ¶
func Audio(sampleRate int, channels int, sampleFormat av.SampleFormat) Option
Audio states the audio layout facts: sample rate, channel count, and sample format. Zero or empty fields stay unconstrained — Audio(0, 0, "f32") pins only the sample format, which is how a Prefer steers an otherwise open solver choice.
func Domain ¶
func Domain(domain MediaDomain) Option
Domain pins which representation the Spec describes: packets, frames, or events. The Frame/Packet/Event constructors set it for you.
func Format ¶
Format pins the container or transport framing format (av.FormatRTP, ...); unset matches any format.
type Policy ¶
type Policy struct {
// contains filtered or unexported fields
}
Policy is the shape solver's conversion vocabulary: which classes of automatic conversion a chain allows the planner to insert when an operation pins format facts the current media does not satisfy. The zero Policy allows nothing — every needed conversion is refused with the exact allowance to add. Build policies with AllowResample, AllowResize, and AllowConvert and combine them with Union (or by passing several to .Auto(...)).
func AllowConvert ¶
func AllowConvert() Policy
AllowConvert permits inserting pixel-format and sample-format conversions.
func AllowCustom ¶
AllowCustom permits an application-registered solver delta by name. Custom names are matched against per-runtime delta contributors registered with runconfig; empty names allow nothing.
func AllowResample ¶
func AllowResample() Policy
AllowResample permits inserting audio sample-rate and channel conversions.
func AllowResize ¶
func AllowResize() Policy
AllowResize permits inserting video width and height conversions.
func Conversions ¶
Conversions reports the conversion classes required to make actual satisfy the populated format facts of expected: resample for sample-rate or channel deltas, resize for width or height deltas, convert for pixel-format or sample-format deltas. Facts the expected Spec leaves empty never require a conversion; facts it pins follow Accepts semantics (an unknown actual fact does not satisfy a pinned expectation).
func (Policy) AllowsConvert ¶
AllowsConvert reports whether pixel/sample format conversions are allowed.
func (Policy) AllowsResample ¶
AllowsResample reports whether sample-rate/channel conversions are allowed.
func (Policy) AllowsResize ¶
AllowsResize reports whether width/height conversions are allowed.
func (Policy) Constructors ¶
Constructors lists the shape package constructor calls that build this policy — the exact fix a refusal error should suggest.
func (Policy) Missing ¶
Missing returns the conversion classes in needed that the policy does not allow.
type Set ¶
type Set []Spec
Set is a collection of acceptable Specs. An empty Set accepts any Spec.
type Spec ¶
type Spec struct {
Domain MediaDomain `json:"domain,omitempty"`
MediaKind av.MediaType `json:"mediaKind,omitempty"`
StreamID av.StreamID `json:"streamID,omitempty"`
Codec av.CodecID `json:"codec,omitempty"`
Format av.FormatID `json:"format,omitempty"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
PixelFormat av.PixelFormat `json:"pixelFormat,omitempty"`
SampleRate int `json:"sampleRate,omitempty"`
Channels int `json:"channels,omitempty"`
SampleFormat av.SampleFormat `json:"sampleFormat,omitempty"`
Realtime bool `json:"realtime,omitempty"`
}
Spec is the core media-format descriptor: the shape of a stream at a point in a pipeline. A zero Spec matches anything; populated fields constrain the match.
func FromCodecParameters ¶
func FromCodecParameters(parameters av.CodecParameters) Spec
FromCodecParameters derives a Spec from decoded codec parameters.
func FromStream ¶
func FromStream(stream av.Stream, domain MediaDomain) Spec
FromStream derives a Spec from a demuxed stream in the given domain.
func (Spec) CompatibleWith ¶
CompatibleWith reports whether the receiver satisfies the non-empty fields of expected.