@ikonai/sdk 0.0.39 → 0.0.41
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-Bnqb8-xb.js → audio-capture-worker-BZ6P8AHQ.js} +64 -70
- package/assets/{audio-playback-worker-CXmAFv0O.js → audio-playback-worker-DU7j77Kb.js} +4 -2
- package/assets/{index-C-9F_--I.js → index-7lK3WfPs.js} +40 -96
- package/assets/{index-C3ZAK5YF.js → index-k5wFN_NP.js} +24 -76
- package/assets/libopus-BEPFPIM_.js +139 -0
- package/client/ikon-client-config.d.ts +3 -3
- package/index.js +57 -57
- package/media/ikon-audio-capture.d.ts +3 -3
- package/media/ikon-audio-playback.d.ts +2 -2
- package/media/ikon-video-playback.d.ts +2 -2
- package/package.json +1 -1
- package/assets/libopus-BBY7KH2-.js +0 -169
- package/assets/libopus-simd-CQXMVirP.js +0 -169
|
@@ -1,66 +1,14 @@
|
|
|
1
|
-
let
|
|
2
|
-
const c = new Uint8Array([
|
|
3
|
-
0,
|
|
4
|
-
97,
|
|
5
|
-
115,
|
|
6
|
-
109,
|
|
7
|
-
// magic
|
|
8
|
-
1,
|
|
9
|
-
0,
|
|
10
|
-
0,
|
|
11
|
-
0,
|
|
12
|
-
// version
|
|
13
|
-
1,
|
|
14
|
-
5,
|
|
15
|
-
1,
|
|
16
|
-
96,
|
|
17
|
-
0,
|
|
18
|
-
1,
|
|
19
|
-
123,
|
|
20
|
-
// type section: () -> v128
|
|
21
|
-
3,
|
|
22
|
-
2,
|
|
23
|
-
1,
|
|
24
|
-
0,
|
|
25
|
-
// function section
|
|
26
|
-
10,
|
|
27
|
-
10,
|
|
28
|
-
1,
|
|
29
|
-
8,
|
|
30
|
-
0,
|
|
31
|
-
// code section start
|
|
32
|
-
65,
|
|
33
|
-
0,
|
|
34
|
-
// i32.const 0
|
|
35
|
-
253,
|
|
36
|
-
15,
|
|
37
|
-
// v128.load (SIMD)
|
|
38
|
-
253,
|
|
39
|
-
98,
|
|
40
|
-
// i32x4.extract_lane 0
|
|
41
|
-
11
|
|
42
|
-
// end
|
|
43
|
-
]);
|
|
1
|
+
let l = null, o = null;
|
|
44
2
|
async function u() {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
async function m() {
|
|
52
|
-
return i || (a || (a = (async () => {
|
|
53
|
-
const l = await u();
|
|
54
|
-
let e;
|
|
55
|
-
l ? e = (await import("./libopus-simd-CQXMVirP.js")).default : e = (await import("./libopus-BBY7KH2-.js")).default;
|
|
56
|
-
const t = l ? "../wasm/libopus-simd.wasm" : "../wasm/libopus.wasm";
|
|
57
|
-
return i = await e({
|
|
58
|
-
locateFile: (s) => s.endsWith(".wasm") ? new URL(t, import.meta.url).href : s
|
|
59
|
-
}), i;
|
|
60
|
-
})()), a);
|
|
3
|
+
return o || (l || (l = (async () => {
|
|
4
|
+
const e = (await import("./libopus-BEPFPIM_.js")).default;
|
|
5
|
+
return o = await e({
|
|
6
|
+
locateFile: (t) => t.endsWith(".wasm") ? new URL("../wasm/libopus.wasm", import.meta.url).href : t
|
|
7
|
+
}), o;
|
|
8
|
+
})()), l);
|
|
61
9
|
}
|
|
62
|
-
const
|
|
63
|
-
class
|
|
10
|
+
const c = 4028, n = 5760, h = 4e3;
|
|
11
|
+
class m {
|
|
64
12
|
module = null;
|
|
65
13
|
decoder = 0;
|
|
66
14
|
channels;
|
|
@@ -75,13 +23,13 @@ class f {
|
|
|
75
23
|
this.channels = e.channels, this.sampleRate = e.sampleRate, this.channelBuffers = Array.from({ length: this.channels }, () => new Float32Array(n)), this.ready = this.initialize();
|
|
76
24
|
}
|
|
77
25
|
async initialize() {
|
|
78
|
-
this.module = await
|
|
26
|
+
this.module = await u();
|
|
79
27
|
const e = this.module._malloc(4);
|
|
80
28
|
this.decoder = this.module._opus_decoder_create(this.sampleRate, this.channels, e);
|
|
81
29
|
const t = new DataView(this.module.HEAPU8.buffer).getInt32(e, !0);
|
|
82
30
|
if (this.module._free(e), t !== 0)
|
|
83
31
|
throw new Error(`opus_decoder_create failed with error code ${t}`);
|
|
84
|
-
this.inputPtr = this.module._malloc(
|
|
32
|
+
this.inputPtr = this.module._malloc(h), this.outputPtr = this.module._malloc(n * this.channels * 4);
|
|
85
33
|
}
|
|
86
34
|
/**
|
|
87
35
|
* Decode an Opus frame.
|
|
@@ -96,8 +44,8 @@ class f {
|
|
|
96
44
|
decodeFrame(e) {
|
|
97
45
|
if (!this.module || !this.decoder)
|
|
98
46
|
throw new Error("Decoder not initialized");
|
|
99
|
-
if (e.length >
|
|
100
|
-
throw new Error(`Opus packet too large: ${e.length} > ${
|
|
47
|
+
if (e.length > h)
|
|
48
|
+
throw new Error(`Opus packet too large: ${e.length} > ${h}`);
|
|
101
49
|
this.module.HEAPU8.set(e, this.inputPtr);
|
|
102
50
|
const t = this.module._opus_decode_float(
|
|
103
51
|
this.decoder,
|
|
@@ -110,11 +58,11 @@ class f {
|
|
|
110
58
|
);
|
|
111
59
|
if (t < 0)
|
|
112
60
|
throw new Error(`opus_decode_float failed with error code ${t}`);
|
|
113
|
-
const
|
|
114
|
-
for (let
|
|
115
|
-
const
|
|
116
|
-
for (let
|
|
117
|
-
|
|
61
|
+
const i = this.outputPtr / 4;
|
|
62
|
+
for (let s = 0; s < this.channels; s++) {
|
|
63
|
+
const d = this.channelBuffers[s];
|
|
64
|
+
for (let r = 0; r < t; r++)
|
|
65
|
+
d[r] = this.module.HEAPF32[i + r * this.channels + s];
|
|
118
66
|
}
|
|
119
67
|
return {
|
|
120
68
|
channelData: this.channelBuffers,
|
|
@@ -129,7 +77,7 @@ class f {
|
|
|
129
77
|
decodeFrameAndCopy(e) {
|
|
130
78
|
const t = this.decodeFrame(e);
|
|
131
79
|
return {
|
|
132
|
-
channelData: t.channelData.map((
|
|
80
|
+
channelData: t.channelData.map((i) => i.slice(0, t.samplesDecoded)),
|
|
133
81
|
samplesDecoded: t.samplesDecoded,
|
|
134
82
|
sampleRate: t.sampleRate
|
|
135
83
|
};
|
|
@@ -139,7 +87,7 @@ class f {
|
|
|
139
87
|
* Call this when there's a discontinuity in the audio stream.
|
|
140
88
|
*/
|
|
141
89
|
reset() {
|
|
142
|
-
this.module && this.decoder && this.module._opus_decoder_ctl(this.decoder,
|
|
90
|
+
this.module && this.decoder && this.module._opus_decoder_ctl(this.decoder, c);
|
|
143
91
|
}
|
|
144
92
|
/**
|
|
145
93
|
* Get the number of channels this decoder was created with.
|
|
@@ -163,8 +111,8 @@ class f {
|
|
|
163
111
|
}
|
|
164
112
|
export {
|
|
165
113
|
n as MAX_FRAME_SIZE,
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
114
|
+
h as MAX_PACKET_SIZE,
|
|
115
|
+
c as OPUS_RESET_STATE,
|
|
116
|
+
m as OpusDecoder,
|
|
117
|
+
u as getOpusModule
|
|
170
118
|
};
|