@ikonai/sdk 0.0.36 → 0.0.37
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-CiEMOS9I.js → audio-capture-worker-Bnqb8-xb.js} +357 -237
- package/assets/{audio-playback-worker-WI7y4bo8.js → audio-playback-worker-CXmAFv0O.js} +125 -152
- package/assets/index-C-9F_--I.js +186 -0
- package/assets/index-C3ZAK5YF.js +170 -0
- package/assets/libopus-BBY7KH2-.js +169 -0
- package/assets/libopus-simd-CQXMVirP.js +169 -0
- package/client/ikon-client-config.d.ts +54 -55
- package/index.d.ts +3 -3
- package/index.js +498 -468
- package/media/audio-constants.d.ts +5 -0
- package/media/ikon-audio-capture.d.ts +12 -1
- package/media/ikon-audio-playback.d.ts +8 -9
- package/media/ikon-media-capture.d.ts +5 -2
- package/media/ikon-media.d.ts +8 -0
- package/media/index.d.ts +3 -2
- package/package.json +1 -1
- package/assets/index-CvFH-Dkf.js +0 -650
- /package/utils/{logSink.d.ts → log-sink.d.ts} +0 -0
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
function
|
|
2
|
-
const s = i?.trackId ?? 0,
|
|
3
|
-
|
|
4
|
-
let
|
|
5
|
-
for (let
|
|
6
|
-
|
|
7
|
-
return
|
|
8
|
-
}
|
|
9
|
-
var
|
|
10
|
-
const
|
|
1
|
+
function S(e, t, r, n, i) {
|
|
2
|
+
const s = i?.trackId ?? 0, a = i?.sequenceId ?? 0, c = i?.flags ?? 0, l = i?.targetIds ?? [], h = i?.payloadType ?? 8, I = 27 + l.length * 4, E = I + t.length, y = new Uint8Array(E), u = new DataView(y.buffer);
|
|
3
|
+
u.setUint32(0, E, !0), u.setUint32(4, e >>> 0, !0), u.setUint32(8, n >>> 0, !0), u.setUint32(12, s >>> 0, !0), u.setUint32(16, a >>> 0, !0), u.setUint32(20, l.length >>> 0, !0), u.setUint8(24, r & 255), u.setUint8(25, h & 255), u.setUint8(26, c & 255);
|
|
4
|
+
let U = 27;
|
|
5
|
+
for (let _ = 0; _ < l.length; _++)
|
|
6
|
+
u.setUint32(U, l[_] >>> 0, !0), U += 4;
|
|
7
|
+
return y.set(t, I), y;
|
|
8
|
+
}
|
|
9
|
+
var w = /* @__PURE__ */ ((e) => (e[e.Null = 1] = "Null", e[e.Bool = 2] = "Bool", e[e.Int32 = 3] = "Int32", e[e.Int64 = 4] = "Int64", e[e.UInt32 = 5] = "UInt32", e[e.UInt64 = 6] = "UInt64", e[e.Float32 = 7] = "Float32", e[e.Float64 = 8] = "Float64", e[e.Array = 9] = "Array", e[e.Dict = 10] = "Dict", e[e.Object = 11] = "Object", e[e.String = 12] = "String", e[e.Binary = 13] = "Binary", e[e.Guid = 14] = "Guid", e))(w || {});
|
|
10
|
+
const $ = 161, j = 162, F = new TextEncoder();
|
|
11
11
|
new TextDecoder("utf-8", { fatal: !0 });
|
|
12
|
-
class
|
|
12
|
+
class p {
|
|
13
13
|
constructor(t = 1) {
|
|
14
|
-
this.version = t, this.buffer.writeByte(
|
|
14
|
+
this.version = t, this.buffer.writeByte($), this.buffer.writeVarUInt(t >>> 0);
|
|
15
15
|
}
|
|
16
|
-
buffer = new
|
|
16
|
+
buffer = new b();
|
|
17
17
|
closed = !1;
|
|
18
18
|
cached;
|
|
19
19
|
writeInt32Field(t, r) {
|
|
@@ -38,38 +38,38 @@ class f {
|
|
|
38
38
|
this.writeFixedField(t, 2, () => this.buffer.writeByte(r ? 1 : 0));
|
|
39
39
|
}
|
|
40
40
|
writeGuidField(t, r) {
|
|
41
|
-
const n = r instanceof
|
|
41
|
+
const n = r instanceof o ? r.asBytes() : r;
|
|
42
42
|
if (n.length !== 16)
|
|
43
43
|
throw new Error("Guid payload must be 16 bytes");
|
|
44
44
|
this.writeFixedField(t, 14, () => this.buffer.writeBytes(n));
|
|
45
45
|
}
|
|
46
46
|
writeStringField(t, r) {
|
|
47
|
-
const n =
|
|
47
|
+
const n = F.encode(r ?? "");
|
|
48
48
|
this.writeVariableField(t, 12, n);
|
|
49
49
|
}
|
|
50
50
|
writeBinaryField(t, r) {
|
|
51
51
|
this.writeVariableField(t, 13, r);
|
|
52
52
|
}
|
|
53
53
|
writeObjectField(t, r, n) {
|
|
54
|
-
const i = new
|
|
54
|
+
const i = new p(r);
|
|
55
55
|
n(i);
|
|
56
56
|
const s = i.finish();
|
|
57
57
|
this.writeVariableField(t, 11, s);
|
|
58
58
|
}
|
|
59
59
|
writeArrayField(t, r, n) {
|
|
60
|
-
const i = new
|
|
60
|
+
const i = new O(r);
|
|
61
61
|
n(i);
|
|
62
62
|
const s = i.finish();
|
|
63
63
|
this.writeVariableField(t, 9, s);
|
|
64
64
|
}
|
|
65
65
|
writeDictionaryField(t, r, n, i) {
|
|
66
|
-
const s = new
|
|
66
|
+
const s = new R(r, n);
|
|
67
67
|
i(s);
|
|
68
|
-
const
|
|
69
|
-
this.writeVariableField(t, 10,
|
|
68
|
+
const a = s.finish();
|
|
69
|
+
this.writeVariableField(t, 10, a);
|
|
70
70
|
}
|
|
71
71
|
finish() {
|
|
72
|
-
return this.closed || (this.buffer.writeByte(
|
|
72
|
+
return this.closed || (this.buffer.writeByte(j), this.closed = !0, this.cached = this.buffer.toUint8Array()), this.cached;
|
|
73
73
|
}
|
|
74
74
|
writeFixedField(t, r, n) {
|
|
75
75
|
this.writeFieldHeader(t, r, 0), n();
|
|
@@ -78,14 +78,14 @@ class f {
|
|
|
78
78
|
this.writeFieldHeader(t, r, n.length), this.buffer.writeBytes(n);
|
|
79
79
|
}
|
|
80
80
|
writeFieldHeader(t, r, n) {
|
|
81
|
-
this.buffer.writeUInt32(t >>> 0), this.buffer.writeByte(
|
|
81
|
+
this.buffer.writeUInt32(t >>> 0), this.buffer.writeByte(B(r)), q(r) && this.buffer.writeVarUInt(n >>> 0);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
class
|
|
84
|
+
class O {
|
|
85
85
|
constructor(t) {
|
|
86
86
|
this.elementType = t;
|
|
87
87
|
}
|
|
88
|
-
payload = new
|
|
88
|
+
payload = new b();
|
|
89
89
|
count = 0;
|
|
90
90
|
writeInt32(t) {
|
|
91
91
|
this.ensureElementType(
|
|
@@ -134,7 +134,7 @@ class b {
|
|
|
134
134
|
14
|
|
135
135
|
/* Guid */
|
|
136
136
|
), this.count++;
|
|
137
|
-
const r = t instanceof
|
|
137
|
+
const r = t instanceof o ? t.asBytes() : t;
|
|
138
138
|
if (r.length !== 16)
|
|
139
139
|
throw new Error("Guid payload must be 16 bytes");
|
|
140
140
|
this.payload.writeBytes(r);
|
|
@@ -144,7 +144,7 @@ class b {
|
|
|
144
144
|
12
|
|
145
145
|
/* String */
|
|
146
146
|
), this.count++;
|
|
147
|
-
const r =
|
|
147
|
+
const r = F.encode(t ?? "");
|
|
148
148
|
this.payload.writeVarUInt(r.length), this.payload.writeBytes(r);
|
|
149
149
|
}
|
|
150
150
|
writeBinary(t) {
|
|
@@ -158,7 +158,7 @@ class b {
|
|
|
158
158
|
11
|
|
159
159
|
/* Object */
|
|
160
160
|
), this.count++;
|
|
161
|
-
const n = new
|
|
161
|
+
const n = new p(t);
|
|
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 b {
|
|
|
168
168
|
9
|
|
169
169
|
/* Array */
|
|
170
170
|
), this.count++;
|
|
171
|
-
const n = new
|
|
171
|
+
const n = new O(t);
|
|
172
172
|
r(n);
|
|
173
173
|
const i = n.finish();
|
|
174
174
|
this.payload.writeBytes(i);
|
|
@@ -178,42 +178,42 @@ class b {
|
|
|
178
178
|
10
|
|
179
179
|
/* Dict */
|
|
180
180
|
), this.count++;
|
|
181
|
-
const i = new
|
|
181
|
+
const i = new R(t, r);
|
|
182
182
|
n(i);
|
|
183
183
|
const s = i.finish();
|
|
184
184
|
this.payload.writeBytes(s);
|
|
185
185
|
}
|
|
186
186
|
finish() {
|
|
187
|
-
const t = new
|
|
188
|
-
return t.writeByte(
|
|
187
|
+
const t = new b();
|
|
188
|
+
return t.writeByte(B(this.elementType)), t.writeVarUInt(this.count), t.writeBytes(this.payload.toUint8Array()), t.toUint8Array();
|
|
189
189
|
}
|
|
190
190
|
ensureElementType(t) {
|
|
191
191
|
if (this.elementType !== t)
|
|
192
|
-
throw new Error(`Array element type is ${
|
|
192
|
+
throw new Error(`Array element type is ${w[this.elementType]}, expected ${w[t]}`);
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
-
class
|
|
195
|
+
class R {
|
|
196
196
|
constructor(t, r) {
|
|
197
|
-
this.keyType = t, this.valueType = r,
|
|
197
|
+
this.keyType = t, this.valueType = r, G(t);
|
|
198
198
|
}
|
|
199
|
-
payload = new
|
|
199
|
+
payload = new b();
|
|
200
200
|
count = 0;
|
|
201
201
|
entryOpen = !1;
|
|
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 Y(this.keyType, this.valueType, this.payload, () => {
|
|
206
206
|
this.entryOpen = !1;
|
|
207
207
|
});
|
|
208
208
|
}
|
|
209
209
|
finish() {
|
|
210
210
|
if (this.entryOpen)
|
|
211
211
|
throw new Error("Dictionary entry not completed");
|
|
212
|
-
const t = new
|
|
213
|
-
return t.writeByte(
|
|
212
|
+
const t = new b();
|
|
213
|
+
return t.writeByte(B(this.keyType)), t.writeByte(B(this.valueType)), t.writeVarUInt(this.count), t.writeBytes(this.payload.toUint8Array()), t.toUint8Array();
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
|
-
class
|
|
216
|
+
class Y {
|
|
217
217
|
constructor(t, r, n, i) {
|
|
218
218
|
this.keyType = t, this.valueType = r, this.payload = n, this.onComplete = i;
|
|
219
219
|
}
|
|
@@ -267,7 +267,7 @@ class H {
|
|
|
267
267
|
14
|
|
268
268
|
/* Guid */
|
|
269
269
|
);
|
|
270
|
-
const r = t instanceof
|
|
270
|
+
const r = t instanceof o ? t.asBytes() : t;
|
|
271
271
|
if (r.length !== 16)
|
|
272
272
|
throw new Error("Guid payload must be 16 bytes");
|
|
273
273
|
this.payload.writeBytes(r), this.keyWritten = !0;
|
|
@@ -277,7 +277,7 @@ class H {
|
|
|
277
277
|
12
|
|
278
278
|
/* String */
|
|
279
279
|
);
|
|
280
|
-
const r =
|
|
280
|
+
const r = F.encode(t ?? "");
|
|
281
281
|
this.payload.writeVarUInt(r.length), this.payload.writeBytes(r), this.keyWritten = !0;
|
|
282
282
|
}
|
|
283
283
|
writeKeyBinary(t) {
|
|
@@ -333,7 +333,7 @@ class H {
|
|
|
333
333
|
14
|
|
334
334
|
/* Guid */
|
|
335
335
|
);
|
|
336
|
-
const r = t instanceof
|
|
336
|
+
const r = t instanceof o ? t.asBytes() : t;
|
|
337
337
|
if (r.length !== 16)
|
|
338
338
|
throw new Error("Guid payload must be 16 bytes");
|
|
339
339
|
this.payload.writeBytes(r), this.valueWritten = !0;
|
|
@@ -355,7 +355,7 @@ class H {
|
|
|
355
355
|
12
|
|
356
356
|
/* String */
|
|
357
357
|
);
|
|
358
|
-
const r =
|
|
358
|
+
const r = F.encode(t ?? "");
|
|
359
359
|
this.payload.writeVarUInt(r.length), this.payload.writeBytes(r), this.valueWritten = !0;
|
|
360
360
|
}
|
|
361
361
|
writeValueObject(t, r) {
|
|
@@ -363,7 +363,7 @@ class H {
|
|
|
363
363
|
11
|
|
364
364
|
/* Object */
|
|
365
365
|
);
|
|
366
|
-
const n = new
|
|
366
|
+
const n = new p(t);
|
|
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 H {
|
|
|
373
373
|
9
|
|
374
374
|
/* Array */
|
|
375
375
|
);
|
|
376
|
-
const n = new
|
|
376
|
+
const n = new O(t);
|
|
377
377
|
r(n);
|
|
378
378
|
const i = n.finish();
|
|
379
379
|
this.payload.writeBytes(i), this.valueWritten = !0;
|
|
@@ -383,7 +383,7 @@ class H {
|
|
|
383
383
|
10
|
|
384
384
|
/* Dict */
|
|
385
385
|
);
|
|
386
|
-
const i = new
|
|
386
|
+
const i = new R(t, r);
|
|
387
387
|
n(i);
|
|
388
388
|
const s = i.finish();
|
|
389
389
|
this.payload.writeBytes(s), this.valueWritten = !0;
|
|
@@ -397,14 +397,14 @@ class H {
|
|
|
397
397
|
}
|
|
398
398
|
ensureKeyType(t) {
|
|
399
399
|
if (this.keyType !== t)
|
|
400
|
-
throw new Error(`Dictionary key type is ${
|
|
400
|
+
throw new Error(`Dictionary key type is ${w[this.keyType]}, expected ${w[t]}`);
|
|
401
401
|
}
|
|
402
402
|
ensureValueType(t) {
|
|
403
403
|
if (this.valueType !== t)
|
|
404
|
-
throw new Error(`Dictionary value type is ${
|
|
404
|
+
throw new Error(`Dictionary value type is ${w[this.valueType]}, expected ${w[t]}`);
|
|
405
405
|
}
|
|
406
406
|
}
|
|
407
|
-
class
|
|
407
|
+
class o {
|
|
408
408
|
constructor(t) {
|
|
409
409
|
this.bytes = t;
|
|
410
410
|
}
|
|
@@ -414,19 +414,19 @@ class a {
|
|
|
414
414
|
const r = t.replace(/-/g, "");
|
|
415
415
|
if (r.length !== 32)
|
|
416
416
|
throw new Error("Guid string must be 32 hex characters");
|
|
417
|
-
const n = new Uint8Array(16), i =
|
|
418
|
-
|
|
419
|
-
for (let
|
|
420
|
-
n[8 +
|
|
421
|
-
return new
|
|
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
|
+
o.writeUInt32LE(n, 0, i), o.writeUInt16LE(n, 4, s), o.writeUInt16LE(n, 6, a);
|
|
419
|
+
for (let c = 0; c < 8; c++)
|
|
420
|
+
n[8 + c] = o.parseHexSlice(r, 16 + c * 2, 2);
|
|
421
|
+
return new o(n);
|
|
422
422
|
}
|
|
423
423
|
static fromBytes(t) {
|
|
424
424
|
if (t.length !== 16)
|
|
425
425
|
throw new Error("Guid byte array must be 16 bytes");
|
|
426
|
-
return new
|
|
426
|
+
return new o(Uint8Array.from(t));
|
|
427
427
|
}
|
|
428
428
|
static createZero() {
|
|
429
|
-
return new
|
|
429
|
+
return new o(new Uint8Array(16));
|
|
430
430
|
}
|
|
431
431
|
static createRandom() {
|
|
432
432
|
const t = new Uint8Array(16), r = globalThis.crypto;
|
|
@@ -435,16 +435,16 @@ class a {
|
|
|
435
435
|
else
|
|
436
436
|
for (let n = 0; n < t.length; n++)
|
|
437
437
|
t[n] = Math.floor(Math.random() * 256);
|
|
438
|
-
return t[6] = t[6] & 15 | 64, t[8] = t[8] & 63 | 128, new
|
|
438
|
+
return t[6] = t[6] & 15 | 64, t[8] = t[8] & 63 | 128, new o(t);
|
|
439
439
|
}
|
|
440
440
|
toString() {
|
|
441
441
|
const t = this.bytes;
|
|
442
442
|
return [
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
443
|
+
o.toHex(o.readUInt32LE(t, 0), 8),
|
|
444
|
+
o.toHex(o.readUInt16LE(t, 4), 4),
|
|
445
|
+
o.toHex(o.readUInt16LE(t, 6), 4),
|
|
446
|
+
k(t.subarray(8, 10)),
|
|
447
|
+
k(t.subarray(10, 16))
|
|
448
448
|
].join("-");
|
|
449
449
|
}
|
|
450
450
|
asBytes() {
|
|
@@ -474,7 +474,7 @@ class a {
|
|
|
474
474
|
return (t >>> 0).toString(16).padStart(r, "0");
|
|
475
475
|
}
|
|
476
476
|
}
|
|
477
|
-
class
|
|
477
|
+
class b {
|
|
478
478
|
bytes = [];
|
|
479
479
|
writeByte(t) {
|
|
480
480
|
this.bytes.push(t & 255);
|
|
@@ -515,92 +515,92 @@ class I {
|
|
|
515
515
|
return Uint8Array.from(this.bytes);
|
|
516
516
|
}
|
|
517
517
|
}
|
|
518
|
-
function
|
|
518
|
+
function B(e, t = 0) {
|
|
519
519
|
if ((t & 240) !== 0)
|
|
520
520
|
throw new Error("Teleport flags must fit into 4 bits");
|
|
521
521
|
return (e & 15) << 4 | t & 15;
|
|
522
522
|
}
|
|
523
|
-
function
|
|
523
|
+
function q(e) {
|
|
524
524
|
return e === 12 || e === 13 || e === 9 || e === 11 || e === 10;
|
|
525
525
|
}
|
|
526
|
-
function
|
|
526
|
+
function G(e) {
|
|
527
527
|
if (e === 9 || e === 11 || e === 10 || e === 1)
|
|
528
528
|
throw new Error("Dictionary keys must be primitive Teleport types");
|
|
529
529
|
}
|
|
530
|
-
function
|
|
530
|
+
function k(e) {
|
|
531
531
|
return Array.from(e).map((t) => t.toString(16).padStart(2, "0")).join("");
|
|
532
532
|
}
|
|
533
|
-
var
|
|
534
|
-
const
|
|
535
|
-
function
|
|
533
|
+
var V = /* @__PURE__ */ ((e) => (e[e.Unknown = 0] = "Unknown", e[e.Opus = 1] = "Opus", e[e.Mp3 = 2] = "Mp3", e[e.RawPcm16 = 3] = "RawPcm16", e))(V || {});
|
|
534
|
+
const C = 1, J = 4194307, X = 271275304, Z = 668699606, Q = 945580544, tt = 1594075008, et = 2079085407, rt = 2541432218, nt = 2986785889, it = 3105403172, st = 4017217601;
|
|
535
|
+
function at(e) {
|
|
536
536
|
const t = {};
|
|
537
|
-
return
|
|
537
|
+
return ot(t), e && Object.assign(t, e), t;
|
|
538
538
|
}
|
|
539
|
-
function
|
|
539
|
+
function ot(e) {
|
|
540
540
|
return e.Data = new Uint8Array(0), e.IsKey = !1, e.IsLast = !1, e.TimestampInUs = 0n, e.DurationInUs = 0, e.IsFirst = !1, e.TotalDurationInUs = 0, e.Volume = 0, e.VolumeSampleCount = 0, e;
|
|
541
541
|
}
|
|
542
|
-
function
|
|
543
|
-
const t = new
|
|
544
|
-
return
|
|
542
|
+
function ut(e) {
|
|
543
|
+
const t = new p(C);
|
|
544
|
+
return ct(e, t), t.finish();
|
|
545
545
|
}
|
|
546
|
-
function
|
|
547
|
-
t.writeUInt64Field(
|
|
546
|
+
function ct(e, t) {
|
|
547
|
+
t.writeUInt64Field(X, e.TimestampInUs), t.writeUInt32Field(Z, e.TotalDurationInUs >>> 0), t.writeInt32Field(Q, e.VolumeSampleCount | 0), t.writeBoolField(tt, e.IsFirst), t.writeFloat32Field(et, e.Volume), t.writeUInt32Field(rt, e.DurationInUs >>> 0), t.writeBinaryField(nt, e.Data), t.writeBoolField(it, e.IsKey), t.writeBoolField(st, e.IsLast);
|
|
548
548
|
}
|
|
549
|
-
function
|
|
550
|
-
const n =
|
|
551
|
-
return
|
|
549
|
+
function lt(e, t, r) {
|
|
550
|
+
const n = ut(e);
|
|
551
|
+
return S(J, n, C, t, r);
|
|
552
552
|
}
|
|
553
|
-
const
|
|
554
|
-
function
|
|
553
|
+
const x = 1, dt = 4194308, ht = 2079085407, ft = 3485914759;
|
|
554
|
+
function yt(e) {
|
|
555
555
|
const t = {};
|
|
556
|
-
return
|
|
556
|
+
return pt(t), e && Object.assign(t, e), t;
|
|
557
557
|
}
|
|
558
|
-
function
|
|
558
|
+
function pt(e) {
|
|
559
559
|
return e.Volume = 0, e.Count = 0, e;
|
|
560
560
|
}
|
|
561
|
-
function
|
|
562
|
-
const t = new
|
|
563
|
-
return
|
|
561
|
+
function wt(e) {
|
|
562
|
+
const t = new p(x);
|
|
563
|
+
return mt(e, t), t.finish();
|
|
564
564
|
}
|
|
565
|
-
function
|
|
566
|
-
t.writeFloat32Field(
|
|
565
|
+
function mt(e, t) {
|
|
566
|
+
t.writeFloat32Field(ht, e.Volume), t.writeInt32Field(ft, e.Count | 0);
|
|
567
567
|
}
|
|
568
|
-
function
|
|
569
|
-
const n =
|
|
570
|
-
return
|
|
568
|
+
function It(e, t, r) {
|
|
569
|
+
const n = wt(e);
|
|
570
|
+
return S(dt, n, x, t, r);
|
|
571
571
|
}
|
|
572
|
-
const
|
|
573
|
-
function
|
|
572
|
+
const N = 1, Et = 4194305, gt = 1368629611, bt = 2431514951, Ut = 2914494629, At = 3284746250, Ft = 4101844078;
|
|
573
|
+
function Bt(e) {
|
|
574
574
|
const t = {};
|
|
575
|
-
return
|
|
575
|
+
return St(t), e && Object.assign(t, e), t;
|
|
576
576
|
}
|
|
577
|
-
function
|
|
578
|
-
return e.Description = "", e.Codec =
|
|
577
|
+
function St(e) {
|
|
578
|
+
return e.Description = "", e.Codec = V.Unknown, e.SampleRate = 0, e.Channels = 0, e.BitDepth = 0, e;
|
|
579
579
|
}
|
|
580
|
-
function
|
|
581
|
-
const t = new
|
|
582
|
-
return
|
|
580
|
+
function Ot(e) {
|
|
581
|
+
const t = new p(N);
|
|
582
|
+
return Dt(e, t), t.finish();
|
|
583
583
|
}
|
|
584
|
-
function
|
|
585
|
-
t.writeStringField(
|
|
584
|
+
function Dt(e, t) {
|
|
585
|
+
t.writeStringField(gt, e.Description), t.writeInt32Field(bt, e.Channels | 0), t.writeInt32Field(Ut, e.BitDepth | 0), t.writeInt32Field(At, e.Codec), t.writeInt32Field(Ft, e.SampleRate | 0);
|
|
586
586
|
}
|
|
587
|
-
function
|
|
588
|
-
const n =
|
|
589
|
-
return
|
|
587
|
+
function _t(e, t, r) {
|
|
588
|
+
const n = Ot(e);
|
|
589
|
+
return S(Et, n, N, t, r);
|
|
590
590
|
}
|
|
591
|
-
const
|
|
592
|
-
function
|
|
591
|
+
const v = 1, Mt = 4194306;
|
|
592
|
+
function Rt(e) {
|
|
593
593
|
const t = {};
|
|
594
594
|
return e && Object.assign(t, e), t;
|
|
595
595
|
}
|
|
596
|
-
function
|
|
597
|
-
return new
|
|
596
|
+
function Vt(e) {
|
|
597
|
+
return new p(v).finish();
|
|
598
598
|
}
|
|
599
|
-
function
|
|
600
|
-
const n =
|
|
601
|
-
return
|
|
599
|
+
function Lt(e, t, r) {
|
|
600
|
+
const n = Vt();
|
|
601
|
+
return S(Mt, n, v, t, r);
|
|
602
602
|
}
|
|
603
|
-
class
|
|
603
|
+
class Tt {
|
|
604
604
|
static getStorageForCapacity(t, r) {
|
|
605
605
|
const n = Int32Array.BYTES_PER_ELEMENT * 2, i = r.BYTES_PER_ELEMENT * t;
|
|
606
606
|
return new SharedArrayBuffer(n + i);
|
|
@@ -654,13 +654,13 @@ class Mt {
|
|
|
654
654
|
return n = (n + r) % this.capacity, Atomics.store(this.readWrite, 0, n), r;
|
|
655
655
|
}
|
|
656
656
|
}
|
|
657
|
-
let
|
|
658
|
-
function
|
|
657
|
+
let Wt = 1;
|
|
658
|
+
function Pt(e, t) {
|
|
659
659
|
return `[${e}] ${t}`;
|
|
660
660
|
}
|
|
661
|
-
function
|
|
662
|
-
if ((/* @__PURE__ */ new Date()).toISOString(),
|
|
663
|
-
const i =
|
|
661
|
+
function A(e, t, r, n) {
|
|
662
|
+
if ((/* @__PURE__ */ new Date()).toISOString(), Wt <= e) {
|
|
663
|
+
const i = Pt(t, r);
|
|
664
664
|
switch (e) {
|
|
665
665
|
case 0:
|
|
666
666
|
console.debug(i, ...n);
|
|
@@ -677,38 +677,100 @@ function g(e, t, r, n) {
|
|
|
677
677
|
}
|
|
678
678
|
}
|
|
679
679
|
}
|
|
680
|
-
function
|
|
680
|
+
function kt(e) {
|
|
681
681
|
return {
|
|
682
682
|
debug(t, ...r) {
|
|
683
|
-
|
|
683
|
+
A(0, e, t, r);
|
|
684
684
|
},
|
|
685
685
|
info(t, ...r) {
|
|
686
|
-
|
|
686
|
+
A(1, e, t, r);
|
|
687
687
|
},
|
|
688
688
|
warn(t, ...r) {
|
|
689
|
-
|
|
689
|
+
A(2, e, t, r);
|
|
690
690
|
},
|
|
691
691
|
error(t, ...r) {
|
|
692
|
-
|
|
692
|
+
A(3, e, t, r);
|
|
693
693
|
}
|
|
694
694
|
};
|
|
695
695
|
}
|
|
696
|
-
const
|
|
697
|
-
|
|
696
|
+
const Ct = 20, L = 32e3, xt = 5, T = 8e3, M = kt("AudioCaptureWorker");
|
|
697
|
+
class Nt {
|
|
698
|
+
encoder = null;
|
|
699
|
+
isReady = !1;
|
|
700
|
+
simdEnabled = !1;
|
|
701
|
+
sampleRate;
|
|
702
|
+
channels;
|
|
703
|
+
bitrate;
|
|
704
|
+
frameSize;
|
|
705
|
+
onOutput;
|
|
706
|
+
onError;
|
|
707
|
+
timestampUs = 0;
|
|
708
|
+
frameDurationUs;
|
|
709
|
+
constructor(t) {
|
|
710
|
+
this.sampleRate = t.sampleRate, this.channels = t.channels, this.bitrate = t.bitrate, this.frameSize = t.frameSize, this.frameDurationUs = Math.floor(this.frameSize * 1e6 / this.sampleRate), this.onOutput = t.onOutput, this.onError = t.onError;
|
|
711
|
+
}
|
|
712
|
+
async initialize() {
|
|
713
|
+
try {
|
|
714
|
+
const { OpusEncoder: t, OPUS_APPLICATION_VOIP: r, isSimdSupported: n } = await import("./index-C-9F_--I.js"), i = await n();
|
|
715
|
+
this.encoder = new t({
|
|
716
|
+
sampleRate: this.sampleRate,
|
|
717
|
+
channels: this.channels,
|
|
718
|
+
bitrate: this.bitrate,
|
|
719
|
+
application: r,
|
|
720
|
+
complexity: xt
|
|
721
|
+
}), this.simdEnabled = i, await this.encoder.ready, this.isReady = !0;
|
|
722
|
+
} catch (t) {
|
|
723
|
+
this.onError(t instanceof Error ? t : new Error(String(t)));
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
encode(t) {
|
|
727
|
+
if (!(!this.isReady || !this.encoder))
|
|
728
|
+
try {
|
|
729
|
+
let r;
|
|
730
|
+
if (t instanceof Float32Array)
|
|
731
|
+
r = t;
|
|
732
|
+
else {
|
|
733
|
+
const i = t.numberOfFrames, s = t.numberOfChannels;
|
|
734
|
+
r = new Float32Array(i * s), t.copyTo(r, { planeIndex: 0, format: "f32" }), t.close();
|
|
735
|
+
}
|
|
736
|
+
const n = this.encoder.encodeAndCopy(r);
|
|
737
|
+
this.onOutput(n, this.timestampUs, this.frameDurationUs), this.timestampUs += this.frameDurationUs;
|
|
738
|
+
} catch (r) {
|
|
739
|
+
this.onError(r instanceof Error ? r : new Error(String(r)));
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
async flush() {
|
|
743
|
+
}
|
|
744
|
+
close() {
|
|
745
|
+
try {
|
|
746
|
+
this.encoder?.destroy();
|
|
747
|
+
} catch {
|
|
748
|
+
}
|
|
749
|
+
this.encoder = null, this.isReady = !1;
|
|
750
|
+
}
|
|
751
|
+
isSimdEnabled() {
|
|
752
|
+
return this.simdEnabled;
|
|
753
|
+
}
|
|
754
|
+
getBitrate() {
|
|
755
|
+
return this.bitrate;
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
const W = (e) => self.postMessage(e);
|
|
759
|
+
let f = null;
|
|
698
760
|
function m(e, t) {
|
|
699
761
|
const r = e instanceof Error ? e : new Error(String(e));
|
|
700
|
-
|
|
762
|
+
W({ type: "error", captureId: t, error: { name: r.name, message: r.message, stack: r.stack } });
|
|
701
763
|
}
|
|
702
|
-
function
|
|
764
|
+
function vt(e) {
|
|
703
765
|
return e.byteOffset === 0 && e.byteLength === e.buffer.byteLength ? e.buffer : e.slice().buffer;
|
|
704
766
|
}
|
|
705
|
-
function
|
|
706
|
-
if (!
|
|
767
|
+
function D(e) {
|
|
768
|
+
if (!f)
|
|
707
769
|
return;
|
|
708
|
-
const t =
|
|
709
|
-
|
|
770
|
+
const t = vt(e);
|
|
771
|
+
f.postMessage({ type: "send", message: t }, [t]);
|
|
710
772
|
}
|
|
711
|
-
function
|
|
773
|
+
function Kt(e) {
|
|
712
774
|
if (e.length === 0)
|
|
713
775
|
return 0;
|
|
714
776
|
let t = 0;
|
|
@@ -716,40 +778,40 @@ function Nt(e) {
|
|
|
716
778
|
t += Math.abs(e[r] ?? 0);
|
|
717
779
|
return t / e.length;
|
|
718
780
|
}
|
|
719
|
-
const
|
|
720
|
-
let
|
|
721
|
-
function
|
|
722
|
-
|
|
723
|
-
for (const e of
|
|
781
|
+
const d = /* @__PURE__ */ new Map();
|
|
782
|
+
let g = null;
|
|
783
|
+
function zt() {
|
|
784
|
+
g === null && (g = self.setInterval(() => {
|
|
785
|
+
for (const e of d.values())
|
|
724
786
|
if (!(e.transport !== "sab" || !e.ringBuffer || !e.ringTemp || e.stopped))
|
|
725
787
|
try {
|
|
726
788
|
const t = e.ringBuffer.pop(e.ringTemp);
|
|
727
789
|
if (t <= 0)
|
|
728
790
|
continue;
|
|
729
|
-
|
|
791
|
+
K(e, e.ringTemp.subarray(0, t));
|
|
730
792
|
} catch (t) {
|
|
731
793
|
m(t, e.captureId);
|
|
732
794
|
}
|
|
733
795
|
}, 10));
|
|
734
796
|
}
|
|
735
|
-
function
|
|
736
|
-
if (
|
|
797
|
+
function Ht() {
|
|
798
|
+
if (g === null)
|
|
737
799
|
return;
|
|
738
800
|
let e = !1;
|
|
739
|
-
for (const t of
|
|
801
|
+
for (const t of d.values())
|
|
740
802
|
if (t.transport === "sab" && !t.stopped) {
|
|
741
803
|
e = !0;
|
|
742
804
|
break;
|
|
743
805
|
}
|
|
744
806
|
if (!e) {
|
|
745
807
|
try {
|
|
746
|
-
self.clearInterval(
|
|
808
|
+
self.clearInterval(g);
|
|
747
809
|
} catch {
|
|
748
810
|
}
|
|
749
|
-
|
|
811
|
+
g = null;
|
|
750
812
|
}
|
|
751
813
|
}
|
|
752
|
-
function
|
|
814
|
+
function P(e) {
|
|
753
815
|
if (e.stopped)
|
|
754
816
|
return;
|
|
755
817
|
if (!e.inSegment) {
|
|
@@ -762,29 +824,33 @@ function M(e) {
|
|
|
762
824
|
if (i + t <= n)
|
|
763
825
|
r.set(e.pendingBuffer.subarray(i, i + t));
|
|
764
826
|
else {
|
|
765
|
-
const
|
|
766
|
-
r.set(e.pendingBuffer.subarray(i, n)), r.set(e.pendingBuffer.subarray(0, t -
|
|
827
|
+
const a = n - i;
|
|
828
|
+
r.set(e.pendingBuffer.subarray(i, n)), r.set(e.pendingBuffer.subarray(0, t - a), a);
|
|
767
829
|
}
|
|
768
830
|
e.pendingReadOffset = (i + t) % n, e.pendingSamples -= t;
|
|
769
|
-
const s =
|
|
770
|
-
|
|
831
|
+
const s = Kt(r);
|
|
832
|
+
D(It(yt({ Volume: s, Count: t }), e.senderId, { trackId: e.trackId }));
|
|
771
833
|
try {
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
834
|
+
if (e.useWasmEncoder)
|
|
835
|
+
e.encoder.encode(r);
|
|
836
|
+
else {
|
|
837
|
+
const a = new AudioData({
|
|
838
|
+
format: "f32",
|
|
839
|
+
sampleRate: e.sampleRate,
|
|
840
|
+
numberOfFrames: t,
|
|
841
|
+
numberOfChannels: e.channels,
|
|
842
|
+
timestamp: e.timestampUs,
|
|
843
|
+
data: r.buffer
|
|
844
|
+
});
|
|
845
|
+
e.encoder.encode(a), a.close();
|
|
846
|
+
}
|
|
847
|
+
} catch (a) {
|
|
848
|
+
m(a, e.captureId);
|
|
783
849
|
}
|
|
784
850
|
e.timestampUs += e.frameDurationUs;
|
|
785
851
|
}
|
|
786
852
|
}
|
|
787
|
-
function
|
|
853
|
+
function K(e, t) {
|
|
788
854
|
if (e.stopped)
|
|
789
855
|
return;
|
|
790
856
|
const r = t.length;
|
|
@@ -792,46 +858,59 @@ function v(e, t) {
|
|
|
792
858
|
return;
|
|
793
859
|
const n = e.pendingSamples + r;
|
|
794
860
|
if (n > e.pendingBuffer.length) {
|
|
795
|
-
const
|
|
861
|
+
const a = Math.max(n, e.pendingBuffer.length * 2), c = new Float32Array(a);
|
|
796
862
|
if (e.pendingSamples > 0) {
|
|
797
|
-
const
|
|
798
|
-
if (e.pendingReadOffset + e.pendingSamples <=
|
|
799
|
-
|
|
863
|
+
const l = e.pendingBuffer.length;
|
|
864
|
+
if (e.pendingReadOffset + e.pendingSamples <= l)
|
|
865
|
+
c.set(e.pendingBuffer.subarray(e.pendingReadOffset, e.pendingReadOffset + e.pendingSamples));
|
|
800
866
|
else {
|
|
801
|
-
const
|
|
802
|
-
|
|
867
|
+
const h = l - e.pendingReadOffset;
|
|
868
|
+
c.set(e.pendingBuffer.subarray(e.pendingReadOffset, l)), c.set(e.pendingBuffer.subarray(0, e.pendingSamples - h), h);
|
|
803
869
|
}
|
|
804
870
|
}
|
|
805
|
-
e.pendingBuffer =
|
|
871
|
+
e.pendingBuffer = c, e.pendingReadOffset = 0, e.pendingWriteOffset = e.pendingSamples;
|
|
806
872
|
}
|
|
807
873
|
const i = e.pendingBuffer.length, s = Math.min(r, i - e.pendingWriteOffset);
|
|
808
|
-
e.pendingBuffer.set(t.subarray(0, s), e.pendingWriteOffset), s < r && e.pendingBuffer.set(t.subarray(s), 0), e.pendingWriteOffset = (e.pendingWriteOffset + r) % i, e.pendingSamples += r,
|
|
874
|
+
e.pendingBuffer.set(t.subarray(0, s), e.pendingWriteOffset), s < r && e.pendingBuffer.set(t.subarray(s), 0), e.pendingWriteOffset = (e.pendingWriteOffset + r) % i, e.pendingSamples += r, P(e);
|
|
809
875
|
}
|
|
810
|
-
function
|
|
811
|
-
const
|
|
876
|
+
function z(e, t, r, n, i = !0) {
|
|
877
|
+
const s = d.get(e.captureId);
|
|
878
|
+
if (!s || s.stopped || !s.inSegment && !s.segmentEndPending)
|
|
879
|
+
return;
|
|
880
|
+
const a = t.byteLength;
|
|
881
|
+
s.encoderOutputBuffer.length < a && (s.encoderOutputBuffer = new Uint8Array(Math.max(a, s.encoderOutputBuffer.length * 2))), s.encoderOutputBuffer.set(t);
|
|
882
|
+
const c = s.encoderOutputBuffer.subarray(0, a), l = s.segmentStartPending;
|
|
883
|
+
l && (s.segmentStartPending = !1);
|
|
884
|
+
const h = s.segmentEndPending;
|
|
885
|
+
h && (s.segmentEndPending = !1, s.inSegment = !1), D(
|
|
886
|
+
lt(
|
|
887
|
+
at({
|
|
888
|
+
Data: c,
|
|
889
|
+
IsKey: i,
|
|
890
|
+
IsFirst: l,
|
|
891
|
+
IsLast: h,
|
|
892
|
+
TimestampInUs: BigInt(Math.max(0, Math.round(r))),
|
|
893
|
+
DurationInUs: Math.max(0, Math.round(n)),
|
|
894
|
+
TotalDurationInUs: 0
|
|
895
|
+
}),
|
|
896
|
+
s.senderId,
|
|
897
|
+
{ trackId: s.trackId }
|
|
898
|
+
)
|
|
899
|
+
);
|
|
900
|
+
}
|
|
901
|
+
function $t(e) {
|
|
902
|
+
const t = Math.max(T, Math.floor(e.options?.bitrate ?? L)), r = new AudioEncoder({
|
|
812
903
|
output: (n) => {
|
|
813
|
-
const i =
|
|
814
|
-
if (!i
|
|
904
|
+
const i = d.get(e.captureId);
|
|
905
|
+
if (!i)
|
|
815
906
|
return;
|
|
816
907
|
const s = n.byteLength;
|
|
817
|
-
i.encoderOutputBuffer.length < s && (i.encoderOutputBuffer = new Uint8Array(Math.max(s, i.encoderOutputBuffer.length * 2))), n.copyTo(i.encoderOutputBuffer)
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
rt({
|
|
824
|
-
Data: o,
|
|
825
|
-
IsKey: n.type === "key",
|
|
826
|
-
IsFirst: u,
|
|
827
|
-
IsLast: c,
|
|
828
|
-
TimestampInUs: BigInt(Math.max(0, Math.round(n.timestamp ?? i.timestampUs))),
|
|
829
|
-
DurationInUs: Math.max(0, Math.round(n.duration ?? i.frameDurationUs)),
|
|
830
|
-
TotalDurationInUs: 0
|
|
831
|
-
}),
|
|
832
|
-
i.senderId,
|
|
833
|
-
{ trackId: i.trackId }
|
|
834
|
-
)
|
|
908
|
+
i.encoderOutputBuffer.length < s && (i.encoderOutputBuffer = new Uint8Array(Math.max(s, i.encoderOutputBuffer.length * 2))), n.copyTo(i.encoderOutputBuffer), z(
|
|
909
|
+
i,
|
|
910
|
+
i.encoderOutputBuffer.subarray(0, s),
|
|
911
|
+
n.timestamp ?? i.timestampUs,
|
|
912
|
+
n.duration ?? i.frameDurationUs,
|
|
913
|
+
n.type === "key"
|
|
835
914
|
);
|
|
836
915
|
},
|
|
837
916
|
error: (n) => {
|
|
@@ -851,14 +930,41 @@ function Ct(e) {
|
|
|
851
930
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
852
931
|
}), r;
|
|
853
932
|
}
|
|
854
|
-
function
|
|
855
|
-
|
|
933
|
+
function jt(e) {
|
|
934
|
+
const t = Math.max(T, Math.floor(e.options?.bitrate ?? L));
|
|
935
|
+
return new Nt({
|
|
936
|
+
sampleRate: e.sampleRate,
|
|
937
|
+
channels: e.channels,
|
|
938
|
+
bitrate: t,
|
|
939
|
+
frameSize: e.frameSize,
|
|
940
|
+
onOutput: (r, n, i) => {
|
|
941
|
+
const s = d.get(e.captureId);
|
|
942
|
+
s && z(s, r, n, i, !0);
|
|
943
|
+
},
|
|
944
|
+
onError: (r) => {
|
|
945
|
+
m(r, e.captureId);
|
|
946
|
+
}
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
async function Yt() {
|
|
950
|
+
if (typeof AudioEncoder > "u")
|
|
951
|
+
return !1;
|
|
952
|
+
try {
|
|
953
|
+
return (await AudioEncoder.isConfigSupported({
|
|
954
|
+
codec: "opus",
|
|
955
|
+
numberOfChannels: 1,
|
|
956
|
+
sampleRate: 48e3
|
|
957
|
+
})).supported === !0;
|
|
958
|
+
} catch {
|
|
959
|
+
return !1;
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
async function qt(e) {
|
|
963
|
+
if (!f)
|
|
856
964
|
throw new Error("Audio capture worker missing send port");
|
|
857
|
-
if (
|
|
965
|
+
if (d.has(e.captureId))
|
|
858
966
|
return;
|
|
859
|
-
|
|
860
|
-
throw new Error("AudioEncoder is not available in this browser");
|
|
861
|
-
const t = Math.max(8e3, Math.floor(e.sampleRate)), r = Math.max(1, Math.floor(e.channels)), n = Math.max(1, Math.floor(t * Tt / 1e3)), i = Math.max(1, Math.floor(n * 1e6 / t)), s = n * 4, o = {
|
|
967
|
+
const t = Math.max(8e3, Math.floor(e.sampleRate)), r = Math.max(1, Math.floor(e.channels)), n = Math.max(1, Math.floor(t * Ct / 1e3)), i = Math.max(1, Math.floor(n * 1e6 / t)), s = n * 4, a = {
|
|
862
968
|
captureId: e.captureId,
|
|
863
969
|
senderId: e.senderId,
|
|
864
970
|
trackId: e.trackId,
|
|
@@ -882,21 +988,37 @@ function Kt(e) {
|
|
|
882
988
|
segmentStartPending: !1,
|
|
883
989
|
segmentEndPending: !1,
|
|
884
990
|
options: e.options
|
|
885
|
-
},
|
|
886
|
-
|
|
887
|
-
|
|
991
|
+
}, l = (e.options?.preferWebCodecs ?? !0) && await Yt();
|
|
992
|
+
let h, I = !1;
|
|
993
|
+
const E = Math.max(T, Math.floor(e.options?.bitrate ?? L));
|
|
994
|
+
if (l)
|
|
995
|
+
h = $t(a), M.info(
|
|
996
|
+
`Audio capture started: encoder=WebCodecs, sampleRate=${t}Hz, channels=${r}, bitrate=${E}bps`
|
|
997
|
+
);
|
|
998
|
+
else {
|
|
999
|
+
const u = jt(a);
|
|
1000
|
+
await u.initialize(), h = u, I = !0;
|
|
1001
|
+
const U = u.isSimdEnabled() ? "SIMD" : "non-SIMD";
|
|
1002
|
+
M.info(
|
|
1003
|
+
`Audio capture started: encoder=WASM Opus (${U}), sampleRate=${t}Hz, channels=${r}, bitrate=${E}bps`
|
|
1004
|
+
);
|
|
1005
|
+
}
|
|
1006
|
+
const y = {
|
|
1007
|
+
...a,
|
|
1008
|
+
encoder: h,
|
|
1009
|
+
useWasmEncoder: I
|
|
888
1010
|
};
|
|
889
1011
|
if (e.transport === "sab") {
|
|
890
1012
|
if (!e.sharedArrayBuffer)
|
|
891
1013
|
throw new Error("Missing SharedArrayBuffer for sab transport");
|
|
892
|
-
const
|
|
893
|
-
|
|
1014
|
+
const u = new Tt(e.sharedArrayBuffer, Float32Array);
|
|
1015
|
+
y.ringBuffer = u, y.ringTemp = new Float32Array(Math.max(y.frameSize * 4, 4096)), zt();
|
|
894
1016
|
}
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
1017
|
+
d.set(e.captureId, y), D(
|
|
1018
|
+
_t(
|
|
1019
|
+
Bt({
|
|
898
1020
|
Description: `mic:${e.captureId}`,
|
|
899
|
-
Codec:
|
|
1021
|
+
Codec: V.Opus,
|
|
900
1022
|
SampleRate: t,
|
|
901
1023
|
Channels: r,
|
|
902
1024
|
BitDepth: 32
|
|
@@ -904,14 +1026,14 @@ function Kt(e) {
|
|
|
904
1026
|
e.senderId,
|
|
905
1027
|
{ trackId: e.trackId }
|
|
906
1028
|
)
|
|
907
|
-
),
|
|
1029
|
+
), W({ type: "started", captureId: e.captureId, sampleRate: t, channels: r });
|
|
908
1030
|
}
|
|
909
|
-
async function
|
|
910
|
-
const t =
|
|
1031
|
+
async function H(e) {
|
|
1032
|
+
const t = d.get(e);
|
|
911
1033
|
if (t) {
|
|
912
|
-
t.stopped = !0,
|
|
1034
|
+
t.stopped = !0, d.delete(e);
|
|
913
1035
|
try {
|
|
914
|
-
|
|
1036
|
+
P(t);
|
|
915
1037
|
} catch {
|
|
916
1038
|
}
|
|
917
1039
|
try {
|
|
@@ -922,71 +1044,69 @@ async function x(e) {
|
|
|
922
1044
|
t.encoder.close();
|
|
923
1045
|
} catch {
|
|
924
1046
|
}
|
|
925
|
-
|
|
1047
|
+
D(Lt(Rt({}), t.senderId, { trackId: t.trackId })), W({ type: "stopped", captureId: e }), Ht();
|
|
926
1048
|
}
|
|
927
1049
|
}
|
|
928
|
-
function
|
|
929
|
-
const t =
|
|
1050
|
+
function Gt(e) {
|
|
1051
|
+
const t = d.get(e);
|
|
930
1052
|
!t || t.stopped || (t.inSegment = !0, t.segmentStartPending = !0);
|
|
931
1053
|
}
|
|
932
|
-
function
|
|
933
|
-
const t =
|
|
934
|
-
!t || t.stopped || !t.inSegment || (t.segmentEndPending = !0,
|
|
1054
|
+
function Jt(e) {
|
|
1055
|
+
const t = d.get(e);
|
|
1056
|
+
!t || t.stopped || !t.inSegment || (t.segmentEndPending = !0, P(t));
|
|
935
1057
|
}
|
|
936
|
-
function
|
|
937
|
-
for (const e of Array.from(
|
|
938
|
-
|
|
939
|
-
if (
|
|
1058
|
+
function Xt() {
|
|
1059
|
+
for (const e of Array.from(d.keys()))
|
|
1060
|
+
H(e);
|
|
1061
|
+
if (f) {
|
|
940
1062
|
try {
|
|
941
|
-
|
|
1063
|
+
f.close();
|
|
942
1064
|
} catch {
|
|
943
1065
|
}
|
|
944
|
-
|
|
1066
|
+
f = null;
|
|
945
1067
|
}
|
|
946
1068
|
}
|
|
947
1069
|
self.addEventListener("message", (e) => {
|
|
948
1070
|
const t = e.data;
|
|
949
1071
|
if (t.type === "attachSendPort") {
|
|
950
|
-
if (
|
|
1072
|
+
if (f)
|
|
951
1073
|
try {
|
|
952
|
-
|
|
1074
|
+
f.close();
|
|
953
1075
|
} catch {
|
|
954
1076
|
}
|
|
955
|
-
|
|
1077
|
+
f = t.port;
|
|
956
1078
|
try {
|
|
957
|
-
|
|
1079
|
+
f.start?.();
|
|
958
1080
|
} catch {
|
|
959
1081
|
}
|
|
960
1082
|
return;
|
|
961
1083
|
}
|
|
962
1084
|
if (t.type === "start") {
|
|
963
|
-
|
|
964
|
-
Kt(t);
|
|
965
|
-
} catch (r) {
|
|
1085
|
+
qt(t).catch((r) => {
|
|
966
1086
|
m(r, t.captureId);
|
|
967
|
-
}
|
|
1087
|
+
});
|
|
968
1088
|
return;
|
|
969
1089
|
}
|
|
970
1090
|
if (t.type === "pcm") {
|
|
971
|
-
const r =
|
|
1091
|
+
const r = d.get(t.captureId);
|
|
972
1092
|
if (!r || r.stopped)
|
|
973
1093
|
return;
|
|
974
|
-
|
|
1094
|
+
K(r, t.pcm);
|
|
975
1095
|
return;
|
|
976
1096
|
}
|
|
977
1097
|
if (t.type === "stop") {
|
|
978
|
-
|
|
979
|
-
|
|
1098
|
+
H(t.captureId).catch((r) => {
|
|
1099
|
+
M.warn(`Failed to stop audio capture: ${r}`), m(r, t.captureId);
|
|
980
1100
|
});
|
|
981
1101
|
return;
|
|
982
1102
|
}
|
|
983
1103
|
if (t.type === "startSegment") {
|
|
984
|
-
|
|
1104
|
+
Gt(t.captureId);
|
|
985
1105
|
return;
|
|
986
1106
|
}
|
|
987
1107
|
if (t.type === "endSegment") {
|
|
988
|
-
|
|
1108
|
+
Jt(t.captureId);
|
|
989
1109
|
return;
|
|
990
1110
|
}
|
|
991
|
-
t.type === "dispose" &&
|
|
1111
|
+
t.type === "dispose" && Xt();
|
|
992
1112
|
});
|