@apocaliss92/nodelink-js 0.4.1 → 0.4.2

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
@@ -1,7 +1,8 @@
1
1
  import { EventEmitter } from 'node:events';
2
2
  import { Readable } from 'node:stream';
3
+ import * as net from 'node:net';
4
+ import net__default from 'node:net';
3
5
  import http from 'node:http';
4
- import net from 'node:net';
5
6
 
6
7
  declare const BC_TCP_DEFAULT_PORT = 9000;
7
8
  /** Magic header bytes: `f0 de bc 0a` */
@@ -3346,6 +3347,12 @@ interface BaichuanRtspServerOptions {
3346
3347
  * isolating it from other streams on the shared socket (avoids streamType mismatch).
3347
3348
  */
3348
3349
  deviceId?: string;
3350
+ /**
3351
+ * When true, the server does NOT create its own net.Server.
3352
+ * Connections are accepted externally via acceptConnection().
3353
+ * start() still performs metadata fetch and codec detection.
3354
+ */
3355
+ externalListener?: boolean;
3349
3356
  }
3350
3357
  /**
3351
3358
  * BaichuanRtspServer - RTSP server that serves a Baichuan video stream.
@@ -3377,6 +3384,7 @@ declare class BaichuanRtspServer extends EventEmitter<{
3377
3384
  private flow;
3378
3385
  private deviceId;
3379
3386
  private dedicatedSessionRelease;
3387
+ private externalListener;
3380
3388
  private authCredentials;
3381
3389
  private requireAuth;
3382
3390
  private authNonces;
@@ -3441,6 +3449,13 @@ declare class BaichuanRtspServer extends EventEmitter<{
3441
3449
  * Start the RTSP server.
3442
3450
  */
3443
3451
  start(): Promise<void>;
3452
+ /**
3453
+ * Accept an externally-routed RTSP connection.
3454
+ * Used in directHandoff mode where RtspProxyServer routes sockets here.
3455
+ * @param socket - The client TCP socket (already authenticated by proxy)
3456
+ * @param initialBuffer - Any bytes already read during path parsing/auth
3457
+ */
3458
+ acceptConnection(socket: net.Socket, initialBuffer?: Buffer): void;
3444
3459
  /**
3445
3460
  * Handle RTSP connection from a client.
3446
3461
  */
@@ -3493,6 +3508,33 @@ declare class BaichuanRtspServer extends EventEmitter<{
3493
3508
  * Get number of connected clients.
3494
3509
  */
3495
3510
  getClientCount(): number;
3511
+ /**
3512
+ * Subscribe to the raw native stream for diagnostic purposes.
3513
+ * The subscriber receives the same frames as RTSP clients.
3514
+ * Counts as a "consumer" for lifecycle — prevents auto-stop while subscribed.
3515
+ * If the native stream is not active, starts it automatically.
3516
+ */
3517
+ subscribeDiagnostic(id: string): Promise<AsyncGenerator<{
3518
+ audio: boolean;
3519
+ data: Buffer;
3520
+ codec: string | null;
3521
+ sampleRate: number | null;
3522
+ microseconds: number | null;
3523
+ videoType?: "H264" | "H265";
3524
+ }, void, unknown>>;
3525
+ /**
3526
+ * Unsubscribe a diagnostic session.
3527
+ */
3528
+ unsubscribeDiagnostic(id: string): void;
3529
+ /**
3530
+ * Returns detected audio metadata (available after first audio frame).
3531
+ */
3532
+ getAudioInfo(): {
3533
+ codec: "aac-adts";
3534
+ sampleRate: number;
3535
+ channels: number;
3536
+ configHex: string;
3537
+ } | null;
3496
3538
  }
3497
3539
 
