/** * Extracts and parses SEI from access units * * @module */ import SetManager from "../SetManager.js"; import { SEIMessageType } from "./MessageType.js"; import { parsePictureTiming, PictureTimingParseOptions } from "./PictureTiming.js"; export interface SEIExtractorOptions { /** behavior on parsing errors. override `handleError` for finer control (default: log) */ errors?: 'throw' | 'log'; /** parse unregistered user data messages (default: true) */ enableUserDataUnregistered?: boolean; /** parse picture timing messages (default: false) */ enablePicTiming?: boolean; /** when parsing picture timing messages, assume cpb_removal_delay and dpb_output_delay are present, even if not enabled in SPS (default: false) */ forceCpbDpbDelaysPresent?: boolean; } export type SEIExtractedMessage = { type: SEIMessageType.USER_DATA_UNREGISTERED; uuid: bigint; data: Uint8Array; } | { type: SEIMessageType.PIC_TIMING; message: ReturnType; }; export declare class SEIExtractorError extends Error { /** * source of the error: * - `byteStream` (when slicing/parsing NALUs from the byte stream) * - `psManager` (when `SetManager` was preprocessing a NALU), * - `nalu` (when parsing the SEI NALU itself) * - `message` (when parsing a SEI message) * - `missingPs` (parsing failed due to missing SPS/PPS) * * unstable, treat with care. */ context: 'byteStream' | 'psManager' | 'nalu' | 'message' | 'missingPs'; /** original error */ cause: unknown; constructor( /** * source of the error: * - `byteStream` (when slicing/parsing NALUs from the byte stream) * - `psManager` (when `SetManager` was preprocessing a NALU), * - `nalu` (when parsing the SEI NALU itself) * - `message` (when parsing a SEI message) * - `missingPs` (parsing failed due to missing SPS/PPS) * * unstable, treat with care. */ context: 'byteStream' | 'psManager' | 'nalu' | 'message' | 'missingPs', /** original error */ cause: unknown); private static formatMessage; } export default class SEIExtractor { options: SEIExtractorOptions; psManager: SetManager; mutePsErrors: boolean; constructor(options?: SEIExtractorOptions); /** * Process the next AU, in decoding order, and return the extracted messages. */ processAU( /** AU data, in Annex B byte stream format */ data: Uint8Array | ArrayBuffer): SEIExtractedMessage[]; protected derivePicTimingOptions(): PictureTimingParseOptions; /** * handle an error that occurred during parsing. the default implementation * formats an error message and, depending on `options.errors`, throws it * or `console.warn()`s it. the default implementation also silences errors * related to missing SPS/PPS until the first SPS is seen. */ protected handleError(err: SEIExtractorError): void; }