@apocaliss92/nodelink-js 0.6.6 → 0.6.7
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-JQ5NSEVD.js → chunk-T22QCNBR.js} +54 -16
- package/dist/chunk-T22QCNBR.js.map +1 -0
- package/dist/cli/rtsp-server.cjs +53 -15
- package/dist/cli/rtsp-server.cjs.map +1 -1
- package/dist/cli/rtsp-server.js +1 -1
- package/dist/index.cjs +75 -842
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -192
- package/dist/index.d.ts +4 -171
- package/dist/index.js +21 -823
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-JQ5NSEVD.js.map +0 -1
package/dist/cli/rtsp-server.cjs
CHANGED
|
@@ -8836,6 +8836,38 @@ function createRtspFlow(transport, videoType) {
|
|
|
8836
8836
|
return new H265Flow(transport);
|
|
8837
8837
|
}
|
|
8838
8838
|
|
|
8839
|
+
// src/baichuan/stream/rtpVideoTimestamp.ts
|
|
8840
|
+
var U32 = 4294967296;
|
|
8841
|
+
var DEFAULT_VIDEO_CLOCK_RATE = 9e4;
|
|
8842
|
+
function deriveRtpVideoTimestamp(state, frameMicroseconds, clockRate = DEFAULT_VIDEO_CLOCK_RATE) {
|
|
8843
|
+
if (frameMicroseconds === null || frameMicroseconds === void 0 || !Number.isFinite(frameMicroseconds)) {
|
|
8844
|
+
return { timestamp: state.timestamp, state };
|
|
8845
|
+
}
|
|
8846
|
+
const curRaw = frameMicroseconds >>> 0;
|
|
8847
|
+
if (state.baseUnwrappedUs === void 0) {
|
|
8848
|
+
return {
|
|
8849
|
+
timestamp: state.timestamp,
|
|
8850
|
+
state: {
|
|
8851
|
+
...state,
|
|
8852
|
+
unwrappedUs: curRaw,
|
|
8853
|
+
lastRawUs: curRaw,
|
|
8854
|
+
baseUnwrappedUs: curRaw,
|
|
8855
|
+
baseTimestamp: state.timestamp
|
|
8856
|
+
}
|
|
8857
|
+
};
|
|
8858
|
+
}
|
|
8859
|
+
const lastRaw = state.lastRawUs ?? curRaw;
|
|
8860
|
+
let forwardDelta = curRaw - lastRaw >>> 0;
|
|
8861
|
+
if (forwardDelta > U32 / 2) forwardDelta = 0;
|
|
8862
|
+
const unwrappedUs = (state.unwrappedUs ?? curRaw) + forwardDelta;
|
|
8863
|
+
const deltaUs = unwrappedUs - state.baseUnwrappedUs;
|
|
8864
|
+
const timestamp = state.baseTimestamp + Math.round(deltaUs * clockRate / 1e6) >>> 0;
|
|
8865
|
+
return {
|
|
8866
|
+
timestamp,
|
|
8867
|
+
state: { ...state, unwrappedUs, lastRawUs: curRaw, timestamp }
|
|
8868
|
+
};
|
|
8869
|
+
}
|
|
8870
|
+
|
|
8839
8871
|
// src/baichuan/stream/BaichuanRtspServer.ts
|
|
8840
8872
|
init_H264Converter();
|
|
8841
8873
|
init_H265Converter();
|
|
@@ -9410,7 +9442,10 @@ var BaichuanRtspServer = class _BaichuanRtspServer extends import_node_events3.E
|
|
|
9410
9442
|
let useTcpInterleaved = false;
|
|
9411
9443
|
let clientUdpSocket = null;
|
|
9412
9444
|
let clientUdpSocketAudio = null;
|
|
9445
|
+
let cleanedUp = false;
|
|
9413
9446
|
const cleanup = () => {
|
|
9447
|
+
if (cleanedUp) return;
|
|
9448
|
+
cleanedUp = true;
|
|
9414
9449
|
const sessionDurationMs = Date.now() - connectTime;
|
|
9415
9450
|
const res = this.clientResources.get(clientId);
|
|
9416
9451
|
const framesSent = res?.framesSent ?? 0;
|
|
@@ -10158,22 +10193,25 @@ var BaichuanRtspServer = class _BaichuanRtspServer extends import_node_events3.E
|
|
|
10158
10193
|
resources.rtpVideoTimestamp = 0;
|
|
10159
10194
|
if (resources.rtpVideoBaseTimestamp === void 0)
|
|
10160
10195
|
resources.rtpVideoBaseTimestamp = resources.rtpVideoTimestamp;
|
|
10161
|
-
|
|
10196
|
+
const { timestamp, state } = deriveRtpVideoTimestamp(
|
|
10197
|
+
{
|
|
10198
|
+
timestamp: resources.rtpVideoTimestamp,
|
|
10199
|
+
baseTimestamp: resources.rtpVideoBaseTimestamp,
|
|
10200
|
+
unwrappedUs: resources.rtpVideoUnwrappedUs,
|
|
10201
|
+
lastRawUs: resources.rtpVideoLastRawUs,
|
|
10202
|
+
baseUnwrappedUs: resources.rtpVideoBaseUnwrappedUs
|
|
10203
|
+
},
|
|
10204
|
+
frameMicroseconds,
|
|
10205
|
+
videoClockRate
|
|
10206
|
+
);
|
|
10207
|
+
resources.rtpVideoTimestamp = timestamp;
|
|
10208
|
+
resources.rtpVideoBaseTimestamp = state.baseTimestamp;
|
|
10209
|
+
resources.rtpVideoUnwrappedUs = state.unwrappedUs;
|
|
10210
|
+
resources.rtpVideoLastRawUs = state.lastRawUs;
|
|
10211
|
+
resources.rtpVideoBaseUnwrappedUs = state.baseUnwrappedUs;
|
|
10212
|
+
resources.rtpVideoLastTimestamp = timestamp;
|
|
10213
|
+
if (resources.rtpVideoBaseMicroseconds === void 0)
|
|
10162
10214
|
resources.rtpVideoBaseMicroseconds = frameMicroseconds >>> 0;
|
|
10163
|
-
resources.rtpVideoLastTimestamp = resources.rtpVideoTimestamp;
|
|
10164
|
-
return;
|
|
10165
|
-
}
|
|
10166
|
-
const baseUs = resources.rtpVideoBaseMicroseconds >>> 0;
|
|
10167
|
-
const curUs = frameMicroseconds >>> 0;
|
|
10168
|
-
const deltaUs = curUs - baseUs >>> 0;
|
|
10169
|
-
const baseTs = (resources.rtpVideoBaseTimestamp ?? 0) >>> 0;
|
|
10170
|
-
let ts = baseTs + Math.round(deltaUs * videoClockRate / 1e6) >>> 0;
|
|
10171
|
-
const last = resources.rtpVideoLastTimestamp;
|
|
10172
|
-
if (last !== void 0 && ts <= last >>> 0) {
|
|
10173
|
-
ts = (last >>> 0) + 1 >>> 0;
|
|
10174
|
-
}
|
|
10175
|
-
resources.rtpVideoTimestamp = ts;
|
|
10176
|
-
resources.rtpVideoLastTimestamp = ts;
|
|
10177
10215
|
};
|
|
10178
10216
|
const sendVideoAccessUnit = (videoType, accessUnitAnnexB, advanceTimestamp = true) => {
|
|
10179
10217
|
const nals = _BaichuanRtspServer.splitAnnexBNals(accessUnitAnnexB);
|