3498
3540
  /**
@@ -7610,7 +7652,7 @@ declare function packetizeAacRawFrame(raw: Buffer, rtp: RtpWriter): {
7610
7652
  packets: Buffer[];
7611
7653
  };
7612
7654
  interface Rfc4571Client {
7613
- socket: net.Socket;
7655
+ socket: net__default.Socket;
7614
7656
  needsKeyframe: boolean;
7615
7657
  sentVideoConfig: boolean;
7616
7658
  }
@@ -7637,7 +7679,7 @@ declare class Rfc4571Muxer {
7637
7679
  private cachedH264ParamSetsAnnexB;
7638
7680
  private cachedH265ParamSetsAnnexB;
7639
7681
  constructor(logger: Console, videoPayloadType: number, audioPayloadType: number | undefined, videoFpsFallback?: number, maxRtpPayload?: number);
7640
- addClient(socket: net.Socket): void;
7682
+ addClient(socket: net__default.Socket): void;
7641
7683
  private static readonly ANNEXB_START_CODE;
7642
7684
  private static joinAnnexBNals;
7643
7685
  private updateVideoParamSetsFromAccessUnit;
@@ -7759,7 +7801,7 @@ interface Rfc4571TcpServer {
7759
7801
  };
7760
7802
  username: string;
7761
7803
  password: string;
7762
- server: net.Server;
7804
+ server: net__default.Server;
7763
7805
  videoStream: BaichuanVideoStream | CompositeStream;
7764
7806
  close: (reason?: unknown) => Promise<void>;
7765
7807
  }
@@ -7815,7 +7857,7 @@ interface Rfc4571ReplayServer {
7815
7857
  };
7816
7858
  username: string;
7817
7859
  password: string;
7818
- server: net.Server;
7860
+ server: net__default.Server;
7819
7861
  videoStream: BaichuanVideoStream;
7820
7862
  /** Called when replay naturally ends (all data sent). */
7821
7863
  onReplayEnd?: () => void;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { EventEmitter } from 'node:events';
2
2
  import http from 'node:http';
3
- import net from 'node:net';
3
+ import * as net from 'node:net';
4
+ import { default as net_2 } from 'node:net';
4
5
  import { Readable } from 'node:stream';
5
6
 
6
7
  export declare function abilitiesHasAny(abilities: AbilityInfo | undefined, re: RegExp): boolean;
