avbridge 2.8.4 → 2.9.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.
Files changed (77) hide show
  1. package/CHANGELOG.md +133 -0
  2. package/README.md +74 -1
  3. package/dist/{avi-F6WZJK5T.cjs → avi-2ILLBNPQ.cjs} +8 -2
  4. package/dist/avi-2ILLBNPQ.cjs.map +1 -0
  5. package/dist/{avi-W6L3BTWU.cjs → avi-B5CQYB7L.cjs} +8 -2
  6. package/dist/avi-B5CQYB7L.cjs.map +1 -0
  7. package/dist/{avi-2JPBSHGA.js → avi-JXU4GQL2.js} +8 -2
  8. package/dist/avi-JXU4GQL2.js.map +1 -0
  9. package/dist/{avi-NJXAXUXK.js → avi-RWWPN2PR.js} +8 -2
  10. package/dist/avi-RWWPN2PR.js.map +1 -0
  11. package/dist/{chunk-X2K3GIWE.js → chunk-2NSOOMXW.js} +14 -3
  12. package/dist/chunk-2NSOOMXW.js.map +1 -0
  13. package/dist/{chunk-ZCUXHW55.cjs → chunk-BYGZN4Z5.cjs} +5 -5
  14. package/dist/{chunk-ZCUXHW55.cjs.map → chunk-BYGZN4Z5.cjs.map} +1 -1
  15. package/dist/{chunk-SMH6IOP2.js → chunk-CL6UEUQF.js} +4 -4
  16. package/dist/{chunk-SMH6IOP2.js.map → chunk-CL6UEUQF.js.map} +1 -1
  17. package/dist/{chunk-YX4AGLNF.cjs → chunk-EY6DZEDT.cjs} +89 -15
  18. package/dist/chunk-EY6DZEDT.cjs.map +1 -0
  19. package/dist/{chunk-SR3MPV4D.js → chunk-GYIJU44C.js} +5 -5
  20. package/dist/{chunk-SR3MPV4D.js.map → chunk-GYIJU44C.js.map} +1 -1
  21. package/dist/{chunk-CPZ7PXAM.cjs → chunk-L7A3ECI2.cjs} +14 -2
  22. package/dist/chunk-L7A3ECI2.cjs.map +1 -0
  23. package/dist/{chunk-Q2VUO52Z.cjs → chunk-OTFS7DC4.cjs} +12 -12
  24. package/dist/{chunk-Q2VUO52Z.cjs.map → chunk-OTFS7DC4.cjs.map} +1 -1
  25. package/dist/{chunk-KBWQRGHS.js → chunk-SN4WZE24.js} +79 -5
  26. package/dist/chunk-SN4WZE24.js.map +1 -0
  27. package/dist/element-browser.js +104 -7
  28. package/dist/element-browser.js.map +1 -1
  29. package/dist/element.cjs +16 -10
  30. package/dist/element.cjs.map +1 -1
  31. package/dist/element.d.cts +11 -6
  32. package/dist/element.d.ts +11 -6
  33. package/dist/element.js +15 -9
  34. package/dist/element.js.map +1 -1
  35. package/dist/index.cjs +20 -20
  36. package/dist/index.d.cts +2 -2
  37. package/dist/index.d.ts +2 -2
  38. package/dist/index.js +8 -8
  39. package/dist/libav-demux-3N5Y3VQA.cjs +31 -0
  40. package/dist/{libav-demux-H2GS46GH.cjs.map → libav-demux-3N5Y3VQA.cjs.map} +1 -1
  41. package/dist/libav-demux-JXD4OTLM.js +6 -0
  42. package/dist/{libav-demux-OWZ4T2YW.js.map → libav-demux-JXD4OTLM.js.map} +1 -1
  43. package/dist/{player-BptSJPfn.d.cts → player-DEcidWk6.d.cts} +1 -1
  44. package/dist/{player-BptSJPfn.d.ts → player-DEcidWk6.d.ts} +1 -1
  45. package/dist/player.cjs +187 -23
  46. package/dist/player.cjs.map +1 -1
  47. package/dist/player.d.cts +17 -11
  48. package/dist/player.d.ts +17 -11
  49. package/dist/player.js +187 -23
  50. package/dist/player.js.map +1 -1
  51. package/dist/{remux-WBYIZBBX.js → remux-56V7LDAD.js} +5 -5
  52. package/dist/{remux-WBYIZBBX.js.map → remux-56V7LDAD.js.map} +1 -1
  53. package/dist/{remux-OBSMIENG.cjs → remux-KUS5GIL6.cjs} +10 -10
  54. package/dist/{remux-OBSMIENG.cjs.map → remux-KUS5GIL6.cjs.map} +1 -1
  55. package/package.json +1 -1
  56. package/src/classify/rules.ts +2 -0
  57. package/src/element/avbridge-player.ts +22 -11
  58. package/src/element/avbridge-video.ts +22 -6
  59. package/src/element/player-styles.ts +68 -3
  60. package/src/probe/avi.ts +2 -0
  61. package/src/strategies/fallback/decoder.ts +30 -0
  62. package/src/strategies/fallback/index.ts +30 -0
  63. package/src/strategies/hybrid/decoder.ts +35 -0
  64. package/src/strategies/hybrid/index.ts +17 -0
  65. package/src/strategies/remux/index.ts +8 -0
  66. package/src/types.ts +6 -0
  67. package/src/util/libav-demux.ts +26 -0
  68. package/dist/avi-2JPBSHGA.js.map +0 -1
  69. package/dist/avi-F6WZJK5T.cjs.map +0 -1
  70. package/dist/avi-NJXAXUXK.js.map +0 -1
  71. package/dist/avi-W6L3BTWU.cjs.map +0 -1
  72. package/dist/chunk-CPZ7PXAM.cjs.map +0 -1
  73. package/dist/chunk-KBWQRGHS.js.map +0 -1
  74. package/dist/chunk-X2K3GIWE.js.map +0 -1
  75. package/dist/chunk-YX4AGLNF.cjs.map +0 -1
  76. package/dist/libav-demux-H2GS46GH.cjs +0 -27
  77. package/dist/libav-demux-OWZ4T2YW.js +0 -6
