@camstack/addon-pipeline 1.2.283 → 1.2.285
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/audio-analyzer/index.js +2 -2
- package/dist/audio-analyzer/index.mjs +2 -2
- package/dist/{default-detection-model-CKdfniKn.js → default-detection-model-B9sgmjNE.js} +1 -1
- package/dist/{default-detection-model-i-0An9uD.mjs → default-detection-model-BbaeqJWd.mjs} +1 -1
- package/dist/detection-pipeline/index.js +4 -4
- package/dist/detection-pipeline/index.mjs +4 -4
- package/dist/{dist-BVWT6DUX.mjs → dist-L6fspiMs.mjs} +1479 -3
- package/dist/{dist-CB1sRktk.js → dist-bAVvh6zw.js} +1496 -2
- package/dist/motion-wasm/index.js +1 -1
- package/dist/motion-wasm/index.mjs +1 -1
- package/dist/{node-DZw6MNVd.js → node-BAHXRXps.js} +1 -1
- package/dist/{node-Dj1cgkd_.mjs → node-BKSzm60G.mjs} +1 -1
- package/dist/pipeline-runner/index.js +3 -3
- package/dist/pipeline-runner/index.mjs +3 -3
- package/dist/{process-memory-Cgxk_eAO.js → process-memory-B5Enn1QL.js} +1 -1
- package/dist/{process-memory-C0OIYwit.mjs → process-memory-gIGkgoj7.mjs} +1 -1
- package/dist/recorder/index.js +2 -2
- package/dist/recorder/index.mjs +2 -2
- package/dist/{segment-demux-js-DNN3T56h.js → segment-demux-js-BCxiqxMJ.js} +166 -148
- package/dist/{segment-demux-js-B6OsKCIg.mjs → segment-demux-js-DIMPKsLl.mjs} +149 -149
- package/dist/stream-broker/_stub.js +2 -2
- package/dist/stream-broker/{_virtual_mf-localSharedImportMap___mfe_internal__addon_stream_broker_widgets-C1dCLSas.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_stream_broker_widgets-BQppCOBh.mjs} +2 -2
- package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-BxqJbWC8.mjs +26 -0
- package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-DWcIgV47.mjs +26 -0
- package/dist/stream-broker/demux-worker-child.js +1 -1
- package/dist/stream-broker/demux-worker-child.mjs +1 -1
- package/dist/stream-broker/{hostInit-BNFyaEr_.mjs → hostInit-BMoj1Wh2.mjs} +2 -2
- package/dist/stream-broker/index.js +2141 -37
- package/dist/stream-broker/index.mjs +2141 -37
- package/dist/stream-broker/remoteEntry.js +1 -1
- package/package.json +1 -1
- package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-BV2tQ1w3.mjs +0 -26
- package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-BnLVuoDg.mjs +0 -26
|
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
const require_dist = require("../dist-
|
|
5
|
+
const require_dist = require("../dist-bAVvh6zw.js");
|
|
6
6
|
const require_lazy_sharp = require("../lazy-sharp-BuwKlQLR.js");
|
|
7
7
|
let node_fs = require("node:fs");
|
|
8
8
|
let node_path = require("node:path");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { an as DeviceType, dn as hydrateSchema, it as evaluateZoneRules, tn as BaseAddon, xt as motionDetectionCapability } from "../dist-L6fspiMs.mjs";
|
|
2
2
|
import { t as getSharp } from "../lazy-sharp-DXsqwpph.mjs";
|
|
3
3
|
import { readFileSync } from "node:fs";
|
|
4
4
|
import { join } from "node:path";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-emK7D4bc.js");
|
|
2
|
-
const require_dist = require("./dist-
|
|
2
|
+
const require_dist = require("./dist-bAVvh6zw.js");
|
|
3
3
|
let node_crypto = require("node:crypto");
|
|
4
4
|
let node_fs = require("node:fs");
|
|
5
5
|
node_fs = require_chunk.__toESM(node_fs, 1);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $t as isSoftwareDecode, Jt as errMsg, Xt as Fmp4BoxSplitter, Zt as buildFfmpegArgs } from "./dist-L6fspiMs.mjs";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import { realpathSync } from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
@@ -3,9 +3,9 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_chunk = require("../chunk-emK7D4bc.js");
|
|
6
|
-
const require_dist = require("../dist-
|
|
7
|
-
const require_node = require("../node-
|
|
8
|
-
const require_default_detection_model = require("../default-detection-model-
|
|
6
|
+
const require_dist = require("../dist-bAVvh6zw.js");
|
|
7
|
+
const require_node = require("../node-BAHXRXps.js");
|
|
8
|
+
const require_default_detection_model = require("../default-detection-model-B9sgmjNE.js");
|
|
9
9
|
const require_worker_protocol = require("../worker-protocol-B2MfQLlu.js");
|
|
10
10
|
const require_hub_hostname = require("../hub-hostname-DAJXlOgV.js");
|
|
11
11
|
const require_lazy_sharp = require("../lazy-sharp-BuwKlQLR.js");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as NO_COST_CLAIM, t as ChildCostRegistry } from "../node-
|
|
3
|
-
import { a as localFrameRegistry, d as getStepDefinition, i as rootObjectGate, o as resolveFrameViewGeometry, r as macroGateVerdict } from "../default-detection-model-
|
|
1
|
+
import { An as string, D as NativeLeaseSettingsSchema, Dn as object, Dt as pickNativeLeaseOverride, E as NativeLeaseAdmissionSchema, En as number, Et as pickDetailCropConvention, Jt as errMsg, Mn as EventCategory, S as FailureCounters, Sn as boolean, T as MOTION_CLOSE_AFTER_MS, Tn as literal, Z as deriveDetailCropRect, _ as DEVICE_BACKEND_TO_FORMAT, bn as _enum, cn as customAction, ct as failureContributionCapability, g as DEFAULT_NATIVE_LEASE_SETTINGS, hn as nodePin, kt as pipelineRunnerCapability, ln as defineCustomActions, p as DEFAULT_DETAIL_CROP_CONVENTION, pt as loadContributionCapability, sn as createEvent, tn as BaseAddon, wn as lazy, xn as array } from "../dist-L6fspiMs.mjs";
|
|
2
|
+
import { i as NO_COST_CLAIM, t as ChildCostRegistry } from "../node-BKSzm60G.mjs";
|
|
3
|
+
import { a as localFrameRegistry, d as getStepDefinition, i as rootObjectGate, o as resolveFrameViewGeometry, r as macroGateVerdict } from "../default-detection-model-BbaeqJWd.mjs";
|
|
4
4
|
import { t as isWorkerReply } from "../worker-protocol-C_W-P_g-.mjs";
|
|
5
5
|
import { t as resolveHubHostname } from "../hub-hostname-cCknRYKj.mjs";
|
|
6
6
|
import { t as getSharp } from "../lazy-sharp-DXsqwpph.mjs";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-emK7D4bc.js");
|
|
2
|
-
const require_dist = require("./dist-
|
|
2
|
+
const require_dist = require("./dist-bAVvh6zw.js");
|
|
3
3
|
let node_fs = require("node:fs");
|
|
4
4
|
node_fs = require_chunk.__toESM(node_fs);
|
|
5
5
|
let node_child_process = require("node:child_process");
|
package/dist/recorder/index.js
CHANGED
|
@@ -3,8 +3,8 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_chunk = require("../chunk-emK7D4bc.js");
|
|
6
|
-
const require_dist = require("../dist-
|
|
7
|
-
const require_node = require("../node-
|
|
6
|
+
const require_dist = require("../dist-bAVvh6zw.js");
|
|
7
|
+
const require_node = require("../node-BAHXRXps.js");
|
|
8
8
|
const require_hub_hostname = require("../hub-hostname-DAJXlOgV.js");
|
|
9
9
|
const require_restream_intent = require("../restream-intent-7uDNqMKs.js");
|
|
10
10
|
const require_retire_root_keys = require("../retire-root-keys-Csb8z2f3.js");
|
package/dist/recorder/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as physicalRootOf, i as NO_COST_CLAIM, t as ChildCostRegistry } from "../node-
|
|
1
|
+
import { An as string, Dn as object, En as number, Ft as resolveCreateExportSubject, G as clipExportFailureOf, H as batteryCapability, Ht as storageOccupancyCapability, I as VISIT_MERGE_GAP_MS, Jt as errMsg, Kt as videoclipsCapability, Lt as resolveLocationMode, M as RECORDING_EXPORT_MAX_READ_BYTES, Mn as EventCategory, Mt as recordingExportCapability, N as RecordingConfigSchema, Nt as recordingSignalCapability, O as OpsLogEntrySchema, On as preprocess, P as RecordingSignalStatusSchema, Q as deriveRecordingMode, Sn as boolean, Vt as storageEvictableCapability, W as clipExportFailure, Wt as stripRetiredBandPreBufferSec, X as deriveBatteryPresence, _t as mayReadLocation, an as DeviceType, at as evictionPolicyForMode, bn as _enum, bt as modeMayWrite, cn as customAction, dn as hydrateSchema, ft as isFirstLevelMacroClass, hn as nodePin, i as BatteryStatusSchema, in as DeviceFeature, jt as recordingCapability, kn as record, ln as defineCustomActions, lt as gbToBytes, m as DEFAULT_EVENTS_BAND_BUFFER_SEC, ot as evictionPolicyOfLocation, pt as loadContributionCapability, rt as evaluateSensorEdge, st as exportSubjectOf, tn as BaseAddon, v as EVENT_OWNER_TYPES, vn as selectAssignedProfileSlots, vt as mayWriteToLocation, x as ExportRecordSchema, xn as array, y as EVENT_PAD_MS, yn as sleep$1, yt as migrateLegacyDeviceSignalConfig, zt as resolveRecordingProfiles } from "../dist-L6fspiMs.mjs";
|
|
2
|
+
import { a as physicalRootOf, i as NO_COST_CLAIM, t as ChildCostRegistry } from "../node-BKSzm60G.mjs";
|
|
3
3
|
import { t as resolveHubHostname } from "../hub-hostname-cCknRYKj.mjs";
|
|
4
4
|
import { d as PREBUFFER_MAX_MS, l as withRecordingIntent, r as RECORDING_PRE_ROLL_REQUEST_MS } from "../restream-intent-DyGmLAU9.mjs";
|
|
5
5
|
import { n as RowMapStore, t as retireRootKeys } from "../retire-root-keys-DZvlso2l.mjs";
|
|
@@ -1,6 +1,153 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-emK7D4bc.js");
|
|
2
|
-
const require_dist = require("./dist-
|
|
2
|
+
const require_dist = require("./dist-bAVvh6zw.js");
|
|
3
3
|
let node_child_process = require("node:child_process");
|
|
4
|
+
//#region src/stream-broker/recorded/avcc-annexb.ts
|
|
5
|
+
/**
|
|
6
|
+
* avcc-annexb — pure byte helpers to turn an ISO-BMFF (mp4) length-prefixed
|
|
7
|
+
* video sample plus its `avcC`/`hvcC` decoder config into an Annex-B access
|
|
8
|
+
* unit with the parameter sets prepended (SPS/PPS for H.264, VPS/SPS/PPS for
|
|
9
|
+
* H.265).
|
|
10
|
+
*
|
|
11
|
+
* mp4 stores VCL NALs length-prefixed (AVCC/HVCC: a 1–4 byte big-endian length
|
|
12
|
+
* field, `lengthSizeMinusOne+1`, before each NAL) and keeps the parameter sets
|
|
13
|
+
* OUT of the samples, inside the `avcC`/`hvcC` box. A raw decoder / RTP
|
|
14
|
+
* packetizer needs Annex-B start codes (`00 00 00 01`) AND the parameter sets
|
|
15
|
+
* fused onto every IDR. These helpers do exactly that in JS — no ffmpeg, no
|
|
16
|
+
* decode, byte copies only — so the feeder-scrub keyframe path can skip the
|
|
17
|
+
* per-fragment ffmpeg spawn.
|
|
18
|
+
*
|
|
19
|
+
* All functions are pure and total for well-formed input; malformed config /
|
|
20
|
+
* sample bytes throw a `RangeError` (the caller treats a throw as "fall back to
|
|
21
|
+
* ffmpeg"). The `description` bytes are the box payload WITH the 8-byte box
|
|
22
|
+
* header already stripped (i.e. starting at `configurationVersion`), matching
|
|
23
|
+
* `mp4box`'s `avcC`/`hvcC` DataStream output minus header — see
|
|
24
|
+
* `recorder/scrub/fmp4-keyframes.ts` `extractDescription`.
|
|
25
|
+
*/
|
|
26
|
+
/** Annex-B 4-byte start code prepended before every emitted NAL. */
|
|
27
|
+
var START_CODE = Uint8Array.of(0, 0, 0, 1);
|
|
28
|
+
/** Big-endian unsigned read of `size` (1..4) bytes at `off`. */
|
|
29
|
+
function readUint(bytes, off, size) {
|
|
30
|
+
if (off + size > bytes.length) throw new RangeError(`readUint out of range: off=${off} size=${size} len=${bytes.length}`);
|
|
31
|
+
let v = 0;
|
|
32
|
+
for (let i = 0; i < size; i++) v = v * 256 + bytes[off + i];
|
|
33
|
+
return v;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* NAL length-prefix size in bytes (`lengthSizeMinusOne + 1`, 1..4) read from the
|
|
37
|
+
* decoder config. `avcC` carries it at byte 4 (low 2 bits); `hvcC` at byte 21
|
|
38
|
+
* (low 2 bits).
|
|
39
|
+
*/
|
|
40
|
+
function parseNalLengthSize(description, isHevc) {
|
|
41
|
+
const idx = isHevc ? 21 : 4;
|
|
42
|
+
if (description.length <= idx) throw new RangeError(`config too short for lengthSizeMinusOne (len=${description.length})`);
|
|
43
|
+
return (description[idx] & 3) + 1;
|
|
44
|
+
}
|
|
45
|
+
/** Concatenate byte chunks into one Uint8Array. */
|
|
46
|
+
function concat$1(chunks) {
|
|
47
|
+
let total = 0;
|
|
48
|
+
for (const c of chunks) total += c.length;
|
|
49
|
+
const out = new Uint8Array(total);
|
|
50
|
+
let off = 0;
|
|
51
|
+
for (const c of chunks) {
|
|
52
|
+
out.set(c, off);
|
|
53
|
+
off += c.length;
|
|
54
|
+
}
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
/** Push one Annex-B NAL (start code + payload) onto `chunks`. */
|
|
58
|
+
function pushNal(chunks, payload) {
|
|
59
|
+
chunks.push(START_CODE, payload);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Parse the `avcC` parameter sets (SPS then PPS), emitting each as an Annex-B
|
|
63
|
+
* NAL. Layout after the 4-byte profile/level prefix: byte 4 low-2 = length
|
|
64
|
+
* size; byte 5 low-5 = numSPS; then `[u16 len][SPS]…`; then `[u8 numPPS]`; then
|
|
65
|
+
* `[u16 len][PPS]…`.
|
|
66
|
+
*/
|
|
67
|
+
function extractAvcParameterSets(desc) {
|
|
68
|
+
const chunks = [];
|
|
69
|
+
const numSps = desc[5] & 31;
|
|
70
|
+
let p = 6;
|
|
71
|
+
for (let i = 0; i < numSps; i++) {
|
|
72
|
+
const len = readUint(desc, p, 2);
|
|
73
|
+
p += 2;
|
|
74
|
+
if (p + len > desc.length) throw new RangeError("avcC SPS length overruns config");
|
|
75
|
+
pushNal(chunks, desc.subarray(p, p + len));
|
|
76
|
+
p += len;
|
|
77
|
+
}
|
|
78
|
+
const numPps = readUint(desc, p, 1);
|
|
79
|
+
p += 1;
|
|
80
|
+
for (let i = 0; i < numPps; i++) {
|
|
81
|
+
const len = readUint(desc, p, 2);
|
|
82
|
+
p += 2;
|
|
83
|
+
if (p + len > desc.length) throw new RangeError("avcC PPS length overruns config");
|
|
84
|
+
pushNal(chunks, desc.subarray(p, p + len));
|
|
85
|
+
p += len;
|
|
86
|
+
}
|
|
87
|
+
return chunks;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Parse the `hvcC` parameter-set arrays (typically VPS, SPS, PPS in order),
|
|
91
|
+
* emitting each contained NAL as Annex-B. Layout: byte 22 = numOfArrays; then
|
|
92
|
+
* per array `[u8 flags+NALtype][u16 numNalus]` followed by `numNalus` ×
|
|
93
|
+
* `[u16 len][NAL]`.
|
|
94
|
+
*/
|
|
95
|
+
function extractHevcParameterSets(desc) {
|
|
96
|
+
const chunks = [];
|
|
97
|
+
const numArrays = readUint(desc, 22, 1);
|
|
98
|
+
let p = 23;
|
|
99
|
+
for (let a = 0; a < numArrays; a++) {
|
|
100
|
+
p += 1;
|
|
101
|
+
const numNalus = readUint(desc, p, 2);
|
|
102
|
+
p += 2;
|
|
103
|
+
for (let n = 0; n < numNalus; n++) {
|
|
104
|
+
const len = readUint(desc, p, 2);
|
|
105
|
+
p += 2;
|
|
106
|
+
if (p + len > desc.length) throw new RangeError("hvcC NAL length overruns config");
|
|
107
|
+
pushNal(chunks, desc.subarray(p, p + len));
|
|
108
|
+
p += len;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return chunks;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Parameter sets from the decoder config as one Annex-B blob (each NAL led by a
|
|
115
|
+
* `00 00 00 01` start code): SPS+PPS for H.264, VPS+SPS+PPS (+ any hvcC arrays)
|
|
116
|
+
* for H.265. Throws on a malformed config.
|
|
117
|
+
*/
|
|
118
|
+
function extractParameterSetsAnnexB(description, isHevc) {
|
|
119
|
+
return concat$1(isHevc ? extractHevcParameterSets(description) : extractAvcParameterSets(description));
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Convert one length-prefixed (AVCC/HVCC) sample into Annex-B: walk each
|
|
123
|
+
* `nalLengthSize`-byte length field, replacing it with a `00 00 00 01` start
|
|
124
|
+
* code. Handles multi-NAL samples (multiple slices / SEI + VCL). Throws if a
|
|
125
|
+
* length field overruns the sample.
|
|
126
|
+
*/
|
|
127
|
+
function avccSampleToAnnexB(sample, nalLengthSize) {
|
|
128
|
+
const chunks = [];
|
|
129
|
+
let p = 0;
|
|
130
|
+
while (p + nalLengthSize <= sample.length) {
|
|
131
|
+
const len = readUint(sample, p, nalLengthSize);
|
|
132
|
+
p += nalLengthSize;
|
|
133
|
+
if (len === 0) continue;
|
|
134
|
+
if (p + len > sample.length) throw new RangeError("AVCC NAL length overruns sample");
|
|
135
|
+
pushNal(chunks, sample.subarray(p, p + len));
|
|
136
|
+
p += len;
|
|
137
|
+
}
|
|
138
|
+
if (chunks.length === 0) throw new RangeError("AVCC sample yielded no NALs");
|
|
139
|
+
return concat$1(chunks);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Build a standalone-decodable Annex-B keyframe access unit: the config's
|
|
143
|
+
* parameter sets, then the sample's NALs, all Annex-B framed. Throws on
|
|
144
|
+
* malformed input (caller falls back to the ffmpeg demux).
|
|
145
|
+
*/
|
|
146
|
+
function buildKeyframeAnnexB(sample, description, isHevc) {
|
|
147
|
+
const nalLengthSize = parseNalLengthSize(description, isHevc);
|
|
148
|
+
return concat$1([extractParameterSetsAnnexB(description, isHevc), avccSampleToAnnexB(sample, nalLengthSize)]);
|
|
149
|
+
}
|
|
150
|
+
//#endregion
|
|
4
151
|
//#region ../../node_modules/mp4box/dist/mp4box.all.js
|
|
5
152
|
var require_mp4box_all = /* @__PURE__ */ require_chunk.__commonJSMin(((exports) => {
|
|
6
153
|
var Log = (function() {
|
|
@@ -6674,153 +6821,6 @@ async function extractSamples(segment, segmentStartMs) {
|
|
|
6674
6821
|
} : null;
|
|
6675
6822
|
}
|
|
6676
6823
|
//#endregion
|
|
6677
|
-
//#region src/stream-broker/recorded/avcc-annexb.ts
|
|
6678
|
-
/**
|
|
6679
|
-
* avcc-annexb — pure byte helpers to turn an ISO-BMFF (mp4) length-prefixed
|
|
6680
|
-
* video sample plus its `avcC`/`hvcC` decoder config into an Annex-B access
|
|
6681
|
-
* unit with the parameter sets prepended (SPS/PPS for H.264, VPS/SPS/PPS for
|
|
6682
|
-
* H.265).
|
|
6683
|
-
*
|
|
6684
|
-
* mp4 stores VCL NALs length-prefixed (AVCC/HVCC: a 1–4 byte big-endian length
|
|
6685
|
-
* field, `lengthSizeMinusOne+1`, before each NAL) and keeps the parameter sets
|
|
6686
|
-
* OUT of the samples, inside the `avcC`/`hvcC` box. A raw decoder / RTP
|
|
6687
|
-
* packetizer needs Annex-B start codes (`00 00 00 01`) AND the parameter sets
|
|
6688
|
-
* fused onto every IDR. These helpers do exactly that in JS — no ffmpeg, no
|
|
6689
|
-
* decode, byte copies only — so the feeder-scrub keyframe path can skip the
|
|
6690
|
-
* per-fragment ffmpeg spawn.
|
|
6691
|
-
*
|
|
6692
|
-
* All functions are pure and total for well-formed input; malformed config /
|
|
6693
|
-
* sample bytes throw a `RangeError` (the caller treats a throw as "fall back to
|
|
6694
|
-
* ffmpeg"). The `description` bytes are the box payload WITH the 8-byte box
|
|
6695
|
-
* header already stripped (i.e. starting at `configurationVersion`), matching
|
|
6696
|
-
* `mp4box`'s `avcC`/`hvcC` DataStream output minus header — see
|
|
6697
|
-
* `recorder/scrub/fmp4-keyframes.ts` `extractDescription`.
|
|
6698
|
-
*/
|
|
6699
|
-
/** Annex-B 4-byte start code prepended before every emitted NAL. */
|
|
6700
|
-
var START_CODE = Uint8Array.of(0, 0, 0, 1);
|
|
6701
|
-
/** Big-endian unsigned read of `size` (1..4) bytes at `off`. */
|
|
6702
|
-
function readUint(bytes, off, size) {
|
|
6703
|
-
if (off + size > bytes.length) throw new RangeError(`readUint out of range: off=${off} size=${size} len=${bytes.length}`);
|
|
6704
|
-
let v = 0;
|
|
6705
|
-
for (let i = 0; i < size; i++) v = v * 256 + bytes[off + i];
|
|
6706
|
-
return v;
|
|
6707
|
-
}
|
|
6708
|
-
/**
|
|
6709
|
-
* NAL length-prefix size in bytes (`lengthSizeMinusOne + 1`, 1..4) read from the
|
|
6710
|
-
* decoder config. `avcC` carries it at byte 4 (low 2 bits); `hvcC` at byte 21
|
|
6711
|
-
* (low 2 bits).
|
|
6712
|
-
*/
|
|
6713
|
-
function parseNalLengthSize(description, isHevc) {
|
|
6714
|
-
const idx = isHevc ? 21 : 4;
|
|
6715
|
-
if (description.length <= idx) throw new RangeError(`config too short for lengthSizeMinusOne (len=${description.length})`);
|
|
6716
|
-
return (description[idx] & 3) + 1;
|
|
6717
|
-
}
|
|
6718
|
-
/** Concatenate byte chunks into one Uint8Array. */
|
|
6719
|
-
function concat$1(chunks) {
|
|
6720
|
-
let total = 0;
|
|
6721
|
-
for (const c of chunks) total += c.length;
|
|
6722
|
-
const out = new Uint8Array(total);
|
|
6723
|
-
let off = 0;
|
|
6724
|
-
for (const c of chunks) {
|
|
6725
|
-
out.set(c, off);
|
|
6726
|
-
off += c.length;
|
|
6727
|
-
}
|
|
6728
|
-
return out;
|
|
6729
|
-
}
|
|
6730
|
-
/** Push one Annex-B NAL (start code + payload) onto `chunks`. */
|
|
6731
|
-
function pushNal(chunks, payload) {
|
|
6732
|
-
chunks.push(START_CODE, payload);
|
|
6733
|
-
}
|
|
6734
|
-
/**
|
|
6735
|
-
* Parse the `avcC` parameter sets (SPS then PPS), emitting each as an Annex-B
|
|
6736
|
-
* NAL. Layout after the 4-byte profile/level prefix: byte 4 low-2 = length
|
|
6737
|
-
* size; byte 5 low-5 = numSPS; then `[u16 len][SPS]…`; then `[u8 numPPS]`; then
|
|
6738
|
-
* `[u16 len][PPS]…`.
|
|
6739
|
-
*/
|
|
6740
|
-
function extractAvcParameterSets(desc) {
|
|
6741
|
-
const chunks = [];
|
|
6742
|
-
const numSps = desc[5] & 31;
|
|
6743
|
-
let p = 6;
|
|
6744
|
-
for (let i = 0; i < numSps; i++) {
|
|
6745
|
-
const len = readUint(desc, p, 2);
|
|
6746
|
-
p += 2;
|
|
6747
|
-
if (p + len > desc.length) throw new RangeError("avcC SPS length overruns config");
|
|
6748
|
-
pushNal(chunks, desc.subarray(p, p + len));
|
|
6749
|
-
p += len;
|
|
6750
|
-
}
|
|
6751
|
-
const numPps = readUint(desc, p, 1);
|
|
6752
|
-
p += 1;
|
|
6753
|
-
for (let i = 0; i < numPps; i++) {
|
|
6754
|
-
const len = readUint(desc, p, 2);
|
|
6755
|
-
p += 2;
|
|
6756
|
-
if (p + len > desc.length) throw new RangeError("avcC PPS length overruns config");
|
|
6757
|
-
pushNal(chunks, desc.subarray(p, p + len));
|
|
6758
|
-
p += len;
|
|
6759
|
-
}
|
|
6760
|
-
return chunks;
|
|
6761
|
-
}
|
|
6762
|
-
/**
|
|
6763
|
-
* Parse the `hvcC` parameter-set arrays (typically VPS, SPS, PPS in order),
|
|
6764
|
-
* emitting each contained NAL as Annex-B. Layout: byte 22 = numOfArrays; then
|
|
6765
|
-
* per array `[u8 flags+NALtype][u16 numNalus]` followed by `numNalus` ×
|
|
6766
|
-
* `[u16 len][NAL]`.
|
|
6767
|
-
*/
|
|
6768
|
-
function extractHevcParameterSets(desc) {
|
|
6769
|
-
const chunks = [];
|
|
6770
|
-
const numArrays = readUint(desc, 22, 1);
|
|
6771
|
-
let p = 23;
|
|
6772
|
-
for (let a = 0; a < numArrays; a++) {
|
|
6773
|
-
p += 1;
|
|
6774
|
-
const numNalus = readUint(desc, p, 2);
|
|
6775
|
-
p += 2;
|
|
6776
|
-
for (let n = 0; n < numNalus; n++) {
|
|
6777
|
-
const len = readUint(desc, p, 2);
|
|
6778
|
-
p += 2;
|
|
6779
|
-
if (p + len > desc.length) throw new RangeError("hvcC NAL length overruns config");
|
|
6780
|
-
pushNal(chunks, desc.subarray(p, p + len));
|
|
6781
|
-
p += len;
|
|
6782
|
-
}
|
|
6783
|
-
}
|
|
6784
|
-
return chunks;
|
|
6785
|
-
}
|
|
6786
|
-
/**
|
|
6787
|
-
* Parameter sets from the decoder config as one Annex-B blob (each NAL led by a
|
|
6788
|
-
* `00 00 00 01` start code): SPS+PPS for H.264, VPS+SPS+PPS (+ any hvcC arrays)
|
|
6789
|
-
* for H.265. Throws on a malformed config.
|
|
6790
|
-
*/
|
|
6791
|
-
function extractParameterSetsAnnexB(description, isHevc) {
|
|
6792
|
-
return concat$1(isHevc ? extractHevcParameterSets(description) : extractAvcParameterSets(description));
|
|
6793
|
-
}
|
|
6794
|
-
/**
|
|
6795
|
-
* Convert one length-prefixed (AVCC/HVCC) sample into Annex-B: walk each
|
|
6796
|
-
* `nalLengthSize`-byte length field, replacing it with a `00 00 00 01` start
|
|
6797
|
-
* code. Handles multi-NAL samples (multiple slices / SEI + VCL). Throws if a
|
|
6798
|
-
* length field overruns the sample.
|
|
6799
|
-
*/
|
|
6800
|
-
function avccSampleToAnnexB(sample, nalLengthSize) {
|
|
6801
|
-
const chunks = [];
|
|
6802
|
-
let p = 0;
|
|
6803
|
-
while (p + nalLengthSize <= sample.length) {
|
|
6804
|
-
const len = readUint(sample, p, nalLengthSize);
|
|
6805
|
-
p += nalLengthSize;
|
|
6806
|
-
if (len === 0) continue;
|
|
6807
|
-
if (p + len > sample.length) throw new RangeError("AVCC NAL length overruns sample");
|
|
6808
|
-
pushNal(chunks, sample.subarray(p, p + len));
|
|
6809
|
-
p += len;
|
|
6810
|
-
}
|
|
6811
|
-
if (chunks.length === 0) throw new RangeError("AVCC sample yielded no NALs");
|
|
6812
|
-
return concat$1(chunks);
|
|
6813
|
-
}
|
|
6814
|
-
/**
|
|
6815
|
-
* Build a standalone-decodable Annex-B keyframe access unit: the config's
|
|
6816
|
-
* parameter sets, then the sample's NALs, all Annex-B framed. Throws on
|
|
6817
|
-
* malformed input (caller falls back to the ffmpeg demux).
|
|
6818
|
-
*/
|
|
6819
|
-
function buildKeyframeAnnexB(sample, description, isHevc) {
|
|
6820
|
-
const nalLengthSize = parseNalLengthSize(description, isHevc);
|
|
6821
|
-
return concat$1([extractParameterSetsAnnexB(description, isHevc), avccSampleToAnnexB(sample, nalLengthSize)]);
|
|
6822
|
-
}
|
|
6823
|
-
//#endregion
|
|
6824
6824
|
//#region src/stream-broker/recorded/ffmpeg-run-once.ts
|
|
6825
6825
|
/**
|
|
6826
6826
|
* ffmpeg-run-once — spawn ffmpeg for ONE batch conversion: feed an in-memory
|
|
@@ -7285,6 +7285,18 @@ async function demuxSegmentPreferJs(bytes, opts = {}) {
|
|
|
7285
7285
|
return demuxSegmentToAnnexB(bytes, opts.ffmpegPath);
|
|
7286
7286
|
}
|
|
7287
7287
|
//#endregion
|
|
7288
|
+
Object.defineProperty(exports, "avccSampleToAnnexB", {
|
|
7289
|
+
enumerable: true,
|
|
7290
|
+
get: function() {
|
|
7291
|
+
return avccSampleToAnnexB;
|
|
7292
|
+
}
|
|
7293
|
+
});
|
|
7294
|
+
Object.defineProperty(exports, "buildKeyframeAnnexB", {
|
|
7295
|
+
enumerable: true,
|
|
7296
|
+
get: function() {
|
|
7297
|
+
return buildKeyframeAnnexB;
|
|
7298
|
+
}
|
|
7299
|
+
});
|
|
7288
7300
|
Object.defineProperty(exports, "demuxSegmentFullJs", {
|
|
7289
7301
|
enumerable: true,
|
|
7290
7302
|
get: function() {
|
|
@@ -7297,6 +7309,12 @@ Object.defineProperty(exports, "demuxSegmentPreferJs", {
|
|
|
7297
7309
|
return demuxSegmentPreferJs;
|
|
7298
7310
|
}
|
|
7299
7311
|
});
|
|
7312
|
+
Object.defineProperty(exports, "parseNalLengthSize", {
|
|
7313
|
+
enumerable: true,
|
|
7314
|
+
get: function() {
|
|
7315
|
+
return parseNalLengthSize;
|
|
7316
|
+
}
|
|
7317
|
+
});
|
|
7300
7318
|
Object.defineProperty(exports, "require_mp4box_all", {
|
|
7301
7319
|
enumerable: true,
|
|
7302
7320
|
get: function() {
|