Documentation
¶
Index ¶
- Constants
- func FrameDurationNS(frame *av.Frame) int64
- func MarkTimelinePaced(clock av.Clock)
- func MixS16Into(dst []byte, inputs [][]byte, n int)
- func MixS16KernelName() string
- type ArmRestamp
- type AudioMix
- func NewAudioMix(name string, inputs []av.StreamID, out av.StreamID, mode compile.JoinSyncMode) *AudioMix
- func NewAudioMixWithPrealloc(name string, inputs []av.StreamID, out av.StreamID, mode compile.JoinSyncMode, ...) *AudioMix
- func NewAudioMixWithPreallocAndPools(name string, inputs []av.StreamID, out av.StreamID, mode compile.JoinSyncMode, ...) *AudioMix
- func (b *AudioMix) Admit(ctx context.Context, msg *pipeline.Message) error
- func (b *AudioMix) Admits(_ interleave.Token, arm int) bool
- func (b *AudioMix) Arm(_ interleave.Token, msg any) (int, bool)
- func (b *AudioMix) Close() error
- func (b *AudioMix) DescribeNode() pipeline.NodeSpec
- func (b *AudioMix) DroppedMessages() uint64
- func (b *AudioMix) EnableAdmission()
- func (s *AudioMix) Handle(ctx context.Context, msg *pipeline.Message, emitter pipeline.Emitter) error
- func (b *AudioMix) Name() string
- type JoinSyncState
- type MediaPools
- type Selector
- type Timeline
- func (t *Timeline) Inner() av.Clock
- func (t *Timeline) MarkPaced()
- func (t *Timeline) Now() time.Duration
- func (t *Timeline) Paced() bool
- func (t *Timeline) Pause()
- func (t *Timeline) PausedNow() bool
- func (t *Timeline) Rate() float64
- func (t *Timeline) Resume()
- func (t *Timeline) SetRate(rate float64) error
- func (t *Timeline) Sleep(ctx context.Context, d time.Duration) error
- type VideoComposite
- func NewVideoComposite(name string, inputs []av.StreamID, out av.StreamID, ...) *VideoComposite
- func NewVideoCompositeWithPrealloc(name string, inputs []av.StreamID, out av.StreamID, ...) *VideoComposite
- func NewVideoCompositeWithPreallocAndPools(name string, inputs []av.StreamID, out av.StreamID, ...) *VideoComposite
- func (b *VideoComposite) Admit(ctx context.Context, msg *pipeline.Message) error
- func (b *VideoComposite) Admits(_ interleave.Token, arm int) bool
- func (b *VideoComposite) Arm(_ interleave.Token, msg any) (int, bool)
- func (b *VideoComposite) Close() error
- func (b *VideoComposite) DescribeNode() pipeline.NodeSpec
- func (b *VideoComposite) DroppedMessages() uint64
- func (b *VideoComposite) EnableAdmission()
- func (s *VideoComposite) Handle(ctx context.Context, msg *pipeline.Message, emitter pipeline.Emitter) error
- func (b *VideoComposite) Name() string
Constants ¶
const ( CompositeBlackLuma = 16 CompositeNeutralChroma = 128 )
Limited-range I420 black: the canvas color wherever no arm paints.
Variables ¶
This section is empty.
Functions ¶
func FrameDurationNS ¶
frameDurationNS reports the frame's span on the nanosecond clock: the declared Duration when usable, else the audio length derived from samples/rate, else 0 (exact-match tolerance). FrameDurationNS reports the frame's span on the nanosecond clock: the explicit Duration when valid, else the sample count over the sample rate for audio frames, else 0.
func MarkTimelinePaced ¶
markTimelinePaced records a paced consumer on clock when it is the task timeline — the one call every seam that hands out the clock (provider open, realtime demux, gate lowering) makes so task-wide rate and pause controls have a consumer to scale. Non-timeline clocks (unit-test fakes) are ignored.
func MixS16Into ¶
func MixS16KernelName ¶
func MixS16KernelName() string
Types ¶
type ArmRestamp ¶
type ArmRestamp struct {
// contains filtered or unexported fields
}
armRestampStage republishes an arm's stream under the arm's id — the runtime body of a tap arm and of an arm bound when its input opens. Join stages identify arms by stream id: a tap's own media keeps flowing down its declaring arm unchanged, and two files carry the same track ids, so the converged copy is re-stamped: a shallow per-message copy (payloads are shared exactly like every other fanout; downstream joins clone what they buffer). With in set, only that stream and stream-less events pass: a file's source carries all its streams.
func NewArmRestamp ¶
func (*ArmRestamp) Close ¶
func (s *ArmRestamp) Close() error
func (*ArmRestamp) DescribeNode ¶
func (s *ArmRestamp) DescribeNode() pipeline.NodeSpec
DescribeNode reports the same detail the join planner records on the planned restamp node, keeping Describe() ≡ Build().
func (*ArmRestamp) Name ¶
func (s *ArmRestamp) Name() string
type AudioMix ¶
type AudioMix struct {
// contains filtered or unexported fields
}
audioMixStage sums N synchronized audio inputs into one output stream — the runtime heart of a convergent Mix. Each input arm is identified by its frame StreamID. It is a normal pipeline.Stage: the buffered runner calls Handle serially per node, so the per-input queues need no locking (lock-free by design — the hot path takes no mutex).
func NewAudioMix ¶
func NewAudioMixWithPrealloc ¶
func NewAudioMixWithPreallocAndPools ¶
func NewAudioMixWithPreallocAndPools(name string, inputs []av.StreamID, out av.StreamID, mode compile.JoinSyncMode, preallocDepth int, pools *MediaPools) *AudioMix
func (*AudioMix) Arm ¶
func (b *AudioMix) Arm(_ interleave.Token, msg any) (int, bool)
Arm and Admits implement interleave.Gate.
func (*AudioMix) DescribeNode ¶
DescribeNode reports the same detail the join planner records on the planned node, keeping Describe() ≡ Build() when ByPTS annotates the join.
func (*AudioMix) DroppedMessages ¶
func (b *AudioMix) DroppedMessages() uint64
DroppedMessages implements pipeline.DropReporter.
func (*AudioMix) EnableAdmission ¶
func (b *AudioMix) EnableAdmission()
type JoinSyncState ¶
type JoinSyncState struct {
// contains filtered or unexported fields
}
joinSyncState is the arm buffering and alignment state shared by the convergence stages (audioMixStage, videoCompositeStage). Every field is touched only inside the owning stage's serial Handle — lock-free by design, no mutex on the hot path — and alignment is pure PTS math: no wall clock, deterministic, unit-testable.
EOS semantics (both modes): an ended arm stops gating — its buffered frames still participate, then the remaining arms keep joining without it; the joined stream ends only when every arm has ended.
func NewJoinSyncStateWithPendingCap ¶
func NewJoinSyncStateWithPendingCap(mode compile.JoinSyncMode, inputs []av.StreamID, pendingCap int) *JoinSyncState
func (*JoinSyncState) Buffer ¶
func (s *JoinSyncState) Buffer(frame *av.Frame)
buffer queues one arm frame by StreamID lookup.
func (*JoinSyncState) MarkEOS ¶
func (s *JoinSyncState) MarkEOS(id av.StreamID) bool
markEOS records an arm's end of stream and reports whether every arm ended for the first time. A stream-less EOS marks every declared arm ended; unknown stream IDs are ignored.
func (*JoinSyncState) PendingCount ¶
func (s *JoinSyncState) PendingCount(id av.StreamID) int
pendingCount returns the number of buffered frames for id (used by tests).
type MediaPools ¶
type MediaPools struct {
// contains filtered or unexported fields
}
func NewMediaPools ¶
func NewMediaPools() *MediaPools
func (*MediaPools) PlanePoolCounts ¶
func (p *MediaPools) PlanePoolCounts() (audio, video int)
PlanePoolCounts returns the number of pooled audio and video plane slices.
func (*MediaPools) PutMetadata ¶
func (p *MediaPools) PutMetadata(metadata av.Metadata)
func (*MediaPools) PutPlanes ¶
func (p *MediaPools) PutPlanes(planes []av.Plane)
func (*MediaPools) TakeMetadata ¶
func (p *MediaPools) TakeMetadata() av.Metadata
func (*MediaPools) TakePlanes ¶
func (p *MediaPools) TakePlanes(count int) []av.Plane
type Selector ¶
type Selector struct {
// contains filtered or unexported fields
}
selectorStage forwards messages from exactly one of N inputs to a single output and drops the rest — the runtime heart of a one-of-N Select switch (active-speaker camera, simulcast layer switch, failover). Each input arm is identified by its frame/packet StreamID.
It is a normal pipeline.Stage: the buffered runner calls Handle serially per node, so the per-input EOS bookkeeping needs no locking (lock-free by design — the hot path takes no mutex). The active input lives in an atomic pointer so SetActive may be called concurrently with Handle without a mutex: the read on the forwarding hot path is a plain atomic load.
EOS is forwarded like the mixer: one output EOS is emitted only after every input has ended. Non-EOS events are forwarded only from the currently active input so the downstream sees a single coherent stream.
A switch is driven live through the control plane: an injected av.EventSelectActive event names the target input in Event.StreamID, calls SetActive, and is consumed (not forwarded). control.SelectActive builds that control.
func (*Selector) ActiveID ¶
ActiveID returns the currently active input id (empty if none configured).
type Timeline ¶
type Timeline struct {
// contains filtered or unexported fields
}
timeline is the task-wide clock service: one shared av.Clock per task that maps the runtime clock onto media run time through an atomically readable rate and pause epoch. Paced consumers — the realtime demux pacer, clock-aware provider sources, and playout gates — read and sleep on the timeline, so one control.Rate re-anchors every consumer coherently instead of each source keeping a private rate.
Concurrency: Now is lock-free (one atomic epoch load, arithmetic only), per the data-plane rule. SetRate/Pause/Resume serialize on a cold-side mutex, re-anchor the epoch atomically, and rotate a broadcast channel so in-flight Sleeps recompute their remaining wall wait under the new epoch.
func NewTimeline ¶
newTimeline anchors a timeline at zero on the inner clock's current reading, running at 1x. A nil inner clock falls back to av.MonotonicClock, matching the pacing default.
func (*Timeline) MarkPaced ¶
func (t *Timeline) MarkPaced()
markPaced records that a paced consumer (demux pacer, clock-aware source) waits on this timeline; the task refuses rate controls until one exists.
func (*Timeline) Now ¶
Now reports the timeline reading: the integral of rate over unpaused inner time since construction. Lock-free — one epoch load plus arithmetic.
func (*Timeline) Pause ¶
func (t *Timeline) Pause()
Pause freezes the timeline at its current reading. Sleeps hold until Resume (or their context ends). Pausing a paused timeline is a no-op.
func (*Timeline) PausedNow ¶
pausedNow reports whether the timeline is currently frozen at its reading.
func (*Timeline) Resume ¶
func (t *Timeline) Resume()
Resume continues a paused timeline from the frozen reading at the current rate. Resuming a running timeline is a no-op.
func (*Timeline) SetRate ¶
SetRate re-anchors the timeline at the current reading with a new rate. In-flight Sleeps wake and recompute their remaining wall wait, so every paced consumer changes pace together, mid-sleep included.
func (*Timeline) Sleep ¶
Sleep blocks until d of timeline time has elapsed or ctx is done. d is a timeline duration: at rate 2 a 100ms sleep costs 50ms of inner time, and a rate or pause change mid-sleep re-derives the remaining wall wait instead of finishing on the stale conversion. While paused it holds for the next epoch change. All wall waits go through the inner clock's Sleep so fake clocks keep pacing deterministic.
type VideoComposite ¶
type VideoComposite struct {
// contains filtered or unexported fields
}
videoCompositeStage overlays N synchronized video inputs into one output frame — the video dual of audioMixStage. Each input arm is identified by its frame StreamID. It is a normal pipeline.Stage: the buffered runner calls Handle serially per node, so the per-input queues need no locking (lock-free by design — the hot path takes no mutex).
func NewVideoComposite ¶
func NewVideoComposite(name string, inputs []av.StreamID, out av.StreamID, layout []compile.CompositeLayout, mode compile.JoinSyncMode) *VideoComposite
func NewVideoCompositeWithPrealloc ¶
func NewVideoCompositeWithPrealloc(name string, inputs []av.StreamID, out av.StreamID, layout []compile.CompositeLayout, mode compile.JoinSyncMode, preallocDepth int) *VideoComposite
func NewVideoCompositeWithPreallocAndPools ¶
func NewVideoCompositeWithPreallocAndPools(name string, inputs []av.StreamID, out av.StreamID, layout []compile.CompositeLayout, mode compile.JoinSyncMode, preallocDepth int, pools *MediaPools) *VideoComposite
func (*VideoComposite) Arm ¶
func (b *VideoComposite) Arm(_ interleave.Token, msg any) (int, bool)
Arm and Admits implement interleave.Gate.
func (*VideoComposite) DescribeNode ¶
DescribeNode reports the same detail the join planner records on the planned node, keeping Describe() ≡ Build() when ByPTS annotates the join.
func (*VideoComposite) DroppedMessages ¶
func (b *VideoComposite) DroppedMessages() uint64
DroppedMessages implements pipeline.DropReporter.
func (*VideoComposite) EnableAdmission ¶
func (b *VideoComposite) EnableAdmission()