forked from video-dev/hls.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demuxer.ts
133 lines (117 loc) · 2.58 KB
/
demuxer.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
export interface Demuxer {
demux(
data: Uint8Array,
timeOffset: number,
isSampleAes?: boolean
): DemuxerResult;
demuxSampleAes(
data: Uint8Array,
keyData: KeyData,
timeOffset: number
): Promise<DemuxerResult>;
flush(timeOffset?: number): DemuxerResult | Promise<DemuxerResult>;
destroy(): void;
resetInitSegment(
audioCodec: string | undefined,
videoCodec: string | undefined,
duration: number
);
resetTimeStamp(defaultInitPTS?: number | null): void;
resetContiguity(): void;
}
export interface DemuxerResult {
audioTrack: DemuxedAudioTrack;
avcTrack: DemuxedVideoTrack;
id3Track: DemuxedMetadataTrack;
textTrack: DemuxedUserdataTrack;
}
export interface DemuxedTrack {
type: string;
id: number;
pid: number;
inputTimeScale: number;
sequenceNumber: number;
samples:
| AudioSample[]
| AvcSample[]
| MetadataSample[]
| UserdataSample[]
| Uint8Array;
timescale?: number;
container?: string;
dropped: number;
duration?: number;
pesData?: ElementaryStreamData | null;
codec?: string;
}
export interface DemuxedAudioTrack extends DemuxedTrack {
config?: number[];
samplerate?: number;
isAAC?: boolean;
channelCount?: number;
manifestCodec?: string;
samples: AudioSample[];
}
export interface DemuxedVideoTrack extends DemuxedTrack {
width?: number;
height?: number;
pixelRatio?: [number, number];
audFound?: boolean;
pps?: number[];
sps?: number[];
naluState?: number;
samples: AvcSample[] | Uint8Array;
}
export interface DemuxedAvcTrack extends DemuxedVideoTrack {
samples: AvcSample[];
}
export interface PassthroughVideoTrack extends DemuxedVideoTrack {
samples: Uint8Array;
}
export interface DemuxedMetadataTrack extends DemuxedTrack {
samples: MetadataSample[];
}
export interface DemuxedUserdataTrack extends DemuxedTrack {
samples: UserdataSample[];
}
export interface MetadataSample {
pts: number;
dts: number;
len?: number;
data: Uint8Array;
}
export interface UserdataSample {
pts: number;
bytes: Uint8Array;
}
export interface AvcSample {
dts: number;
pts: number;
key: boolean;
frame: boolean;
units: AvcSampleUnit[];
debug: string;
length: number;
}
export interface AvcSampleUnit {
data: Uint8Array;
type: number;
}
export type AudioSample = {
unit: Uint8Array;
pts: number;
dts: number;
};
export type AppendedAudioFrame = {
sample: AudioSample;
length: number;
};
export interface ElementaryStreamData {
data: Uint8Array[];
size: number;
}
export interface KeyData {
method: string;
key: Uint8Array;
iv: Uint8Array;
}