@apocaliss92/nodelink-js 0.4.5 → 0.4.6

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.d.cts CHANGED
@@ -2434,6 +2434,7 @@ declare class BcUdpStream extends EventEmitter<{
2434
2434
  private resendTimer;
2435
2435
  private hbTimer;
2436
2436
  private discoveryTid;
2437
+ private discoveryTimers;
2437
2438
  private acceptSent;
2438
2439
  private lastAcceptAtMs;
2439
2440
  private ackScheduled;
@@ -3655,6 +3656,15 @@ declare class BaichuanVideoStream extends EventEmitter<{
3655
3656
  private lastPpsH265;
3656
3657
  private lastPrependedParamSetsH265;
3657
3658
  private aesStreamDecryptor;
3659
+ /**
3660
+ * Pending startup error stashed when emitSafeError is called before any
3661
+ * "error" listener is registered (e.g. camera returns 400 during start()).
3662
+ * The rfc4571-server's waitForKeyframe can consume this immediately instead
3663
+ * of waiting for the full keyframe timeout.
3664
+ */
3665
+ private _pendingStartupError;
3666
+ /** Consume and clear any pending startup error. */
3667
+ consumePendingStartupError(): Error | undefined;
3658
3668
  private emitSafeError;
3659
3669
  private lastMediaAtMs;
3660
3670
  private watchdogTimer;
@@ -4505,6 +4515,18 @@ declare class ReolinkBaichuanApi {
4505
4515
  * which indicates subStream (e.g., RecS03_, RecS_).
4506
4516
  */
4507
4517
  private determineStreamTypeFromFileName;
4518
+ /**
4519
+ * Stream profiles that the device explicitly rejected (response_code 400).
4520
+ * Keyed by `"ch:profile"` (e.g. `"0:ext"`). Once a profile is in this set
4521
+ * it is excluded from `buildVideoStreamOptions()` results and no further
4522
+ * start attempts are made until the API instance is recreated.
4523
+ */
4524
+ private readonly _rejectedStreamProfiles;
4525
+ /**
4526
+ * Check whether a stream profile was rejected by the device at runtime
4527
+ * (e.g. ext returned response_code 400).
4528
+ */
4529
+ isStreamProfileRejected(channel: number, profile: StreamProfile): boolean;
4508
4530
  /**
4509
4531
  * Cache for buildVideoStreamOptions.
4510
4532
  *
package/dist/index.d.ts CHANGED
@@ -1647,6 +1647,15 @@ export declare class BaichuanVideoStream extends EventEmitter<{
1647
1647
  private lastPpsH265;
1648
1648
  private lastPrependedParamSetsH265;
1649
1649
  private aesStreamDecryptor;
1650
+ /**
1651
+ * Pending startup error stashed when emitSafeError is called before any
1652
+ * "error" listener is registered (e.g. camera returns 400 during start()).
1653
+ * The rfc4571-server's waitForKeyframe can consume this immediately instead
1654
+ * of waiting for the full keyframe timeout.
1655
+ */
1656
+ private _pendingStartupError;
1657
+ /** Consume and clear any pending startup error. */
1658
+ consumePendingStartupError(): Error | undefined;
1650
1659
  private emitSafeError;
1651
1660
  private lastMediaAtMs;
1652
1661
  private watchdogTimer;
@@ -2337,6 +2346,7 @@ export declare class BcUdpStream extends EventEmitter<{
2337
2346
  private resendTimer;
2338
2347
  private hbTimer;
2339
2348
  private discoveryTid;
2349
+ private discoveryTimers;
2340
2350
  private acceptSent;
2341
2351
  private lastAcceptAtMs;
2342
2352
  private ackScheduled;
@@ -5348,6 +5358,18 @@ export declare class ReolinkBaichuanApi {
5348
5358
  * which indicates subStream (e.g., RecS03_, RecS_).
5349
5359
  */
5350
5360
  private determineStreamTypeFromFileName;
5361
+ /**
5362
+ * Stream profiles that the device explicitly rejected (response_code 400).
5363
+ * Keyed by `"ch:profile"` (e.g. `"0:ext"`). Once a profile is in this set
5364
+ * it is excluded from `buildVideoStreamOptions()` results and no further
5365
+ * start attempts are made until the API instance is recreated.
5366
+ */
5367
+ private readonly _rejectedStreamProfiles;
5368
+ /**
5369
+ * Check whether a stream profile was rejected by the device at runtime
5370
+ * (e.g. ext returned response_code 400).
5371
+ */
5372
+ isStreamProfileRejected(channel: number, profile: StreamProfile): boolean;
5351
5373
  /**
5352
5374
  * Cache for buildVideoStreamOptions.
5353
5375
  *
package/dist/index.js CHANGED
@@ -43,7 +43,7 @@ import {
43
43
  parseSupportXml,
44
44
  setGlobalLogger,
45
45
  xmlIndicatesFloodlight
46
- } from "./chunk-WDFKIHM5.js";
46
+ } from "./chunk-F2Y5U3YP.js";
47
47
  import {
48
48
  AesStreamDecryptor,
49
49
  BC_AES_IV,
@@ -223,7 +223,7 @@ import {
223
223
  testChannelStreams,
224
224
  xmlEscape,
225
225
  zipDirectory
226
- } from "./chunk-DEOMUWBN.js";
226
+ } from "./chunk-TR3V5FTO.js";
227
227
 
228
228
  // src/reolink/baichuan/HlsSessionManager.ts
229
229
  var withTimeout = async (p, ms, label) => {
@@ -3466,6 +3466,11 @@ async function createRfc4571TcpServerInternal(options) {
3466
3466
  "videoAccessUnit",
3467
3467
  onAu
3468
3468
  );
3469
+ const pendingErr = videoStream.consumePendingStartupError?.();
3470
+ if (pendingErr) {
3471
+ cleanup();
3472
+ reject(pendingErr);
3473
+ }
3469
3474
  });
3470
3475
  }
3471
3476
  };
@@ -3477,24 +3482,32 @@ async function createRfc4571TcpServerInternal(options) {
3477
3482
  await videoStream.stop();
3478
3483
  } catch {
3479
3484
  }
3480
- if (closeApiOnTeardown) {
3481
- await Promise.allSettled(
3482
- Array.from(apisToClose).map(async (a) => {
3485
+ if (dedicatedSession) {
3486
+ try {
3487
+ await dedicatedSession.release();
3488
+ } catch {
3489
+ }
3490
+ }
3491
+ if (!dedicatedSession) {
3492
+ if (closeApiOnTeardown) {
3493
+ await Promise.allSettled(
3494
+ Array.from(apisToClose).map(async (a) => {
3495
+ try {
3496
+ await a.close();
3497
+ } catch {
3498
+ }
3499
+ })
3500
+ );
3501
+ } else {
3502
+ const graceMs = isComposite ? 5e3 : 0;
3503
+ for (const a of Array.from(apisToClose)) {
3483
3504
  try {
3484
- await a.close();
3505
+ a?.client?.requestIdleDisconnectSoon?.(
3506
+ "rfc4571_teardown",
3507
+ graceMs
3508
+ );
3485
3509
  } catch {
3486
3510
  }
3487
- })
3488
- );
3489
- } else {
3490
- const graceMs = isComposite ? 5e3 : 0;
3491
- for (const a of Array.from(apisToClose)) {
3492
- try {
3493
- a?.client?.requestIdleDisconnectSoon?.(
3494
- "rfc4571_teardown",
3495
- graceMs
3496
- );
3497
- } catch {
3498
3511
  }
3499
3512
  }
3500
3513
  }
@@ -3750,7 +3763,7 @@ async function createRfc4571TcpServerInternal(options) {
3750
3763
  } catch {
3751
3764
  }
3752
3765
  }
3753
- if (closeApiOnTeardown) {
3766
+ if (closeApiOnTeardown && !dedicatedSession) {
3754
3767
  await Promise.allSettled(
3755
3768
  Array.from(apisToClose).map(async (a) => {
3756
3769
  try {