Documentation
¶
Overview ¶
Package source contains helpers for application-owned media sources.
Index ¶
- type Func
- type Push
- type Result
- type StreamMatch
- func MatchAfter(d time.Duration) StreamMatch
- func MatchCodec(id av.CodecID) StreamMatch
- func MatchFirst(n int) StreamMatch
- func MatchMedia(media av.MediaType) StreamMatch
- func MatchStream(fn func(av.Stream) bool) StreamMatch
- func MatchStreamID(id av.StreamID) StreamMatch
- func MatchWithin(d time.Duration) StreamMatch
- func (m StreamMatch) After(d time.Duration) StreamMatch
- func (m StreamMatch) Description() string
- func (m StreamMatch) Empty() bool
- func (m StreamMatch) First(n int) StreamMatch
- func (m StreamMatch) Matcher() StreamMatcher
- func (m StreamMatch) MatcherAt(start time.Time) StreamMatcher
- func (m StreamMatch) Matches(stream av.Stream) bool
- func (m StreamMatch) Within(d time.Duration) StreamMatch
- type StreamMatcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Func ¶
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 ¶
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 ¶
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 ¶
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.
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.