fluxkit-player 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/CHANGELOG.md +120 -0
  2. package/LICENSE +21 -0
  3. package/README.en.md +224 -0
  4. package/README.md +549 -2
  5. package/THIRD-PARTY-NOTICES.md +30 -0
  6. package/dist/fluxkit.js +5536 -0
  7. package/dist/fluxkit.js.map +1 -0
  8. package/dist/fluxkit.umd.cjs +94 -0
  9. package/dist/fluxkit.umd.cjs.map +1 -0
  10. package/dist/types/codec/aac.d.ts +19 -0
  11. package/dist/types/codec/bit.d.ts +15 -0
  12. package/dist/types/codec/config.d.ts +19 -0
  13. package/dist/types/codec/g711.d.ts +4 -0
  14. package/dist/types/codec/h264.d.ts +37 -0
  15. package/dist/types/codec/h265.d.ts +27 -0
  16. package/dist/types/config.d.ts +66 -0
  17. package/dist/types/crypto/hls-aes.d.ts +13 -0
  18. package/dist/types/demux/flv.d.ts +48 -0
  19. package/dist/types/demux/hls.d.ts +79 -0
  20. package/dist/types/demux/mp4.d.ts +45 -0
  21. package/dist/types/demux/ts.d.ts +41 -0
  22. package/dist/types/index.d.ts +32 -0
  23. package/dist/types/io/http.d.ts +32 -0
  24. package/dist/types/io/websocket.d.ts +27 -0
  25. package/dist/types/pipeline/segmenter.d.ts +16 -0
  26. package/dist/types/pipeline/timeline.d.ts +15 -0
  27. package/dist/types/player.d.ts +169 -0
  28. package/dist/types/protocol/amf0.d.ts +12 -0
  29. package/dist/types/remux/fmp4.d.ts +32 -0
  30. package/dist/types/render/audio.d.ts +61 -0
  31. package/dist/types/render/backlog.d.ts +27 -0
  32. package/dist/types/render/mse.d.ts +56 -0
  33. package/dist/types/render/software.d.ts +110 -0
  34. package/dist/types/render/subtitles.d.ts +36 -0
  35. package/dist/types/render/webcodecs.d.ts +73 -0
  36. package/dist/types/soft/h264bsd.d.ts +23 -0
  37. package/dist/types/soft/index.d.ts +14 -0
  38. package/dist/types/soft/libde265.d.ts +16 -0
  39. package/dist/types/soft/openh264.d.ts +21 -0
  40. package/dist/types/soft/soft-worker.d.ts +2 -0
  41. package/dist/types/soft/types.d.ts +37 -0
  42. package/dist/types/soft/worker-protocol.d.ts +52 -0
  43. package/dist/types/source/abr.d.ts +22 -0
  44. package/dist/types/source/hls.d.ts +66 -0
  45. package/dist/types/source/stream.d.ts +23 -0
  46. package/dist/types/types.d.ts +354 -0
  47. package/dist/types/ui/controls.d.ts +68 -0
  48. package/dist/types/utils/async.d.ts +12 -0
  49. package/dist/types/utils/buffer.d.ts +17 -0
  50. package/dist/types/utils/bytes.d.ts +62 -0
  51. package/dist/types/utils/events.d.ts +10 -0
  52. package/dist/types/utils/log.d.ts +14 -0
  53. package/docs/PUBLISHING.md +142 -0
  54. package/docs/README.md +42 -0
  55. package/docs/TEST-REPORT.md +370 -0
  56. package/docs/USAGE.md +513 -0
  57. package/docs/architecture.md +213 -0
  58. package/docs/test-logs/build.txt +19 -0
  59. package/docs/test-logs/coverage.txt +64 -0
  60. package/docs/test-logs/e2e-firefox.txt +1667 -0
  61. package/docs/test-logs/e2e.txt +1667 -0
  62. package/docs/test-logs/environment.json +62 -0
  63. package/docs/test-logs/typecheck.txt +1 -0
  64. package/docs/test-logs/unit.txt +81 -0
  65. package/examples/README.md +53 -0
  66. package/examples/minimal.html +49 -0
  67. package/examples/react/FluxPlayer.tsx +48 -0
  68. package/examples/soft-worker.js +6 -0
  69. package/examples/vue/FluxPlayer.vue +47 -0
  70. package/package.json +96 -4
