source

package
v0.1.0-alpha.7 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package source contains helpers for application-owned media sources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Func

type Func func(context.Context, Push) error

Func is the body of a custom source: push packets, frames, or events until the media ends (push.EOS) or the context is cancelled. The returned error stops the task; a clean EOS return ends the stream naturally.

type Push

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

Push is how a custom Source delivers packets, frames, and events into the pipeline. Packet/Frame/Event return a Result for per-push delivery visibility plus a flow-control error:

  • err == nil: the push was handled. Result says what happened.
  • errors.Is(err, goav.ErrBackpressure): strict paths refused the message.
  • errors.Is(err, goav.ErrClosed): the task has stopped; return cleanly.

On a fan-out, one slow branch never fails the push: its shed is reported on the Result while delivery continues to siblings. Any other error is fatal to the push.

func NewPush

func NewPush(ctx context.Context, emitter pipeline.Emitter, stream av.StreamID) Push

NewPush binds a pipeline emitter to one source stream. Runtime code uses it to call a Func; application code normally receives Push from goav.Source.

func (*Push) EOS

func (p *Push) EOS(streams ...av.StreamID) error

EOS ends the given streams (or the source's declared stream when none are listed): downstream nodes flush and destinations finalize naturally.

func (*Push) Event

func (p *Push) Event(event av.Event) (Result, error)

Event delivers one out-of-band event. It is also the dynamic stream announce seam: a source that discovers a stream mid-run pushes av.Event{Type: av.EventStreamAdded, Stream: &stream} before that stream's media, and av.Event{Type: av.EventStreamRemoved, StreamID: id} when it ends. Events with an empty StreamID inherit the source's declared stream id, so stream announces must set StreamID (or Stream.ID) explicitly.

func (*Push) Frame

func (p *Push) Frame(frame *av.Frame) (Result, error)

Frame delivers one decoded frame. Nil is a no-op. If frame.StreamID is empty, the source's declared stream id is applied before delivery.

func (*Push) Packet

func (p *Push) Packet(packet *av.Packet) (Result, error)

Packet delivers one packet. Nil is a no-op. If packet.StreamID is empty, the source's declared stream id is applied before delivery.

type Result

type Result struct {
	// Accepted is true when at least one downstream target queued the message.
	Accepted bool
	// Dropped is true when at least one target deliberately shed the message: a
	// full queue under a dropping policy, an exhausted byte budget, or a paused
	// branch. Shedding is normal realtime behavior, not failure.
	Dropped bool
}

Result reports what happened to one push across its matching downstream targets. On a fan-out a single push can be both Accepted and Dropped: one branch queued the message while another shed it.

type StreamMatch

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

StreamMatch selects which discovered streams a dynamic-stream rule reacts to. Build one with MatchMedia, MatchCodec, MatchStreamID, MatchStream, MatchFirst, MatchAfter, or MatchWithin; the zero value matches nothing and is rejected by goav.Job.OnStream.

func MatchAfter

func MatchAfter(d time.Duration) StreamMatch

MatchAfter matches streams announced at least d after the matcher starts. Combine it with identity predicates by calling After on another matcher.

func MatchCodec

func MatchCodec(id av.CodecID) StreamMatch

MatchCodec matches discovered streams carrying the given codec.

func MatchFirst

func MatchFirst(n int) StreamMatch

MatchFirst matches the first n discovered streams. Combine it with identity predicates by calling First on another matcher, for example MatchMedia(av.MediaAudio).First(1).

func MatchMedia

func MatchMedia(media av.MediaType) StreamMatch

MatchMedia matches discovered streams of the given media kind.

func MatchStream

func MatchStream(fn func(av.Stream) bool) StreamMatch

MatchStream matches discovered streams with a custom predicate.

func MatchStreamID

func MatchStreamID(id av.StreamID) StreamMatch

MatchStreamID matches the discovered stream with exactly this id.

func MatchWithin

func MatchWithin(d time.Duration) StreamMatch

MatchWithin matches streams announced no later than d after the matcher starts. Combine it with identity predicates by calling Within on another matcher.

func (StreamMatch) After

func (m StreamMatch) After(d time.Duration) StreamMatch

After limits a matcher to streams announced at least d after the matcher starts. Non-positive d leaves the matcher unchanged.

func (StreamMatch) Description

func (m StreamMatch) Description() string

Description returns a compact human-readable summary of the matcher.

func (StreamMatch) Empty

func (m StreamMatch) Empty() bool

Empty reports whether the matcher has no predicate.

func (StreamMatch) First

func (m StreamMatch) First(n int) StreamMatch

First limits a matcher to the first n streams that satisfy its stateless predicates. Non-positive n leaves the matcher unchanged.

func (StreamMatch) Matcher

func (m StreamMatch) Matcher() StreamMatcher

Matcher returns a runtime evaluator for this matcher config.

func (StreamMatch) MatcherAt

func (m StreamMatch) MatcherAt(start time.Time) StreamMatcher

MatcherAt returns a runtime evaluator whose stateful time conditions are measured from start.

func (StreamMatch) Matches

func (m StreamMatch) Matches(stream av.Stream) bool

Matches reports whether stream satisfies the stateless predicates. Stateful conditions such as First are applied by StreamMatcher.

func (StreamMatch) Within

func (m StreamMatch) Within(d time.Duration) StreamMatch

Within limits a matcher to streams announced no later than d after the matcher starts. Non-positive d leaves the matcher unchanged.

type StreamMatcher

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

StreamMatcher is the runtime evaluator for a StreamMatch. It keeps state for conditions such as First without storing mutable counters in the public StreamMatch value, so the same match config can be reused across jobs.

func (*StreamMatcher) Matches

func (m *StreamMatcher) Matches(stream av.Stream) bool

Matches reports whether stream satisfies the matcher config and consumes one stateful match budget when it does.

func (*StreamMatcher) MatchesAt

func (m *StreamMatcher) MatchesAt(stream av.Stream, at time.Time) bool

MatchesAt is Matches evaluated at a known announcement time. A zero time uses the current clock.

Jump to

Keyboard shortcuts

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