@@ -1,7 +1,7 @@
1
1
  import { SubtitleResourceBag, discoverSidecars, attachSubtitleTracks, SubtitleOverlay } from './chunk-5KVLE6YI.js';
2
- import { probe, avbridgeVideoToMediabunny, buildMediabunnySourceFromInput, avbridgeAudioToMediabunny } from './chunk-SR3MPV4D.js';
2
+ import { probe, avbridgeVideoToMediabunny, buildMediabunnySourceFromInput, avbridgeAudioToMediabunny } from './chunk-GYIJU44C.js';
3
3
  import { AvbridgeError, ERR_ALL_STRATEGIES_EXHAUSTED, ERR_PLAYER_NOT_READY, ERR_MSE_NOT_SUPPORTED, ERR_MSE_CODEC_NOT_SUPPORTED } from './chunk-CPJLFFCC.js';
4
- import { sanitizePacketTimestamp, sanitizeFrameTimestamp, libavFrameToInterleavedFloat32 } from './chunk-X2K3GIWE.js';
4
+ import { packetPtsSec, sanitizePacketTimestamp, sanitizeFrameTimestamp, libavFrameToInterleavedFloat32 } from './chunk-2NSOOMXW.js';
5
5
  import { dbg, loadLibav } from './chunk-5DMTJVIU.js';
6
6
  import { pickLibavVariant } from './chunk-5YAWWKA3.js';
7
7
 
@@ -90,7 +90,13 @@ var FALLBACK_VIDEO_CODECS = /* @__PURE__ */ new Set([
90
90
  "rv40",
91
91
  "mpeg2",
92
92
  "mpeg1",
93
- "theora"
93
+ "theora",
94
+ "dv",
95
+ "hq_hqa",
96
+ "rawvideo",
97
+ "qtrle",
98
+ "png",
99
+ "vp6f"
94
100
  ]);