@@ -0,0 +1,19 @@
1
+ /** AAC / ADTS / AudioSpecificConfig helpers. */
2
+ export declare const AAC_SAMPLE_RATES: number[];
3
+ export interface AdtsHeader {
4
+ objectType: number;
5
+ sampleRate: number;
6
+ sampleRateIndex: number;
7
+ channels: number;
8
+ frameLength: number;
9
+ headerLength: number;
10
+ }
11
+ export declare function parseAdts(data: Uint8Array, offset?: number): AdtsHeader | null;
12
+ export declare function buildAudioSpecificConfig(objectType: number, sampleRate: number, channels: number): Uint8Array;
13
+ export interface AudioSpecificConfig {
14
+ objectType: number;
15
+ sampleRate: number;
16
+ channels: number;
17
+ }
18
+ export declare function parseAudioSpecificConfig(asc: Uint8Array): AudioSpecificConfig;
19
+ export declare function aacCodecString(asc?: Uint8Array): string;
@@ -0,0 +1,15 @@
1
+ /** Exp-Golomb bit reader used by H.264 / H.265 SPS parsers. */
2
+ export declare class BitReader {
3
+ private readonly data;
4
+ private bitPos;
5
+ constructor(data: Uint8Array, bitOffset?: number);
6
+ get bitsLeft(): number;
7
+ skip(bits: number): void;
8
+ u1(): number;
9
+ /** Read up to 32 bits, big-endian. */
10
+ u(bits: number): number;
11
+ ue(): number;
12
+ se(): number;
13
+ }
14
+ /** Strip H.264/H.265 emulation-prevention bytes (0x00 0x00 0x03 -> 0x00 0x00). */
15
+ export declare function unescapeRbsp(data: Uint8Array): Uint8Array;
@@ -0,0 +1,19 @@
1
+ import { type AvcSpsInfo } from './h264';
2
+ import { type HevcSpsInfo } from './h265';
3
+ export interface AvcCConfig {
4
+ nalLengthSize: number;
5
+ sps: Uint8Array[];
6
+ pps: Uint8Array[];
7
+ info: AvcSpsInfo | null;
8
+ }
9
+ export interface HvcCConfig {
10
+ nalLengthSize: number;
11
+ vps: Uint8Array[];
12
+ sps: Uint8Array[];
13
+ pps: Uint8Array[];
14
+ info: HevcSpsInfo | null;
15
+ }
16
+ export declare function parseAvcC(data: Uint8Array): AvcCConfig;
17
+ export declare function parseHvcC(data: Uint8Array): HvcCConfig;
18
+ /** Read a 24-bit signed composition time offset. */
19
+ export declare function readI24(data: Uint8Array, offset: number): number;
@@ -0,0 +1,4 @@
1
+ /** G.711 A-law / μ-law codecs (used by IP cameras inside FLV). */
2
+ export type G711Law = 'alaw' | 'ulaw';
3
+ export declare function decodeG711(data: Uint8Array, law: G711Law): Int16Array;
4
+ export declare function decodeG711Float(data: Uint8Array, law: G711Law): Float32Array;
@@ -0,0 +1,37 @@
1
+ export declare const AVC_NAL: {
2
+ readonly SLICE: 1;
3
+ readonly IDR: 5;
4
+ readonly SEI: 6;
5
+ readonly SPS: 7;
6
+ readonly PPS: 8;
7
+ readonly AUD: 9;
8
+ };
9
+ export declare function avcNalType(nal: Uint8Array): number;
10
+ /** Split an Annex-B byte stream into NAL units (start codes removed). */
11
+ export declare function splitAnnexB(data: Uint8Array): Uint8Array[];
12
+ /** Convert NAL units to length-prefixed (AVCC) form. */
13
+ export declare function nalsToAvcc(nals: Uint8Array[], lengthSize?: number): Uint8Array;
14
+ export interface AvcSpsInfo {
15
+ profile: number;
16
+ compat: number;
17
+ level: number;
18
+ width: number;
19
+ height: number;
20
+ fps?: number;
21
+ chromaFormat: number;
22
+ bitDepthLuma: number;
23
+ bitDepthChroma: number;
24
+ }
25
+ export declare function parseAvcSps(nal: Uint8Array): AvcSpsInfo;
26
+ /** Build an AVCDecoderConfigurationRecord (avcC). */
27
+ export declare function buildAvcC(spsList: Uint8Array[], ppsList: Uint8Array[], info: AvcSpsInfo, lengthSize?: number): Uint8Array;
28
+ export declare function avcCodecString(avcC: Uint8Array): string;
29
+ export declare function avcProfileLevel(avcC: Uint8Array): {
30
+ profile: number;
31
+ level: number;
32
+ compat: number;
33
+ };
34
+ /** Convert an AVCC access unit back to Annex-B (used by gateways / debugging). */
35
+ export declare function avccToAnnexB(data: Uint8Array, lengthSize?: number): Uint8Array;
36
+ /** True when the first NAL in an access unit is an IDR slice. */
37
+ export declare function isAvcKeyframe(data: Uint8Array, lengthSize?: number): boolean;
@@ -0,0 +1,27 @@
1
+ export declare const HEVC_NAL: {
2
+ readonly VPS: 32;
3
+ readonly SPS: 33;
4
+ readonly PPS: 34;
5
+ readonly AUD: 35;
6
+ readonly PREFIX_SEI: 39;
7
+ readonly SUFFIX_SEI: 40;
8
+ };
9
+ export declare function hevcNalType(nal: Uint8Array): number;
10
+ export interface HevcSpsInfo {
11
+ profileSpace: number;
12
+ tier: number;
13
+ profileIdc: number;
14
+ compatFlags: number;
15
+ constraintFlags: Uint8Array;
16
+ levelIdc: number;
17
+ width: number;
18
+ height: number;
19
+ chromaFormat: number;
20
+ bitDepthLuma: number;
21
+ bitDepthChroma: number;
22
+ maxSubLayers: number;
23
+ }
24
+ export declare function parseHevcSps(nal: Uint8Array): HevcSpsInfo;
25
+ export declare function buildHvcC(info: HevcSpsInfo, vps: Uint8Array, sps: Uint8Array, pps: Uint8Array, lengthSize?: number): Uint8Array;
26
+ export declare function hevcCodecString(hvcC: Uint8Array): string;
27
+ export declare function isHevcKeyframe(data: Uint8Array, lengthSize?: number): boolean;
@@ -0,0 +1,66 @@
1
+ import type { FluxKitOptions, LogLevel } from './types';
2
+ export interface ResolvedOptions extends Required<Omit<FluxKitOptions, 'logger' | 'hls' | 'webcodecs' | 'headers' | 'retry' | 'softDecode' | 'controls' | 'live'>> {
3
+ /** undefined = auto-detect from Content-Length / HLS ENDLIST. */
4
+ live?: boolean;
5
+ controls: {
6
+ enabled: boolean;
7
+ autoHide: number;
8
+ screenshot: boolean;
9
+ record: boolean;
10
+ fullscreen: boolean;
11
+ downloadName: string;
12
+ };
13
+ logger?: FluxKitOptions['logger'];
14
+ headers: Record<string, string>;
15
+ retry: {
16
+ maxRetries: number;
17
+ delay: number;
18
+ maxDelay: number;
19
+ };
20
+ hls: {
21
+ mode: 'demux' | 'native';
22
+ maxBandwidth?: number;
23
+ liveReloadFactor: number;
24
+ abr: boolean;
25
+ abrLowBuffer: number;
26
+ abrHighBuffer: number;
27
+ };
28
+ webcodecs: {
29
+ fit: 'contain' | 'cover' | 'fill';
30
+ audioBuffer: number;
31
+ };
32
+ softDecode: {
33
+ enabled: boolean;
34
+ maxDecodeAhead: number;
35
+ dropLateFrames: boolean;
36
+ loaders?: {
37
+ avc?: () => Promise<unknown>;
38
+ openh264?: () => Promise<unknown>;
39
+ hevc?: () => Promise<unknown>;
40
+ };
41
+ worker?: string | (() => Worker);
42
+ modules?: {
43
+ avc?: string;
44
+ openh264?: string;
45
+ hevc?: string;
46
+ };
47
+ };
48
+ }
49
+ export declare const DEFAULTS: {
50
+ decoder: "auto";
51
+ protocol: "native";
52
+ autoplay: boolean;
53
+ muted: boolean;
54
+ loop: boolean;
55
+ volume: number;
56
+ logLevel: LogLevel;
57
+ allowNativeFallback: boolean;
58
+ hardwareAcceleration: "prefer-hardware";
59
+ segmentDuration: number;
60
+ liveBufferTarget: number;
61
+ catchUp: boolean;
62
+ timeout: number;
63
+ };
64
+ export declare function resolveOptions(options?: FluxKitOptions): ResolvedOptions;
65
+ /** Map a URL to the container/transport we should use. */
66
+ export declare function detectProtocol(url: string): import('./types').Protocol;
@@ -0,0 +1,13 @@
1
+ /** Big-endian media sequence number padded to 128 bits (RFC 8216 §5.2). */
2
+ export declare function sequenceIv(sequence: number): Uint8Array;
3
+ /** Parse `IV=0x...`; returns null for malformed values. */
4
+ export declare function parseIv(value: string | undefined): Uint8Array | null;
5
+ export declare function ivForSegment(ivHex: string | undefined, sequence: number): Uint8Array;
6
+ export declare function importAes128Key(raw: Uint8Array): Promise<CryptoKey>;
7
+ export declare function importAes256GcmKey(raw: Uint8Array): Promise<CryptoKey>;
8
+ /**
9
+ * HLS AES-256-GCM segments are `IV(16) || ciphertext || tag(16)`; WebCrypto
10
+ * expects the tag appended to the ciphertext and the IV passed separately.
11
+ */
12
+ export declare function decryptAes256Gcm(key: CryptoKey, data: Uint8Array): Promise<Uint8Array>;
13
+ export declare function decryptAes128(key: CryptoKey, iv: Uint8Array, data: Uint8Array): Promise<Uint8Array>;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * FLV demuxer.
3
+ *
4
+ * Handles plain FLV, HTTP-FLV and WS-FLV.
5
+ * Supports AVC, HEVC (legacy codecId 12 and Enhanced-RTMP `hvc1` fourCC),
6
+ * AAC, MP3 and onMetaData.
7
+ */
8
+ import type { Demuxer, DemuxerSink } from '../types';
9
+ export declare const FLV_TIMESCALE = 1000;
10
+ export type FlvTagHandler = (type: number, timestamp: number, data: Uint8Array) => void;
11
+ /** Splits a byte stream into FLV tags. */
12
+ export declare class FlvTagParser {
13
+ private readonly onTag;
14
+ private buf;
15
+ private headerParsed;
16
+ constructor(onTag: FlvTagHandler);
17
+ push(chunk: Uint8Array): void;
18
+ flush(): void;
19
+ reset(): void;
20
+ private parse;
21
+ }
22
+ export declare class FlvDemuxer implements Demuxer {
23
+ private readonly sink;
24
+ readonly format = "flv";
25
+ private readonly parser;
26
+ private videoTrack;
27
+ private audioTrack;
28
+ private meta;
29
+ private warnedUnsupported;
30
+ constructor(sink: DemuxerSink);
31
+ push(chunk: Uint8Array): void;
32
+ /** Feed an already-demuxed FLV tag (for custom transports). */
33
+ pushTag(type: number, timestamp: number, data: Uint8Array): void;
34
+ /** Duration in seconds from onMetaData, when the stream is a VOD file. */
35
+ get duration(): number | undefined;
36
+ flush(): void;
37
+ reset(): void;
38
+ private tracks;
39
+ private handleTag;
40
+ private handleScript;
41
+ private applyMetaSize;
42
+ private handleVideo;
43
+ private configureAvc;
44
+ private configureHevc;
45
+ private handleAudio;
46
+ private configureAac;
47
+ private warnOnce;
48
+ }
@@ -0,0 +1,79 @@
1
+ /** HLS playlist (m3u8) parsing. */
2
+ export interface HlsVariant {
3
+ uri: string;
4
+ bandwidth: number;
5
+ resolution?: string;
6
+ codecs?: string;
7
+ frameRate?: number;
8
+ audioGroup?: string;
9
+ subtitleGroup?: string;
10
+ }
11
+ export interface HlsRendition {
12
+ type: string;
13
+ groupId: string;
14
+ name: string;
15
+ uri?: string;
16
+ default: boolean;
17
+ autoselect: boolean;
18
+ language?: string;
19
+ }
20
+ export interface HlsKey {
21
+ method: string;
22
+ uri?: string;
23
+ /** Explicit `IV=0x...` (128-bit hex). */
24
+ iv?: string;
25
+ /** `KEYFORMAT`, defaulting to `identity` when omitted. */
26
+ keyformat?: string;
27
+ }
28
+ export interface HlsByteRange {
29
+ offset: number;
30
+ length: number;
31
+ }
32
+ /** LL-HLS partial segment (`EXT-X-PART`). */
33
+ export interface HlsPart {
34
+ uri: string;
35
+ duration: number;
36
+ independent: boolean;
37
+ gap: boolean;
38
+ byterange?: HlsByteRange;
39
+ }
40
+ export interface HlsSegment {
41
+ uri: string;
42
+ duration: number;
43
+ sequence: number;
44
+ discontinuity: boolean;
45
+ /** True once the full segment URI is available. */
46
+ complete: boolean;
47
+ /** LL-HLS parts listed for this segment (possibly still growing). */
48
+ parts: HlsPart[];
49
+ byterange?: HlsByteRange;
50
+ map?: string;
51
+ mapByterange?: HlsByteRange;
52
+ key?: HlsKey;
53
+ }
54
+ export interface HlsMediaPlaylist {
55
+ targetDuration: number;
56
+ mediaSequence: number;
57
+ /** Monotonic count of discontinuities before this playlist window. */
58
+ discontinuitySequence: number;
59
+ /** LL-HLS `PART-TARGET` in seconds. */
60
+ partTarget: number;
61
+ /** LL-HLS blocking playlist reload. */
62
+ canBlockReload: boolean;
63
+ /** LL-HLS `PART-HOLD-BACK` in seconds. */
64
+ partHoldBack?: number;
65
+ segments: HlsSegment[];
66
+ endList: boolean;
67
+ map?: string;
68
+ mapByterange?: HlsByteRange;
69
+ encrypted: boolean;
70
+ }
71
+ export declare function resolveUrl(uri: string, base: string): string;
72
+ /** Parse `KEY=VALUE,KEY="a,b"` attribute lists. */
73
+ export declare function parseAttributes(input: string): Record<string, string>;
74
+ export declare function parseMasterPlaylist(text: string, baseUrl: string): HlsVariant[];
75
+ /** `#EXT-X-MEDIA` entries (alternate audio / subtitles). */
76
+ export declare function parseMediaRenditions(text: string, baseUrl: string): HlsRendition[];
77
+ export declare function parseMediaPlaylist(text: string, baseUrl: string): HlsMediaPlaylist;
78
+ /** Pick a variant under the bitrate cap, preferring the highest quality. */
79
+ export declare function selectVariant(variants: HlsVariant[], maxBandwidth?: number): HlsVariant | null;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * MP4 / fMP4 demuxer.
3
+ *
4
+ * Streaming design: boxes are parsed as they arrive and mdat payloads are
5
+ * sliced into samples on the fly, so HTTP-FMP4 starts playing before the
6
+ * segment finishes downloading. Non-fragmented MP4 is supported when `moov`
7
+ * precedes `mdat` (faststart), which is what streaming services ship.
8
+ */
9
+ import type { Demuxer, DemuxerSink } from '../types';
10
+ export declare class Mp4Demuxer implements Demuxer {
11
+ private readonly sink;
12
+ readonly format = "mp4";
13
+ private buf;
14
+ private bufStart;
15
+ private skipBytes;
16
+ private state;
17
+ private mdatEnd;
18
+ private pending;
19
+ private pendingIndex;
20
+ private moovDone;
21
+ private sawMdatFirst;
22
+ private mediaDuration;
23
+ private readonly tracks;
24
+ constructor(sink: DemuxerSink);
25
+ private sawMoof;
26
+ get fragmented(): boolean;
27
+ /** Movie duration in seconds from mvhd, when present. */
28
+ get duration(): number | undefined;
29
+ push(chunk: Uint8Array): void;
30
+ flush(): void;
31
+ reset(): void;
32
+ private consume;
33
+ /** Drop n bytes that we never need, buffering only what has arrived. */
34
+ private skipAhead;
35
+ private parse;
36
+ private pumpMdat;
37
+ private handleBox;
38
+ private parseMoov;
39
+ private parseTrak;
40
+ private hasSampleTable;
41
+ private buildSampleTable;
42
+ private parseVideoTrack;
43
+ private parseAudioTrack;
44
+ private parseMoof;
45
+ }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * MPEG-TS demuxer used for HLS.
3
+ *
4
+ * Reads PAT/PMT, reassembles PES packets, converts Annex-B NAL units into
5
+ * AVCC access units and ADTS AAC into raw frames. Produces 90 kHz timestamps.
6
+ */
7
+ import type { Demuxer, DemuxerSink } from '../types';
8
+ export declare const TS_TIMESCALE = 90000;
9
+ export declare class TsDemuxer implements Demuxer {
10
+ private readonly sink;
11
+ readonly format = "ts";
12
+ private buf;
13
+ private packetSize;
14
+ private syncOffset;
15
+ private synced;
16
+ private pmtPid;
17
+ private readonly streams;
18
+ private readonly tracks;
19
+ private videoPid;
20
+ private audioPid;
21
+ private warned;
22
+ constructor(sink: DemuxerSink);
23
+ push(chunk: Uint8Array): void;
24
+ flush(): void;
25
+ reset(): void;
26
+ private parse;
27
+ private detectPacketSize;
28
+ private resync;
29
+ private consumePacket;
30
+ private handleSection;
31
+ private parsePmt;
32
+ private addStream;
33
+ private finishPes;
34
+ private unwrap;
35
+ private handleVideoPes;
36
+ private maybeBuildVideoTrack;
37
+ private flushAu;
38
+ private handleAudioPes;
39
+ private buildAudioTrack;
40
+ private warnOnce;
41
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * FluxKit public entry point.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ export { FluxKit, VERSION } from './player';
7
+ export { FluxKit as default } from './player';
8
+ export * from './types';
9
+ export { resolveOptions, detectProtocol, DEFAULTS } from './config';
10
+ export { FlvDemuxer, FlvTagParser, FLV_TIMESCALE } from './demux/flv';
11
+ export { Mp4Demuxer } from './demux/mp4';
12
+ export { TsDemuxer, TS_TIMESCALE } from './demux/ts';
13
+ export { parseMasterPlaylist, parseMediaPlaylist, parseMediaRenditions, parseAttributes, selectVariant, resolveUrl, type HlsMediaPlaylist, type HlsSegment, type HlsVariant, } from './demux/hls';
14
+ export { StreamSource } from './source/stream';
15
+ export { HlsSource } from './source/hls';
16
+ export { MseRenderer } from './render/mse';
17
+ export { WebCodecsRenderer, isWebCodecsSupported } from './render/webcodecs';
18
+ export { SoftwareRenderer } from './render/software';
19
+ export { createSoftwareDecoder, installSoftWorker, type SoftFrame, type SoftVideoDecoder, type SoftLoaders, type SoftWorkerResponse, type SoftWorkerScope, } from './soft';
20
+ export { Libde265Decoder } from './soft/libde265';
21
+ export { H264BsdDecoder } from './soft/h264bsd';
22
+ export { buildInitSegment, Fmp4Muxer, mimeTypeFor, videoMimeType, audioMimeType, codecLabel, } from './remux/fmp4';
23
+ export { parseAvcSps, buildAvcC, avcCodecString, avccToAnnexB, splitAnnexB, nalsToAvcc, isAvcKeyframe, } from './codec/h264';
24
+ export { parseHevcSps, buildHvcC, hevcCodecString, isHevcKeyframe } from './codec/h265';
25
+ export { parseAudioSpecificConfig, buildAudioSpecificConfig, aacCodecString, parseAdts } from './codec/aac';
26
+ export { parseAvcC, parseHvcC } from './codec/config';
27
+ export { decodeG711, decodeG711Float, type G711Law } from './codec/g711';
28
+ export { HttpStream, fetchText, fetchBytes } from './io/http';
29
+ export { WsTransport, WsStream } from './io/websocket';
30
+ export { encodeAmf0, decodeAmf0, encodeAmf0Values, decodeAmf0All } from './protocol/amf0';
31
+ export { Timeline } from './pipeline/timeline';
32
+ export { Segmenter } from './pipeline/segmenter';
@@ -0,0 +1,32 @@
1
+ export interface StreamSink {
2
+ onData(chunk: Uint8Array): void;
3
+ onEnd(): void;
4
+ onError(err: Error): void;
5
+ onResponse?(meta: {
6
+ status: number;
7
+ contentType: string | null;
8
+ contentLength: number | null;
9
+ url: string;
10
+ }): void;
11
+ }
12
+ export interface HttpOptions {
13
+ headers?: Record<string, string>;
14
+ timeout?: number;
15
+ retry?: {
16
+ maxRetries: number;
17
+ delay: number;
18
+ maxDelay: number;
19
+ };
20
+ }
21
+ export declare class HttpStream {
22
+ private controller;
23
+ private paused;
24
+ private resumeWaiters;
25
+ pause(): void;
26
+ resume(): void;
27
+ private waitIfPaused;
28
+ start(url: string, sink: StreamSink, options?: HttpOptions): Promise<void>;
29
+ stop(): void;
30
+ }
31
+ export declare function fetchText(url: string, options?: HttpOptions): Promise<string>;
32
+ export declare function fetchBytes(url: string, options?: HttpOptions): Promise<Uint8Array>;
@@ -0,0 +1,27 @@
1
+ /** WebSocket transport for WS-FLV. */
2
+ export interface WsOptions {
3
+ timeout?: number;
4
+ protocols?: string | string[];
5
+ }
6
+ export declare class WsTransport {
7
+ private socket;
8
+ private closedByUs;
9
+ onData?: (data: Uint8Array) => void;
10
+ onText?: (text: string) => void;
11
+ onClose?: (clean: boolean) => void;
12
+ onError?: (err: Error) => void;
13
+ get readyState(): number;
14
+ connect(url: string, options?: WsOptions): Promise<void>;
15
+ send(data: Uint8Array | string): void;
16
+ close(): void;
17
+ }
18
+ /** WS-FLV: raw FLV bytes pushed from a WebSocket. */
19
+ export declare class WsStream {
20
+ private transport;
21
+ start(url: string, sink: {
22
+ onData: (chunk: Uint8Array) => void;
23
+ onEnd: () => void;
24
+ onError: (err: Error) => void;
25
+ }, options?: WsOptions): Promise<void>;
26
+ stop(): void;
27
+ }
@@ -0,0 +1,16 @@
1
+ /** Groups samples into MSE-friendly fragments, cutting on video keyframes. */
2
+ import type { Sample, Track } from '../types';
3
+ export interface SegmenterOptions {
4
+ durationMs: number;
5
+ onSegment: (track: Track, samples: Sample[]) => void;
6
+ getTrack: (id: number) => Track | undefined;
7
+ }
8
+ export declare class Segmenter {
9
+ private readonly options;
10
+ private readonly buffers;
11
+ private windowStart;
12
+ constructor(options: SegmenterOptions);
13
+ push(sample: Sample): void;
14
+ private hasSamples;
15
+ flush(): void;
16
+ }
@@ -0,0 +1,15 @@
1
+ /** Timeline normalization: origin, 33-bit wrap tolerance and monotonic DTS. */
2
+ import type { Sample, Track } from '../types';
3
+ export declare class Timeline {
4
+ private readonly tracks;
5
+ private baseMs;
6
+ private startMs;
7
+ private readonly lastDts;
8
+ private readonly offsets;
9
+ private readonly pendingDiscontinuity;
10
+ constructor(tracks: Map<number, Track>);
11
+ setStart(startMs: number): void;
12
+ /** Rebase every known track at its next sample (HLS discontinuity / ad break). */
13
+ markDiscontinuity(): void;
14
+ normalize(sample: Sample): Sample;
15
+ }