/** * HEVC Transmuxer for Shaka Player. * * Implements the `shaka.extern.Transmuxer` interface so Shaka can ingest * HEVC/H.265 fMP4 segments on browsers that lack native HEVC support. * Uses `@hevcjs/core` SegmentTranscoder to decode HEVC and re-encode to * H.264 fMP4 that the browser's MSE can play. * * Modeled after `lib/transmuxer/aac_transmuxer.js` in shaka-player. */ import type { SegmentTranscoderConfig } from "@hevcjs/core"; /** * Config accepted by `HevcTransmuxer` (and forwarded by `registerHevcTransmuxer`). * When `workerUrl` is set, transcoding runs inside a Web Worker; otherwise * the HEVC decode + H.264 encode pipeline runs on the main thread. */ export interface HevcTransmuxerConfig extends SegmentTranscoderConfig { /** URL to the transcode worker script. When set, transcoding runs off main thread. */ workerUrl?: string; } type ShakaStream = any; type ShakaSegmentReference = any; /** * Return type of `HevcTransmuxer.transmux`. Compatible with both Shaka 4.x * (which expects a raw `Uint8Array` and passes it straight to MSE) and 5+ * (which checks `ArrayBuffer.isView` and falls back to `{data, init}` * when the value is a plain object). Returning a `Uint8Array` is the * common subset that works on every supported Shaka version. */ export type TransmuxOutput = Uint8Array; /** * Sniff whether a buffer starts with an ISO BMFF init segment. * Init segments begin with the `ftyp` box; media segments begin with * `moof` (or `styp` followed by `moof`). * * Box header layout: 4 bytes big-endian size, 4 bytes ASCII type. */ export declare function isInitSegment(bytes: Uint8Array): boolean; export declare class HevcTransmuxer { private readonly originalMimeType_; private readonly transcoderConfig_; private transcoder_; private initPromise_; private pendingHevcInit_; private h264InitEmitted_; private lastHevcInitBytes_; private cachedH264Init_; constructor(mimeType: string, config?: HevcTransmuxerConfig); destroy(): void; isSupported(mimeType: string, _contentType?: string): boolean; /** * Output mime advertised to Shaka before any frame has been encoded. * Best-effort mapping based on the HEVC level declared in the input * (see `@hevcjs/core/codec-mapping`). The actual encoded stream may * use a slightly different profile/level if `H264Encoder` decides * differently from the encoded resolution. */ convertCodecs(_contentType: string, mimeType: string): string; getOriginalMimeType(): string; /** * Convert one HEVC fMP4 segment into an MSE-ready H.264 fMP4 segment. * * Shaka calls this once per segment with `reference === null` for the * init segment and a non-null `reference` for media segments. * * - Init segment: warm up the H.264 encoder eagerly (encodes a single * black frame to obtain a valid avcC) and return a complete H.264 * init segment that MSE can immediately ingest. * - Media segment: decode HEVC, re-encode to H.264, mux fMP4, return. * * Returns a raw `Uint8Array` rather than `{data, init}` so the same * code path works on Shaka 4.x (which expects a `Uint8Array` directly) * and on Shaka 5+ (which accepts either via an `ArrayBuffer.isView` * check). Init/media segmentation is implicit in the call sequence. */ transmux(data: BufferSource, _stream: ShakaStream, reference: ShakaSegmentReference, _duration: number, _contentType: string): Promise; } export {}; //# sourceMappingURL=transmuxer.d.ts.map