/** * Shaka Player HEVC Plugin — public entry point. * * Usage (main thread, no Worker): * ```ts * import shaka from 'shaka-player'; * import { registerHevcTransmuxer } from '@hevcjs/shaka-plugin'; * * registerHevcTransmuxer(shaka, { wasmUrl: '/hevc-decode.js' }); * const player = new shaka.Player(); * await player.attach(videoElement); * await player.load(manifestUrl); * ``` * * Usage (off-main-thread via Web Worker — recommended for 4K / smoothness): * ```ts * registerHevcTransmuxer(shaka, { * wasmUrl: '/hevc-decode.js', * workerUrl: '/transcode-worker.js', * }); * ``` * * Compute-aware ABR is ON by default — Shaka's bandwidth-based ABR keeps * choosing freely while we narrow the ceiling when the device can't keep * up. The player is supplied later via `attachComputeAware`: * ```ts * const handle = registerHevcTransmuxer(shaka, { * wasmUrl: '/hevc-decode.js', * workerUrl: '/transcode-worker.js', * // adaptiveCompute is ON by default. * // To opt out: adaptiveCompute: false * // To tune: adaptiveCompute: { targetSpeedX: 1.5, lowerAfter: 1 } * }); * const player = new shaka.Player(); * handle.attachComputeAware(player); // wire the feedback loop * await player.load(manifestUrl); * // ... * handle(); // unregister + detach (callable) * ``` * * To force the transmuxer even on browsers with native HEVC support * (Safari, recent Chrome on macOS), use Shaka's built-in config rather * than patching MSE yourself: * * ```ts * player.configure({ mediaSource: { forceTransmux: true } }); * ``` */ import type { HevcTransmuxerConfig } from "./transmuxer.js"; import type { ShakaComputeAwareOptions } from "./compute-aware.js"; export { HevcTransmuxer } from "./transmuxer.js"; export type { TransmuxOutput, HevcTransmuxerConfig } from "./transmuxer.js"; export { attachShakaComputeAware } from "./compute-aware.js"; export type { ShakaComputeAwareOptions } from "./compute-aware.js"; export { subscribeSegmentStat } from "@hevcjs/core"; export type { SegmentPerfStat } from "@hevcjs/core"; type ShakaNamespace = any; type ShakaPlayer = any; /** * Plugin configuration. Forwarded as-is to `HevcTransmuxer`. Supports the * `SegmentTranscoderConfig` fields (`wasmUrl`, `wasmBinaryUrl`, `fps`, * `bitrate`) plus an optional `workerUrl` that, when set, routes the * HEVC decode + H.264 encode pipeline through a Web Worker, plus an * optional `adaptiveCompute` flag/config to enable the compute-aware * ABR feedback loop. */ export interface HevcShakaPluginConfig extends HevcTransmuxerConfig { /** * Compute-aware ABR feedback. The returned handle exposes * `attachComputeAware(player)` that wires the host Shaka player to the * transcode perf bus and caps variants when the device can't keep up. * * - **On by default** (undefined or `true`) — sensible defaults. * - Pass an object to tune the decider knobs (`targetSpeedX`, etc.). * - Pass `false` to opt out: `attachComputeAware` becomes a silent no-op. * * `attachComputeAware(player)` must still be called explicitly because * the player instance isn't available at register time. */ adaptiveCompute?: boolean | ShakaComputeAwareOptions; } /** * Return shape of `registerHevcTransmuxer`. Callable for backwards compat * (`handle()` unregisters the transmuxer, same as before). Methods are * attached as properties when `adaptiveCompute` is enabled so the existing * `const cleanup = registerHevcTransmuxer(...)` pattern still works. */ export interface HevcShakaPluginHandle { (): void; /** Explicit alias for the callable form. */ unregister(): void; /** * Attach the compute-aware feedback loop to a Shaka player. * Active by default; becomes a silent no-op only when the registration * config explicitly passed `adaptiveCompute: false`. * * Options passed here are merged on top of any options passed at * register time, which is convenient when the telemetry sink * (`onObservation`) is only available once the UI exists. * * @returns cleanup function — detaches the perf-bus listener. */ attachComputeAware(player: ShakaPlayer, options?: ShakaComputeAwareOptions): () => void; } /** * Register the HEVC transmuxer with Shaka's TransmuxerEngine. * * Must be called before `player.load()`. Registers a factory for both * `hev1` and `hvc1` MIME types at APPLICATION priority so Shaka picks * our transmuxer over any default fallback. * * @param shaka the global `shaka` namespace (import or window.shaka) * @param config forwarded to `HevcTransmuxer` (wasmUrl, wasmBinaryUrl, fps, bitrate, workerUrl, adaptiveCompute) * @returns A handle that is both callable (unregisters) and exposes * `attachComputeAware(player)` when `adaptiveCompute` is enabled. */ export declare function registerHevcTransmuxer(shaka: ShakaNamespace, config?: HevcShakaPluginConfig): HevcShakaPluginHandle; //# sourceMappingURL=index.d.ts.map