@mega-yfue/eufy-sdk 0.2.0-beta.3 → 0.2.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -16417,10 +16417,12 @@ var LiveStream = class extends EventEmitter3 {
16417
16417
  if (!this.listening || this.kaTimer)
16418
16418
  return;
16419
16419
  if (this.opts.reassertWanted?.() === false) {
16420
+ this.trace({ phase: "channel-silent", silentMs: stallMs, outcome: "declined" });
16420
16421
  this.logger.debug(`[live ch${this.channel}] no own media for ${stallMs}ms, and its owner does not want this channel re-asserted \u2014 staying quiet`);
16421
16422
  this.armStallWatch();
16422
16423
  return;
16423
16424
  }
16425
+ this.trace({ phase: "channel-silent", silentMs: stallMs, outcome: "reasserted" });
16424
16426
  this.logger.debug(`[live ch${this.channel}] no own media for ${stallMs}ms \u2014 re-asserting this camera's channel`);
16425
16427
  this.sendStart();
16426
16428
  this.kaTimer = setInterval(() => this.sendStart(), keepAliveMs);
@@ -16641,10 +16643,12 @@ async function captureSnapshotFromShared(source, opts = {}) {
16641
16643
  const timeoutMs = opts.timeoutMs ?? 2e4;
16642
16644
  const collectMs = opts.collectMs ?? 1500;
16643
16645
  const skip = opts.skipKeyframes ?? 1;
16646
+ opts.signal?.throwIfAborted();
16644
16647
  const consumer = source.attach();
16645
16648
  const primed = consumer.primed;
16649
+ let burst;
16646
16650
  try {
16647
- const burst = await new Promise((resolve, reject) => {
16651
+ burst = await new Promise((resolve, reject) => {
16648
16652
  const bufs = [];
16649
16653
  let sets = source.parameterSets;
16650
16654
  let codec = "h264";
@@ -16679,6 +16683,10 @@ async function captureSnapshotFromShared(source, opts = {}) {
16679
16683
  cleanup();
16680
16684
  reject(new LiveSnapshotUnavailableError("source-failed", `source ended before a keyframe (state: ${source.state})`));
16681
16685
  };
16686
+ const onAbandoned = () => {
16687
+ cleanup();
16688
+ reject(opts.signal?.reason);
16689
+ };
16682
16690
  const cleanup = () => {
16683
16691
  clearTimeout(timer);
16684
16692
  if (settle)
@@ -16686,19 +16694,21 @@ async function captureSnapshotFromShared(source, opts = {}) {
16686
16694
  consumer.off("video", onVideo);
16687
16695
  consumer.off("error", onError);
16688
16696
  consumer.off("stop", onStop);
16697
+ opts.signal?.removeEventListener("abort", onAbandoned);
16689
16698
  };
16690
16699
  consumer.on("video", onVideo);
16691
16700
  consumer.on("error", onError);
16692
16701
  consumer.on("stop", onStop);
16693
- });
16694
- return await annexbToJpeg(primeForDecode(burst.h264, burst.sets, burst.codec), {
16695
- logger: opts.logger ?? noopLogger,
16696
- level: opts.ffmpegLevel,
16697
- executable: opts.ffmpegPath
16702
+ opts.signal?.addEventListener("abort", onAbandoned, { once: true });
16698
16703
  });
16699
16704
  } finally {
16700
16705
  consumer.detach();
16701
16706
  }
16707
+ return annexbToJpeg(primeForDecode(burst.h264, burst.sets, burst.codec), {
16708
+ logger: opts.logger ?? noopLogger,
16709
+ level: opts.ffmpegLevel,
16710
+ executable: opts.ffmpegPath
16711
+ });
16702
16712
  }
16703
16713
  async function recordClip(session, seconds, opts = {}) {
16704
16714
  const timeoutMs = opts.timeoutMs ?? 2e4;
@@ -19271,12 +19281,12 @@ var P2PCommandRouter = class _P2PCommandRouter {
19271
19281
  return {
19272
19282
  snapshotLive: async (opts) => {
19273
19283
  const source = await this.sharedLiveSourceFor(sn, opts ?? {});
19274
- return abortable(captureSnapshotFromShared(source, {
19284
+ return captureSnapshotFromShared(source, {
19275
19285
  ...opts,
19276
19286
  logger: this.deps.logger ?? noopLogger,
19277
19287
  ffmpegLevel: this.deps.ffmpegLogLevel,
19278
19288
  ffmpegPath: this.deps.ffmpegPath
19279
- }), opts?.signal);
19289
+ });
19280
19290
  },
19281
19291
  live: async (opts) => {
19282
19292
  const source = await this.sharedLiveSourceFor(sn, opts);