Skip to content

@mega-yfue/eufy-sdk / SharedLiveSource

Class: SharedLiveSource

Constructors

Constructor

ts
new SharedLiveSource(opts): SharedLiveSource;

Parameters

opts

SharedLiveSourceOptions

Returns

SharedLiveSource

Accessors

consumerCount

Get Signature

ts
get consumerCount(): number;
Returns

number


parameterSets

Get Signature

ts
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

ts
get state(): SharedLiveState;
Returns

SharedLiveState

Methods

attach()

ts
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

LiveConsumer


attachWithPrebuffer()

ts
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
ts
buffered: TimedMediaFrame[];
consumer
ts
consumer: LiveConsumer;

dispose()

ts
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()

ts
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()

ts
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

Returns

LiveVideoFrame[]

Independent and unofficial. Not affiliated with, endorsed by, or sponsored by Anker Innovations, Anker eufy, or eufy. "Anker eufy", "eufy" and "Anker" are trademarks of their respective owners. Use responsibly — rapid or failed logins can trigger captcha or temporary cooldowns.