95
101
  var FALLBACK_AUDIO_CODECS = /* @__PURE__ */ new Set([
96
102
  "wmav2",
@@ -974,6 +980,12 @@ async function createRemuxSession(context, video) {
974
980
  }
975
981
  const wasPlaying = !video.paused;
976
982
  await pipeline.seek(time, wasPlaying || wantPlay);
983
+ queueMicrotask(() => {
984
+ try {
985
+ video.dispatchEvent(new Event("seeked"));
986
+ } catch {
987
+ }
988
+ });
977
989
  },
978
990
  async setAudioTrack(id) {
979
991
  if (!context.audioTracks.some((t) => t.id === id)) {
@@ -1701,6 +1713,7 @@ async function startHybridDecoder(opts) {
1701
1713
  let videoFramesDecoded = 0;
1702
1714
  let audioFramesDecoded = 0;
1703
1715
  let videoChunksFed = 0;
1716
+ let bufferedUntilSec = 0;
1704
1717
  let syntheticVideoUs = 0;
1705
1718
  let syntheticAudioUs = 0;
1706
1719
  const videoTrackInfo = opts.context.videoTracks.find((t) => t.id === videoStream?.index);
@@ -1721,6 +1734,18 @@ async function startHybridDecoder(opts) {
1721
1734
  if (myToken !== pumpToken || destroyed) return;
1722
1735
  const videoPackets = videoStream ? packets[videoStream.index] : void 0;
1723
1736
  const audioPackets = audioStream ? packets[audioStream.index] : void 0;
1737
+ if (videoPackets && videoTimeBase) {
1738
+ for (const pkt of videoPackets) {
1739
+ const sec = packetPtsSec(pkt, videoTimeBase);
1740
+ if (sec != null && sec > bufferedUntilSec) bufferedUntilSec = sec;
1741
+ }
1742
+ }
1743
+ if (audioPackets && audioTimeBase) {
1744
+ for (const pkt of audioPackets) {
1745
+ const sec = packetPtsSec(pkt, audioTimeBase);
1746
+ if (sec != null && sec > bufferedUntilSec) bufferedUntilSec = sec;
1747
+ }
1748
+ }
1724
1749
  if (audioDec && audioPackets && audioPackets.length > 0) {
1725
1750
  await decodeAudioBatch(audioPackets, myToken);
1726
1751
  }
@@ -1977,6 +2002,9 @@ async function startHybridDecoder(opts) {
1977
2002
  (err) => console.error("[avbridge] hybrid pump failed (post-seek):", err)
1978
2003
  );
1979
2004
  },
2005
+ bufferedUntilSec() {
2006
+ return bufferedUntilSec;
2007
+ },
1980
2008
  stats() {
1981
2009
  return {
1982
2010
  decoderType: "webcodecs-hybrid",
@@ -2104,6 +2132,13 @@ async function createHybridSession(ctx, target, transport) {
2104
2132
  configurable: true,
2105
2133
  get: () => makeTimeRanges(ctx.duration && Number.isFinite(ctx.duration) && ctx.duration > 0 ? [[0, ctx.duration]] : [])
2106
2134
  });
2135
+ Object.defineProperty(target, "buffered", {
2136
+ configurable: true,
2137
+ get: () => {
2138
+ const end = handles.bufferedUntilSec();
2139
+ return makeTimeRanges(end > 0 ? [[0, end]] : []);
2140
+ }
2141
+ });
2107
2142
  async function waitForBuffer() {
2108
2143
  const start = performance.now();
2109
2144
  while (true) {
@@ -2117,6 +2152,7 @@ async function createHybridSession(ctx, target, transport) {
2117
2152
  }
2118
2153
  async function doSeek(timeSec) {
2119
2154
  const wasPlaying = audio.isPlaying();
2155
+ target.dispatchEvent(new Event("seeking"));
2120
2156
  await audio.pause().catch(() => {
2121
2157
  });
2122
2158
  await handles.seek(timeSec).catch(
@@ -2128,7 +2164,14 @@ async function createHybridSession(ctx, target, transport) {
2128
2164
  await waitForBuffer();
2129
2165
  await audio.start();
2130
2166
  }
2167
+ target.dispatchEvent(new Event("seeked"));
2131
2168
  }
2169
+ queueMicrotask(() => {
2170
+ try {
2171
+ target.dispatchEvent(new Event("loadedmetadata"));
2172
+ } catch {
2173
+ }
2174
+ });
2132
2175
  let fatalErrorHandler = null;
2133
2176
  handles.onFatalError((reason) => fatalErrorHandler?.(reason));
2134
2177
  return {
@@ -2313,6 +2356,7 @@ async function startDecoder(opts) {
2313
2356
  let pumpRunning = null;
2314
2357
  let packetsRead = 0;
2315
2358
  let videoFramesDecoded = 0;
2359
+ let bufferedUntilSec = 0;
2316
2360
  let audioFramesDecoded = 0;
2317
2361
  let watchdogFirstFrameMs = 0;
2318
2362
  let watchdogSlowSinceMs = 0;
@@ -2338,6 +2382,18 @@ async function startDecoder(opts) {
2338
2382
  if (myToken !== pumpToken || destroyed) return;
2339
2383
  const videoPackets = videoStream ? packets[videoStream.index] : void 0;
2340
2384
  const audioPackets = audioStream ? packets[audioStream.index] : void 0;
2385
+ if (videoPackets && videoTimeBase) {
2386
+ for (const pkt of videoPackets) {
2387
+ const sec = packetPtsSec(pkt, videoTimeBase);
2388
+ if (sec != null && sec > bufferedUntilSec) bufferedUntilSec = sec;
2389
+ }
2390
+ }
2391
+ if (audioPackets && audioTimeBase) {
2392
+ for (const pkt of audioPackets) {
2393
+ const sec = packetPtsSec(pkt, audioTimeBase);
2394
+ if (sec != null && sec > bufferedUntilSec) bufferedUntilSec = sec;
2395
+ }
2396
+ }
2341
2397
  if (audioDec && audioPackets && audioPackets.length > 0) {
2342
2398
  await decodeAudioBatch(audioPackets, myToken);
2343
2399
  }
@@ -2619,6 +2675,9 @@ async function startDecoder(opts) {
2619
2675
  (err) => console.error("[avbridge] decoder pump failed (post-seek):", err)
2620
2676
  );
2621
2677
  },
2678
+ bufferedUntilSec() {
2679
+ return bufferedUntilSec;
2680
+ },
2622
2681
  stats() {
2623
2682
  return {
2624
2683
  decoderType: "libav-wasm",
@@ -2718,6 +2777,13 @@ async function createFallbackSession(ctx, target, transport) {
2718
2777
  configurable: true,
2719
2778
  get: () => makeTimeRanges(ctx.duration && Number.isFinite(ctx.duration) && ctx.duration > 0 ? [[0, ctx.duration]] : [])
2720
2779
  });
2780
+ Object.defineProperty(target, "buffered", {
2781
+ configurable: true,
2782
+ get: () => {
2783
+ const end = handles.bufferedUntilSec();
2784
+ return makeTimeRanges(end > 0 ? [[0, end]] : []);
2785
+ }
2786
+ });
2721
2787
  async function waitForBuffer() {
2722
2788
  const start = performance.now();
2723
2789
  let firstFrameAtMs = 0;
@@ -2757,6 +2823,7 @@ async function createFallbackSession(ctx, target, transport) {
2757
2823
  }
2758
2824
  async function doSeek(timeSec) {
2759
2825
  const wasPlaying = audio.isPlaying();
2826
+ target.dispatchEvent(new Event("seeking"));
2760
2827
  await audio.pause().catch(() => {
2761
2828
  });
2762
2829
  await handles.seek(timeSec).catch(
@@ -2768,7 +2835,14 @@ async function createFallbackSession(ctx, target, transport) {
2768
2835
  await waitForBuffer();
2769
2836
  await audio.start();
2770
2837
  }
2838
+ target.dispatchEvent(new Event("seeked"));
2771
2839
  }
2840
+ queueMicrotask(() => {
2841
+ try {
2842
+ target.dispatchEvent(new Event("loadedmetadata"));
2843
+ } catch {
2844
+ }
2845
+ });
2772
2846
  return {
2773
2847
  strategy: "fallback",
2774
2848
  async play() {
@@ -3424,5 +3498,5 @@ function defaultFallbackChain(strategy) {
3424
3498
  }
3425
3499
 
3426
3500
  export { FALLBACK_AUDIO_CODECS, FALLBACK_VIDEO_CODECS, NATIVE_AUDIO_CODECS, NATIVE_VIDEO_CODECS, UnifiedPlayer, classifyContext, createPlayer };
3427
- //# sourceMappingURL=chunk-KBWQRGHS.js.map
3428
- //# sourceMappingURL=chunk-KBWQRGHS.js.map
3501
+ //# sourceMappingURL=chunk-SN4WZE24.js.map
3502
+ //# sourceMappingURL=chunk-SN4WZE24.js.map