@ikonai/sdk 1.0.13 → 1.0.14
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/assets/{audio-capture-worker-Ca53cEkv.js → audio-capture-worker-D0wmp7vo.js} +242 -212
- package/assets/{audio-playback-worker-D0LDYB5W.js → audio-playback-worker-Bhbw6iLB.js} +13 -13
- package/assets/{protocol-worker-CH5R2dxZ.js → protocol-worker-BBmGiA1Z.js} +28 -28
- package/assets/{video-capture-worker-Odc_mLEl.js → video-capture-worker-BQmgp10t.js} +1 -1
- package/assets/{video-playback-worker-OwSrJCnC.js → video-playback-worker-4vRt6hVt.js} +31 -31
- package/client/ikon-client.d.ts +15 -0
- package/functions/browser-functions.d.ts +27 -0
- package/index.js +1513 -1365
- package/media/audio-constants.d.ts +2 -2
- package/media/capabilities.d.ts +9 -0
- package/media/ring-buffer.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
function
|
|
2
|
-
const s = i?.trackId ?? 0, a = i?.sequenceId ?? 0,
|
|
3
|
-
l.setUint32(0, I, !0), l.setUint32(4, t >>> 0, !0), l.setUint32(8, n >>> 0, !0), l.setUint32(12, s >>> 0, !0), l.setUint32(16, a >>> 0, !0), l.setUint32(20,
|
|
4
|
-
let
|
|
5
|
-
for (let
|
|
6
|
-
l.setUint32(
|
|
7
|
-
return
|
|
1
|
+
function R(t, e, r, n, i) {
|
|
2
|
+
const s = i?.trackId ?? 0, a = i?.sequenceId ?? 0, c = i?.flags ?? 0, u = i?.targetIds ?? [], d = i?.payloadType ?? 8, w = 27 + u.length * 4, I = w + e.length, p = new Uint8Array(I), l = new DataView(p.buffer);
|
|
3
|
+
l.setUint32(0, I, !0), l.setUint32(4, t >>> 0, !0), l.setUint32(8, n >>> 0, !0), l.setUint32(12, s >>> 0, !0), l.setUint32(16, a >>> 0, !0), l.setUint32(20, u.length >>> 0, !0), l.setUint8(24, r & 255), l.setUint8(25, d & 255), l.setUint8(26, c & 255);
|
|
4
|
+
let v = 27;
|
|
5
|
+
for (let O = 0; O < u.length; O++)
|
|
6
|
+
l.setUint32(v, u[O] >>> 0, !0), v += 4;
|
|
7
|
+
return p.set(e, w), p;
|
|
8
8
|
}
|
|
9
9
|
var f = /* @__PURE__ */ ((t) => (t[t.Null = 1] = "Null", t[t.Bool = 2] = "Bool", t[t.Int32 = 3] = "Int32", t[t.Int64 = 4] = "Int64", t[t.UInt32 = 5] = "UInt32", t[t.UInt64 = 6] = "UInt64", t[t.Float32 = 7] = "Float32", t[t.Float64 = 8] = "Float64", t[t.Array = 9] = "Array", t[t.Dict = 10] = "Dict", t[t.Object = 11] = "Object", t[t.String = 12] = "String", t[t.Binary = 13] = "Binary", t[t.Guid = 14] = "Guid", t))(f || {});
|
|
10
|
-
const
|
|
10
|
+
const j = 161, q = 162, _ = new TextEncoder();
|
|
11
11
|
new TextDecoder("utf-8", { fatal: !0 });
|
|
12
|
-
class
|
|
12
|
+
class g {
|
|
13
13
|
constructor(e = 1) {
|
|
14
|
-
this.version = e, this.buffer.writeByte(
|
|
14
|
+
this.version = e, this.buffer.writeByte(j), this.buffer.writeVarUInt(e >>> 0);
|
|
15
15
|
}
|
|
16
16
|
buffer = new m();
|
|
17
17
|
closed = !1;
|
|
@@ -44,32 +44,32 @@ class E {
|
|
|
44
44
|
this.writeFixedField(e, 14, () => this.buffer.writeBytes(n));
|
|
45
45
|
}
|
|
46
46
|
writeStringField(e, r) {
|
|
47
|
-
const n =
|
|
47
|
+
const n = _.encode(r ?? "");
|
|
48
48
|
this.writeVariableField(e, 12, n);
|
|
49
49
|
}
|
|
50
50
|
writeBinaryField(e, r) {
|
|
51
51
|
this.writeVariableField(e, 13, r);
|
|
52
52
|
}
|
|
53
53
|
writeObjectField(e, r, n) {
|
|
54
|
-
const i = new
|
|
54
|
+
const i = new g(r);
|
|
55
55
|
n(i);
|
|
56
56
|
const s = i.finish();
|
|
57
57
|
this.writeVariableField(e, 11, s);
|
|
58
58
|
}
|
|
59
59
|
writeArrayField(e, r, n) {
|
|
60
|
-
const i = new
|
|
60
|
+
const i = new D(r);
|
|
61
61
|
n(i);
|
|
62
62
|
const s = i.finish();
|
|
63
63
|
this.writeVariableField(e, 9, s);
|
|
64
64
|
}
|
|
65
65
|
writeDictionaryField(e, r, n, i) {
|
|
66
|
-
const s = new
|
|
66
|
+
const s = new M(r, n);
|
|
67
67
|
i(s);
|
|
68
68
|
const a = s.finish();
|
|
69
69
|
this.writeVariableField(e, 10, a);
|
|
70
70
|
}
|
|
71
71
|
finish() {
|
|
72
|
-
return this.closed || (this.buffer.writeByte(
|
|
72
|
+
return this.closed || (this.buffer.writeByte(q), this.closed = !0, this.cached = this.buffer.toUint8Array()), this.cached;
|
|
73
73
|
}
|
|
74
74
|
writeFixedField(e, r, n) {
|
|
75
75
|
this.writeFieldHeader(e, r, 0), n();
|
|
@@ -78,10 +78,10 @@ class E {
|
|
|
78
78
|
this.writeFieldHeader(e, r, n.length), this.buffer.writeBytes(n);
|
|
79
79
|
}
|
|
80
80
|
writeFieldHeader(e, r, n) {
|
|
81
|
-
this.buffer.writeUInt32(e >>> 0), this.buffer.writeByte(
|
|
81
|
+
this.buffer.writeUInt32(e >>> 0), this.buffer.writeByte(F(r)), Y(r) && this.buffer.writeVarUInt(n >>> 0);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
class
|
|
84
|
+
class D {
|
|
85
85
|
constructor(e) {
|
|
86
86
|
this.elementType = e;
|
|
87
87
|
}
|
|
@@ -144,7 +144,7 @@ class U {
|
|
|
144
144
|
12
|
|
145
145
|
/* String */
|
|
146
146
|
), this.count++;
|
|
147
|
-
const r =
|
|
147
|
+
const r = _.encode(e ?? "");
|
|
148
148
|
this.payload.writeVarUInt(r.length), this.payload.writeBytes(r);
|
|
149
149
|
}
|
|
150
150
|
writeBinary(e) {
|
|
@@ -158,7 +158,7 @@ class U {
|
|
|
158
158
|
11
|
|
159
159
|
/* Object */
|
|
160
160
|
), this.count++;
|
|
161
|
-
const n = new
|
|
161
|
+
const n = new g(e);
|
|
162
162
|
r(n);
|
|
163
163
|
const i = n.finish();
|
|
164
164
|
this.payload.writeVarUInt(i.length), this.payload.writeBytes(i);
|
|
@@ -168,7 +168,7 @@ class U {
|
|
|
168
168
|
9
|
|
169
169
|
/* Array */
|
|
170
170
|
), this.count++;
|
|
171
|
-
const n = new
|
|
171
|
+
const n = new D(e);
|
|
172
172
|
r(n);
|
|
173
173
|
const i = n.finish();
|
|
174
174
|
this.payload.writeBytes(i);
|
|
@@ -178,23 +178,23 @@ class U {
|
|
|
178
178
|
10
|
|
179
179
|
/* Dict */
|
|
180
180
|
), this.count++;
|
|
181
|
-
const i = new
|
|
181
|
+
const i = new M(e, r);
|
|
182
182
|
n(i);
|
|
183
183
|
const s = i.finish();
|
|
184
184
|
this.payload.writeBytes(s);
|
|
185
185
|
}
|
|
186
186
|
finish() {
|
|
187
187
|
const e = new m();
|
|
188
|
-
return e.writeByte(
|
|
188
|
+
return e.writeByte(F(this.elementType)), e.writeVarUInt(this.count), e.writeBytes(this.payload.toUint8Array()), e.toUint8Array();
|
|
189
189
|
}
|
|
190
190
|
ensureElementType(e) {
|
|
191
191
|
if (this.elementType !== e)
|
|
192
192
|
throw new Error(`Array element type is ${f[this.elementType]}, expected ${f[e]}`);
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
-
class
|
|
195
|
+
class M {
|
|
196
196
|
constructor(e, r) {
|
|
197
|
-
this.keyType = e, this.valueType = r,
|
|
197
|
+
this.keyType = e, this.valueType = r, J(e);
|
|
198
198
|
}
|
|
199
199
|
payload = new m();
|
|
200
200
|
count = 0;
|
|
@@ -202,7 +202,7 @@ class B {
|
|
|
202
202
|
beginEntry() {
|
|
203
203
|
if (this.entryOpen)
|
|
204
204
|
throw new Error("Previous dictionary entry not completed");
|
|
205
|
-
return this.count++, this.entryOpen = !0, new
|
|
205
|
+
return this.count++, this.entryOpen = !0, new G(this.keyType, this.valueType, this.payload, () => {
|
|
206
206
|
this.entryOpen = !1;
|
|
207
207
|
});
|
|
208
208
|
}
|
|
@@ -210,10 +210,10 @@ class B {
|
|
|
210
210
|
if (this.entryOpen)
|
|
211
211
|
throw new Error("Dictionary entry not completed");
|
|
212
212
|
const e = new m();
|
|
213
|
-
return e.writeByte(
|
|
213
|
+
return e.writeByte(F(this.keyType)), e.writeByte(F(this.valueType)), e.writeVarUInt(this.count), e.writeBytes(this.payload.toUint8Array()), e.toUint8Array();
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
|
-
class
|
|
216
|
+
class G {
|
|
217
217
|
constructor(e, r, n, i) {
|
|
218
218
|
this.keyType = e, this.valueType = r, this.payload = n, this.onComplete = i;
|
|
219
219
|
}
|
|
@@ -277,7 +277,7 @@ class j {
|
|
|
277
277
|
12
|
|
278
278
|
/* String */
|
|
279
279
|
);
|
|
280
|
-
const r =
|
|
280
|
+
const r = _.encode(e ?? "");
|
|
281
281
|
this.payload.writeVarUInt(r.length), this.payload.writeBytes(r), this.keyWritten = !0;
|
|
282
282
|
}
|
|
283
283
|
writeKeyBinary(e) {
|
|
@@ -355,7 +355,7 @@ class j {
|
|
|
355
355
|
12
|
|
356
356
|
/* String */
|
|
357
357
|
);
|
|
358
|
-
const r =
|
|
358
|
+
const r = _.encode(e ?? "");
|
|
359
359
|
this.payload.writeVarUInt(r.length), this.payload.writeBytes(r), this.valueWritten = !0;
|
|
360
360
|
}
|
|
361
361
|
writeValueObject(e, r) {
|
|
@@ -363,7 +363,7 @@ class j {
|
|
|
363
363
|
11
|
|
364
364
|
/* Object */
|
|
365
365
|
);
|
|
366
|
-
const n = new
|
|
366
|
+
const n = new g(e);
|
|
367
367
|
r(n);
|
|
368
368
|
const i = n.finish();
|
|
369
369
|
this.payload.writeVarUInt(i.length), this.payload.writeBytes(i), this.valueWritten = !0;
|
|
@@ -373,7 +373,7 @@ class j {
|
|
|
373
373
|
9
|
|
374
374
|
/* Array */
|
|
375
375
|
);
|
|
376
|
-
const n = new
|
|
376
|
+
const n = new D(e);
|
|
377
377
|
r(n);
|
|
378
378
|
const i = n.finish();
|
|
379
379
|
this.payload.writeBytes(i), this.valueWritten = !0;
|
|
@@ -383,7 +383,7 @@ class j {
|
|
|
383
383
|
10
|
|
384
384
|
/* Dict */
|
|
385
385
|
);
|
|
386
|
-
const i = new
|
|
386
|
+
const i = new M(e, r);
|
|
387
387
|
n(i);
|
|
388
388
|
const s = i.finish();
|
|
389
389
|
this.payload.writeBytes(s), this.valueWritten = !0;
|
|
@@ -416,8 +416,8 @@ class o {
|
|
|
416
416
|
throw new Error("Guid string must be 32 hex characters");
|
|
417
417
|
const n = new Uint8Array(16), i = o.parseHexSlice(r, 0, 8), s = o.parseHexSlice(r, 8, 4), a = o.parseHexSlice(r, 12, 4);
|
|
418
418
|
o.writeUInt32LE(n, 0, i), o.writeUInt16LE(n, 4, s), o.writeUInt16LE(n, 6, a);
|
|
419
|
-
for (let
|
|
420
|
-
n[8 +
|
|
419
|
+
for (let c = 0; c < 8; c++)
|
|
420
|
+
n[8 + c] = o.parseHexSlice(r, 16 + c * 2, 2);
|
|
421
421
|
return new o(n);
|
|
422
422
|
}
|
|
423
423
|
static fromBytes(e) {
|
|
@@ -443,8 +443,8 @@ class o {
|
|
|
443
443
|
o.toHex(o.readUInt32LE(e, 0), 8),
|
|
444
444
|
o.toHex(o.readUInt16LE(e, 4), 4),
|
|
445
445
|
o.toHex(o.readUInt16LE(e, 6), 4),
|
|
446
|
-
|
|
447
|
-
|
|
446
|
+
N(e.subarray(8, 10)),
|
|
447
|
+
N(e.subarray(10, 16))
|
|
448
448
|
].join("-");
|
|
449
449
|
}
|
|
450
450
|
asBytes() {
|
|
@@ -526,101 +526,101 @@ class m {
|
|
|
526
526
|
return this.buffer.slice(0, this.length);
|
|
527
527
|
}
|
|
528
528
|
}
|
|
529
|
-
function
|
|
529
|
+
function F(t, e = 0) {
|
|
530
530
|
if ((e & 240) !== 0)
|
|
531
531
|
throw new Error("Teleport flags must fit into 4 bits");
|
|
532
532
|
return (t & 15) << 4 | e & 15;
|
|
533
533
|
}
|
|
534
|
-
function
|
|
534
|
+
function Y(t) {
|
|
535
535
|
return t === 12 || t === 13 || t === 9 || t === 11 || t === 10;
|
|
536
536
|
}
|
|
537
|
-
function
|
|
537
|
+
function J(t) {
|
|
538
538
|
if (t === 9 || t === 11 || t === 10 || t === 1)
|
|
539
539
|
throw new Error("Dictionary keys must be primitive Teleport types");
|
|
540
540
|
}
|
|
541
|
-
function
|
|
541
|
+
function N(t) {
|
|
542
542
|
return Array.from(t).map((e) => e.toString(16).padStart(2, "0")).join("");
|
|
543
543
|
}
|
|
544
|
-
var
|
|
545
|
-
const
|
|
546
|
-
function
|
|
544
|
+
var T = /* @__PURE__ */ ((t) => (t[t.Unknown = 0] = "Unknown", t[t.Opus = 1] = "Opus", t[t.Mp3 = 2] = "Mp3", t[t.RawPcm16 = 3] = "RawPcm16", t))(T || {});
|
|
545
|
+
const x = 1, X = 4194309, Z = 205938238, Q = 717315017, ee = 1594075008, te = 2026534360, re = 3409001585, ne = 3466650495, ie = 4007456593, se = 4017217601, ae = 4065417427, oe = 4086360332;
|
|
546
|
+
function ce(t) {
|
|
547
547
|
const e = {};
|
|
548
|
-
return
|
|
548
|
+
return ue(e), t && Object.assign(e, t), e;
|
|
549
549
|
}
|
|
550
|
-
function
|
|
550
|
+
function ue(t) {
|
|
551
551
|
return t.Samples = new Uint8Array(0), t.Epoch = 0, t.Sequence = 0, t.FrameSizeInInterleavedSamples = 0, t.TimeStampInInterleavedSamples = 0n, t.IsFirst = !1, t.IsLast = !1, t.AverageVolume = 0, t.AudioEventEstimatedDuration = 0, t.ShapeSetValues = void 0, t;
|
|
552
552
|
}
|
|
553
|
-
function
|
|
554
|
-
const e = new
|
|
555
|
-
return
|
|
553
|
+
function le(t) {
|
|
554
|
+
const e = new g(x);
|
|
555
|
+
return de(t, e), e.finish();
|
|
556
556
|
}
|
|
557
|
-
function
|
|
558
|
-
e.writeFloat32Field(
|
|
557
|
+
function de(t, e) {
|
|
558
|
+
e.writeFloat32Field(Z, t.AverageVolume);
|
|
559
559
|
const r = t.ShapeSetValues;
|
|
560
|
-
r != null && e.writeArrayField(
|
|
560
|
+
r != null && e.writeArrayField(Q, f.Object, (n) => {
|
|
561
561
|
for (const i of r)
|
|
562
|
-
n.writeObject(
|
|
563
|
-
|
|
562
|
+
n.writeObject(fe, (s) => {
|
|
563
|
+
we(i, s);
|
|
564
564
|
});
|
|
565
|
-
}), e.writeBoolField(
|
|
565
|
+
}), e.writeBoolField(ee, t.IsFirst), e.writeUInt64Field(te, t.TimeStampInInterleavedSamples), e.writeBinaryField(re, t.Samples), e.writeFloat32Field(ne, t.AudioEventEstimatedDuration), e.writeUInt32Field(ie, t.FrameSizeInInterleavedSamples >>> 0), e.writeBoolField(se, t.IsLast), e.writeUInt32Field(ae, t.Sequence >>> 0), e.writeUInt32Field(oe, t.Epoch >>> 0);
|
|
566
566
|
}
|
|
567
|
-
function
|
|
568
|
-
const n =
|
|
569
|
-
return
|
|
567
|
+
function he(t, e, r) {
|
|
568
|
+
const n = le(t);
|
|
569
|
+
return R(X, n, x, e, r);
|
|
570
570
|
}
|
|
571
|
-
const
|
|
572
|
-
function
|
|
573
|
-
e.writeUInt32Field(
|
|
571
|
+
const fe = 1, pe = 1154362099, ye = 3974819915;
|
|
572
|
+
function we(t, e) {
|
|
573
|
+
e.writeUInt32Field(pe, t.SetId >>> 0), e.writeArrayField(ye, f.Float32, (r) => {
|
|
574
574
|
for (const n of t.Values)
|
|
575
575
|
r.writeFloat32(n);
|
|
576
576
|
});
|
|
577
577
|
}
|
|
578
|
-
const
|
|
579
|
-
function
|
|
578
|
+
const H = 5, Ie = 4194305, me = 161083277, Ee = 265814330, ge = 1368629611, Se = 2431514951, Ae = 2745379226, be = 3282782683, _e = 3284746250, Fe = 4101844078;
|
|
579
|
+
function Ue(t) {
|
|
580
580
|
const e = {};
|
|
581
|
-
return
|
|
581
|
+
return De(e), t && Object.assign(e, t), e;
|
|
582
582
|
}
|
|
583
|
-
function
|
|
584
|
-
return t.StreamId = "", t.Description = "", t.SourceType = "", t.Codec =
|
|
583
|
+
function De(t) {
|
|
584
|
+
return t.StreamId = "", t.Description = "", t.SourceType = "", t.Codec = T.Unknown, t.CodecDetails = "", t.SampleRate = 0, t.Channels = 0, t.ShapeSets = void 0, t;
|
|
585
585
|
}
|
|
586
|
-
function
|
|
587
|
-
const e = new
|
|
588
|
-
return
|
|
586
|
+
function Be(t) {
|
|
587
|
+
const e = new g(H);
|
|
588
|
+
return Oe(t, e), e.finish();
|
|
589
589
|
}
|
|
590
|
-
function
|
|
591
|
-
e.writeStringField(
|
|
590
|
+
function Oe(t, e) {
|
|
591
|
+
e.writeStringField(me, t.StreamId);
|
|
592
592
|
const r = t.ShapeSets;
|
|
593
|
-
r != null && e.writeArrayField(
|
|
593
|
+
r != null && e.writeArrayField(Ee, f.Object, (n) => {
|
|
594
594
|
for (const i of r)
|
|
595
|
-
n.writeObject(
|
|
596
|
-
|
|
595
|
+
n.writeObject(Me, (s) => {
|
|
596
|
+
We(i, s);
|
|
597
597
|
});
|
|
598
|
-
}), e.writeStringField(
|
|
598
|
+
}), e.writeStringField(ge, t.Description), e.writeInt32Field(Se, t.Channels | 0), e.writeStringField(Ae, t.CodecDetails), e.writeStringField(be, t.SourceType), e.writeInt32Field(_e, t.Codec), e.writeInt32Field(Fe, t.SampleRate | 0);
|
|
599
599
|
}
|
|
600
|
-
function
|
|
601
|
-
const n =
|
|
602
|
-
return
|
|
600
|
+
function Re(t, e, r) {
|
|
601
|
+
const n = Be(t);
|
|
602
|
+
return R(Ie, n, H, e, r);
|
|
603
603
|
}
|
|
604
|
-
const
|
|
605
|
-
function
|
|
606
|
-
e.writeStringField(
|
|
604
|
+
const Me = 5, Te = 1107713536, Ve = 1154362099, Le = 1185721362;
|
|
605
|
+
function We(t, e) {
|
|
606
|
+
e.writeStringField(Te, t.Name), e.writeUInt32Field(Ve, t.SetId >>> 0), e.writeArrayField(Le, f.String, (r) => {
|
|
607
607
|
for (const n of t.ShapeNames)
|
|
608
608
|
r.writeString(n);
|
|
609
609
|
});
|
|
610
610
|
}
|
|
611
|
-
const
|
|
612
|
-
function
|
|
611
|
+
const z = 1, Pe = 4194306;
|
|
612
|
+
function Ce(t) {
|
|
613
613
|
const e = {};
|
|
614
614
|
return t && Object.assign(e, t), e;
|
|
615
615
|
}
|
|
616
|
-
function
|
|
617
|
-
return new
|
|
616
|
+
function ve(t) {
|
|
617
|
+
return new g(z).finish();
|
|
618
618
|
}
|
|
619
|
-
function
|
|
620
|
-
const n =
|
|
621
|
-
return
|
|
619
|
+
function Ne(t, e, r) {
|
|
620
|
+
const n = ve();
|
|
621
|
+
return R(Pe, n, z, e, r);
|
|
622
622
|
}
|
|
623
|
-
class
|
|
623
|
+
class ke {
|
|
624
624
|
static getStorageForCapacity(e, r) {
|
|
625
625
|
const n = Int32Array.BYTES_PER_ELEMENT * 2, i = r.BYTES_PER_ELEMENT * e;
|
|
626
626
|
return new SharedArrayBuffer(n + i);
|
|
@@ -674,19 +674,19 @@ class ve {
|
|
|
674
674
|
return n = (n + r) % this.capacity, Atomics.store(this.readWrite, 0, n), r;
|
|
675
675
|
}
|
|
676
676
|
}
|
|
677
|
-
let
|
|
678
|
-
const
|
|
677
|
+
let xe = 1;
|
|
678
|
+
const He = /* @__PURE__ */ new Map(), ze = {
|
|
679
679
|
0: "DEBUG",
|
|
680
680
|
1: "INFO",
|
|
681
681
|
2: "WARN",
|
|
682
682
|
3: "ERROR",
|
|
683
683
|
4: "NONE"
|
|
684
684
|
};
|
|
685
|
-
function
|
|
685
|
+
function Ke(t, e) {
|
|
686
686
|
return `[${t}] ${e}`;
|
|
687
687
|
}
|
|
688
688
|
function A(t, e, r, n) {
|
|
689
|
-
const i = (/* @__PURE__ */ new Date()).toISOString(), s =
|
|
689
|
+
const i = (/* @__PURE__ */ new Date()).toISOString(), s = ze[t], a = {
|
|
690
690
|
timestamp: i,
|
|
691
691
|
level: t,
|
|
692
692
|
levelName: s,
|
|
@@ -694,33 +694,33 @@ function A(t, e, r, n) {
|
|
|
694
694
|
message: r,
|
|
695
695
|
args: n
|
|
696
696
|
};
|
|
697
|
-
for (const [
|
|
698
|
-
const d =
|
|
697
|
+
for (const [c, u] of He) {
|
|
698
|
+
const d = u?.minLevel ?? 2;
|
|
699
699
|
if (t >= d)
|
|
700
700
|
try {
|
|
701
|
-
|
|
701
|
+
c(a);
|
|
702
702
|
} catch {
|
|
703
703
|
}
|
|
704
704
|
}
|
|
705
|
-
if (
|
|
706
|
-
const
|
|
705
|
+
if (xe <= t) {
|
|
706
|
+
const c = Ke(e, r);
|
|
707
707
|
switch (t) {
|
|
708
708
|
case 0:
|
|
709
|
-
console.debug(
|
|
709
|
+
console.debug(c, ...n);
|
|
710
710
|
break;
|
|
711
711
|
case 1:
|
|
712
|
-
console.info(
|
|
712
|
+
console.info(c, ...n);
|
|
713
713
|
break;
|
|
714
714
|
case 2:
|
|
715
|
-
console.warn(
|
|
715
|
+
console.warn(c, ...n);
|
|
716
716
|
break;
|
|
717
717
|
case 3:
|
|
718
|
-
console.error(
|
|
718
|
+
console.error(c, ...n);
|
|
719
719
|
break;
|
|
720
720
|
}
|
|
721
721
|
}
|
|
722
722
|
}
|
|
723
|
-
function
|
|
723
|
+
function $e(t) {
|
|
724
724
|
return {
|
|
725
725
|
debug(e, ...r) {
|
|
726
726
|
A(0, t, e, r);
|
|
@@ -736,8 +736,8 @@ function ze(t) {
|
|
|
736
736
|
}
|
|
737
737
|
};
|
|
738
738
|
}
|
|
739
|
-
const
|
|
740
|
-
class
|
|
739
|
+
const je = 20, V = 32e3, qe = 5, L = 8e3, U = $e("AudioCaptureWorker");
|
|
740
|
+
class Ge {
|
|
741
741
|
encoder = null;
|
|
742
742
|
isReady = !1;
|
|
743
743
|
sampleRate;
|
|
@@ -759,7 +759,7 @@ class je {
|
|
|
759
759
|
channels: this.channels,
|
|
760
760
|
bitrate: this.bitrate,
|
|
761
761
|
application: r,
|
|
762
|
-
complexity:
|
|
762
|
+
complexity: qe
|
|
763
763
|
}), await this.encoder.ready, this.isReady = !0;
|
|
764
764
|
} catch (e) {
|
|
765
765
|
this.onError(e instanceof Error ? e : new Error(String(e)));
|
|
@@ -794,24 +794,24 @@ class je {
|
|
|
794
794
|
return this.bitrate;
|
|
795
795
|
}
|
|
796
796
|
}
|
|
797
|
-
const
|
|
798
|
-
let
|
|
799
|
-
function
|
|
797
|
+
const W = (t) => self.postMessage(t);
|
|
798
|
+
let y = null;
|
|
799
|
+
function E(t, e) {
|
|
800
800
|
const r = t instanceof Error ? t : new Error(String(t));
|
|
801
|
-
|
|
801
|
+
W({ type: "error", captureId: e, error: { name: r.name, message: r.message, stack: r.stack } });
|
|
802
802
|
}
|
|
803
|
-
function
|
|
803
|
+
function Ye(t) {
|
|
804
804
|
return t.byteOffset === 0 && t.byteLength === t.buffer.byteLength ? t.buffer : t.slice().buffer;
|
|
805
805
|
}
|
|
806
|
-
function
|
|
807
|
-
if (!
|
|
808
|
-
|
|
806
|
+
function P(t) {
|
|
807
|
+
if (!y) {
|
|
808
|
+
U.warn("Audio capture message dropped: sendPort not available");
|
|
809
809
|
return;
|
|
810
810
|
}
|
|
811
|
-
const e =
|
|
812
|
-
|
|
811
|
+
const e = Ye(t);
|
|
812
|
+
y.postMessage({ type: "send", message: e }, [e]);
|
|
813
813
|
}
|
|
814
|
-
function
|
|
814
|
+
function Je(t) {
|
|
815
815
|
if (t.length === 0)
|
|
816
816
|
return 0;
|
|
817
817
|
let e = 0;
|
|
@@ -819,40 +819,70 @@ function Ge(t) {
|
|
|
819
819
|
e += Math.abs(t[r] ?? 0);
|
|
820
820
|
return e / t.length;
|
|
821
821
|
}
|
|
822
|
-
const h = /* @__PURE__ */ new Map();
|
|
822
|
+
const h = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Map();
|
|
823
823
|
let S = null;
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
if (!(t.transport !== "sab" || !t.ringBuffer || !t.ringTemp || t.stopped))
|
|
828
|
-
try {
|
|
829
|
-
const e = t.ringBuffer.pop(t.ringTemp);
|
|
830
|
-
if (e <= 0)
|
|
831
|
-
continue;
|
|
832
|
-
W(t, t.ringTemp.subarray(0, e));
|
|
833
|
-
} catch (e) {
|
|
834
|
-
g(e, t.captureId);
|
|
835
|
-
}
|
|
836
|
-
}, 10));
|
|
824
|
+
const k = 1;
|
|
825
|
+
function Xe() {
|
|
826
|
+
return typeof Atomics < "u" && typeof Atomics.waitAsync == "function";
|
|
837
827
|
}
|
|
838
|
-
function
|
|
839
|
-
if (
|
|
828
|
+
async function Ze(t) {
|
|
829
|
+
if (!t.ringBuffer || !t.ringTemp)
|
|
840
830
|
return;
|
|
841
|
-
|
|
842
|
-
for (
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
831
|
+
const e = t.ringBuffer, r = t.ringTemp;
|
|
832
|
+
for (; !t.stopped && t.transport === "sab"; ) {
|
|
833
|
+
try {
|
|
834
|
+
const n = e.pop(r);
|
|
835
|
+
n > 0 && B(t, r.subarray(0, n));
|
|
836
|
+
} catch (n) {
|
|
837
|
+
E(n, t.captureId);
|
|
846
838
|
}
|
|
847
|
-
if (!t) {
|
|
848
839
|
try {
|
|
849
|
-
|
|
840
|
+
const n = Atomics.load(e.readWrite, k), i = Atomics.waitAsync(e.readWrite, k, n, 100);
|
|
841
|
+
i.async && await i.value;
|
|
850
842
|
} catch {
|
|
843
|
+
await new Promise((n) => setTimeout(n, 10));
|
|
851
844
|
}
|
|
852
|
-
S = null;
|
|
853
845
|
}
|
|
854
846
|
}
|
|
855
|
-
function
|
|
847
|
+
function Qe() {
|
|
848
|
+
for (const t of h.values())
|
|
849
|
+
if (!(t.transport !== "sab" || !t.ringBuffer || !t.ringTemp || t.stopped))
|
|
850
|
+
try {
|
|
851
|
+
const e = t.ringBuffer.pop(t.ringTemp);
|
|
852
|
+
e > 0 && B(t, t.ringTemp.subarray(0, e));
|
|
853
|
+
} catch (e) {
|
|
854
|
+
E(e, t.captureId);
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
function et(t) {
|
|
858
|
+
if (Xe()) {
|
|
859
|
+
if (!b.has(t.captureId)) {
|
|
860
|
+
const e = Ze(t);
|
|
861
|
+
b.set(t.captureId, e), e.finally(() => {
|
|
862
|
+
b.delete(t.captureId);
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
} else
|
|
866
|
+
S === null && (S = self.setInterval(Qe, 50));
|
|
867
|
+
}
|
|
868
|
+
function tt(t) {
|
|
869
|
+
if (b.delete(t), S !== null) {
|
|
870
|
+
let e = !1;
|
|
871
|
+
for (const r of h.values())
|
|
872
|
+
if (r.transport === "sab" && !r.stopped) {
|
|
873
|
+
e = !0;
|
|
874
|
+
break;
|
|
875
|
+
}
|
|
876
|
+
if (!e) {
|
|
877
|
+
try {
|
|
878
|
+
self.clearInterval(S);
|
|
879
|
+
} catch {
|
|
880
|
+
}
|
|
881
|
+
S = null;
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
function C(t) {
|
|
856
886
|
if (t.stopped)
|
|
857
887
|
return;
|
|
858
888
|
if (!t.inSegment) {
|
|
@@ -869,7 +899,7 @@ function P(t) {
|
|
|
869
899
|
r.set(t.pendingBuffer.subarray(i, n)), r.set(t.pendingBuffer.subarray(0, e - a), a);
|
|
870
900
|
}
|
|
871
901
|
t.pendingReadOffset = (i + e) % n, t.pendingSamples -= e;
|
|
872
|
-
const s =
|
|
902
|
+
const s = Je(r);
|
|
873
903
|
t.lastVolume = s;
|
|
874
904
|
try {
|
|
875
905
|
if (t.useWasmEncoder)
|
|
@@ -886,12 +916,12 @@ function P(t) {
|
|
|
886
916
|
t.encoder.encode(a), a.close();
|
|
887
917
|
}
|
|
888
918
|
} catch (a) {
|
|
889
|
-
|
|
919
|
+
E(a, t.captureId);
|
|
890
920
|
}
|
|
891
921
|
t.timestampUs += t.frameDurationUs;
|
|
892
922
|
}
|
|
893
923
|
}
|
|
894
|
-
function
|
|
924
|
+
function B(t, e) {
|
|
895
925
|
if (t.stopped)
|
|
896
926
|
return;
|
|
897
927
|
const r = e.length;
|
|
@@ -899,41 +929,41 @@ function W(t, e) {
|
|
|
899
929
|
return;
|
|
900
930
|
const n = t.pendingSamples + r;
|
|
901
931
|
if (n > t.pendingBuffer.length) {
|
|
902
|
-
const a = Math.max(n, t.pendingBuffer.length * 2),
|
|
932
|
+
const a = Math.max(n, t.pendingBuffer.length * 2), c = new Float32Array(a);
|
|
903
933
|
if (t.pendingSamples > 0) {
|
|
904
|
-
const
|
|
905
|
-
if (t.pendingReadOffset + t.pendingSamples <=
|
|
906
|
-
|
|
934
|
+
const u = t.pendingBuffer.length;
|
|
935
|
+
if (t.pendingReadOffset + t.pendingSamples <= u)
|
|
936
|
+
c.set(t.pendingBuffer.subarray(t.pendingReadOffset, t.pendingReadOffset + t.pendingSamples));
|
|
907
937
|
else {
|
|
908
|
-
const d =
|
|
909
|
-
|
|
938
|
+
const d = u - t.pendingReadOffset;
|
|
939
|
+
c.set(t.pendingBuffer.subarray(t.pendingReadOffset, u)), c.set(t.pendingBuffer.subarray(0, t.pendingSamples - d), d);
|
|
910
940
|
}
|
|
911
941
|
}
|
|
912
|
-
t.pendingBuffer =
|
|
942
|
+
t.pendingBuffer = c, t.pendingReadOffset = 0, t.pendingWriteOffset = t.pendingSamples;
|
|
913
943
|
}
|
|
914
944
|
const i = t.pendingBuffer.length, s = Math.min(r, i - t.pendingWriteOffset);
|
|
915
|
-
t.pendingBuffer.set(e.subarray(0, s), t.pendingWriteOffset), s < r && t.pendingBuffer.set(e.subarray(s), 0), t.pendingWriteOffset = (t.pendingWriteOffset + r) % i, t.pendingSamples += r,
|
|
945
|
+
t.pendingBuffer.set(e.subarray(0, s), t.pendingWriteOffset), s < r && t.pendingBuffer.set(e.subarray(s), 0), t.pendingWriteOffset = (t.pendingWriteOffset + r) % i, t.pendingSamples += r, C(t);
|
|
916
946
|
}
|
|
917
|
-
function
|
|
947
|
+
function K(t, e, r, n, i = !0) {
|
|
918
948
|
const s = h.get(t.captureId);
|
|
919
949
|
if (!s || s.stopped || !s.inSegment && !s.segmentEndPending)
|
|
920
950
|
return;
|
|
921
951
|
const a = e.byteLength;
|
|
922
952
|
s.encoderOutputBuffer.length < a && (s.encoderOutputBuffer = new Uint8Array(Math.max(a, s.encoderOutputBuffer.length * 2))), s.encoderOutputBuffer.set(e);
|
|
923
|
-
const
|
|
924
|
-
|
|
953
|
+
const c = s.encoderOutputBuffer.subarray(0, a), u = s.segmentStartPending;
|
|
954
|
+
u && (s.segmentStartPending = !1, s.epoch++, s.sequence = 0);
|
|
925
955
|
const d = s.segmentEndPending;
|
|
926
956
|
d && (s.segmentEndPending = !1, s.inSegment = !1);
|
|
927
957
|
const w = s.frameSize * s.channels, I = BigInt(Math.floor(r / 1e6 * s.sampleRate * s.channels));
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
Samples:
|
|
958
|
+
P(
|
|
959
|
+
he(
|
|
960
|
+
ce({
|
|
961
|
+
Samples: c,
|
|
932
962
|
Epoch: s.epoch,
|
|
933
963
|
Sequence: s.sequence,
|
|
934
964
|
FrameSizeInInterleavedSamples: w,
|
|
935
965
|
TimeStampInInterleavedSamples: I,
|
|
936
|
-
IsFirst:
|
|
966
|
+
IsFirst: u,
|
|
937
967
|
IsLast: d,
|
|
938
968
|
AverageVolume: s.lastVolume,
|
|
939
969
|
AudioEventEstimatedDuration: 0
|
|
@@ -943,14 +973,14 @@ function H(t, e, r, n, i = !0) {
|
|
|
943
973
|
)
|
|
944
974
|
), s.sequence++;
|
|
945
975
|
}
|
|
946
|
-
function
|
|
947
|
-
const e = Math.max(
|
|
976
|
+
function rt(t) {
|
|
977
|
+
const e = Math.max(L, Math.floor(t.options?.bitrate ?? V)), r = new AudioEncoder({
|
|
948
978
|
output: (n) => {
|
|
949
979
|
const i = h.get(t.captureId);
|
|
950
980
|
if (!i)
|
|
951
981
|
return;
|
|
952
982
|
const s = n.byteLength;
|
|
953
|
-
i.encoderOutputBuffer.length < s && (i.encoderOutputBuffer = new Uint8Array(Math.max(s, i.encoderOutputBuffer.length * 2))), n.copyTo(i.encoderOutputBuffer),
|
|
983
|
+
i.encoderOutputBuffer.length < s && (i.encoderOutputBuffer = new Uint8Array(Math.max(s, i.encoderOutputBuffer.length * 2))), n.copyTo(i.encoderOutputBuffer), K(
|
|
954
984
|
i,
|
|
955
985
|
i.encoderOutputBuffer.subarray(0, s),
|
|
956
986
|
n.timestamp ?? i.timestampUs,
|
|
@@ -959,7 +989,7 @@ function Ze(t) {
|
|
|
959
989
|
);
|
|
960
990
|
},
|
|
961
991
|
error: (n) => {
|
|
962
|
-
|
|
992
|
+
E(n, t.captureId);
|
|
963
993
|
}
|
|
964
994
|
});
|
|
965
995
|
return r.configure({
|
|
@@ -975,23 +1005,23 @@ function Ze(t) {
|
|
|
975
1005
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
976
1006
|
}), r;
|
|
977
1007
|
}
|
|
978
|
-
function
|
|
979
|
-
const e = Math.max(
|
|
980
|
-
return new
|
|
1008
|
+
function nt(t) {
|
|
1009
|
+
const e = Math.max(L, Math.floor(t.options?.bitrate ?? V));
|
|
1010
|
+
return new Ge({
|
|
981
1011
|
sampleRate: t.sampleRate,
|
|
982
1012
|
channels: t.channels,
|
|
983
1013
|
bitrate: e,
|
|
984
1014
|
frameSize: t.frameSize,
|
|
985
1015
|
onOutput: (r, n, i) => {
|
|
986
1016
|
const s = h.get(t.captureId);
|
|
987
|
-
s &&
|
|
1017
|
+
s && K(s, r, n, i, !0);
|
|
988
1018
|
},
|
|
989
1019
|
onError: (r) => {
|
|
990
|
-
|
|
1020
|
+
E(r, t.captureId);
|
|
991
1021
|
}
|
|
992
1022
|
});
|
|
993
1023
|
}
|
|
994
|
-
async function
|
|
1024
|
+
async function it() {
|
|
995
1025
|
if (typeof AudioEncoder > "u")
|
|
996
1026
|
return !1;
|
|
997
1027
|
try {
|
|
@@ -1004,12 +1034,12 @@ async function Xe() {
|
|
|
1004
1034
|
return !1;
|
|
1005
1035
|
}
|
|
1006
1036
|
}
|
|
1007
|
-
async function
|
|
1008
|
-
if (!
|
|
1037
|
+
async function st(t) {
|
|
1038
|
+
if (!y)
|
|
1009
1039
|
throw new Error("Audio capture worker missing send port");
|
|
1010
1040
|
if (h.has(t.captureId))
|
|
1011
1041
|
return;
|
|
1012
|
-
const e = Math.max(8e3, Math.floor(t.sampleRate)), r = Math.max(1, Math.floor(t.channels)), n = Math.max(1, Math.floor(e *
|
|
1042
|
+
const e = Math.max(8e3, Math.floor(t.sampleRate)), r = Math.max(1, Math.floor(t.channels)), n = Math.max(1, Math.floor(e * je / 1e3)), i = Math.max(1, Math.floor(n * 1e6 / e)), s = n * 4, a = {
|
|
1013
1043
|
captureId: t.captureId,
|
|
1014
1044
|
streamId: t.streamId,
|
|
1015
1045
|
sourceType: t.sourceType,
|
|
@@ -1039,20 +1069,20 @@ async function et(t) {
|
|
|
1039
1069
|
lastVolume: 0,
|
|
1040
1070
|
targetIds: t.options?.targetIds,
|
|
1041
1071
|
options: t.options
|
|
1042
|
-
},
|
|
1072
|
+
}, u = (t.options?.preferWebCodecs ?? !0) && await it();
|
|
1043
1073
|
let d, w = !1;
|
|
1044
|
-
const I = Math.max(
|
|
1045
|
-
if (
|
|
1046
|
-
d =
|
|
1074
|
+
const I = Math.max(L, Math.floor(t.options?.bitrate ?? V));
|
|
1075
|
+
if (u)
|
|
1076
|
+
d = rt(a), U.info(
|
|
1047
1077
|
`Audio capture started: encoder=WebCodecs, sampleRate=${e}Hz, channels=${r}, bitrate=${I}bps`
|
|
1048
1078
|
);
|
|
1049
1079
|
else {
|
|
1050
|
-
const l =
|
|
1051
|
-
await l.initialize(), d = l, w = !0,
|
|
1080
|
+
const l = nt(a);
|
|
1081
|
+
await l.initialize(), d = l, w = !0, U.info(
|
|
1052
1082
|
`Audio capture started: encoder=WASM Opus, sampleRate=${e}Hz, channels=${r}, bitrate=${I}bps`
|
|
1053
1083
|
);
|
|
1054
1084
|
}
|
|
1055
|
-
const
|
|
1085
|
+
const p = {
|
|
1056
1086
|
...a,
|
|
1057
1087
|
encoder: d,
|
|
1058
1088
|
useWasmEncoder: w
|
|
@@ -1060,31 +1090,31 @@ async function et(t) {
|
|
|
1060
1090
|
if (t.transport === "sab") {
|
|
1061
1091
|
if (!t.sharedArrayBuffer)
|
|
1062
1092
|
throw new Error("Missing SharedArrayBuffer for sab transport");
|
|
1063
|
-
const l = new
|
|
1064
|
-
|
|
1093
|
+
const l = new ke(t.sharedArrayBuffer, Float32Array);
|
|
1094
|
+
p.ringBuffer = l, p.ringTemp = new Float32Array(Math.max(p.frameSize * 4, 4096)), et(p);
|
|
1065
1095
|
}
|
|
1066
|
-
h.set(t.captureId,
|
|
1067
|
-
|
|
1068
|
-
|
|
1096
|
+
h.set(t.captureId, p), P(
|
|
1097
|
+
Re(
|
|
1098
|
+
Ue({
|
|
1069
1099
|
StreamId: t.streamId,
|
|
1070
1100
|
Description: `mic:${t.streamId}`,
|
|
1071
1101
|
SourceType: t.sourceType,
|
|
1072
|
-
Codec:
|
|
1102
|
+
Codec: T.Opus,
|
|
1073
1103
|
CodecDetails: "",
|
|
1074
1104
|
SampleRate: e,
|
|
1075
1105
|
Channels: r
|
|
1076
1106
|
}),
|
|
1077
1107
|
t.senderId,
|
|
1078
|
-
{ trackId: t.trackId, targetIds:
|
|
1108
|
+
{ trackId: t.trackId, targetIds: p.targetIds }
|
|
1079
1109
|
)
|
|
1080
|
-
),
|
|
1110
|
+
), W({ type: "started", captureId: t.captureId, sampleRate: e, channels: r });
|
|
1081
1111
|
}
|
|
1082
|
-
async function
|
|
1112
|
+
async function $(t) {
|
|
1083
1113
|
const e = h.get(t);
|
|
1084
1114
|
if (e) {
|
|
1085
1115
|
e.stopped = !0, h.delete(t);
|
|
1086
1116
|
try {
|
|
1087
|
-
|
|
1117
|
+
C(e);
|
|
1088
1118
|
} catch {
|
|
1089
1119
|
}
|
|
1090
1120
|
try {
|
|
@@ -1095,52 +1125,52 @@ async function z(t) {
|
|
|
1095
1125
|
e.encoder.close();
|
|
1096
1126
|
} catch {
|
|
1097
1127
|
}
|
|
1098
|
-
|
|
1128
|
+
P(Ne(Ce({}), e.senderId, { trackId: e.trackId, targetIds: e.targetIds })), W({ type: "stopped", captureId: e.captureId }), tt(t);
|
|
1099
1129
|
}
|
|
1100
1130
|
}
|
|
1101
|
-
function
|
|
1131
|
+
function at(t) {
|
|
1102
1132
|
const e = h.get(t);
|
|
1103
1133
|
!e || e.stopped || (e.inSegment = !0, e.segmentStartPending = !0);
|
|
1104
1134
|
}
|
|
1105
|
-
function
|
|
1135
|
+
function ot(t) {
|
|
1106
1136
|
const e = h.get(t);
|
|
1107
|
-
if (!(!e || e.stopped || !e.inSegment) && (e.segmentEndPending = !0,
|
|
1137
|
+
if (!(!e || e.stopped || !e.inSegment) && (e.segmentEndPending = !0, C(e), e.segmentEndPending && !e.stopped)) {
|
|
1108
1138
|
const r = e.frameSize - e.pendingSamples;
|
|
1109
1139
|
if (r > 0) {
|
|
1110
1140
|
const n = new Float32Array(r);
|
|
1111
|
-
|
|
1141
|
+
B(e, n);
|
|
1112
1142
|
}
|
|
1113
1143
|
}
|
|
1114
1144
|
}
|
|
1115
|
-
function
|
|
1145
|
+
function ct() {
|
|
1116
1146
|
for (const t of Array.from(h.keys()))
|
|
1117
|
-
|
|
1118
|
-
if (
|
|
1147
|
+
$(t);
|
|
1148
|
+
if (y) {
|
|
1119
1149
|
try {
|
|
1120
|
-
|
|
1150
|
+
y.close();
|
|
1121
1151
|
} catch {
|
|
1122
1152
|
}
|
|
1123
|
-
|
|
1153
|
+
y = null;
|
|
1124
1154
|
}
|
|
1125
1155
|
}
|
|
1126
1156
|
self.addEventListener("message", (t) => {
|
|
1127
1157
|
const e = t.data;
|
|
1128
1158
|
if (e.type === "attachSendPort") {
|
|
1129
|
-
if (
|
|
1159
|
+
if (y)
|
|
1130
1160
|
try {
|
|
1131
|
-
|
|
1161
|
+
y.close();
|
|
1132
1162
|
} catch {
|
|
1133
1163
|
}
|
|
1134
|
-
|
|
1164
|
+
y = e.port;
|
|
1135
1165
|
try {
|
|
1136
|
-
|
|
1166
|
+
y.start?.();
|
|
1137
1167
|
} catch {
|
|
1138
1168
|
}
|
|
1139
1169
|
return;
|
|
1140
1170
|
}
|
|
1141
1171
|
if (e.type === "start") {
|
|
1142
|
-
|
|
1143
|
-
|
|
1172
|
+
st(e).catch((r) => {
|
|
1173
|
+
E(r, e.captureId);
|
|
1144
1174
|
});
|
|
1145
1175
|
return;
|
|
1146
1176
|
}
|
|
@@ -1148,22 +1178,22 @@ self.addEventListener("message", (t) => {
|
|
|
1148
1178
|
const r = h.get(e.captureId);
|
|
1149
1179
|
if (!r || r.stopped)
|
|
1150
1180
|
return;
|
|
1151
|
-
|
|
1181
|
+
B(r, e.pcm);
|
|
1152
1182
|
return;
|
|
1153
1183
|
}
|
|
1154
1184
|
if (e.type === "stop") {
|
|
1155
|
-
|
|
1156
|
-
|
|
1185
|
+
$(e.captureId).catch((r) => {
|
|
1186
|
+
U.warn(`Failed to stop audio capture: ${r}`), E(r, e.captureId);
|
|
1157
1187
|
});
|
|
1158
1188
|
return;
|
|
1159
1189
|
}
|
|
1160
1190
|
if (e.type === "startSegment") {
|
|
1161
|
-
|
|
1191
|
+
at(e.captureId);
|
|
1162
1192
|
return;
|
|
1163
1193
|
}
|
|
1164
1194
|
if (e.type === "endSegment") {
|
|
1165
|
-
|
|
1195
|
+
ot(e.captureId);
|
|
1166
1196
|
return;
|
|
1167
1197
|
}
|
|
1168
|
-
e.type === "dispose" &&
|
|
1198
|
+
e.type === "dispose" && ct();
|
|
1169
1199
|
});
|