@vindral/web-sdk 4.2.0 → 4.2.1-1-gf6c6f2fd
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/B7hT-BKr.js +32 -0
- package/B9WEkxkT.js +268 -0
- package/BdFcdkj1.js +143 -0
- package/BsfwXDui.js +65 -0
- package/Bt-ONXfO.js +59 -0
- package/C01DcfYu.js +118 -0
- package/CL0_JU7W.js +1761 -0
- package/CYgjrKff.js +11538 -0
- package/CrDL5rng.js +223 -0
- package/Cug44nXk.js +149 -0
- package/DDbXsjIU.js +4361 -0
- package/Ddby8xU_.js +18624 -0
- package/DeYmk5AL.js +210 -0
- package/DrWNJwZx.js +35 -0
- package/DtpcQ7ay.js +166 -0
- package/FYiEDBC4.js +50 -0
- package/RxoWWyzp.js +25 -0
- package/api-client.d.ts +3 -3
- package/api-client.js +2 -4
- package/cast-sender.d.ts +7 -7
- package/cast-sender.js +2 -230
- package/core.d.ts +35 -24
- package/core.js +3 -13
- package/legacy.d.ts +44 -33
- package/legacy.es.js +13703 -15261
- package/legacy.umd.js +1188 -15
- package/package.json +1 -1
- package/player.d.ts +60 -41
- package/player.js +4 -5476
- package/react.d.ts +53 -42
- package/react.js +0 -1
- package/vindral-player-component.js +5 -2
- package/BQEuFJLn.js +0 -206
- package/BoKiM5eL.js +0 -232
- package/CuhQLT-7.js +0 -254
- package/DBHv5ggB.js +0 -13182
- package/DGo74EDo.js +0 -59
- package/HT5RB929.js +0 -312
- package/h5LA1Y1W.js +0 -21750
package/CrDL5rng.js
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { n as e } from "./BsfwXDui.js";
|
|
2
|
+
import { a as t, n, r } from "./B7hT-BKr.js";
|
|
3
|
+
//#region ../../libs/utils/src/formatting.ts
|
|
4
|
+
var i = 1e3, a = i * 1e3, o = a * 1e3, s = (e, t, n) => e % t === 0 ? e / t : (e / t).toFixed(n), c = (e, t = 1) => e >= o ? `${s(e, o, t)} Gbit/s` : e >= a ? `${s(e, a, t)} Mbit/s` : e >= i ? `${s(e, i, t)} Kbit/s` : `${e} bit/s`, l = ({ width: e, height: t }) => `${e}x${t}`, u = {
|
|
5
|
+
PAUSED: "paused",
|
|
6
|
+
MUTED: "muted",
|
|
7
|
+
USER_INTERACTING: "user-interacting",
|
|
8
|
+
IS_CASTING: "is-casting",
|
|
9
|
+
CAST_AVAILABLE: "cast-available",
|
|
10
|
+
CAST_RECEIVER_NAME: "cast-receiver-name",
|
|
11
|
+
BUFFERING: "buffering",
|
|
12
|
+
UI_LOCKED: "ui-locked",
|
|
13
|
+
HIDE_UI_ON_PAUSE: "hide-ui-on-pause",
|
|
14
|
+
FULLSCREEN: "is-fullscreen",
|
|
15
|
+
FULLSCREEN_FALLBACK: "is-fullscreen-fallback",
|
|
16
|
+
RENDITION_LEVELS: "rendition-levels",
|
|
17
|
+
RENDITION_LEVEL: "rendition-level",
|
|
18
|
+
MAX_VIDEO_BITRATE: "max-video-bit-rate",
|
|
19
|
+
MAX_INITIAL_BITRATE: "max-initial-bit-rate",
|
|
20
|
+
ABR_ENABLED: "abr-enabled",
|
|
21
|
+
SIZE_BASED_RESOLUTION_CAP_ENABLED: "size-based-resolution-cap-enabled",
|
|
22
|
+
CHANNELS: "channels",
|
|
23
|
+
CHANNEL_ID: "channel-id",
|
|
24
|
+
CHANNEL_GROUP_ID: "channel-group-id",
|
|
25
|
+
PIP_AVAILABLE: "pip-available",
|
|
26
|
+
IS_PIP: "is-pip",
|
|
27
|
+
AIRPLAY_AVAILABLE: "airplay-available",
|
|
28
|
+
IS_AIRPLAYING: "is-airplaying",
|
|
29
|
+
MEDIA: "media",
|
|
30
|
+
LANGUAGES: "languages",
|
|
31
|
+
LANGUAGE: "language",
|
|
32
|
+
TEXT_TRACKS: "text-tracks",
|
|
33
|
+
TEXT_TRACK: "text-track",
|
|
34
|
+
NEEDS_USER_INPUT_VIDEO: "needs-user-input-video",
|
|
35
|
+
NEEDS_USER_INPUT_AUDIO: "needs-user-input-audio",
|
|
36
|
+
AUTHENTICATION_TOKEN: "authentication-token",
|
|
37
|
+
VOLUME: "volume",
|
|
38
|
+
VOLUME_LEVEL: "volume-level",
|
|
39
|
+
CAST_ENABLED: "cast",
|
|
40
|
+
AIRPLAY_ENABLED: "airplay",
|
|
41
|
+
PIP_ENABLED: "pip",
|
|
42
|
+
FULLSCREEN_ENABLED: "fullscreen",
|
|
43
|
+
VU_METER_ENABLED: "vu-meter",
|
|
44
|
+
TIMESHIFT_ENABLED: "timeshift",
|
|
45
|
+
TIMESHIFT_POSITION: "timeshift-position",
|
|
46
|
+
POSTER_SRC: "poster-src",
|
|
47
|
+
DURATION: "duration",
|
|
48
|
+
DEBUG_PANEL_OPEN: "debug-panel-open",
|
|
49
|
+
TARGET_BUFFER_TIME: "target-buffer-time",
|
|
50
|
+
DRIFT: "drift",
|
|
51
|
+
PLAYBACK_LATENCY: "playback-latency",
|
|
52
|
+
CONNECTION_STATE: "connection-state"
|
|
53
|
+
}, d = Object.values(u), f = {
|
|
54
|
+
PLAY: "play",
|
|
55
|
+
PAUSE: "pause",
|
|
56
|
+
MUTE: "mute",
|
|
57
|
+
UNMUTE: "unmute",
|
|
58
|
+
LOCK_UI: "lock-ui",
|
|
59
|
+
UNLOCK_UI: "unlock-ui",
|
|
60
|
+
ENTER_FULLSCREEN: "enter-fullscreen",
|
|
61
|
+
EXIT_FULLSCREEN: "exit-fullscreen",
|
|
62
|
+
SET_RENDITION: "set-rendition",
|
|
63
|
+
SET_ABR_MODE: "set-abr-mode",
|
|
64
|
+
SET_SIZE_BASED_RESOLUTION_CAP_MODE: "set-size-based-resolution-cap-mode",
|
|
65
|
+
CHANNEL_GRID_OPENED: "channel-grid-opened",
|
|
66
|
+
CHANNEL_GRID_CLOSED: "channel-grid-closed",
|
|
67
|
+
ENTER_PIP: "enter-pip",
|
|
68
|
+
EXIT_PIP: "exit-pip",
|
|
69
|
+
REQUEST_AIRPLAY: "request-airplay",
|
|
70
|
+
SET_LANGUAGE: "set-language",
|
|
71
|
+
SET_TEXT_TRACK: "set-text-track",
|
|
72
|
+
REQUEST_USER_INPUT: "request-user-input",
|
|
73
|
+
SET_VOLUME: "set-volume",
|
|
74
|
+
SEEK: "seek",
|
|
75
|
+
GO_LIVE: "go-live",
|
|
76
|
+
TOGGLE_DEBUG_PANEL: "toggle-debug-panel",
|
|
77
|
+
SET_TARGET_BUFFER_TIME: "set-target-buffer-time"
|
|
78
|
+
};
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region ../../libs/player-next/src/utils/vindralAttributesUtils.ts
|
|
81
|
+
function p(e) {
|
|
82
|
+
return e === "audio" || e === "video" || e === "audio+video" ? e : "audio+video";
|
|
83
|
+
}
|
|
84
|
+
function m(e) {
|
|
85
|
+
return e === "trace" || e === "debug" || e === "info" || e === "warn" || e === "error" || e === "off" ? e : "off";
|
|
86
|
+
}
|
|
87
|
+
function h(e) {
|
|
88
|
+
if (e === null) return;
|
|
89
|
+
let t = e.split(",").map((e) => e.trim()).filter((e) => e === "h264" || e === "h265" || e === "av1");
|
|
90
|
+
if (t.length !== 0) return t;
|
|
91
|
+
}
|
|
92
|
+
function g(e) {
|
|
93
|
+
if (e !== null) try {
|
|
94
|
+
let t = JSON.parse(e);
|
|
95
|
+
if (typeof t == "object" && t) {
|
|
96
|
+
let e = t;
|
|
97
|
+
if (typeof e.width == "number" && typeof e.height == "number") return e;
|
|
98
|
+
}
|
|
99
|
+
} catch (e) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function _(e) {
|
|
104
|
+
if (e !== null) try {
|
|
105
|
+
let t = JSON.parse(e);
|
|
106
|
+
if (typeof t == "object" && t) return t;
|
|
107
|
+
} catch (e) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function v(e) {
|
|
112
|
+
if (e === null) return;
|
|
113
|
+
let t = parseFloat(e);
|
|
114
|
+
return Number.isNaN(t) ? void 0 : t;
|
|
115
|
+
}
|
|
116
|
+
function y(e) {
|
|
117
|
+
return typeof e == "string";
|
|
118
|
+
}
|
|
119
|
+
function b(e, t) {
|
|
120
|
+
if (e === null) return t == null ? void 0 : t;
|
|
121
|
+
let n = e.toLowerCase();
|
|
122
|
+
return n === "false" ? !1 : n === "true" || n === "" || t == null ? !0 : t;
|
|
123
|
+
}
|
|
124
|
+
function x(e, t) {
|
|
125
|
+
return e === null ? t == null ? void 0 : t : e === "" || e.toLowerCase() === "true" ? !0 : e.toLowerCase() === "false" ? !1 : e;
|
|
126
|
+
}
|
|
127
|
+
function S(e) {
|
|
128
|
+
if (e === null) return;
|
|
129
|
+
let t = {}, n = e.split(",");
|
|
130
|
+
for (let e of n) {
|
|
131
|
+
let [n, r] = e.split(":");
|
|
132
|
+
n && r && (t[n.trim()] = r.trim());
|
|
133
|
+
}
|
|
134
|
+
return Object.keys(t).length > 0 ? t : void 0;
|
|
135
|
+
}
|
|
136
|
+
function C(e) {
|
|
137
|
+
if (e === null) return;
|
|
138
|
+
let t = e.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
|
|
139
|
+
return t.length > 0 ? t : void 0;
|
|
140
|
+
}
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region ../../libs/player-next/src/components/VindralButton.ts
|
|
143
|
+
var w = document.createElement("template");
|
|
144
|
+
w.innerHTML = "\n <style>\n :host {\n cursor: pointer;\n color: var(--fg-strong);\n padding: var(--button-padding) !important;\n background: transparent;\n transition: background 0.2s linear;\n -webkit-tap-highlight-color: transparent;\n }\n\n :host(:focus-visible) {\n box-shadow: inset 0 0 0 2px var(--fg-strong);\n outline: 0;\n }\n\n :host(:where(:focus)) {\n box-shadow: none;\n outline: 0;\n }\n\n @media (hover: hover) and (pointer: fine) {\n :host(:hover) {\n background: rgba(255, 255, 255, 0.15);\n }\n }\n\n :host(:active) {\n background: rgba(255, 255, 255, 0.25);\n }\n\n :host(:active) svg {\n scale: 0.9;\n }\n\n :host([disabled]) {\n opacity: 0.5;\n background: transparent;\n }\n\n slot > svg {\n display: block;\n width: var(--button-icon-size);\n height: var(--button-icon-size);\n }\n </style>\n";
|
|
145
|
+
var T = /* @__PURE__ */ new WeakMap(), E = /* @__PURE__ */ new WeakMap(), D = /* @__PURE__ */ new WeakMap(), O = /* @__PURE__ */ new WeakMap(), k = class extends HTMLElement {
|
|
146
|
+
constructor() {
|
|
147
|
+
super(), t(this, T, null), t(this, E, (e) => {
|
|
148
|
+
this.handleClick(e);
|
|
149
|
+
}), t(this, D, (e) => {
|
|
150
|
+
let { key: t } = e;
|
|
151
|
+
if (!this.keysUsed.includes(t)) {
|
|
152
|
+
this.removeEventListener("keyup", n(D, this));
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
this.handleClick(e);
|
|
156
|
+
}), t(this, O, (e) => {
|
|
157
|
+
let { metaKey: t, altKey: r, key: i } = e;
|
|
158
|
+
if (t || r || !this.keysUsed.includes(i)) {
|
|
159
|
+
this.removeEventListener("keyup", n(D, this));
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
this.addEventListener("keyup", n(D, this), { once: !0 });
|
|
163
|
+
}), this.attachShadow({ mode: "open" }).appendChild(w.content.cloneNode(!0));
|
|
164
|
+
}
|
|
165
|
+
get keysUsed() {
|
|
166
|
+
return ["Enter", " "];
|
|
167
|
+
}
|
|
168
|
+
connectedCallback() {
|
|
169
|
+
var e;
|
|
170
|
+
r(T, this, this.closest("vindral-controller")), (e = n(T, this)) == null || e.connectListener(this), this.hasAttribute("disabled") || this.enable(), this.setAttribute("role", "button");
|
|
171
|
+
}
|
|
172
|
+
enable() {
|
|
173
|
+
this.addEventListener("click", n(E, this)), this.addEventListener("keydown", n(O, this)), this.tabIndex = 0;
|
|
174
|
+
}
|
|
175
|
+
disable() {
|
|
176
|
+
this.removeEventListener("click", n(E, this)), this.removeEventListener("keydown", n(O, this)), this.removeEventListener("keyup", n(D, this)), this.tabIndex = -1;
|
|
177
|
+
}
|
|
178
|
+
disconnectedCallback() {
|
|
179
|
+
var e;
|
|
180
|
+
(e = n(T, this)) == null || e.disconnectListener(this);
|
|
181
|
+
}
|
|
182
|
+
attributeChangedCallback(e, t, n) {
|
|
183
|
+
e === "disabled" && (y(n) ? this.disable() : this.enable());
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
e(k, "observedAttributes", ["disabled"]);
|
|
187
|
+
//#endregion
|
|
188
|
+
//#region \0@oxc-project+runtime@0.115.0/helpers/getPrototypeOf.js
|
|
189
|
+
function A(e) {
|
|
190
|
+
return A = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(e) {
|
|
191
|
+
return e.__proto__ || Object.getPrototypeOf(e);
|
|
192
|
+
}, A(e);
|
|
193
|
+
}
|
|
194
|
+
//#endregion
|
|
195
|
+
//#region \0@oxc-project+runtime@0.115.0/helpers/superPropBase.js
|
|
196
|
+
function j(e, t) {
|
|
197
|
+
for (; !{}.hasOwnProperty.call(e, t) && (e = A(e)) !== null;);
|
|
198
|
+
return e;
|
|
199
|
+
}
|
|
200
|
+
//#endregion
|
|
201
|
+
//#region \0@oxc-project+runtime@0.115.0/helpers/get.js
|
|
202
|
+
function M() {
|
|
203
|
+
return M = typeof Reflect < "u" && Reflect.get ? Reflect.get.bind() : function(e, t, n) {
|
|
204
|
+
var r = j(e, t);
|
|
205
|
+
if (r) {
|
|
206
|
+
var i = Object.getOwnPropertyDescriptor(r, t);
|
|
207
|
+
return i.get ? i.get.call(arguments.length < 3 ? e : n) : i.value;
|
|
208
|
+
}
|
|
209
|
+
}, M.apply(null, arguments);
|
|
210
|
+
}
|
|
211
|
+
//#endregion
|
|
212
|
+
//#region \0@oxc-project+runtime@0.115.0/helpers/superPropGet.js
|
|
213
|
+
function N(e, t, n, r) {
|
|
214
|
+
var i = M(A(1 & r ? e.prototype : e), t, n);
|
|
215
|
+
return 2 & r && typeof i == "function" ? function(e) {
|
|
216
|
+
return i.apply(n, e);
|
|
217
|
+
} : i;
|
|
218
|
+
}
|
|
219
|
+
//#endregion
|
|
220
|
+
//#region ../../libs/player-next/src/constants.ts
|
|
221
|
+
var P = 5e3;
|
|
222
|
+
//#endregion
|
|
223
|
+
export { d as _, _ as a, m as c, p as d, v as f, u as g, f as h, y as i, S as l, h as m, N as n, b as o, C as p, k as r, x as s, P as t, g as u, c as v, l as y };
|
package/Cug44nXk.js
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { n as e, t } from "./BsfwXDui.js";
|
|
2
|
+
import { t as n } from "./DrWNJwZx.js";
|
|
3
|
+
import { t as r } from "./RxoWWyzp.js";
|
|
4
|
+
import { i, n as a, t as o } from "./Bt-ONXfO.js";
|
|
5
|
+
//#region ../../libs/web-sdk/src/decoders/PendingSampleMap.ts
|
|
6
|
+
var s = class {
|
|
7
|
+
constructor() {
|
|
8
|
+
e(this, "map", /* @__PURE__ */ new Map());
|
|
9
|
+
}
|
|
10
|
+
enqueue(e, t) {
|
|
11
|
+
let r = this.map.get(e);
|
|
12
|
+
if (r) r.push(t);
|
|
13
|
+
else {
|
|
14
|
+
let r = new n(Infinity);
|
|
15
|
+
r.push(t), this.map.set(e, r);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
dequeue(e) {
|
|
19
|
+
let t = this.map.get(e);
|
|
20
|
+
if (!t) return;
|
|
21
|
+
let n = t.pop();
|
|
22
|
+
return t.isEmpty() && this.map.delete(e), n;
|
|
23
|
+
}
|
|
24
|
+
dequeueWithFallback(e) {
|
|
25
|
+
let t = this.dequeue(e);
|
|
26
|
+
if (t !== void 0) return t;
|
|
27
|
+
for (let [e, t] of this.map) {
|
|
28
|
+
let n = t.pop();
|
|
29
|
+
if (t.isEmpty() && this.map.delete(e), n !== void 0) return n;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
removeLast(e) {
|
|
33
|
+
let t = this.map.get(e);
|
|
34
|
+
t && (t.popLast(), t.isEmpty() && this.map.delete(e));
|
|
35
|
+
}
|
|
36
|
+
clear() {
|
|
37
|
+
this.map.clear();
|
|
38
|
+
}
|
|
39
|
+
}, c, l = globalThis, u = class {
|
|
40
|
+
constructor(c) {
|
|
41
|
+
var l = this;
|
|
42
|
+
e(this, "decodedSamples", []), e(this, "decoder", null), e(this, "logger", void 0), e(this, "initSegments", /* @__PURE__ */ new Map()), e(this, "previousSample", void 0), e(this, "previousCodec", void 0), e(this, "pendingSamples", new s()), e(this, "errors", new n(10)), e(this, "resetDecoderState", () => {
|
|
43
|
+
this.pendingSamples.clear(), this.previousSample = void 0, this.previousCodec = void 0;
|
|
44
|
+
}), e(this, "ensureDecoder", () => ((!this.decoder || this.decoder.state === "closed") && (this.decoder = this.createDecoder()), this.decoder)), e(this, "createDecoder", () => new AudioDecoder({
|
|
45
|
+
output: (e) => {
|
|
46
|
+
let t = this.pendingSamples.dequeueWithFallback(e.timestamp);
|
|
47
|
+
if (!t) {
|
|
48
|
+
e.close();
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
let { sample: n, decodeStartTime: i } = t;
|
|
52
|
+
try {
|
|
53
|
+
let t = e.numberOfFrames, a = e.numberOfChannels, o = e.sampleRate, s = e.timestamp, c = e.duration, l = new Float32Array(t * a);
|
|
54
|
+
e.copyTo(l, {
|
|
55
|
+
planeIndex: 0,
|
|
56
|
+
format: "f32"
|
|
57
|
+
});
|
|
58
|
+
let u = Math.round(s * n.timescale / 1e6), d = typeof c == "number" && Number.isFinite(c) ? Math.max(0, Math.round(c * n.timescale / 1e6)) : n.duration, f = r(r({}, n), {}, {
|
|
59
|
+
timestamp: u,
|
|
60
|
+
duration: d,
|
|
61
|
+
type: "audio",
|
|
62
|
+
format: "f32",
|
|
63
|
+
data: l,
|
|
64
|
+
sampleRate: o,
|
|
65
|
+
channels: a,
|
|
66
|
+
statistics: {
|
|
67
|
+
decodeTime: Math.max(performance.now() - i, 0),
|
|
68
|
+
transportTimeFromWorker: 0,
|
|
69
|
+
transportTimeToWorker: 0,
|
|
70
|
+
samplesInBatch: 1
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
this.decodedSamples.push(f);
|
|
74
|
+
} finally {
|
|
75
|
+
e.close();
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
error: (e) => {
|
|
79
|
+
this.logger.error("Decoder error:", e.name, e.message), this.resetDecoderState(), this.errors.push(e);
|
|
80
|
+
}
|
|
81
|
+
})), e(this, "buildCodecString", o), e(this, "getDescription", (e, t) => {
|
|
82
|
+
let n = this.initSegments.get(t.renditionId);
|
|
83
|
+
if (n && n.data.byteLength > 0 && n.codec === e) return n.data;
|
|
84
|
+
if (e === "opus") return a(t.channels, t.sampleRate);
|
|
85
|
+
if (e === "aac") return i(t.channels, t.sampleRate);
|
|
86
|
+
}), e(this, "unload", () => {
|
|
87
|
+
this.decodedSamples = [], this.resetDecoderState(), this.decoder && this.decoder.state !== "closed" && this.decoder.close(), this.decoder = null;
|
|
88
|
+
}), e(this, "initSegment", (e) => {
|
|
89
|
+
this.initSegments.set(e.renditionId, e);
|
|
90
|
+
}), e(this, "enqueue", (e) => {
|
|
91
|
+
var t, n;
|
|
92
|
+
let r = this.ensureDecoder(), i = e.codec, a = ((t = this.previousSample) == null ? void 0 : t.channelId) !== e.channelId, o = ((n = this.previousSample) == null ? void 0 : n.renditionId) !== e.renditionId, s = this.previousCodec !== i;
|
|
93
|
+
if (!this.previousSample || a || o || s) {
|
|
94
|
+
this.previousSample && r.state === "configured" && r.flush().catch((e) => {
|
|
95
|
+
this.logger.warn("Failed to flush before reconfiguration:", e);
|
|
96
|
+
});
|
|
97
|
+
let t = this.buildCodecString(i), n = this.getDescription(i, e), a = {
|
|
98
|
+
codec: t,
|
|
99
|
+
sampleRate: e.sampleRate,
|
|
100
|
+
numberOfChannels: e.channels,
|
|
101
|
+
description: n
|
|
102
|
+
};
|
|
103
|
+
try {
|
|
104
|
+
r.configure(a), this.previousCodec = i;
|
|
105
|
+
} catch (t) {
|
|
106
|
+
this.logger.error(`Failed to configure decoder for ${i} (rendition ${e.renditionId}), dropping sample`, t), this.errors.push(t instanceof Error ? t : /* @__PURE__ */ Error(`Failed to configure decoder for ${i}`)), this.resetDecoderState(), this.ensureDecoder();
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (e.timescale <= 0) {
|
|
111
|
+
this.logger.error(`Invalid timescale ${e.timescale} in sample, dropping sample`);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
this.previousSample = e;
|
|
115
|
+
let c = Math.floor(1e6 * e.timestamp / e.timescale), l = Math.floor(1e6 * e.duration / e.timescale);
|
|
116
|
+
try {
|
|
117
|
+
let t = new EncodedAudioChunk({
|
|
118
|
+
type: "key",
|
|
119
|
+
timestamp: c,
|
|
120
|
+
duration: l > 0 ? l : void 0,
|
|
121
|
+
data: e.data
|
|
122
|
+
});
|
|
123
|
+
this.pendingSamples.enqueue(c, {
|
|
124
|
+
sample: e,
|
|
125
|
+
decodeStartTime: performance.now()
|
|
126
|
+
}), r.decode(t);
|
|
127
|
+
} catch (e) {
|
|
128
|
+
this.logger.error("Failed to decode chunk:", e), this.pendingSamples.removeLast(c), r.state === "closed" && (this.resetDecoderState(), this.ensureDecoder());
|
|
129
|
+
}
|
|
130
|
+
}), e(this, "flush", t(function* () {
|
|
131
|
+
if (l.decoder && l.decoder.state === "configured") try {
|
|
132
|
+
yield l.decoder.flush();
|
|
133
|
+
} catch (e) {
|
|
134
|
+
l.logger.error("Failed to flush decoder:", e), l.resetDecoderState();
|
|
135
|
+
}
|
|
136
|
+
})), e(this, "error", () => this.errors.pop()), e(this, "take", () => this.decodedSamples.shift()), this.logger = c, this.decoder = this.createDecoder();
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
c = u, e(u, "isSupported", () => l.AudioDecoder !== void 0), e(u, "create", function() {
|
|
140
|
+
var e = t(function* (e) {
|
|
141
|
+
if (!c.isSupported()) throw Error("WebCodecs AudioDecoder is not supported in this environment");
|
|
142
|
+
return new c(e);
|
|
143
|
+
});
|
|
144
|
+
return function(t) {
|
|
145
|
+
return e.apply(this, arguments);
|
|
146
|
+
};
|
|
147
|
+
}());
|
|
148
|
+
//#endregion
|
|
149
|
+
export { u as WebCodecsAudioDecoderContext };
|