@camstack/addon-pipeline 1.1.19 → 1.1.21

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.
Files changed (34) hide show
  1. package/dist/audio-analyzer/index.js +1 -1
  2. package/dist/audio-analyzer/index.mjs +1 -1
  3. package/dist/audio-codec-ffmpeg/index.js +1125 -0
  4. package/dist/audio-codec-ffmpeg/index.mjs +1107 -0
  5. package/dist/decoder-ffmpeg/index.js +543 -288
  6. package/dist/decoder-ffmpeg/index.mjs +542 -287
  7. package/dist/detection-pipeline/index.js +1 -1
  8. package/dist/detection-pipeline/index.mjs +1 -1
  9. package/dist/{dist-BgoBMCez.js → dist-BiP1gPeY.js} +20 -1
  10. package/dist/{dist-7Yx2dmuV.mjs → dist-tzhTTRq4.mjs} +20 -1
  11. package/dist/{ffmpeg-args-common-c3p-nWtU.mjs → frame-dropper-CwkBTPGV.mjs} +22 -22
  12. package/dist/motion-wasm/index.js +1 -1
  13. package/dist/motion-wasm/index.mjs +1 -1
  14. package/dist/pipeline-runner/index.js +1 -1
  15. package/dist/pipeline-runner/index.mjs +1 -1
  16. package/dist/recorder/index.js +24 -4
  17. package/dist/recorder/index.mjs +24 -4
  18. package/dist/stream-broker/_stub.js +35 -35
  19. package/dist/stream-broker/{_virtual_mf-localSharedImportMap___mfe_internal__addon_stream_broker_widgets-w2pP0MYO.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_stream_broker_widgets-D08qJTw_.mjs} +3 -3
  20. package/dist/stream-broker/{hostInit-BUEbBinp.mjs → hostInit-CGnMNtPl.mjs} +3 -3
  21. package/dist/stream-broker/index.js +487 -458
  22. package/dist/stream-broker/index.mjs +477 -448
  23. package/dist/stream-broker/remoteEntry.js +1 -1
  24. package/embed-dist/assets/{MaskShapeCanvas-DI4BY7W2-CYmHXacX.js → MaskShapeCanvas-DI4BY7W2-CW4Qu4V6.js} +1 -1
  25. package/embed-dist/assets/{MotionZonesSettings-NcxxQN8r-B-BkPQvX.js → MotionZonesSettings-NcxxQN8r-CHJ39tfi.js} +1 -1
  26. package/embed-dist/assets/{PrivacyMaskSettings-APgPLF7p-DC3Jw85p.js → PrivacyMaskSettings-APgPLF7p-dInJ7kcz.js} +1 -1
  27. package/embed-dist/assets/{index-B0IQgci0.js → index-CKpVWKSG.js} +4 -4
  28. package/embed-dist/index.html +1 -1
  29. package/package.json +10 -10
  30. package/dist/audio-codec-nodeav/index.js +0 -310
  31. package/dist/audio-codec-nodeav/index.mjs +0 -305
  32. package/dist/codec-runtime-BOk-13PN.js +0 -202
  33. package/dist/codec-runtime-BsqlEjPi.mjs +0 -197
  34. package/dist/{ffmpeg-args-common-CASoNt42.js → frame-dropper-7RTo_YyG.js} +21 -21
