@vindral/web-sdk 4.1.10 → 4.2.0
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/BQEuFJLn.js +206 -0
- package/BoKiM5eL.js +232 -0
- package/{CPEMXA01.js → CuhQLT-7.js} +1 -1
- package/{BWE6d-4K.js → DBHv5ggB.js} +5884 -5139
- package/{uEFjK_x4.js → DGo74EDo.js} +15 -8
- package/{BJjv9_f9.js → HT5RB929.js} +1 -1
- package/api-client.d.ts +41 -42
- package/api-client.js +1 -1
- package/cast-sender.d.ts +37 -43
- package/cast-sender.js +1 -1
- package/core.d.ts +149 -94
- package/core.js +1 -1
- package/legacy.d.ts +149 -94
- package/legacy.es.js +8469 -7447
- package/legacy.umd.js +9 -9
- package/package.json +1 -1
- package/player.d.ts +134 -90
- package/player.js +1275 -1265
- package/react.d.ts +134 -90
- package/C8BeO5Y9.js +0 -117
package/BQEuFJLn.js
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
var k = Object.defineProperty, I = Object.defineProperties;
|
|
2
|
+
var T = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var w = Object.getOwnPropertySymbols;
|
|
4
|
+
var M = Object.prototype.hasOwnProperty, C = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var S = (s, e, t) => e in s ? k(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t, b = (s, e) => {
|
|
6
|
+
for (var t in e || (e = {}))
|
|
7
|
+
M.call(e, t) && S(s, t, e[t]);
|
|
8
|
+
if (w)
|
|
9
|
+
for (var t of w(e))
|
|
10
|
+
C.call(e, t) && S(s, t, e[t]);
|
|
11
|
+
return s;
|
|
12
|
+
}, y = (s, e) => I(s, T(e));
|
|
13
|
+
var i = (s, e, t) => S(s, typeof e != "symbol" ? e + "" : e, t);
|
|
14
|
+
var v = (s, e, t) => new Promise((r, n) => {
|
|
15
|
+
var a = (o) => {
|
|
16
|
+
try {
|
|
17
|
+
c(t.next(o));
|
|
18
|
+
} catch (d) {
|
|
19
|
+
n(d);
|
|
20
|
+
}
|
|
21
|
+
}, l = (o) => {
|
|
22
|
+
try {
|
|
23
|
+
c(t.throw(o));
|
|
24
|
+
} catch (d) {
|
|
25
|
+
n(d);
|
|
26
|
+
}
|
|
27
|
+
}, c = (o) => o.done ? r(o.value) : Promise.resolve(o.value).then(a, l);
|
|
28
|
+
c((t = t.apply(s, e)).next());
|
|
29
|
+
});
|
|
30
|
+
import { F as D, a as q, b as R, c as O } from "./DBHv5ggB.js";
|
|
31
|
+
class E {
|
|
32
|
+
constructor() {
|
|
33
|
+
i(this, "map", /* @__PURE__ */ new Map());
|
|
34
|
+
}
|
|
35
|
+
enqueue(e, t) {
|
|
36
|
+
const r = this.map.get(e);
|
|
37
|
+
r ? r.push(t) : this.map.set(e, [t]);
|
|
38
|
+
}
|
|
39
|
+
dequeue(e) {
|
|
40
|
+
const t = this.map.get(e);
|
|
41
|
+
if (t && t.length > 0) {
|
|
42
|
+
const r = t.shift();
|
|
43
|
+
return t.length === 0 && this.map.delete(e), r;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Dequeue by exact timestamp, falling back to the oldest pending entry
|
|
48
|
+
* when the decoder outputs a timestamp that differs from input.
|
|
49
|
+
*
|
|
50
|
+
* Safe for audio because all audio frames are independently decodable
|
|
51
|
+
* key frames — there's no B-frame reordering that could cause metadata
|
|
52
|
+
* mismatches like in video.
|
|
53
|
+
*/
|
|
54
|
+
dequeueWithFallback(e) {
|
|
55
|
+
const t = this.dequeue(e);
|
|
56
|
+
if (t !== void 0) return t;
|
|
57
|
+
for (const [r, n] of this.map)
|
|
58
|
+
if (n.length > 0) {
|
|
59
|
+
const a = n.shift();
|
|
60
|
+
return n.length === 0 && this.map.delete(r), a;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
removeLast(e) {
|
|
64
|
+
const t = this.map.get(e);
|
|
65
|
+
!t || t.length === 0 || (t.pop(), t.length === 0 && this.map.delete(e));
|
|
66
|
+
}
|
|
67
|
+
clear() {
|
|
68
|
+
this.map.clear();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const $ = globalThis, u = class u {
|
|
72
|
+
constructor(e) {
|
|
73
|
+
i(this, "decodedSamples", []);
|
|
74
|
+
i(this, "decoder", null);
|
|
75
|
+
i(this, "logger");
|
|
76
|
+
i(this, "initSegments", /* @__PURE__ */ new Map());
|
|
77
|
+
i(this, "previousSample");
|
|
78
|
+
i(this, "previousCodec");
|
|
79
|
+
i(this, "pendingSamples", new E());
|
|
80
|
+
i(this, "errors", new D(10));
|
|
81
|
+
i(this, "resetDecoderState", () => {
|
|
82
|
+
this.pendingSamples.clear(), this.previousSample = void 0, this.previousCodec = void 0;
|
|
83
|
+
});
|
|
84
|
+
i(this, "ensureDecoder", () => ((!this.decoder || this.decoder.state === "closed") && (this.decoder = this.createDecoder()), this.decoder));
|
|
85
|
+
i(this, "createDecoder", () => new AudioDecoder({
|
|
86
|
+
output: (e) => {
|
|
87
|
+
const t = this.pendingSamples.dequeueWithFallback(e.timestamp);
|
|
88
|
+
if (!t) {
|
|
89
|
+
e.close();
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const { sample: r, decodeStartTime: n } = t;
|
|
93
|
+
try {
|
|
94
|
+
const a = e.numberOfFrames, l = e.numberOfChannels, c = e.sampleRate, o = e.timestamp, d = e.duration, p = new Float32Array(a * l);
|
|
95
|
+
e.copyTo(p, { planeIndex: 0, format: "f32" });
|
|
96
|
+
const h = Math.round(o * r.timescale / 1e6), f = typeof d == "number" && Number.isFinite(d) ? Math.max(0, Math.round(d * r.timescale / 1e6)) : r.duration, g = y(b({}, r), {
|
|
97
|
+
timestamp: h,
|
|
98
|
+
duration: f,
|
|
99
|
+
type: "audio",
|
|
100
|
+
format: "f32",
|
|
101
|
+
data: p,
|
|
102
|
+
sampleRate: c,
|
|
103
|
+
channels: l,
|
|
104
|
+
statistics: {
|
|
105
|
+
decodeTime: Math.max(performance.now() - n, 0),
|
|
106
|
+
transportTimeFromWorker: 0,
|
|
107
|
+
transportTimeToWorker: 0,
|
|
108
|
+
samplesInBatch: 1
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
this.decodedSamples.push(g);
|
|
112
|
+
} finally {
|
|
113
|
+
e.close();
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
error: (e) => {
|
|
117
|
+
this.logger.error("Decoder error:", e.name, e.message), this.resetDecoderState(), this.errors.push(e);
|
|
118
|
+
}
|
|
119
|
+
}));
|
|
120
|
+
/**
|
|
121
|
+
* Build AudioDecoderConfig codec string from audio codec type.
|
|
122
|
+
*/
|
|
123
|
+
i(this, "buildCodecString", q);
|
|
124
|
+
/**
|
|
125
|
+
* Get the description for AudioDecoderConfig.
|
|
126
|
+
* Uses init segment data if available, otherwise generates codec-specific description.
|
|
127
|
+
*/
|
|
128
|
+
i(this, "getDescription", (e, t) => {
|
|
129
|
+
const r = this.initSegments.get(t.renditionId);
|
|
130
|
+
if (r && r.data.byteLength > 0 && r.codec === e)
|
|
131
|
+
return r.data;
|
|
132
|
+
if (e === "opus")
|
|
133
|
+
return R(t.channels, t.sampleRate);
|
|
134
|
+
if (e === "aac")
|
|
135
|
+
return O(t.channels, t.sampleRate);
|
|
136
|
+
});
|
|
137
|
+
i(this, "unload", () => {
|
|
138
|
+
this.decodedSamples = [], this.resetDecoderState(), this.decoder && this.decoder.state !== "closed" && this.decoder.close(), this.decoder = null;
|
|
139
|
+
});
|
|
140
|
+
i(this, "initSegment", (e) => {
|
|
141
|
+
this.initSegments.set(e.renditionId, e);
|
|
142
|
+
});
|
|
143
|
+
i(this, "enqueue", (e) => {
|
|
144
|
+
var d, p;
|
|
145
|
+
const t = this.ensureDecoder(), r = e.codec, n = ((d = this.previousSample) == null ? void 0 : d.channelId) !== e.channelId, a = ((p = this.previousSample) == null ? void 0 : p.renditionId) !== e.renditionId, l = this.previousCodec !== r;
|
|
146
|
+
if (!this.previousSample || n || a || l) {
|
|
147
|
+
this.previousSample && t.state === "configured" && t.flush().catch((m) => {
|
|
148
|
+
this.logger.warn("Failed to flush before reconfiguration:", m);
|
|
149
|
+
});
|
|
150
|
+
const h = this.buildCodecString(r), f = this.getDescription(r, e), g = {
|
|
151
|
+
codec: h,
|
|
152
|
+
sampleRate: e.sampleRate,
|
|
153
|
+
numberOfChannels: e.channels,
|
|
154
|
+
description: f
|
|
155
|
+
};
|
|
156
|
+
try {
|
|
157
|
+
t.configure(g), this.previousCodec = r;
|
|
158
|
+
} catch (m) {
|
|
159
|
+
this.logger.error(
|
|
160
|
+
`Failed to configure decoder for ${r} (rendition ${e.renditionId}), dropping sample`,
|
|
161
|
+
m
|
|
162
|
+
), this.errors.push(m instanceof Error ? m : new Error(`Failed to configure decoder for ${r}`)), this.resetDecoderState(), this.ensureDecoder();
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (e.timescale <= 0) {
|
|
167
|
+
this.logger.error(`Invalid timescale ${e.timescale} in sample, dropping sample`);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
this.previousSample = e;
|
|
171
|
+
const c = Math.floor(1e6 * e.timestamp / e.timescale), o = Math.floor(1e6 * e.duration / e.timescale);
|
|
172
|
+
try {
|
|
173
|
+
const h = new EncodedAudioChunk({
|
|
174
|
+
// Audio codecs (Opus, AAC, MP3) always produce independently decodable frames
|
|
175
|
+
type: "key",
|
|
176
|
+
timestamp: c,
|
|
177
|
+
duration: o > 0 ? o : void 0,
|
|
178
|
+
data: e.data
|
|
179
|
+
});
|
|
180
|
+
this.pendingSamples.enqueue(c, { sample: e, decodeStartTime: performance.now() }), t.decode(h);
|
|
181
|
+
} catch (h) {
|
|
182
|
+
this.logger.error("Failed to decode chunk:", h), this.pendingSamples.removeLast(c), t.state === "closed" && (this.resetDecoderState(), this.ensureDecoder());
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
i(this, "flush", () => v(this, null, function* () {
|
|
186
|
+
if (this.decoder && this.decoder.state === "configured")
|
|
187
|
+
try {
|
|
188
|
+
yield this.decoder.flush();
|
|
189
|
+
} catch (e) {
|
|
190
|
+
this.logger.error("Failed to flush decoder:", e), this.resetDecoderState();
|
|
191
|
+
}
|
|
192
|
+
}));
|
|
193
|
+
i(this, "error", () => this.errors.pop());
|
|
194
|
+
i(this, "take", () => this.decodedSamples.shift());
|
|
195
|
+
this.logger = e, this.decoder = this.createDecoder();
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
i(u, "isSupported", () => typeof $.AudioDecoder != "undefined"), i(u, "create", (e) => v(null, null, function* () {
|
|
199
|
+
if (!u.isSupported())
|
|
200
|
+
throw new Error("WebCodecs AudioDecoder is not supported in this environment");
|
|
201
|
+
return new u(e);
|
|
202
|
+
}));
|
|
203
|
+
let F = u;
|
|
204
|
+
export {
|
|
205
|
+
F as WebCodecsAudioDecoderContext
|
|
206
|
+
};
|