@mega-yfue/eufy-sdk / SharedLiveSource
Class: SharedLiveSource
Constructors
Constructor
new SharedLiveSource(opts): SharedLiveSource;Parameters
opts
Returns
SharedLiveSource
Accessors
consumerCount
Get Signature
get consumerCount(): number;Returns
number
parameterSets
Get Signature
get parameterSets(): ParamSets | undefined;The parameter sets (SPS/PPS, plus VPS for H.265) most recently announced on this stream, or undefined before any have been seen.
A camera commonly sends them ONCE, with the first keyframe of a stream. Every later access unit is then undecodable in isolation, so a consumer that collects a burst — and cannot see frames from before it joined — has no way to recover them. This source watches every frame from stream start, which makes it the only holder of the answer. A caller re-emits them ahead of its collected burst.
Cleared when the stream is torn down, so a rebuilt stream never primes a burst with a dead stream's sets.
Returns
ParamSets | undefined
state
Get Signature
get state(): SharedLiveState;Returns
Methods
attach()
attach(): LiveConsumer;Attach a new consumer. Warms the stream on the first attach (or cancels a pending linger teardown and reuses the warm stream), then replays the cached keyframe so the consumer can decode at once.
Returns
attachWithPrebuffer()
attachWithPrebuffer(seconds): object;Attach at the same instant a keyframe-aligned prebuffer snapshot is taken. The returned consumer is not separately keyframe-primed, so replaying buffered followed by its live events neither duplicates the newest IDR nor leaves a gap at the handoff.
Parameters
seconds
number
Returns
object
buffered
buffered: TimedMediaFrame[];consumer
consumer: LiveConsumer;dispose()
dispose(): void;Permanent shutdown (session close / router closeAll). Consumers get stop; no rebuild.
Releases the session user when consumers were still attached: SharedLiveSourceOptions.onActive fired on the 0→1 transition, and this is the 1→0 one, so skipping it would leave the station pinned open for a source that can never serve anyone again.
Returns
void
rewarm()
rewarm(): void;Warm again on a session the owner has replaced, inside the deadline the first attempt started.
The previous stream is dropped rather than stopped through the state machine: it speaks to a session that is gone, and its stop would be read as an upstream end. Only a warm-up that asked for a replacement rewarms, so this is inert on a source that is streaming or has already failed.
Returns
void
ringBuffer()
ringBuffer(seconds): LiveVideoFrame[];Drain the rolling prebuffer: a decodable run covering the last seconds of retained media, capped at the configured preBufferSeconds. Asking for none hands over none. The host decides when to drain (e.g. on a motion event) and where to send it.
The run opens on the newest keyframe at or before the window starts, so it covers the whole request and over-delivers by however far back that keyframe sits — one keyframe interval on a steady stream, more where delivery stalled, since retention is timed on arrival and a frame carries no device clock. Beginning inside the window instead would under-deliver by that same distance, which on a short window is most of it, and a decoder allows no third option.
Parameters
seconds
number