@ikonai/sdk 1.0.41 → 1.0.43
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-DuKZS6HJ.js → audio-capture-worker-Dmgg-yWd.js} +151 -165
- package/assets/{audio-playback-worker-BkM1Wq_F.js → audio-playback-worker-MsPNs6k4.js} +449 -384
- package/assets/{protocol-worker-BVD4poVW.js → protocol-worker-4bSKGT40.js} +202 -193
- package/assets/{video-capture-worker-CpzIHq4o.js → video-capture-worker-Bitll1TI.js} +161 -161
- package/assets/{video-playback-worker-Djop0qmb.js → video-playback-worker-BQSKswID.js} +247 -245
- package/channel/channel-manager.d.ts +2 -2
- package/client/ikon-client-config.d.ts +1 -1
- package/client/ikon-client.d.ts +2 -0
- package/connection/authenticator.d.ts +5 -10
- package/index.js +1805 -1777
- package/media/ikon-audio-playback.d.ts +4 -0
- package/package.json +1 -1
- package/webrtc/webrtc-signaling.d.ts +7 -6
- package/worker/audio-playback-worker.d.ts +10 -2
- package/worker/video-playback-worker.d.ts +1 -0
|
@@ -6,14 +6,14 @@ function L(t, e, r, n, i) {
|
|
|
6
6
|
h.setUint32(N, l[V] >>> 0, !0), N += 4;
|
|
7
7
|
return p.set(e, d), p;
|
|
8
8
|
}
|
|
9
|
-
var
|
|
10
|
-
const q = 161, G = 162,
|
|
9
|
+
var m = /* @__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))(m || {});
|
|
10
|
+
const q = 161, G = 162, B = new TextEncoder();
|
|
11
11
|
new TextDecoder("utf-8", { fatal: !0 });
|
|
12
12
|
class S {
|
|
13
13
|
constructor(e = 1) {
|
|
14
14
|
this.version = e, this.buffer.writeByte(q), this.buffer.writeVarUInt(e >>> 0);
|
|
15
15
|
}
|
|
16
|
-
buffer = new
|
|
16
|
+
buffer = new E();
|
|
17
17
|
closed = !1;
|
|
18
18
|
cached;
|
|
19
19
|
writeInt32Field(e, r) {
|
|
@@ -44,7 +44,7 @@ class S {
|
|
|
44
44
|
this.writeFixedField(e, 14, () => this.buffer.writeBytes(n));
|
|
45
45
|
}
|
|
46
46
|
writeStringField(e, r) {
|
|
47
|
-
const n =
|
|
47
|
+
const n = B.encode(r ?? "");
|
|
48
48
|
this.writeVariableField(e, 12, n);
|
|
49
49
|
}
|
|
50
50
|
writeBinaryField(e, r) {
|
|
@@ -63,7 +63,7 @@ class S {
|
|
|
63
63
|
this.writeVariableField(e, 9, s);
|
|
64
64
|
}
|
|
65
65
|
writeDictionaryField(e, r, n, i) {
|
|
66
|
-
const s = new
|
|
66
|
+
const s = new W(r, n);
|
|
67
67
|
i(s);
|
|
68
68
|
const a = s.finish();
|
|
69
69
|
this.writeVariableField(e, 10, a);
|
|
@@ -78,14 +78,14 @@ class S {
|
|
|
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(_(r)), J(r) && this.buffer.writeVarUInt(n >>> 0);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
class R {
|
|
85
85
|
constructor(e) {
|
|
86
86
|
this.elementType = e;
|
|
87
87
|
}
|
|
88
|
-
payload = new
|
|
88
|
+
payload = new E();
|
|
89
89
|
count = 0;
|
|
90
90
|
writeInt32(e) {
|
|
91
91
|
this.ensureElementType(
|
|
@@ -144,7 +144,7 @@ class R {
|
|
|
144
144
|
12
|
|
145
145
|
/* String */
|
|
146
146
|
), this.count++;
|
|
147
|
-
const r =
|
|
147
|
+
const r = B.encode(e ?? "");
|
|
148
148
|
this.payload.writeVarUInt(r.length), this.payload.writeBytes(r);
|
|
149
149
|
}
|
|
150
150
|
writeBinary(e) {
|
|
@@ -178,25 +178,25 @@ class R {
|
|
|
178
178
|
10
|
|
179
179
|
/* Dict */
|
|
180
180
|
), this.count++;
|
|
181
|
-
const i = new
|
|
181
|
+
const i = new W(e, r);
|
|
182
182
|
n(i);
|
|
183
183
|
const s = i.finish();
|
|
184
184
|
this.payload.writeBytes(s);
|
|
185
185
|
}
|
|
186
186
|
finish() {
|
|
187
|
-
const e = new
|
|
188
|
-
return e.writeByte(
|
|
187
|
+
const e = new E();
|
|
188
|
+
return e.writeByte(_(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
|
-
throw new Error(`Array element type is ${
|
|
192
|
+
throw new Error(`Array element type is ${m[this.elementType]}, expected ${m[e]}`);
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
-
class
|
|
195
|
+
class W {
|
|
196
196
|
constructor(e, r) {
|
|
197
197
|
this.keyType = e, this.valueType = r, X(e);
|
|
198
198
|
}
|
|
199
|
-
payload = new
|
|
199
|
+
payload = new E();
|
|
200
200
|
count = 0;
|
|
201
201
|
entryOpen = !1;
|
|
202
202
|
beginEntry() {
|
|
@@ -209,8 +209,8 @@ class P {
|
|
|
209
209
|
finish() {
|
|
210
210
|
if (this.entryOpen)
|
|
211
211
|
throw new Error("Dictionary entry not completed");
|
|
212
|
-
const e = new
|
|
213
|
-
return e.writeByte(
|
|
212
|
+
const e = new E();
|
|
213
|
+
return e.writeByte(_(this.keyType)), e.writeByte(_(this.valueType)), e.writeVarUInt(this.count), e.writeBytes(this.payload.toUint8Array()), e.toUint8Array();
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
class Y {
|
|
@@ -277,7 +277,7 @@ class Y {
|
|
|
277
277
|
12
|
|
278
278
|
/* String */
|
|
279
279
|
);
|
|
280
|
-
const r =
|
|
280
|
+
const r = B.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 Y {
|
|
|
355
355
|
12
|
|
356
356
|
/* String */
|
|
357
357
|
);
|
|
358
|
-
const r =
|
|
358
|
+
const r = B.encode(e ?? "");
|
|
359
359
|
this.payload.writeVarUInt(r.length), this.payload.writeBytes(r), this.valueWritten = !0;
|
|
360
360
|
}
|
|
361
361
|
writeValueObject(e, r) {
|
|
@@ -383,7 +383,7 @@ class Y {
|
|
|
383
383
|
10
|
|
384
384
|
/* Dict */
|
|
385
385
|
);
|
|
386
|
-
const i = new
|
|
386
|
+
const i = new W(e, r);
|
|
387
387
|
n(i);
|
|
388
388
|
const s = i.finish();
|
|
389
389
|
this.payload.writeBytes(s), this.valueWritten = !0;
|
|
@@ -397,11 +397,11 @@ class Y {
|
|
|
397
397
|
}
|
|
398
398
|
ensureKeyType(e) {
|
|
399
399
|
if (this.keyType !== e)
|
|
400
|
-
throw new Error(`Dictionary key type is ${
|
|
400
|
+
throw new Error(`Dictionary key type is ${m[this.keyType]}, expected ${m[e]}`);
|
|
401
401
|
}
|
|
402
402
|
ensureValueType(e) {
|
|
403
403
|
if (this.valueType !== e)
|
|
404
|
-
throw new Error(`Dictionary value type is ${
|
|
404
|
+
throw new Error(`Dictionary value type is ${m[this.valueType]}, expected ${m[e]}`);
|
|
405
405
|
}
|
|
406
406
|
}
|
|
407
407
|
class u {
|
|
@@ -474,13 +474,13 @@ class u {
|
|
|
474
474
|
return (e >>> 0).toString(16).padStart(r, "0");
|
|
475
475
|
}
|
|
476
476
|
}
|
|
477
|
-
class
|
|
477
|
+
class E {
|
|
478
478
|
static INITIAL_CAPACITY = 256;
|
|
479
479
|
buffer;
|
|
480
480
|
dataView;
|
|
481
481
|
length = 0;
|
|
482
482
|
constructor() {
|
|
483
|
-
this.buffer = new Uint8Array(
|
|
483
|
+
this.buffer = new Uint8Array(E.INITIAL_CAPACITY), this.dataView = new DataView(this.buffer.buffer);
|
|
484
484
|
}
|
|
485
485
|
ensureCapacity(e) {
|
|
486
486
|
const r = this.length + e;
|
|
@@ -526,7 +526,7 @@ class g {
|
|
|
526
526
|
return this.buffer.slice(0, this.length);
|
|
527
527
|
}
|
|
528
528
|
}
|
|
529
|
-
function
|
|
529
|
+
function _(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;
|
|
@@ -541,86 +541,72 @@ function X(t) {
|
|
|
541
541
|
function k(t) {
|
|
542
542
|
return Array.from(t).map((e) => e.toString(16).padStart(2, "0")).join("");
|
|
543
543
|
}
|
|
544
|
-
var
|
|
545
|
-
const z = 1, Z = 4194309, Q = 205938238, ee =
|
|
546
|
-
function
|
|
544
|
+
var P = /* @__PURE__ */ ((t) => (t[t.Unknown = 0] = "Unknown", t[t.Opus = 1] = "Opus", t[t.Mp3 = 2] = "Mp3", t[t.RawPcm16 = 3] = "RawPcm16", t))(P || {});
|
|
545
|
+
const z = 1, Z = 4194309, Q = 205938238, 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
|
|
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
|
|
550
|
+
function ue(t) {
|
|
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;
|
|
552
552
|
}
|
|
553
|
-
function
|
|
553
|
+
function le(t) {
|
|
554
554
|
const e = new S(z);
|
|
555
|
-
return
|
|
555
|
+
return de(t, e), e.finish();
|
|
556
556
|
}
|
|
557
|
-
function
|
|
558
|
-
e.writeFloat32Field(Q, t.AverageVolume);
|
|
559
|
-
const r = t.ShapeSetValues;
|
|
560
|
-
r != null && e.writeArrayField(ee, w.Object, (n) => {
|
|
561
|
-
for (const i of r)
|
|
562
|
-
n.writeObject(pe, (s) => {
|
|
563
|
-
Ie(i, s);
|
|
564
|
-
});
|
|
565
|
-
}), e.writeBoolField(te, t.IsFirst), e.writeUInt64Field(re, t.TimeStampInInterleavedSamples), e.writeBinaryField(ne, t.Samples), e.writeFloat32Field(ie, t.AudioEventEstimatedDuration), e.writeUInt32Field(se, t.FrameSizeInInterleavedSamples >>> 0), e.writeBoolField(ae, t.IsLast), e.writeUInt32Field(oe, t.Sequence >>> 0), e.writeUInt32Field(ce, t.Epoch >>> 0);
|
|
557
|
+
function de(t, e) {
|
|
558
|
+
e.writeFloat32Field(Q, t.AverageVolume), 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
559
|
}
|
|
567
|
-
function
|
|
568
|
-
const n =
|
|
560
|
+
function he(t, e, r) {
|
|
561
|
+
const n = le(t);
|
|
569
562
|
return L(Z, n, z, e, r);
|
|
570
563
|
}
|
|
571
|
-
const pe =
|
|
572
|
-
function
|
|
573
|
-
e.writeUInt32Field(ye, t.SetId >>> 0), e.writeArrayField(we, w.Float32, (r) => {
|
|
574
|
-
for (const n of t.Values)
|
|
575
|
-
r.writeFloat32(n);
|
|
576
|
-
});
|
|
577
|
-
}
|
|
578
|
-
const H = 5, me = 4194305, Ee = 161083277, ge = 265814330, Se = 1368629611, Ae = 2431514951, be = 2745379226, _e = 3282782683, Fe = 3284746250, Ue = 4101844078;
|
|
579
|
-
function De(t) {
|
|
564
|
+
const H = 5, fe = 4194305, pe = 161083277, ye = 265814330, we = 1368629611, Ie = 2431514951, me = 2745379226, ge = 3282782683, Ee = 3284746250, Se = 4101844078;
|
|
565
|
+
function Ae(t) {
|
|
580
566
|
const e = {};
|
|
581
|
-
return
|
|
567
|
+
return be(e), t && Object.assign(e, t), e;
|
|
582
568
|
}
|
|
583
|
-
function
|
|
584
|
-
return t.StreamId = "", t.Description = "", t.SourceType = "", t.Codec =
|
|
569
|
+
function be(t) {
|
|
570
|
+
return t.StreamId = "", t.Description = "", t.SourceType = "", t.Codec = P.Unknown, t.CodecDetails = "", t.SampleRate = 0, t.Channels = 0, t.ShapeSets = void 0, t;
|
|
585
571
|
}
|
|
586
|
-
function
|
|
572
|
+
function Fe(t) {
|
|
587
573
|
const e = new S(H);
|
|
588
|
-
return
|
|
574
|
+
return Ue(t, e), e.finish();
|
|
589
575
|
}
|
|
590
|
-
function
|
|
591
|
-
e.writeStringField(
|
|
576
|
+
function Ue(t, e) {
|
|
577
|
+
e.writeStringField(pe, t.StreamId);
|
|
592
578
|
const r = t.ShapeSets;
|
|
593
|
-
r != null && e.writeArrayField(
|
|
579
|
+
r != null && e.writeArrayField(ye, m.Object, (n) => {
|
|
594
580
|
for (const i of r)
|
|
595
|
-
n.writeObject(
|
|
596
|
-
|
|
581
|
+
n.writeObject(_e, (s) => {
|
|
582
|
+
Me(i, s);
|
|
597
583
|
});
|
|
598
|
-
}), e.writeStringField(
|
|
584
|
+
}), e.writeStringField(we, t.Description), e.writeInt32Field(Ie, t.Channels | 0), e.writeStringField(me, t.CodecDetails), e.writeStringField(ge, t.SourceType), e.writeInt32Field(Ee, t.Codec), e.writeInt32Field(Se, t.SampleRate | 0);
|
|
599
585
|
}
|
|
600
|
-
function
|
|
601
|
-
const n =
|
|
602
|
-
return L(
|
|
586
|
+
function Be(t, e, r) {
|
|
587
|
+
const n = Fe(t);
|
|
588
|
+
return L(fe, n, H, e, r);
|
|
603
589
|
}
|
|
604
|
-
const
|
|
605
|
-
function
|
|
606
|
-
e.writeStringField(
|
|
590
|
+
const _e = 5, Oe = 1107713536, De = 1154362099, Re = 1185721362;
|
|
591
|
+
function Me(t, e) {
|
|
592
|
+
e.writeStringField(Oe, t.Name), e.writeUInt32Field(De, t.SetId >>> 0), e.writeArrayField(Re, m.String, (r) => {
|
|
607
593
|
for (const n of t.ShapeNames)
|
|
608
594
|
r.writeString(n);
|
|
609
595
|
});
|
|
610
596
|
}
|
|
611
|
-
const K = 1,
|
|
612
|
-
function
|
|
597
|
+
const K = 1, Te = 4194306;
|
|
598
|
+
function Ve(t) {
|
|
613
599
|
const e = {};
|
|
614
600
|
return t && Object.assign(e, t), e;
|
|
615
601
|
}
|
|
616
|
-
function
|
|
602
|
+
function Le(t) {
|
|
617
603
|
return new S(K).finish();
|
|
618
604
|
}
|
|
619
|
-
function
|
|
620
|
-
const n =
|
|
621
|
-
return L(
|
|
605
|
+
function We(t, e, r) {
|
|
606
|
+
const n = Le();
|
|
607
|
+
return L(Te, n, K, e, r);
|
|
622
608
|
}
|
|
623
|
-
class
|
|
609
|
+
class Pe {
|
|
624
610
|
static getStorageForCapacity(e, r) {
|
|
625
611
|
const n = Int32Array.BYTES_PER_ELEMENT * 2, i = r.BYTES_PER_ELEMENT * e;
|
|
626
612
|
return new SharedArrayBuffer(n + i);
|
|
@@ -674,19 +660,19 @@ class xe {
|
|
|
674
660
|
return n = (n + r) % this.capacity, Atomics.store(this.readWrite, 0, n), r;
|
|
675
661
|
}
|
|
676
662
|
}
|
|
677
|
-
let
|
|
678
|
-
const
|
|
663
|
+
let Ce = 1;
|
|
664
|
+
const ve = /* @__PURE__ */ new Map(), Ne = {
|
|
679
665
|
0: "DEBUG",
|
|
680
666
|
1: "INFO",
|
|
681
667
|
2: "WARN",
|
|
682
668
|
3: "ERROR",
|
|
683
669
|
4: "NONE"
|
|
684
670
|
};
|
|
685
|
-
function
|
|
671
|
+
function ke(t, e) {
|
|
686
672
|
return `[${t}] ${e}`;
|
|
687
673
|
}
|
|
688
|
-
function
|
|
689
|
-
const i = (/* @__PURE__ */ new Date()).toISOString(), s =
|
|
674
|
+
function F(t, e, r, n) {
|
|
675
|
+
const i = (/* @__PURE__ */ new Date()).toISOString(), s = Ne[t], a = {
|
|
690
676
|
timestamp: i,
|
|
691
677
|
level: t,
|
|
692
678
|
levelName: s,
|
|
@@ -694,7 +680,7 @@ function _(t, e, r, n) {
|
|
|
694
680
|
message: r,
|
|
695
681
|
args: n
|
|
696
682
|
};
|
|
697
|
-
for (const [c, l] of
|
|
683
|
+
for (const [c, l] of ve) {
|
|
698
684
|
const o = l?.minLevel ?? 2;
|
|
699
685
|
if (t >= o)
|
|
700
686
|
try {
|
|
@@ -702,8 +688,8 @@ function _(t, e, r, n) {
|
|
|
702
688
|
} catch {
|
|
703
689
|
}
|
|
704
690
|
}
|
|
705
|
-
if (
|
|
706
|
-
const c =
|
|
691
|
+
if (Ce <= t) {
|
|
692
|
+
const c = ke(e, r);
|
|
707
693
|
switch (t) {
|
|
708
694
|
case 0:
|
|
709
695
|
console.debug(c, ...n);
|
|
@@ -720,23 +706,23 @@ function _(t, e, r, n) {
|
|
|
720
706
|
}
|
|
721
707
|
}
|
|
722
708
|
}
|
|
723
|
-
function
|
|
709
|
+
function xe(t) {
|
|
724
710
|
return {
|
|
725
711
|
debug(e, ...r) {
|
|
726
|
-
|
|
712
|
+
F(0, t, e, r);
|
|
727
713
|
},
|
|
728
714
|
info(e, ...r) {
|
|
729
|
-
|
|
715
|
+
F(1, t, e, r);
|
|
730
716
|
},
|
|
731
717
|
warn(e, ...r) {
|
|
732
|
-
|
|
718
|
+
F(2, t, e, r);
|
|
733
719
|
},
|
|
734
720
|
error(e, ...r) {
|
|
735
|
-
|
|
721
|
+
F(3, t, e, r);
|
|
736
722
|
}
|
|
737
723
|
};
|
|
738
724
|
}
|
|
739
|
-
const
|
|
725
|
+
const ze = 20, b = 32e3, He = 5, M = 8e3, g = xe("AudioCaptureWorker");
|
|
740
726
|
class $ {
|
|
741
727
|
encoder = null;
|
|
742
728
|
isReady = !1;
|
|
@@ -759,7 +745,7 @@ class $ {
|
|
|
759
745
|
channels: this.channels,
|
|
760
746
|
bitrate: this.bitrate,
|
|
761
747
|
application: r,
|
|
762
|
-
complexity:
|
|
748
|
+
complexity: He
|
|
763
749
|
}), await this.encoder.ready, this.isReady = !0;
|
|
764
750
|
} catch (e) {
|
|
765
751
|
this.onError(e instanceof Error ? e : new Error(String(e)));
|
|
@@ -795,23 +781,23 @@ class $ {
|
|
|
795
781
|
}
|
|
796
782
|
}
|
|
797
783
|
const O = (t) => self.postMessage(t);
|
|
798
|
-
let
|
|
799
|
-
function
|
|
784
|
+
let I = null;
|
|
785
|
+
function w(t, e) {
|
|
800
786
|
const r = t instanceof Error ? t : new Error(String(t));
|
|
801
787
|
O({ type: "error", captureId: e, error: { name: r.name, message: r.message, stack: r.stack } });
|
|
802
788
|
}
|
|
803
|
-
function
|
|
789
|
+
function Ke(t) {
|
|
804
790
|
return t.byteOffset === 0 && t.byteLength === t.buffer.byteLength ? t.buffer : t.slice().buffer;
|
|
805
791
|
}
|
|
806
792
|
function C(t) {
|
|
807
|
-
if (!
|
|
808
|
-
|
|
793
|
+
if (!I) {
|
|
794
|
+
g.warn("Audio capture message dropped: sendPort not available");
|
|
809
795
|
return;
|
|
810
796
|
}
|
|
811
|
-
const e =
|
|
812
|
-
|
|
797
|
+
const e = Ke(t);
|
|
798
|
+
I.postMessage({ type: "send", message: e }, [e]);
|
|
813
799
|
}
|
|
814
|
-
function
|
|
800
|
+
function $e(t) {
|
|
815
801
|
if (t.length === 0)
|
|
816
802
|
return 0;
|
|
817
803
|
let e = 0;
|
|
@@ -819,13 +805,13 @@ function Je(t) {
|
|
|
819
805
|
e += Math.abs(t[r] ?? 0);
|
|
820
806
|
return e / t.length;
|
|
821
807
|
}
|
|
822
|
-
const f = /* @__PURE__ */ new Map(),
|
|
808
|
+
const f = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new Map();
|
|
823
809
|
let A = null;
|
|
824
810
|
const x = 1;
|
|
825
|
-
function
|
|
811
|
+
function je() {
|
|
826
812
|
return typeof Atomics < "u" && typeof Atomics.waitAsync == "function";
|
|
827
813
|
}
|
|
828
|
-
async function
|
|
814
|
+
async function qe(t) {
|
|
829
815
|
if (!t.ringBuffer || !t.ringTemp)
|
|
830
816
|
return;
|
|
831
817
|
const e = t.ringBuffer, r = t.ringTemp;
|
|
@@ -834,7 +820,7 @@ async function Ze(t) {
|
|
|
834
820
|
const n = e.pop(r);
|
|
835
821
|
n > 0 && T(t, r.subarray(0, n));
|
|
836
822
|
} catch (n) {
|
|
837
|
-
|
|
823
|
+
w(n, t.captureId);
|
|
838
824
|
}
|
|
839
825
|
try {
|
|
840
826
|
const n = Atomics.load(e.readWrite, x), i = Atomics.waitAsync(e.readWrite, x, n, 100);
|
|
@@ -844,29 +830,29 @@ async function Ze(t) {
|
|
|
844
830
|
}
|
|
845
831
|
}
|
|
846
832
|
}
|
|
847
|
-
function
|
|
833
|
+
function Ge() {
|
|
848
834
|
for (const t of f.values())
|
|
849
835
|
if (!(t.transport !== "sab" || !t.ringBuffer || !t.ringTemp || t.stopped))
|
|
850
836
|
try {
|
|
851
837
|
const e = t.ringBuffer.pop(t.ringTemp);
|
|
852
838
|
e > 0 && T(t, t.ringTemp.subarray(0, e));
|
|
853
839
|
} catch (e) {
|
|
854
|
-
|
|
840
|
+
w(e, t.captureId);
|
|
855
841
|
}
|
|
856
842
|
}
|
|
857
|
-
function
|
|
858
|
-
if (
|
|
859
|
-
if (!
|
|
860
|
-
const e =
|
|
861
|
-
|
|
862
|
-
|
|
843
|
+
function Ye(t) {
|
|
844
|
+
if (je()) {
|
|
845
|
+
if (!U.has(t.captureId)) {
|
|
846
|
+
const e = qe(t);
|
|
847
|
+
U.set(t.captureId, e), e.finally(() => {
|
|
848
|
+
U.delete(t.captureId);
|
|
863
849
|
});
|
|
864
850
|
}
|
|
865
851
|
} else
|
|
866
|
-
A === null && (A = self.setInterval(
|
|
852
|
+
A === null && (A = self.setInterval(Ge, 50));
|
|
867
853
|
}
|
|
868
|
-
function
|
|
869
|
-
if (
|
|
854
|
+
function Je(t) {
|
|
855
|
+
if (U.delete(t), A !== null) {
|
|
870
856
|
let e = !1;
|
|
871
857
|
for (const r of f.values())
|
|
872
858
|
if (r.transport === "sab" && !r.stopped) {
|
|
@@ -899,7 +885,7 @@ function v(t) {
|
|
|
899
885
|
r.set(t.pendingBuffer.subarray(i, n)), r.set(t.pendingBuffer.subarray(0, e - a), a);
|
|
900
886
|
}
|
|
901
887
|
t.pendingReadOffset = (i + e) % n, t.pendingSamples -= e;
|
|
902
|
-
const s =
|
|
888
|
+
const s = $e(r);
|
|
903
889
|
t.lastVolume = s;
|
|
904
890
|
try {
|
|
905
891
|
if (t.useWasmEncoder)
|
|
@@ -916,7 +902,7 @@ function v(t) {
|
|
|
916
902
|
t.encoder.encode(a), a.close();
|
|
917
903
|
}
|
|
918
904
|
} catch (a) {
|
|
919
|
-
|
|
905
|
+
w(a, t.captureId);
|
|
920
906
|
}
|
|
921
907
|
t.timestampUs += t.frameDurationUs;
|
|
922
908
|
}
|
|
@@ -944,7 +930,7 @@ function T(t, e) {
|
|
|
944
930
|
const i = t.pendingBuffer.length, s = Math.min(r, i - t.pendingWriteOffset);
|
|
945
931
|
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, v(t);
|
|
946
932
|
}
|
|
947
|
-
function
|
|
933
|
+
function D(t, e, r, n, i = !0) {
|
|
948
934
|
const s = f.get(t.captureId);
|
|
949
935
|
if (!s || s.stopped || !s.inSegment && !s.segmentEndPending)
|
|
950
936
|
return;
|
|
@@ -956,8 +942,8 @@ function B(t, e, r, n, i = !0) {
|
|
|
956
942
|
o && (s.segmentEndPending = !1, s.inSegment = !1);
|
|
957
943
|
const d = s.frameSize * s.channels, y = BigInt(Math.floor(r / 1e6 * s.sampleRate * s.channels));
|
|
958
944
|
C(
|
|
959
|
-
|
|
960
|
-
|
|
945
|
+
he(
|
|
946
|
+
ce({
|
|
961
947
|
Samples: c,
|
|
962
948
|
Epoch: s.epoch,
|
|
963
949
|
Sequence: s.sequence,
|
|
@@ -973,14 +959,14 @@ function B(t, e, r, n, i = !0) {
|
|
|
973
959
|
)
|
|
974
960
|
), s.sequence++;
|
|
975
961
|
}
|
|
976
|
-
function
|
|
962
|
+
function Xe(t) {
|
|
977
963
|
const e = Math.max(M, Math.floor(t.options?.bitrate ?? b)), r = new AudioEncoder({
|
|
978
964
|
output: (n) => {
|
|
979
965
|
const i = f.get(t.captureId);
|
|
980
966
|
if (!i)
|
|
981
967
|
return;
|
|
982
968
|
const s = n.byteLength;
|
|
983
|
-
i.encoderOutputBuffer.length < s && (i.encoderOutputBuffer = new Uint8Array(Math.max(s, i.encoderOutputBuffer.length * 2))), n.copyTo(i.encoderOutputBuffer),
|
|
969
|
+
i.encoderOutputBuffer.length < s && (i.encoderOutputBuffer = new Uint8Array(Math.max(s, i.encoderOutputBuffer.length * 2))), n.copyTo(i.encoderOutputBuffer), D(
|
|
984
970
|
i,
|
|
985
971
|
i.encoderOutputBuffer.subarray(0, s),
|
|
986
972
|
n.timestamp ?? i.timestampUs,
|
|
@@ -989,7 +975,7 @@ function rt(t) {
|
|
|
989
975
|
);
|
|
990
976
|
},
|
|
991
977
|
error: (n) => {
|
|
992
|
-
|
|
978
|
+
w(n, t.captureId);
|
|
993
979
|
}
|
|
994
980
|
});
|
|
995
981
|
return r.configure({
|
|
@@ -1005,7 +991,7 @@ function rt(t) {
|
|
|
1005
991
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1006
992
|
}), r;
|
|
1007
993
|
}
|
|
1008
|
-
function
|
|
994
|
+
function Ze(t) {
|
|
1009
995
|
const e = Math.max(M, Math.floor(t.options?.bitrate ?? b));
|
|
1010
996
|
return new $({
|
|
1011
997
|
sampleRate: t.sampleRate,
|
|
@@ -1014,14 +1000,14 @@ function nt(t) {
|
|
|
1014
1000
|
frameSize: t.frameSize,
|
|
1015
1001
|
onOutput: (r, n, i) => {
|
|
1016
1002
|
const s = f.get(t.captureId);
|
|
1017
|
-
s &&
|
|
1003
|
+
s && D(s, r, n, i, !0);
|
|
1018
1004
|
},
|
|
1019
1005
|
onError: (r) => {
|
|
1020
|
-
|
|
1006
|
+
w(r, t.captureId);
|
|
1021
1007
|
}
|
|
1022
1008
|
});
|
|
1023
1009
|
}
|
|
1024
|
-
async function
|
|
1010
|
+
async function Qe() {
|
|
1025
1011
|
if (typeof AudioEncoder > "u")
|
|
1026
1012
|
return !1;
|
|
1027
1013
|
try {
|
|
@@ -1034,15 +1020,15 @@ async function it() {
|
|
|
1034
1020
|
return !1;
|
|
1035
1021
|
}
|
|
1036
1022
|
}
|
|
1037
|
-
async function
|
|
1038
|
-
if (!
|
|
1023
|
+
async function et(t) {
|
|
1024
|
+
if (!I)
|
|
1039
1025
|
throw new Error("Audio capture worker missing send port");
|
|
1040
1026
|
if (f.has(t.captureId)) {
|
|
1041
1027
|
const h = f.get(t.captureId);
|
|
1042
1028
|
O({ type: "started", captureId: t.captureId, sampleRate: h.sampleRate, channels: h.channels });
|
|
1043
1029
|
return;
|
|
1044
1030
|
}
|
|
1045
|
-
const e = Math.max(8e3, Math.floor(t.sampleRate)), r = Math.max(1, Math.floor(t.channels)), n = Math.max(1, Math.floor(e *
|
|
1031
|
+
const e = Math.max(8e3, Math.floor(t.sampleRate)), r = Math.max(1, Math.floor(t.channels)), n = Math.max(1, Math.floor(e * ze / 1e3)), i = Math.max(1, Math.floor(n * 1e6 / e)), s = n * 4, a = {
|
|
1046
1032
|
captureId: t.captureId,
|
|
1047
1033
|
streamId: t.streamId,
|
|
1048
1034
|
sourceType: t.sourceType,
|
|
@@ -1072,16 +1058,16 @@ async function st(t) {
|
|
|
1072
1058
|
lastVolume: 0,
|
|
1073
1059
|
targetIds: t.options?.targetIds,
|
|
1074
1060
|
options: t.options
|
|
1075
|
-
}, l = (t.options?.preferWebCodecs ?? !0) && await
|
|
1061
|
+
}, l = (t.options?.preferWebCodecs ?? !0) && await Qe();
|
|
1076
1062
|
let o, d = !1;
|
|
1077
1063
|
const y = Math.max(M, Math.floor(t.options?.bitrate ?? b));
|
|
1078
1064
|
if (l)
|
|
1079
|
-
o =
|
|
1065
|
+
o = Xe(a), g.debug(
|
|
1080
1066
|
`Audio capture started: encoder=WebCodecs, sampleRate=${e}Hz, channels=${r}, bitrate=${y}bps`
|
|
1081
1067
|
);
|
|
1082
1068
|
else {
|
|
1083
|
-
const h =
|
|
1084
|
-
await h.initialize(), o = h, d = !0,
|
|
1069
|
+
const h = Ze(a);
|
|
1070
|
+
await h.initialize(), o = h, d = !0, g.debug(
|
|
1085
1071
|
`Audio capture started: encoder=WASM Opus, sampleRate=${e}Hz, channels=${r}, bitrate=${y}bps`
|
|
1086
1072
|
);
|
|
1087
1073
|
}
|
|
@@ -1094,16 +1080,16 @@ async function st(t) {
|
|
|
1094
1080
|
if (t.transport === "sab") {
|
|
1095
1081
|
if (!t.sharedArrayBuffer)
|
|
1096
1082
|
throw new Error("Missing SharedArrayBuffer for sab transport");
|
|
1097
|
-
const h = new
|
|
1098
|
-
p.ringBuffer = h, p.ringTemp = new Float32Array(Math.max(p.frameSize * 4, 4096)),
|
|
1083
|
+
const h = new Pe(t.sharedArrayBuffer, Float32Array);
|
|
1084
|
+
p.ringBuffer = h, p.ringTemp = new Float32Array(Math.max(p.frameSize * 4, 4096)), Ye(p);
|
|
1099
1085
|
}
|
|
1100
1086
|
f.set(t.captureId, p), C(
|
|
1101
|
-
|
|
1102
|
-
|
|
1087
|
+
Be(
|
|
1088
|
+
Ae({
|
|
1103
1089
|
StreamId: t.streamId,
|
|
1104
1090
|
Description: `mic:${t.streamId}`,
|
|
1105
1091
|
SourceType: t.sourceType,
|
|
1106
|
-
Codec:
|
|
1092
|
+
Codec: P.Opus,
|
|
1107
1093
|
CodecDetails: "",
|
|
1108
1094
|
SampleRate: e,
|
|
1109
1095
|
Channels: r
|
|
@@ -1129,14 +1115,14 @@ async function j(t) {
|
|
|
1129
1115
|
e.encoder.close();
|
|
1130
1116
|
} catch {
|
|
1131
1117
|
}
|
|
1132
|
-
C(
|
|
1118
|
+
C(We(Ve({}), e.senderId, { trackId: e.trackId, targetIds: e.targetIds })), O({ type: "stopped", captureId: e.captureId }), Je(t);
|
|
1133
1119
|
}
|
|
1134
1120
|
}
|
|
1135
|
-
function
|
|
1121
|
+
function tt(t) {
|
|
1136
1122
|
const e = f.get(t);
|
|
1137
1123
|
!e || e.stopped || (e.inSegment = !0, e.segmentStartPending = !0);
|
|
1138
1124
|
}
|
|
1139
|
-
function
|
|
1125
|
+
function rt(t) {
|
|
1140
1126
|
const e = f.get(t);
|
|
1141
1127
|
if (!(!e || e.stopped || !e.inSegment) && (e.segmentEndPending = !0, v(e), e.segmentEndPending && !e.stopped)) {
|
|
1142
1128
|
const r = e.frameSize - e.pendingSamples;
|
|
@@ -1146,7 +1132,7 @@ function ot(t) {
|
|
|
1146
1132
|
}
|
|
1147
1133
|
}
|
|
1148
1134
|
}
|
|
1149
|
-
async function
|
|
1135
|
+
async function nt(t, e) {
|
|
1150
1136
|
const r = f.get(t);
|
|
1151
1137
|
if (!r || r.stopped)
|
|
1152
1138
|
return;
|
|
@@ -1166,16 +1152,16 @@ async function ct(t, e) {
|
|
|
1166
1152
|
frameSize: r.frameSize,
|
|
1167
1153
|
onOutput: (o, d, y) => {
|
|
1168
1154
|
const p = f.get(r.captureId);
|
|
1169
|
-
!p || p.isReconfiguring ||
|
|
1155
|
+
!p || p.isReconfiguring || D(p, o, d, y, !0);
|
|
1170
1156
|
},
|
|
1171
1157
|
onError: (o) => {
|
|
1172
|
-
|
|
1158
|
+
w(o, r.captureId);
|
|
1173
1159
|
}
|
|
1174
1160
|
});
|
|
1175
1161
|
try {
|
|
1176
1162
|
await l.initialize();
|
|
1177
1163
|
} catch (o) {
|
|
1178
|
-
r.isReconfiguring = !1,
|
|
1164
|
+
r.isReconfiguring = !1, w(o, t);
|
|
1179
1165
|
return;
|
|
1180
1166
|
}
|
|
1181
1167
|
a = l;
|
|
@@ -1186,7 +1172,7 @@ async function ct(t, e) {
|
|
|
1186
1172
|
if (!d || d.isReconfiguring)
|
|
1187
1173
|
return;
|
|
1188
1174
|
const y = o.byteLength;
|
|
1189
|
-
d.encoderOutputBuffer.length < y && (d.encoderOutputBuffer = new Uint8Array(Math.max(y, d.encoderOutputBuffer.length * 2))), o.copyTo(d.encoderOutputBuffer),
|
|
1175
|
+
d.encoderOutputBuffer.length < y && (d.encoderOutputBuffer = new Uint8Array(Math.max(y, d.encoderOutputBuffer.length * 2))), o.copyTo(d.encoderOutputBuffer), D(
|
|
1190
1176
|
d,
|
|
1191
1177
|
d.encoderOutputBuffer.subarray(0, y),
|
|
1192
1178
|
o.timestamp ?? d.timestampUs,
|
|
@@ -1195,7 +1181,7 @@ async function ct(t, e) {
|
|
|
1195
1181
|
);
|
|
1196
1182
|
},
|
|
1197
1183
|
error: (o) => {
|
|
1198
|
-
|
|
1184
|
+
w(o, r.captureId);
|
|
1199
1185
|
}
|
|
1200
1186
|
});
|
|
1201
1187
|
l.configure({
|
|
@@ -1220,39 +1206,39 @@ async function ct(t, e) {
|
|
|
1220
1206
|
c.close();
|
|
1221
1207
|
} catch {
|
|
1222
1208
|
}
|
|
1223
|
-
r.encoder = a, r.isReconfiguring = !1,
|
|
1209
|
+
r.encoder = a, r.isReconfiguring = !1, g.debug(`Audio capture bitrate updated: ${s}bps`);
|
|
1224
1210
|
}
|
|
1225
|
-
async function
|
|
1211
|
+
async function it() {
|
|
1226
1212
|
const t = Array.from(f.keys()).map(
|
|
1227
1213
|
(e) => j(e).catch(() => {
|
|
1228
1214
|
})
|
|
1229
1215
|
);
|
|
1230
|
-
if (await Promise.all(t),
|
|
1216
|
+
if (await Promise.all(t), I) {
|
|
1231
1217
|
try {
|
|
1232
|
-
|
|
1218
|
+
I.close();
|
|
1233
1219
|
} catch {
|
|
1234
1220
|
}
|
|
1235
|
-
|
|
1221
|
+
I = null;
|
|
1236
1222
|
}
|
|
1237
1223
|
}
|
|
1238
1224
|
self.addEventListener("message", (t) => {
|
|
1239
1225
|
const e = t.data;
|
|
1240
1226
|
if (e.type === "attachSendPort") {
|
|
1241
|
-
if (
|
|
1227
|
+
if (I)
|
|
1242
1228
|
try {
|
|
1243
|
-
|
|
1229
|
+
I.close();
|
|
1244
1230
|
} catch {
|
|
1245
1231
|
}
|
|
1246
|
-
|
|
1232
|
+
I = e.port;
|
|
1247
1233
|
try {
|
|
1248
|
-
|
|
1234
|
+
I.start?.();
|
|
1249
1235
|
} catch {
|
|
1250
1236
|
}
|
|
1251
1237
|
return;
|
|
1252
1238
|
}
|
|
1253
1239
|
if (e.type === "start") {
|
|
1254
|
-
|
|
1255
|
-
|
|
1240
|
+
et(e).catch((r) => {
|
|
1241
|
+
w(r, e.captureId);
|
|
1256
1242
|
});
|
|
1257
1243
|
return;
|
|
1258
1244
|
}
|
|
@@ -1265,25 +1251,25 @@ self.addEventListener("message", (t) => {
|
|
|
1265
1251
|
}
|
|
1266
1252
|
if (e.type === "stop") {
|
|
1267
1253
|
j(e.captureId).catch((r) => {
|
|
1268
|
-
|
|
1254
|
+
g.warn(`Failed to stop audio capture: ${r}`), w(r, e.captureId);
|
|
1269
1255
|
});
|
|
1270
1256
|
return;
|
|
1271
1257
|
}
|
|
1272
1258
|
if (e.type === "startSegment") {
|
|
1273
|
-
|
|
1259
|
+
tt(e.captureId);
|
|
1274
1260
|
return;
|
|
1275
1261
|
}
|
|
1276
1262
|
if (e.type === "endSegment") {
|
|
1277
|
-
|
|
1263
|
+
rt(e.captureId);
|
|
1278
1264
|
return;
|
|
1279
1265
|
}
|
|
1280
1266
|
if (e.type === "updateOptions") {
|
|
1281
|
-
|
|
1282
|
-
|
|
1267
|
+
nt(e.captureId, e.options).catch((r) => {
|
|
1268
|
+
g.warn(`Failed to update audio capture options: ${r}`), w(r, e.captureId);
|
|
1283
1269
|
});
|
|
1284
1270
|
return;
|
|
1285
1271
|
}
|
|
1286
|
-
e.type === "dispose" &&
|
|
1287
|
-
|
|
1272
|
+
e.type === "dispose" && it().catch((r) => {
|
|
1273
|
+
g.warn(`Failed to dispose audio capture worker: ${r}`);
|
|
1288
1274
|
});
|
|
1289
1275
|
});
|