@@ -1,202 +0,0 @@
1
- let node_av = require("node-av");
2
- //#region src/audio-codec-nodeav/addon/codec-runtime.ts
3
- /**
4
- * Thin libavcodec/libswresample wrapper backing one decode or encode
5
- * session in `audio-codec`. Holds:
6
- * - CodecContext (decoder or encoder)
7
- * - SoftwareResampleContext for input format → output format
8
- * - reusable Packet + input/output Frame
9
- *
10
- * Stateful — one runtime per session. The cap addon owns the lifecycle.
11
- */
12
- var CODEC_ID_BY_NAME = {
13
- aac: node_av.AV_CODEC_ID_AAC,
14
- aac_latm: node_av.AV_CODEC_ID_AAC_LATM,
15
- opus: node_av.AV_CODEC_ID_OPUS,
16
- pcm_alaw: node_av.AV_CODEC_ID_PCM_ALAW,
17
- pcm_mulaw: node_av.AV_CODEC_ID_PCM_MULAW
18
- };
19
- function resolveCodecId(codec) {
20
- return CODEC_ID_BY_NAME[codec.toLowerCase()] ?? null;
21
- }
22
- function buildChannelLayout(channels) {
23
- if (channels === 1) return {
24
- nbChannels: 1,
25
- order: node_av.AV_CHANNEL_ORDER_NATIVE,
26
- mask: node_av.AV_CH_LAYOUT_MONO
27
- };
28
- if (channels === 2) return {
29
- nbChannels: 2,
30
- order: node_av.AV_CHANNEL_ORDER_NATIVE,
31
- mask: node_av.AV_CH_LAYOUT_STEREO
32
- };
33
- return {
34
- nbChannels: channels,
35
- order: node_av.AV_CHANNEL_ORDER_NATIVE,
36
- mask: 0n
37
- };
38
- }
39
- function pcmFormatToAv(format) {
40
- switch (format) {
41
- case "f32le": return node_av.AV_SAMPLE_FMT_FLT;
42
- case "s16le": return node_av.AV_SAMPLE_FMT_S16;
43
- }
44
- }
45
- function bytesPerSample(format) {
46
- switch (format) {
47
- case "f32le": return 4;
48
- case "s16le": return 2;
49
- }
50
- }
51
- var DecodeRuntime = class DecodeRuntime {
52
- ctx;
53
- swr;
54
- packet;
55
- inFrame;
56
- outFrame;
57
- cfg;
58
- inLayout;
59
- outLayout;
60
- inSampleFmt;
61
- outSampleFmt;
62
- outBytesPerSample;
63
- nextPts = 0;
64
- closed = false;
65
- static create(cfg) {
66
- const codecId = resolveCodecId(cfg.codec);
67
- if (codecId === null) throw new Error(`audio-codec: unknown codec '${cfg.codec}' for decode runtime`);
68
- const codec = node_av.Codec.findDecoder(codecId);
69
- if (!codec) throw new Error(`audio-codec: decoder not registered for codec '${cfg.codec}'`);
70
- const ctx = new node_av.CodecContext();
71
- ctx.allocContext3(codec);
72
- ctx.sampleRate = cfg.sourceSampleRate;
73
- ctx.channels = cfg.sourceChannels;
74
- const inLayout = buildChannelLayout(cfg.sourceChannels);
75
- ctx.channelLayout = inLayout;
76
- if (cfg.extraData && cfg.extraData.byteLength > 0) ctx.extraData = Buffer.from(cfg.extraData);
77
- const ret = ctx.open2Sync(codec, null);
78
- if (ret < 0) {
79
- ctx.freeContext();
80
- throw new Error(`audio-codec: open2 failed for '${cfg.codec}' (ret=${ret})`);
81
- }
82
- const inSampleFmt = ctx.sampleFormat ?? node_av.AV_SAMPLE_FMT_FLT;
83
- const outSampleFmt = pcmFormatToAv(cfg.targetFormat);
84
- const outLayout = buildChannelLayout(cfg.targetChannels);
85
- const swr = new node_av.SoftwareResampleContext();
86
- const allocRet = swr.allocSetOpts2(outLayout, outSampleFmt, cfg.targetSampleRate, inLayout, inSampleFmt, cfg.sourceSampleRate);
87
- if (allocRet < 0) {
88
- ctx.freeContext();
89
- throw new Error(`audio-codec: swr allocSetOpts2 failed (ret=${allocRet})`);
90
- }
91
- const initRet = swr.init();
92
- if (initRet < 0) {
93
- ctx.freeContext();
94
- throw new Error(`audio-codec: swr init failed (ret=${initRet})`);
95
- }
96
- const packet = new node_av.Packet();
97
- packet.alloc();
98
- const inFrame = new node_av.Frame();
99
- inFrame.alloc();
100
- const outFrame = new node_av.Frame();
101
- outFrame.alloc();
102
- return new DecodeRuntime(ctx, swr, packet, inFrame, outFrame, cfg, inLayout, outLayout, inSampleFmt, outSampleFmt);
103
- }
104
- constructor(ctx, swr, packet, inFrame, outFrame, cfg, inLayout, outLayout, inSampleFmt, outSampleFmt) {
105
- this.ctx = ctx;
106
- this.swr = swr;
107
- this.packet = packet;
108
- this.inFrame = inFrame;
109
- this.outFrame = outFrame;
110
- this.cfg = cfg;
111
- this.inLayout = inLayout;
112
- this.outLayout = outLayout;
113
- this.inSampleFmt = inSampleFmt;
114
- this.outSampleFmt = outSampleFmt;
115
- this.outBytesPerSample = bytesPerSample(cfg.targetFormat);
116
- }
117
- decode(buf, pts) {
118
- if (this.closed) return [];
119
- this.packet.data = Buffer.from(buf);
120
- if (pts !== void 0) {
121
- this.packet.pts = BigInt(Math.round(pts));
122
- this.packet.dts = BigInt(Math.round(pts));
123
- }
124
- const sendRet = this.ctx.sendPacketSync(this.packet);
125
- if (sendRet < 0 && sendRet !== node_av.AVERROR_EAGAIN) throw new Error(`audio-codec: sendPacket failed (ret=${sendRet})`);
126
- const out = [];
127
- while (true) {
128
- const recvRet = this.ctx.receiveFrameSync(this.inFrame);
129
- if (recvRet === node_av.AVERROR_EAGAIN || recvRet === node_av.AVERROR_EOF) break;
130
- if (recvRet < 0) throw new Error(`audio-codec: receiveFrame failed (ret=${recvRet})`);
131
- const pcm = this.resampleFrame(this.inFrame);
132
- if (pcm) out.push(pcm);
133
- this.inFrame.unref();
134
- }
135
- return out;
136
- }
137
- resampleFrame(inFrame) {
138
- const inSamples = inFrame.nbSamples;
139
- const outSamples = Math.ceil(inSamples * this.cfg.targetSampleRate / this.cfg.sourceSampleRate) + 32;
140
- this.outFrame.unref();
141
- this.outFrame.format = this.outSampleFmt;
142
- this.outFrame.sampleRate = this.cfg.targetSampleRate;
143
- this.outFrame.channelLayout = this.outLayout;
144
- this.outFrame.nbSamples = outSamples;
145
- const allocRet = this.outFrame.getBuffer(0);
146
- if (allocRet < 0) throw new Error(`audio-codec: outFrame.getBuffer failed (ret=${allocRet})`);
147
- const convRet = this.swr.convertFrame(this.outFrame, inFrame);
148
- if (convRet < 0) throw new Error(`audio-codec: swr.convertFrame failed (ret=${convRet})`);
149
- const producedSamples = this.outFrame.nbSamples;
150
- if (producedSamples <= 0) return null;
151
- const planes = this.outFrame.extendedData;
152
- if (!planes || planes.length === 0 || !planes[0]) return null;
153
- const bytes = producedSamples * this.cfg.targetChannels * this.outBytesPerSample;
154
- const src = planes[0];
155
- const out = new Uint8Array(new ArrayBuffer(bytes));
156
- out.set(src.subarray(0, bytes));
157
- const ptsMs = this.nextPts;
158
- this.nextPts = ptsMs + Math.round(producedSamples * 1e3 / this.cfg.targetSampleRate);
159
- return {
160
- data: out,
161
- sampleRate: this.cfg.targetSampleRate,
162
- channels: this.cfg.targetChannels,
163
- format: this.cfg.targetFormat,
164
- pts: ptsMs
165
- };
166
- }
167
- close() {
168
- if (this.closed) return;
169
- this.closed = true;
170
- try {
171
- this.outFrame.free();
172
- } catch {}
173
- try {
174
- this.inFrame.free();
175
- } catch {}
176
- try {
177
- this.packet.free();
178
- } catch {}
179
- try {
180
- this.swr.free();
181
- } catch {}
182
- try {
183
- this.ctx.freeContext();
184
- } catch {}
185
- }
186
- /** Surfaced for assertion-style tests to inspect computed layouts. */
187
- describe() {
188
- return {
189
- inLayoutMask: this.inLayout.mask,
190
- outLayoutMask: this.outLayout.mask,
191
- inSampleFormat: this.inSampleFmt,
192
- outSampleFormat: this.outSampleFmt
193
- };
194
- }
195
- };
196
- //#endregion
197
- Object.defineProperty(exports, "DecodeRuntime", {
198
- enumerable: true,
199
- get: function() {
200
- return DecodeRuntime;
201
- }
202
- });
@@ -1,197 +0,0 @@
1
- import { AVERROR_EAGAIN, AVERROR_EOF, AV_CHANNEL_ORDER_NATIVE, AV_CH_LAYOUT_MONO, AV_CH_LAYOUT_STEREO, AV_CODEC_ID_AAC, AV_CODEC_ID_AAC_LATM, AV_CODEC_ID_OPUS, AV_CODEC_ID_PCM_ALAW, AV_CODEC_ID_PCM_MULAW, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, Codec, CodecContext, Frame, Packet, SoftwareResampleContext } from "node-av";
2
- //#region src/audio-codec-nodeav/addon/codec-runtime.ts
3
- /**
4
- * Thin libavcodec/libswresample wrapper backing one decode or encode
5
- * session in `audio-codec`. Holds:
6
- * - CodecContext (decoder or encoder)
7
- * - SoftwareResampleContext for input format → output format
8
- * - reusable Packet + input/output Frame
9
- *
10
- * Stateful — one runtime per session. The cap addon owns the lifecycle.
11
- */
12
- var CODEC_ID_BY_NAME = {
13
- aac: AV_CODEC_ID_AAC,
14
- aac_latm: AV_CODEC_ID_AAC_LATM,
15
- opus: AV_CODEC_ID_OPUS,
16
- pcm_alaw: AV_CODEC_ID_PCM_ALAW,
17
- pcm_mulaw: AV_CODEC_ID_PCM_MULAW
18
- };
19
- function resolveCodecId(codec) {
20
- return CODEC_ID_BY_NAME[codec.toLowerCase()] ?? null;
21
- }
22
- function buildChannelLayout(channels) {
23
- if (channels === 1) return {
24
- nbChannels: 1,
25
- order: AV_CHANNEL_ORDER_NATIVE,
26
- mask: AV_CH_LAYOUT_MONO
27
- };
28
- if (channels === 2) return {
29
- nbChannels: 2,
30
- order: AV_CHANNEL_ORDER_NATIVE,
31
- mask: AV_CH_LAYOUT_STEREO
32
- };
33
- return {
34
- nbChannels: channels,
35
- order: AV_CHANNEL_ORDER_NATIVE,
36
- mask: 0n
37
- };
38
- }
39
- function pcmFormatToAv(format) {
40
- switch (format) {
41
- case "f32le": return AV_SAMPLE_FMT_FLT;
42
- case "s16le": return AV_SAMPLE_FMT_S16;
43
- }
44
- }
45
- function bytesPerSample(format) {
46
- switch (format) {
47
- case "f32le": return 4;
48
- case "s16le": return 2;
49
- }
50
- }
51
- var DecodeRuntime = class DecodeRuntime {
52
- ctx;
53
- swr;
54
- packet;
55
- inFrame;
56
- outFrame;
57
- cfg;
58
- inLayout;
59
- outLayout;
60
- inSampleFmt;
61
- outSampleFmt;
62
- outBytesPerSample;
63
- nextPts = 0;
64
- closed = false;
65
- static create(cfg) {
66
- const codecId = resolveCodecId(cfg.codec);
67
- if (codecId === null) throw new Error(`audio-codec: unknown codec '${cfg.codec}' for decode runtime`);
68
- const codec = Codec.findDecoder(codecId);
69
- if (!codec) throw new Error(`audio-codec: decoder not registered for codec '${cfg.codec}'`);
70
- const ctx = new CodecContext();
71
- ctx.allocContext3(codec);
72
- ctx.sampleRate = cfg.sourceSampleRate;
73
- ctx.channels = cfg.sourceChannels;
74
- const inLayout = buildChannelLayout(cfg.sourceChannels);
75
- ctx.channelLayout = inLayout;
76
- if (cfg.extraData && cfg.extraData.byteLength > 0) ctx.extraData = Buffer.from(cfg.extraData);
77
- const ret = ctx.open2Sync(codec, null);
78
- if (ret < 0) {
79
- ctx.freeContext();
80
- throw new Error(`audio-codec: open2 failed for '${cfg.codec}' (ret=${ret})`);
81
- }
82
- const inSampleFmt = ctx.sampleFormat ?? AV_SAMPLE_FMT_FLT;
83
- const outSampleFmt = pcmFormatToAv(cfg.targetFormat);
84
- const outLayout = buildChannelLayout(cfg.targetChannels);
85
- const swr = new SoftwareResampleContext();
86
- const allocRet = swr.allocSetOpts2(outLayout, outSampleFmt, cfg.targetSampleRate, inLayout, inSampleFmt, cfg.sourceSampleRate);
87
- if (allocRet < 0) {
88
- ctx.freeContext();
89
- throw new Error(`audio-codec: swr allocSetOpts2 failed (ret=${allocRet})`);
90
- }
91
- const initRet = swr.init();
92
- if (initRet < 0) {
93
- ctx.freeContext();
94
- throw new Error(`audio-codec: swr init failed (ret=${initRet})`);
95
- }
96
- const packet = new Packet();
97
- packet.alloc();
98
- const inFrame = new Frame();
99
- inFrame.alloc();
100
- const outFrame = new Frame();
101
- outFrame.alloc();
102
- return new DecodeRuntime(ctx, swr, packet, inFrame, outFrame, cfg, inLayout, outLayout, inSampleFmt, outSampleFmt);
103
- }
104
- constructor(ctx, swr, packet, inFrame, outFrame, cfg, inLayout, outLayout, inSampleFmt, outSampleFmt) {
105
- this.ctx = ctx;
106
- this.swr = swr;
107
- this.packet = packet;
108
- this.inFrame = inFrame;
109
- this.outFrame = outFrame;
110
- this.cfg = cfg;
111
- this.inLayout = inLayout;
112
- this.outLayout = outLayout;
113
- this.inSampleFmt = inSampleFmt;
114
- this.outSampleFmt = outSampleFmt;
115
- this.outBytesPerSample = bytesPerSample(cfg.targetFormat);
116
- }
117
- decode(buf, pts) {
118
- if (this.closed) return [];
119
- this.packet.data = Buffer.from(buf);
120
- if (pts !== void 0) {
121
- this.packet.pts = BigInt(Math.round(pts));
122
- this.packet.dts = BigInt(Math.round(pts));
123
- }
124
- const sendRet = this.ctx.sendPacketSync(this.packet);
125
- if (sendRet < 0 && sendRet !== AVERROR_EAGAIN) throw new Error(`audio-codec: sendPacket failed (ret=${sendRet})`);
126
- const out = [];
127
- while (true) {
128
- const recvRet = this.ctx.receiveFrameSync(this.inFrame);
129
- if (recvRet === AVERROR_EAGAIN || recvRet === AVERROR_EOF) break;
130
- if (recvRet < 0) throw new Error(`audio-codec: receiveFrame failed (ret=${recvRet})`);
131
- const pcm = this.resampleFrame(this.inFrame);
132
- if (pcm) out.push(pcm);
133
- this.inFrame.unref();
134
- }
135
- return out;
136
- }
137
- resampleFrame(inFrame) {
138
- const inSamples = inFrame.nbSamples;
139
- const outSamples = Math.ceil(inSamples * this.cfg.targetSampleRate / this.cfg.sourceSampleRate) + 32;
140
- this.outFrame.unref();
141
- this.outFrame.format = this.outSampleFmt;
142
- this.outFrame.sampleRate = this.cfg.targetSampleRate;
143
- this.outFrame.channelLayout = this.outLayout;
144
- this.outFrame.nbSamples = outSamples;
145
- const allocRet = this.outFrame.getBuffer(0);
146
- if (allocRet < 0) throw new Error(`audio-codec: outFrame.getBuffer failed (ret=${allocRet})`);
147
- const convRet = this.swr.convertFrame(this.outFrame, inFrame);
148
- if (convRet < 0) throw new Error(`audio-codec: swr.convertFrame failed (ret=${convRet})`);
149
- const producedSamples = this.outFrame.nbSamples;
150
- if (producedSamples <= 0) return null;
151
- const planes = this.outFrame.extendedData;
152
- if (!planes || planes.length === 0 || !planes[0]) return null;
153
- const bytes = producedSamples * this.cfg.targetChannels * this.outBytesPerSample;
154
- const src = planes[0];
155
- const out = new Uint8Array(new ArrayBuffer(bytes));
156
- out.set(src.subarray(0, bytes));
157
- const ptsMs = this.nextPts;
158
- this.nextPts = ptsMs + Math.round(producedSamples * 1e3 / this.cfg.targetSampleRate);
159
- return {
160
- data: out,
161
- sampleRate: this.cfg.targetSampleRate,
162
- channels: this.cfg.targetChannels,
163
- format: this.cfg.targetFormat,
164
- pts: ptsMs
165
- };
166
- }
167
- close() {
168
- if (this.closed) return;
169
- this.closed = true;
170
- try {
171
- this.outFrame.free();
172
- } catch {}
173
- try {
174
- this.inFrame.free();
175
- } catch {}
176
- try {
177
- this.packet.free();
178
- } catch {}
179
- try {
180
- this.swr.free();
181
- } catch {}
182
- try {
183
- this.ctx.freeContext();
184
- } catch {}
185
- }
186
- /** Surfaced for assertion-style tests to inspect computed layouts. */
187
- describe() {
188
- return {
189
- inLayoutMask: this.inLayout.mask,
190
- outLayoutMask: this.outLayout.mask,
191
- inSampleFormat: this.inSampleFmt,
192
- outSampleFormat: this.outSampleFmt
193
- };
194
- }
195
- };
196
- //#endregion
197
- export { DecodeRuntime as t };
@@ -1,24 +1,3 @@
1
- //#region src/stream-broker/stream-broker/frame-dropper.ts
2
- var FrameDropper = class {
3
- intervalMs;
4
- lastPassedAt = -Infinity;
5
- constructor(maxFps) {
6
- this.intervalMs = maxFps > 0 ? 1e3 / maxFps : 0;
7
- }
8
- shouldKeep() {
9
- if (this.intervalMs === 0) return true;
10
- const now = Date.now();
11
- if (now - this.lastPassedAt >= this.intervalMs) {
12
- this.lastPassedAt = now;
13
- return true;
14
- }
15
- return false;
16
- }
17
- setMaxFps(maxFps) {
18
- this.intervalMs = maxFps > 0 ? 1e3 / maxFps : 0;
19
- }
20
- };
21
- //#endregion
22
1
  //#region src/stream-broker/stream-broker/ffmpeg-args-common.ts
23
2
  var AUDIO_ENCODER_BY_CODEC = {
24
3
  opus: "libopus",
@@ -48,6 +27,27 @@ function logBannerArgs(level) {
48
27
  ];
49
28
  }
50
29
  //#endregion
30
+ //#region src/stream-broker/stream-broker/frame-dropper.ts
31
+ var FrameDropper = class {
32
+ intervalMs;
33
+ lastPassedAt = -Infinity;
34
+ constructor(maxFps) {
35
+ this.intervalMs = maxFps > 0 ? 1e3 / maxFps : 0;
36
+ }
37
+ shouldKeep() {
38
+ if (this.intervalMs === 0) return true;
39
+ const now = Date.now();
40
+ if (now - this.lastPassedAt >= this.intervalMs) {
41
+ this.lastPassedAt = now;
42
+ return true;
43
+ }
44
+ return false;
45
+ }
46
+ setMaxFps(maxFps) {
47
+ this.intervalMs = maxFps > 0 ? 1e3 / maxFps : 0;
48
+ }
49
+ };
50
+ //#endregion
51
51
  Object.defineProperty(exports, "FrameDropper", {
52
52
  enumerable: true,
53
53
  get: function() {