StreamSwitchSmoothNode class

Signature:

export declare class StreamSwitchSmoothNode<Pins extends string> extends ProcessorMediaNode<Pins>

Extends: ProcessorMediaNode<Pins>

Properties

Property Type Description

activeSource

Pins | undefined

The currently active source

Methods

Method Modifiers Description

endCurrentSource()

End the currently active source immediately. The engine fires a synthetic PreloadEnded for the active pin, which surfaces as the existing onSourceEnded(pin, lastSeenPts) callback with lastSeenPts set to the source’s last rebased output PTS (engine’s state.latestOutputPts captured atomically at the synthetic-end moment).

After this call, no further frames from the just-ended pin flow downstream — the engine inserts the tag into its trimmedSources map so any in-flight upstream frames are silently dropped at processInput.

Useful for cross-node manual cuts where the caller wants to anchor the next node’s releasePreloaded at the just-ended source’s PTS (e.g. an HSS downstream alternating between SSS- and SSQ-output — the SSS’s lastSeenPts becomes the SSQ’s anchorPts).

Idempotent — calling a second time while the tag is already ended is a silent no-op (logged engine-side, no callback re-fires). No-op when there is no active source.

releasePreloaded(pin, options)

Release held frames for a preloaded pin, allowing them to flow through with rebased timestamps.

options.anchorPts — optional video-display PTS anchor (in microseconds) overriding the engine’s internal per-pin videoPrevEndByTag tracking for this release. Used by clients needing cross-switch PTS continuity (e.g. when an HSS downstream alternates between SSS-output and SSQ-output and the boundary needs the OTHER switch’s last PTS as the anchor). Audio + DTS anchors still use internal tracking.

silence()

Park the switch in a silent state and forget all internal clock and audio-transition bookkeeping. The next switchSource will be processed as a cold-start switch — the new pin’s first emitted frame becomes the new PTS baseline rather than being interpreted as a continuation of the previously-active source’s timeline.

Use this when the switch is being parked between consumer windows — e.g. when an HSS downstream is routing to a sibling switch and this switch’s output is not on the wire. Without silence, the switch’s compose chain retains latestPts etc. from its previous activeSource; when it later resumes for an anchored cross-mode handoff, that stale anchor collides with the new pin’s intended one and produces a multi-second forward jump that downstream encoders / muxers report as a timestamp discontinuity.

After this call: no output frames flow until a subsequent switchSource or releasePreloaded. The switch remains subscribed to its inputs — no upstream teardown.

switchSource(newSource, options)

Switches the source used for the current output of this node