UNPKG

npaw-plugin-nwf

Version:
81 lines (80 loc) 2.92 kB
import { SegmentIndex, SegmentMatchInfo } from './ManifestModel'; /** * Dual-mode HLS segment index aligned with Android HlsSegmentIndex. * Pattern mode: O(1) matching for sequential numeric filenames (e.g. seg0.ts, seg1.ts). * List mode: stored URIs with round-robin search for irregular filenames. */ export default class HlsSegmentIndex implements SegmentIndex { readonly startNumber: number; readonly targetDurationSecs: number; readonly totalDurationSecs: number; readonly isLive: boolean; readonly segmentCount: number; readonly hasUniqueSegmentUris: boolean; private readonly segmentDurations; private readonly uniformSegmentDuration; private readonly initUri; private readonly isPatternBased; private readonly uriTemplate; private readonly patternStartNumber; private readonly storedUris; private readonly byteRangeOffsets; private readonly sharedByteRangeUri; private patternRegex; private nextListSearchStart; constructor(opts: { startNumber: number; targetDurationSecs: number; totalDurationSecs: number; isLive: boolean; segmentCount: number; segmentDurations?: Float32Array; uniformSegmentDuration?: number; initUri?: string; isPatternBased?: boolean; uriTemplate?: string; patternStartNumber?: number; storedUris?: string[]; byteRangeOffsets?: number[]; sharedByteRangeUri?: string; }); private getPatternRegex; getSegmentUri(segmentNumber: number): string | undefined; getSegmentInfoForUri(chunkUri: string, byteRangeOffset?: number): SegmentMatchInfo | undefined; matchesInitUri(chunkUri: string): boolean; getSegmentInfoByNumber(segmentNumber: number): SegmentMatchInfo | undefined; private matchPattern; private matchList; private matchListByByteRange; private buildSegmentMatchInfo; private cumulativeDurationAt; } /** * Builder that auto-detects pattern vs list on the first two URIs, * aligned with Android HlsSegmentIndex.Builder. * Extracted as a standalone class to support declaration emit (TS4094). */ export declare class HlsSegmentIndexBuilder { private startNumber; private targetDurationSecs; private isLive; private initUri?; private state; private count; private firstUri; private prefix; private suffix; private firstNumber; private lastNumber; private listUris; private hasByteRanges; private byteRangeArray; private durations; constructor(startNumber: number, targetDurationSecs: number, isLive: boolean, initUri?: string | undefined); addUri(uri: string, duration?: number, byteRangeOffset?: number): void; private handlePending; private handlePattern; private switchToList; private switchToListFromPattern; build(finalInitUri?: string): HlsSegmentIndex; }