@apocaliss92/nodelink-js 0.2.5 → 0.3.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/{chunk-EG5IY3CM.js → chunk-YSEFEQYV.js} +412 -19
- package/dist/chunk-YSEFEQYV.js.map +1 -0
- package/dist/cli/rtsp-server.cjs +46 -15
- package/dist/cli/rtsp-server.cjs.map +1 -1
- package/dist/cli/rtsp-server.js +1 -1
- package/dist/index.cjs +480 -173
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +75 -70
- package/dist/index.d.ts +78 -69
- package/dist/index.js +46 -128
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-EG5IY3CM.js.map +0 -1
package/dist/cli/rtsp-server.cjs
CHANGED
|
@@ -8079,14 +8079,16 @@ var BaichuanRtspServer = class _BaichuanRtspServer extends import_node_events2.E
|
|
|
8079
8079
|
`;
|
|
8080
8080
|
}
|
|
8081
8081
|
if (body) {
|
|
8082
|
-
|
|
8082
|
+
const bodyBuf = Buffer.from(body, "utf8");
|
|
8083
|
+
response += `Content-Length: ${bodyBuf.length}\r
|
|
8083
8084
|
`;
|
|
8085
|
+
response += "\r\n";
|
|
8086
|
+
socket.write(response);
|
|
8087
|
+
socket.write(bodyBuf);
|
|
8088
|
+
} else {
|
|
8089
|
+
response += "\r\n";
|
|
8090
|
+
socket.write(response);
|
|
8084
8091
|
}
|
|
8085
|
-
response += "\r\n";
|
|
8086
|
-
if (body) {
|
|
8087
|
-
response += body;
|
|
8088
|
-
}
|
|
8089
|
-
socket.write(response);
|
|
8090
8092
|
};
|
|
8091
8093
|
this.rtspDebugLog(`RTSP ${method} ${url}`);
|
|
8092
8094
|
if (this.requireAuth) {
|
|
@@ -8296,10 +8298,25 @@ var BaichuanRtspServer = class _BaichuanRtspServer extends import_node_events2.E
|
|
|
8296
8298
|
);
|
|
8297
8299
|
}
|
|
8298
8300
|
}
|
|
8299
|
-
|
|
8300
|
-
|
|
8301
|
-
|
|
8302
|
-
|
|
8301
|
+
{
|
|
8302
|
+
const baseUrl = `rtsp://${this.listenHost}:${this.listenPort}${this.path}`;
|
|
8303
|
+
const resources = this.clientResources.get(clientId);
|
|
8304
|
+
const rtpInfoParts = [];
|
|
8305
|
+
if (resources?.setupTrack0) {
|
|
8306
|
+
rtpInfoParts.push(`url=${baseUrl}/track0`);
|
|
8307
|
+
}
|
|
8308
|
+
if (resources?.setupTrack1) {
|
|
8309
|
+
rtpInfoParts.push(`url=${baseUrl}/track1`);
|
|
8310
|
+
}
|
|
8311
|
+
const playHeaders = {
|
|
8312
|
+
Session: sessionId,
|
|
8313
|
+
Range: "npt=now-"
|
|
8314
|
+
};
|
|
8315
|
+
if (rtpInfoParts.length > 0) {
|
|
8316
|
+
playHeaders["RTP-Info"] = rtpInfoParts.join(",");
|
|
8317
|
+
}
|
|
8318
|
+
sendResponse(200, "OK", playHeaders);
|
|
8319
|
+
}
|
|
8303
8320
|
} else if (method === "TEARDOWN") {
|
|
8304
8321
|
this.logger.info(
|
|
8305
8322
|
`[rebroadcast] TEARDOWN client=${clientId} session=${sessionId}`
|
|
@@ -8329,6 +8346,8 @@ var BaichuanRtspServer = class _BaichuanRtspServer extends import_node_events2.E
|
|
|
8329
8346
|
sdp += `c=IN IP4 ${this.listenHost}\r
|
|
8330
8347
|
`;
|
|
8331
8348
|
sdp += "t=0 0\r\n";
|
|
8349
|
+
sdp += "a=range:npt=now-\r\n";
|
|
8350
|
+
sdp += "a=control:*\r\n";
|
|
8332
8351
|
sdp += `m=video 0 RTP/AVP ${videoPayloadType}\r
|
|
8333
8352
|
`;
|
|
8334
8353
|
sdp += `a=rtpmap:${videoPayloadType} ${codec}/90000\r
|
|
@@ -9271,7 +9290,14 @@ var BaichuanRtspServer = class _BaichuanRtspServer extends import_node_events2.E
|
|
|
9271
9290
|
this.firstFramePromise = null;
|
|
9272
9291
|
this.firstFrameResolve = null;
|
|
9273
9292
|
this.nativeFanout = null;
|
|
9274
|
-
|
|
9293
|
+
for (const [, resources] of this.clientResources) {
|
|
9294
|
+
const res = resources;
|
|
9295
|
+
res.rtpVideoBaseMicroseconds = void 0;
|
|
9296
|
+
res.rtpVideoBaseTimestamp = void 0;
|
|
9297
|
+
res.rtpVideoLastTimestamp = void 0;
|
|
9298
|
+
res.seenFirstVideoKeyframe = false;
|
|
9299
|
+
res.rtpSentVideoConfig = false;
|
|
9300
|
+
}
|
|
9275
9301
|
if (this.dedicatedSessionRelease) {
|
|
9276
9302
|
const release = this.dedicatedSessionRelease;
|
|
9277
9303
|
this.dedicatedSessionRelease = void 0;
|
|
@@ -22003,13 +22029,13 @@ ${stderr}`)
|
|
|
22003
22029
|
*/
|
|
22004
22030
|
async muxToMp4(params) {
|
|
22005
22031
|
const { spawn: spawn4 } = await import("child_process");
|
|
22006
|
-
const { randomUUID:
|
|
22032
|
+
const { randomUUID: randomUUID3 } = await import("crypto");
|
|
22007
22033
|
const fs5 = await import("fs/promises");
|
|
22008
22034
|
const os = await import("os");
|
|
22009
22035
|
const path5 = await import("path");
|
|
22010
22036
|
const ffmpeg = params.ffmpegPath ?? "ffmpeg";
|
|
22011
22037
|
const tmpDir = os.tmpdir();
|
|
22012
|
-
const id =
|
|
22038
|
+
const id = randomUUID3();
|
|
22013
22039
|
const videoFormat = params.videoCodec === "H265" ? "hevc" : "h264";
|
|
22014
22040
|
const videoPath = path5.join(tmpDir, `reolink-${id}.${videoFormat}`);
|
|
22015
22041
|
const outputPath = path5.join(tmpDir, `reolink-${id}.mp4`);
|
|
@@ -26991,8 +27017,13 @@ ${scheduleItems}
|
|
|
26991
27017
|
init_constants();
|
|
26992
27018
|
|
|
26993
27019
|
// src/reolink/discovery.ts
|
|
27020
|
+
var import_node_child_process4 = require("child_process");
|
|
27021
|
+
var import_node_crypto3 = require("crypto");
|
|
26994
27022
|
var import_node_dgram2 = __toESM(require("dgram"), 1);
|
|
27023
|
+
var net3 = __toESM(require("net"), 1);
|
|
26995
27024
|
var import_node_os2 = require("os");
|
|
27025
|
+
var import_node_util = require("util");
|
|
27026
|
+
var execFileAsync = (0, import_node_util.promisify)(import_node_child_process4.execFile);
|
|
26996
27027
|
async function discoverViaUdpDirect(host, options) {
|
|
26997
27028
|
if (!options.enableUdpDiscovery) return [];
|
|
26998
27029
|
const logger = options.logger;
|
|
@@ -27234,8 +27265,8 @@ function isTcpFailureThatShouldFallbackToUdp(e) {
|
|
|
27234
27265
|
async function pingHost(host, timeoutMs = 3e3) {
|
|
27235
27266
|
return new Promise((resolve) => {
|
|
27236
27267
|
const { exec } = require("child_process");
|
|
27237
|
-
const
|
|
27238
|
-
const pingCmd =
|
|
27268
|
+
const platform2 = process.platform;
|
|
27269
|
+
const pingCmd = platform2 === "win32" ? `ping -n 1 -w ${timeoutMs} ${host}` : platform2 === "darwin" ? (
|
|
27239
27270
|
// macOS: -W is in milliseconds (Linux: seconds)
|
|
27240
27271
|
`ping -c 1 -W ${timeoutMs} ${host}`
|
|
27241
27272
|
) : (
|