/** * hls.js HEVC Plugin — Enables HEVC playback in hls.js via WASM transcoding. * * Patches MSE so hls.js keeps HEVC levels in its ladder (the patched * `MediaSource.isTypeSupported` answers for the H.264 equivalent) and * transparently transcodes HEVC segments to H.264. * * Usage: * ```ts * import Hls from 'hls.js'; * import { attachHevcSupport } from '@hevcjs/hlsjs-plugin'; * * const cleanup = await attachHevcSupport({ wasmUrl: '/hevc-decode.js' }); * const hls = new Hls(); * hls.attachMedia(videoElement); * hls.loadSource(m3u8Url); * ``` * * Must be called BEFORE `new Hls()` — hls.js filters levels against * `MediaSource.isTypeSupported` at manifest parse time, so the intercept * has to be in place first. */ import type { MSEInterceptConfig } from "@hevcjs/core"; import type { HlsComputeAwareOptions } from "./compute-aware.js"; type HlsInstance = any; export interface HevcHlsPluginConfig extends MSEInterceptConfig { /** * Force HEVC transcoding even if the browser supports HEVC natively. * Useful for testing. Default: false. */ forceTranscode?: boolean; /** * Compute-aware ABR feedback. Caps `hls.autoLevelCapping` by observed * transcode `speedX` so the device doesn't pick a level it can't * transcode in real time. * * - **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(hls)` must be called explicitly because the Hls * instance is created after this plugin attaches. */ adaptiveCompute?: boolean | HlsComputeAwareOptions; } /** * Return shape of `attachHevcSupport`. Callable for backwards compat * (`handle()` uninstalls, same as the previous plain cleanup function). */ export interface HevcHlsPluginHandle { (): void; /** Explicit alias for the callable form. */ uninstall(): void; /** * Attach the compute-aware feedback loop to an Hls instance. * Active by default; becomes a silent no-op only when the config * explicitly passed `adaptiveCompute: false`. * * Options passed here are merged on top of options passed at attach * time; call-time options win (typical case: `onObservation` is only * known once the UI exists). * * @returns cleanup function — detaches the perf-bus listener. */ attachComputeAware(hls: HlsInstance, options?: HlsComputeAwareOptions): () => void; } /** * Attach HEVC transcoding support for hls.js. * * Must be called BEFORE creating the `Hls` instance. * Skips if the browser has native HEVC support (unless forceTranscode is set). * Checks H.264 encoding support before installing the MSE intercept. * * Unlike the dash.js plugin, no player instance is needed: hls.js keeps * HEVC levels as long as `MediaSource.isTypeSupported` accepts them, which * the MSE intercept guarantees. * * @param config Optional transcoder configuration * @returns A cleanup function to remove the plugin */ export declare function attachHevcSupport(config?: HevcHlsPluginConfig): Promise; export {}; //# sourceMappingURL=plugin.d.ts.map