@@ -1291,6 +1292,7 @@ export declare class BaichuanRtspServer extends EventEmitter<{
1291
1292
  private flow;
1292
1293
  private deviceId;
1293
1294
  private dedicatedSessionRelease;
1295
+ private externalListener;
1294
1296
  private authCredentials;
1295
1297
  private requireAuth;
1296
1298
  private authNonces;
@@ -1355,6 +1357,13 @@ export declare class BaichuanRtspServer extends EventEmitter<{
1355
1357
  * Start the RTSP server.
1356
1358
  */
1357
1359
  start(): Promise<void>;
1360
+ /**
1361
+ * Accept an externally-routed RTSP connection.
1362
+ * Used in directHandoff mode where RtspProxyServer routes sockets here.
1363
+ * @param socket - The client TCP socket (already authenticated by proxy)
1364
+ * @param initialBuffer - Any bytes already read during path parsing/auth
1365
+ */
1366
+ acceptConnection(socket: net.Socket, initialBuffer?: Buffer): void;
1358
1367
  /**
1359
1368
  * Handle RTSP connection from a client.
1360
1369
  */
@@ -1407,6 +1416,33 @@ export declare class BaichuanRtspServer extends EventEmitter<{
1407
1416
  * Get number of connected clients.
1408
1417
  */
1409
1418
  getClientCount(): number;
1419
+ /**
1420
+ * Subscribe to the raw native stream for diagnostic purposes.
1421
+ * The subscriber receives the same frames as RTSP clients.
1422
+ * Counts as a "consumer" for lifecycle — prevents auto-stop while subscribed.
1423
+ * If the native stream is not active, starts it automatically.
1424
+ */
1425
+ subscribeDiagnostic(id: string): Promise<AsyncGenerator<{
1426
+ audio: boolean;
1427
+ data: Buffer;
1428
+ codec: string | null;
1429
+ sampleRate: number | null;
1430
+ microseconds: number | null;
1431
+ videoType?: "H264" | "H265";
1432
+ }, void, unknown>>;
1433
+ /**
1434
+ * Unsubscribe a diagnostic session.
1435
+ */
1436
+ unsubscribeDiagnostic(id: string): void;
1437
+ /**
1438
+ * Returns detected audio metadata (available after first audio frame).
1439
+ */
1440
+ getAudioInfo(): {
1441
+ codec: "aac-adts";
1442
+ sampleRate: number;
1443
+ channels: number;
1444
+ configHex: string;
1445
+ } | null;
1410
1446
  }
1411
1447
 
1412
1448
  export declare interface BaichuanRtspServerOptions {
@@ -1441,6 +1477,12 @@ export declare interface BaichuanRtspServerOptions {
1441
1477
  * isolating it from other streams on the shared socket (avoids streamType mismatch).
1442
1478
  */
1443
1479
  deviceId?: string;
1480
+ /**
1481
+ * When true, the server does NOT create its own net.Server.
1482
+ * Connections are accepted externally via acceptConnection().
1483
+ * start() still performs metadata fetch and codec detection.
1484
+ */
1485
+ externalListener?: boolean;
1444
1486
  }
1445
1487
 
1446
1488
  export declare type BaichuanSerialPush = {
@@ -8409,7 +8451,7 @@ export declare interface Rfc4571ApiFactoryContext {
8409
8451
  }
8410
8452
 
8411
8453
  export declare interface Rfc4571Client {
8412
- socket: net.Socket;
8454
+ socket: net_2.Socket;
8413
8455
  needsKeyframe: boolean;
8414
8456
  sentVideoConfig: boolean;
8415
8457
  }
@@ -8437,7 +8479,7 @@ export declare class Rfc4571Muxer {
8437
8479
  private cachedH264ParamSetsAnnexB;
8438
8480
  private cachedH265ParamSetsAnnexB;
8439
8481
  constructor(logger: Console, videoPayloadType: number, audioPayloadType: number | undefined, videoFpsFallback?: number, maxRtpPayload?: number);
8440
- addClient(socket: net.Socket): void;
8482
+ addClient(socket: net_2.Socket): void;
8441
8483
  private static readonly ANNEXB_START_CODE;
8442
8484
  private static joinAnnexBNals;
8443
8485
  private updateVideoParamSetsFromAccessUnit;
@@ -8477,7 +8519,7 @@ export declare interface Rfc4571ReplayServer {
8477
8519
  };
8478
8520
  username: string;
8479
8521
  password: string;
8480
- server: net.Server;
8522
+ server: net_2.Server;
8481
8523
  videoStream: BaichuanVideoStream;
8482
8524
  /** Called when replay naturally ends (all data sent). */
8483
8525
  onReplayEnd?: () => void;
@@ -8536,7 +8578,7 @@ export declare interface Rfc4571TcpServer {
8536
8578
  };
8537
8579
  username: string;
8538
8580
  password: string;
8539
- server: net.Server;
8581
+ server: net_2.Server;
8540
8582
  videoStream: BaichuanVideoStream | CompositeStream;
8541
8583
  close: (reason?: unknown) => Promise<void>;
8542
8584
  }
package/dist/index.js CHANGED
@@ -43,7 +43,7 @@ import {
43
43
  parseSupportXml,
44
44
  setGlobalLogger,
45
45
  xmlIndicatesFloodlight
46
- } from "./chunk-SDRNJQ5U.js";
46
+ } from "./chunk-TJNPGYJA.js";
47
47
  import {
48
48
  AesStreamDecryptor,
49
49
  BC_AES_IV,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apocaliss92/nodelink-js",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "TypeScript library implementing Reolink Baichuan protocol (control + streaming) with CGI and RTSP helpers. Full TypeScript support with comprehensive type definitions.",
5
5
  "license": "MIT",
6
6
  "author": "",