@vindral/web-sdk 4.2.0 → 4.2.1
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/ABGzdpO4.js +1761 -0
- package/B7hT-BKr.js +32 -0
- package/B9WEkxkT.js +268 -0
- package/BsfwXDui.js +65 -0
- package/Bt-ONXfO.js +59 -0
- package/C01DcfYu.js +118 -0
- package/CF-41rJe.js +223 -0
- package/Cug44nXk.js +149 -0
- package/D5iA4gy8.js +143 -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/ST3epwLf.js +4361 -0
- package/TRlsfsv0.js +11538 -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/react.d.ts
CHANGED
|
@@ -131,7 +131,7 @@ declare class UserAgentInformation {
|
|
|
131
131
|
};
|
|
132
132
|
}
|
|
133
133
|
type AudioCodec = "aac" | "opus" | "mp3";
|
|
134
|
-
type VideoCodec = "h264" | "av1";
|
|
134
|
+
type VideoCodec = "h264" | "h265" | "av1";
|
|
135
135
|
interface ReconnectState {
|
|
136
136
|
/**
|
|
137
137
|
* The number or retry attempts so far.
|
|
@@ -464,8 +464,8 @@ interface TrackObject {
|
|
|
464
464
|
displayWidth?: number;
|
|
465
465
|
displayHeight?: number;
|
|
466
466
|
language?: string;
|
|
467
|
-
|
|
468
|
-
|
|
467
|
+
"com.vindral.variant_uid"?: string;
|
|
468
|
+
"com.vindral.drm"?: string;
|
|
469
469
|
}
|
|
470
470
|
interface CatalogRoot {
|
|
471
471
|
version: number;
|
|
@@ -832,6 +832,7 @@ interface JitterModuleStatistics {
|
|
|
832
832
|
interface MseModuleStatistics {
|
|
833
833
|
quotaErrorCount: number;
|
|
834
834
|
mediaSourceOpenTime: number;
|
|
835
|
+
playbackStallCount: number;
|
|
835
836
|
totalVideoFrames?: number;
|
|
836
837
|
droppedVideoFrames?: number;
|
|
837
838
|
successfulVideoAppendCalls?: number;
|
|
@@ -1163,6 +1164,14 @@ declare class Vindral extends Emitter<PublicVindralEvents> {
|
|
|
1163
1164
|
* setting targetBufferTime within that range for consistancy if using both min/max.
|
|
1164
1165
|
*/
|
|
1165
1166
|
set targetBufferTime(bufferTimeMs: number);
|
|
1167
|
+
/**
|
|
1168
|
+
* Update the dynamic buffer time configuration at runtime.
|
|
1169
|
+
* Allows adjusting min and max buffer time without recreating the Vindral instance.
|
|
1170
|
+
*/
|
|
1171
|
+
updateBufferTimeConfig(config: {
|
|
1172
|
+
minBufferTime?: number;
|
|
1173
|
+
maxBufferTime?: number;
|
|
1174
|
+
}): void;
|
|
1166
1175
|
/**
|
|
1167
1176
|
* The estimated playback latency based on target buffer time, the connection rtt and local playback drift
|
|
1168
1177
|
*/
|
|
@@ -1400,6 +1409,8 @@ declare class Vindral extends Emitter<PublicVindralEvents> {
|
|
|
1400
1409
|
private suspend;
|
|
1401
1410
|
private unsuspend;
|
|
1402
1411
|
private getRuntimeInfo;
|
|
1412
|
+
private getPlaybackBufferState;
|
|
1413
|
+
private onMediaElementBufferState;
|
|
1403
1414
|
private onMediaElementState;
|
|
1404
1415
|
private onBufferEvent;
|
|
1405
1416
|
/**
|
|
@@ -1498,7 +1509,7 @@ interface PublicVindralEvents {
|
|
|
1498
1509
|
* In case of a fatal error it is appropriate to indicate what the error was to the user, either by displaying the error.message or
|
|
1499
1510
|
* by using the error.code() as a key to look up a localization string. To resume streaming it is required to create a new Vindral instance.
|
|
1500
1511
|
*/
|
|
1501
|
-
|
|
1512
|
+
error: Readonly<VindralError>;
|
|
1502
1513
|
/**
|
|
1503
1514
|
* When the instance needs user input to activate audio or sometimes video playback.
|
|
1504
1515
|
* Is called with an object
|
|
@@ -1509,51 +1520,51 @@ interface PublicVindralEvents {
|
|
|
1509
1520
|
* }
|
|
1510
1521
|
* ```
|
|
1511
1522
|
*/
|
|
1512
|
-
|
|
1523
|
+
"needs user input": NeedsUserInputContext;
|
|
1513
1524
|
/**
|
|
1514
1525
|
* When a timed metadata event has been triggered
|
|
1515
1526
|
*/
|
|
1516
|
-
|
|
1527
|
+
metadata: Readonly<Metadata>;
|
|
1517
1528
|
/**
|
|
1518
1529
|
* When the playback state changes
|
|
1519
1530
|
*/
|
|
1520
|
-
|
|
1531
|
+
"playback state": Readonly<PlaybackState>;
|
|
1521
1532
|
/**
|
|
1522
1533
|
* When the connection state changes
|
|
1523
1534
|
*/
|
|
1524
|
-
|
|
1535
|
+
"connection state": Readonly<ConnectionState>;
|
|
1525
1536
|
/**
|
|
1526
1537
|
* When the available rendition levels is changed
|
|
1527
1538
|
*/
|
|
1528
|
-
|
|
1539
|
+
"rendition levels": ReadonlyArray<RenditionLevel>;
|
|
1529
1540
|
/**
|
|
1530
1541
|
* When the rendition level is changed
|
|
1531
1542
|
*/
|
|
1532
|
-
|
|
1543
|
+
"rendition level": Readonly<RenditionLevel>;
|
|
1533
1544
|
/**
|
|
1534
1545
|
* When the available languages is changed
|
|
1535
1546
|
*/
|
|
1536
|
-
|
|
1547
|
+
languages: ReadonlyArray<string>;
|
|
1537
1548
|
/**
|
|
1538
1549
|
* When the available text tracks are changed
|
|
1539
1550
|
*/
|
|
1540
|
-
|
|
1551
|
+
"text tracks": ReadonlyArray<string>;
|
|
1541
1552
|
/**
|
|
1542
1553
|
* When the available channels is changed
|
|
1543
1554
|
*/
|
|
1544
|
-
|
|
1555
|
+
channels: ReadonlyArray<Channel>;
|
|
1545
1556
|
/**
|
|
1546
1557
|
* When a context switch state change has occured.
|
|
1547
1558
|
* E.g. when a channel change has been requested, or quality is changed.
|
|
1548
1559
|
*/
|
|
1549
|
-
|
|
1560
|
+
"context switch": Readonly<ContextSwitchState>;
|
|
1550
1561
|
/**
|
|
1551
1562
|
* Emitted when a wallclock time message has been received from the server.
|
|
1552
1563
|
*
|
|
1553
1564
|
* Note: This is the edge server wallclock time and thus may differ slightly
|
|
1554
1565
|
* between two viewers if they are connected to different edge servers.
|
|
1555
1566
|
*/
|
|
1556
|
-
|
|
1567
|
+
"server wallclock time": Readonly<number>;
|
|
1557
1568
|
/**
|
|
1558
1569
|
* Is emitted during connection whether the channel is live or not.
|
|
1559
1570
|
*
|
|
@@ -1563,41 +1574,41 @@ interface PublicVindralEvents {
|
|
|
1563
1574
|
* Note: If the web-sdk is instantiated at the same time as you are starting the stream it is possible
|
|
1564
1575
|
* that this emits false until the started state has propagated through the system.
|
|
1565
1576
|
*/
|
|
1566
|
-
|
|
1577
|
+
"is live": boolean;
|
|
1567
1578
|
/**
|
|
1568
1579
|
* Emitted when a channel switch has been completed and the first frame of the new channel is rendered.
|
|
1569
1580
|
* A string containing the channel id of the new channel is provided as an argument.
|
|
1570
1581
|
*/
|
|
1571
|
-
|
|
1582
|
+
"channel switch": Readonly<ChannelSwitchContext>;
|
|
1572
1583
|
/**
|
|
1573
1584
|
* Emmitted when a channel switch fails.
|
|
1574
1585
|
* A string containing the channel id of the current channel is provided as an argument.
|
|
1575
1586
|
*/
|
|
1576
|
-
|
|
1587
|
+
"channel switch failed": Readonly<ChannelSwitchContext>;
|
|
1577
1588
|
/**
|
|
1578
1589
|
* Emitted when a language switch has been completed and the new language starts playing.
|
|
1579
1590
|
*/
|
|
1580
|
-
|
|
1591
|
+
"language switch": Readonly<LanguageSwitchContext>;
|
|
1581
1592
|
/**
|
|
1582
1593
|
* Emitted when the volume state changes.
|
|
1583
1594
|
*
|
|
1584
1595
|
* This is triggered triggered both when the user changes the volume through the Vindral instance, but also
|
|
1585
1596
|
* from external sources such as OS media shortcuts or other native UI outside of the browser.
|
|
1586
1597
|
*/
|
|
1587
|
-
|
|
1598
|
+
"volume state": Readonly<VolumeState>;
|
|
1588
1599
|
/**
|
|
1589
1600
|
* Emitted when the timeshift URLs are updated.
|
|
1590
1601
|
*/
|
|
1591
|
-
|
|
1602
|
+
"timeshift info": Readonly<TimeShiftInfo>;
|
|
1592
1603
|
/**
|
|
1593
1604
|
* Emitted for each CMAF fragment received via the MoQ/VoQ path.
|
|
1594
1605
|
* Contains raw fMP4 bytes suitable for recording.
|
|
1595
1606
|
*
|
|
1596
1607
|
* @internal Not part of the public API — may change without notice.
|
|
1597
1608
|
*/
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1609
|
+
"cmaf fragment": Readonly<CmafFragmentEvent>;
|
|
1610
|
+
"buffer state event": Readonly<BufferStateEvent>;
|
|
1611
|
+
"initialized media": void;
|
|
1601
1612
|
}
|
|
1602
1613
|
declare abstract class VindralButton extends HTMLElement {
|
|
1603
1614
|
#private;
|
|
@@ -1611,18 +1622,6 @@ declare abstract class VindralButton extends HTMLElement {
|
|
|
1611
1622
|
attributeChangedCallback(name: string, _old: string, value: string): void;
|
|
1612
1623
|
protected abstract handleClick(e: Event): void;
|
|
1613
1624
|
}
|
|
1614
|
-
type AirPlayButtonAttributes = (typeof AirPlayButton.observedAttributes)[number];
|
|
1615
|
-
declare class AirPlayButton extends VindralButton {
|
|
1616
|
-
#private;
|
|
1617
|
-
static observedAttributes: string[];
|
|
1618
|
-
constructor();
|
|
1619
|
-
connectedCallback(): void;
|
|
1620
|
-
disconnectedCallback(): void;
|
|
1621
|
-
attributeChangedCallback(name: string, old: string, value: string): void;
|
|
1622
|
-
set isAirPlaying(value: boolean);
|
|
1623
|
-
get isAirPlaying(): boolean;
|
|
1624
|
-
protected handleClick(_: Event): void;
|
|
1625
|
-
}
|
|
1626
1625
|
declare class VindralMenuButton extends VindralButton {
|
|
1627
1626
|
#private;
|
|
1628
1627
|
constructor();
|
|
@@ -1656,6 +1655,18 @@ declare class AdvancedRenditionMenuList extends HTMLElement {
|
|
|
1656
1655
|
handleEvent: (event: Event) => void;
|
|
1657
1656
|
focus(): void;
|
|
1658
1657
|
}
|
|
1658
|
+
type AirPlayButtonAttributes = (typeof AirPlayButton.observedAttributes)[number];
|
|
1659
|
+
declare class AirPlayButton extends VindralButton {
|
|
1660
|
+
#private;
|
|
1661
|
+
static observedAttributes: string[];
|
|
1662
|
+
constructor();
|
|
1663
|
+
connectedCallback(): void;
|
|
1664
|
+
disconnectedCallback(): void;
|
|
1665
|
+
attributeChangedCallback(name: string, old: string, value: string): void;
|
|
1666
|
+
set isAirPlaying(value: boolean);
|
|
1667
|
+
get isAirPlaying(): boolean;
|
|
1668
|
+
protected handleClick(_: Event): void;
|
|
1669
|
+
}
|
|
1659
1670
|
type BufferingIconAttributes = (typeof BufferingIcon.observedAttributes)[number];
|
|
1660
1671
|
declare class BufferingIcon extends HTMLElement {
|
|
1661
1672
|
#private;
|
|
@@ -1753,15 +1764,15 @@ interface AirPlaySenderEvents {
|
|
|
1753
1764
|
/**
|
|
1754
1765
|
* When airplay targets are available.
|
|
1755
1766
|
*/
|
|
1756
|
-
|
|
1767
|
+
available: void;
|
|
1757
1768
|
/**
|
|
1758
1769
|
* When a connection has been established with an airplay target.
|
|
1759
1770
|
*/
|
|
1760
|
-
|
|
1771
|
+
connected: void;
|
|
1761
1772
|
/**
|
|
1762
1773
|
* When the airplay target has lost or stopped a connection.
|
|
1763
1774
|
*/
|
|
1764
|
-
|
|
1775
|
+
disconnected: void;
|
|
1765
1776
|
}
|
|
1766
1777
|
interface AirPlayConfig {
|
|
1767
1778
|
/**
|
|
@@ -1820,7 +1831,7 @@ declare class AirPlaySender extends Emitter<AirPlaySenderEvents> {
|
|
|
1820
1831
|
private checkHlsUrl;
|
|
1821
1832
|
}
|
|
1822
1833
|
interface FullscreenEvents {
|
|
1823
|
-
|
|
1834
|
+
"on fullscreen change": boolean;
|
|
1824
1835
|
}
|
|
1825
1836
|
declare class Fullscreen extends Emitter<FullscreenEvents> {
|
|
1826
1837
|
private container;
|
|
@@ -1841,7 +1852,7 @@ type ControllerAttributes = (typeof Controller.observedAttributes)[number];
|
|
|
1841
1852
|
declare class Controller extends HTMLElement {
|
|
1842
1853
|
#private;
|
|
1843
1854
|
static observedAttributes: readonly [
|
|
1844
|
-
...("language" | "channels" | "buffering" | "paused" | "volume" | "muted" | "duration" | "user-interacting" | "is-casting" | "cast-available" | "cast-receiver-name" | "ui-locked" | "hide-ui-on-pause" | "is-fullscreen" | "is-fullscreen-fallback" | "rendition-levels" | "rendition-level" | "max-video-bit-rate" | "max-initial-bit-rate" | "abr-enabled" | "size-based-resolution-cap-enabled" | "channel-id" | "channel-group-id" | "pip-available" | "is-pip" | "airplay-available" | "is-airplaying" | "media" | "languages" | "text-tracks" | "text-track" | "needs-user-input-video" | "needs-user-input-audio" | "authentication-token" | "volume-level" | "cast" | "airplay" | "pip" | "fullscreen" | "vu-meter" | "timeshift" | "timeshift-position" | "poster-src")[],
|
|
1855
|
+
...("language" | "channels" | "buffering" | "paused" | "volume" | "muted" | "duration" | "user-interacting" | "is-casting" | "cast-available" | "cast-receiver-name" | "ui-locked" | "hide-ui-on-pause" | "is-fullscreen" | "is-fullscreen-fallback" | "rendition-levels" | "rendition-level" | "max-video-bit-rate" | "max-initial-bit-rate" | "abr-enabled" | "size-based-resolution-cap-enabled" | "channel-id" | "channel-group-id" | "pip-available" | "is-pip" | "airplay-available" | "is-airplaying" | "media" | "languages" | "text-tracks" | "text-track" | "needs-user-input-video" | "needs-user-input-audio" | "authentication-token" | "volume-level" | "cast" | "airplay" | "pip" | "fullscreen" | "vu-meter" | "timeshift" | "timeshift-position" | "poster-src" | "debug-panel-open" | "target-buffer-time" | "drift" | "playback-latency" | "connection-state")[],
|
|
1845
1856
|
"url",
|
|
1846
1857
|
"edge-url",
|
|
1847
1858
|
"target-buffer-time",
|
|
@@ -1964,7 +1975,7 @@ declare class PlayButton extends VindralButton {
|
|
|
1964
1975
|
type PlayerAttributes = (typeof Player.observedAttributes)[number];
|
|
1965
1976
|
declare class Player extends HTMLElement {
|
|
1966
1977
|
#private;
|
|
1967
|
-
static observedAttributes: readonly ("title" | "offline" | "advanced" | "poster" | "language" | "channels" | "buffering" | "paused" | "volume" | "muted" | "duration" | "user-interacting" | "is-casting" | "cast-available" | "cast-receiver-name" | "ui-locked" | "hide-ui-on-pause" | "is-fullscreen" | "is-fullscreen-fallback" | "rendition-levels" | "rendition-level" | "max-video-bit-rate" | "max-initial-bit-rate" | "abr-enabled" | "size-based-resolution-cap-enabled" | "channel-id" | "channel-group-id" | "pip-available" | "is-pip" | "airplay-available" | "is-airplaying" | "media" | "languages" | "text-tracks" | "text-track" | "needs-user-input-video" | "needs-user-input-audio" | "authentication-token" | "volume-level" | "cast" | "airplay" | "pip" | "fullscreen" | "vu-meter" | "timeshift" | "timeshift-position" | "poster-src" | "
|
|
1978
|
+
static observedAttributes: readonly ("title" | "offline" | "advanced" | "poster" | "language" | "channels" | "buffering" | "paused" | "volume" | "muted" | "duration" | "user-interacting" | "is-casting" | "cast-available" | "cast-receiver-name" | "ui-locked" | "hide-ui-on-pause" | "is-fullscreen" | "is-fullscreen-fallback" | "rendition-levels" | "rendition-level" | "max-video-bit-rate" | "max-initial-bit-rate" | "abr-enabled" | "size-based-resolution-cap-enabled" | "channel-id" | "channel-group-id" | "pip-available" | "is-pip" | "airplay-available" | "is-airplaying" | "media" | "languages" | "text-tracks" | "text-track" | "needs-user-input-video" | "needs-user-input-audio" | "authentication-token" | "volume-level" | "cast" | "airplay" | "pip" | "fullscreen" | "vu-meter" | "timeshift" | "timeshift-position" | "poster-src" | "debug-panel-open" | "target-buffer-time" | "drift" | "playback-latency" | "connection-state" | "url" | "decoders" | "min-buffer-time" | "max-buffer-time" | "edge-url" | "cast-receiver-id" | "cast-background" | "log-level" | "max-size" | "max-audio-bit-rate" | "burst-enabled" | "mse-enabled" | "mse-opus-enabled" | "ios-background-play-enabled" | "ios-wake-lock-enabled" | "stream-to-media-element-enabled" | "ios-media-element-enabled" | "telemetry-enabled" | "video-codecs" | "drm-headers" | "drm-queryparams" | "drm-widevine-video-robustness" | "drm-widevine-audio-robustness" | "drm-playready-video-robustness" | "drm-playready-audio-robustness" | "webtransport-enabled" | "webcodecs-hardware-acceleration" | "offscreen-canvas-enabled" | "reconnect-retries" | "auto-instance-enabled" | "advanced-rendition-menu-enabled" | "refresh-poster-enabled" | "stream-poll-enabled")[];
|
|
1968
1979
|
constructor();
|
|
1969
1980
|
connectedCallback(): void;
|
|
1970
1981
|
disconnectedCallback(): void;
|
package/react.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
package/BQEuFJLn.js
DELETED
|
@@ -1,206 +0,0 @@
|
|
|
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
|
-
};
|