-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.d.ts
249 lines (234 loc) · 7.22 KB
/
index.d.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
declare type OggMimeType = "application/ogg" | "audio/ogg";
declare type FramedMimeType =
| "audio/mpeg"
| "audio/aac"
| "audio/aacp"
| "audio/flac";
declare type MimeType = FramedMimeType | OggMimeType;
declare type CodecValue = "mpeg" | "aac" | "flac" | "opus" | "vorbis";
declare class MPEGHeader {
public bitDepth: number;
public bitrate: number;
public channels: number;
public sampleRate: number;
public channelMode: string;
public emphasis: string;
public framePadding: number;
public isCopyrighted: boolean;
public isOriginal: boolean;
public isPrivate: boolean;
public layer: string;
public modeExtension: string;
public mpegVersion: string;
public protection: string;
}
declare class AACHeader {
public bitDepth: number;
public bitrate: number;
public channels: number;
public sampleRate: number;
public copyrightId: boolean;
public copyrightIdStart: boolean;
public channelMode: string;
public bufferFullness: string;
public isHome: boolean;
public isOriginal: boolean;
public isPrivate: boolean;
public layer: string;
public length: number;
public mpegVersion: string;
public numberAACFrames: number;
public profile: string;
public protection: string;
}
declare class FLACHeader {
public bitDepth: number;
public bitrate: number;
public channels: number;
public sampleRate: number;
public channelMode: string;
public blockingStrategy: string;
public blockSize: number;
public frameNumber: number;
public crc16: number;
public streamInfo: Uint8Array;
}
declare class OpusHeader {
public bitDepth: number;
public bitrate: number;
public channels: number;
public data: Uint8Array;
public sampleRate: number;
public bandwidth: string;
public channelMappingFamily: number;
public channelMappingTable: number[];
public coupledStreamCount: number;
public streamCount: number;
public channelMode: string;
public frameCount: number;
public frameSize: number;
public inputSampleRate: number;
public mode: string;
public outputGain: number;
public preSkip: number;
}
declare class VorbisHeader {
public bitDepth: number;
public bitrate: number;
public channels: number;
public channelMode: string;
public sampleRate: number;
public bitrateMaximum: number;
public bitrateMinimum: number;
public bitrateNominal: number;
public blocksize0: number;
public blocksize1: number;
public data: Uint8Array;
public vorbisComments: Uint8Array;
public vorbisSetup: Uint8Array;
}
declare type CodecHeader =
| MPEGHeader
| AACHeader
| FLACHeader
| OpusHeader
| VorbisHeader;
declare class CodecFrame {
public data: Uint8Array;
public header: CodecHeader;
public crc32: number;
public samples: number;
public duration: number;
public frameNumber: number;
public totalBytesOut: number;
public totalSamples: number;
public totalDuration: number;
}
declare class OggPage {
public absoluteGranulePosition: number;
public codecFrames: CodecFrame[];
public crc32: number;
public data: Uint8Array;
public duration: number;
public isContinuedPacket: boolean;
public isFirstPage: boolean;
public isLastPage: boolean;
public pageSequenceNumber: number;
public rawData: Uint8Array;
public samples: number;
public streamSerialNumber: number;
public totalBytesOut: number;
public totalDuration: number;
public totalSamples: number;
}
declare interface ICodecParserOptions {
onCodec?: (codec: CodecValue) => any;
onCodecUpdate?: (
codecHeaderData: CodecHeader,
updateTimestamp: number,
) => any;
enableLogging?: boolean;
enableFrameCRC32?: boolean;
}
declare class CodecParser<
T extends CodecFrame | OggPage = CodecFrame | OggPage,
> {
public readonly codec: CodecValue;
constructor(mimeType: MimeType, options?: ICodecParserOptions);
public parseAll(file: Uint8Array): T[];
public parseChunk(chunk: Uint8Array): Iterator<T>;
public flush(): Iterator<T>;
}
export default CodecParser;
export type {
CodecValue,
CodecHeader,
MPEGHeader,
AACHeader,
CodecFrame,
FLACHeader,
ICodecParserOptions,
OggPage,
OpusHeader,
VorbisHeader,
MimeType,
OggMimeType,
FramedMimeType,
};
export const absoluteGranulePosition = "absoluteGranulePosition";
export const bandwidth = "bandwidth";
export const bitDepth = "bitDepth";
export const bitrate = "bitrate";
export const bitrateMaximum = "bitrateMaximum";
export const bitrateMinimum = "bitrateMinimum";
export const bitrateNominal = "bitrateNominal";
export const buffer = "buffer";
export const bufferFullness = "bufferFullness";
export const codec = "codec";
export const codecFrames = "codecFrames";
export const coupledStreamCount = "coupledStreamCount";
export const crc = "crc";
export const crc16 = "crc16";
export const crc32 = "crc32";
export const data = "data";
export const description = "description";
export const duration = "duration";
export const emphasis = "emphasis";
export const hasOpusPadding = "hasOpusPadding";
export const header = "header";
export const isContinuedPacket = "isContinuedPacket";
export const isCopyrighted = "isCopyrighted";
export const isFirstPage = "isFirstPage";
export const isHome = "isHome";
export const isLastPage = "isLastPage";
export const isOriginal = "isOriginal";
export const isPrivate = "isPrivate";
export const isVbr = "isVbr";
export const layer = "layer";
export const length = "length";
export const mode = "mode";
export const modeExtension = "modeExtension";
export const mpeg = "mpeg";
export const mpegVersion = "mpegVersion";
export const numberAACFrames = "numberAACFrames";
export const outputGain = "outputGain";
export const preSkip = "preSkip";
export const profile = "profile";
export const protection = "protection";
export const rawData = "rawData";
export const segments = "segments";
export const subarray = "subarray";
export const version = "version";
export const vorbis = "vorbis";
export const vorbisComments = "vorbisComments";
export const vorbisSetup = "vorbisSetup";
export const blockingStrategy = "blockingStrategy";
export const blockSize = "blockSize";
export const blocksize0 = "blocksize0";
export const blocksize1 = "blocksize1";
export const channelMappingFamily = "channelMappingFamily";
export const channelMappingTable = "channelMappingTable";
export const channelMode = "channelMode";
export const channels = "channels";
export const copyrightId = "copyrightId";
export const copyrightIdStart = "copyrightIdStart";
export const frame = "frame";
export const frameCount = "frameCount";
export const frameLength = "frameLength";
export const frameNumber = "frameNumber";
export const framePadding = "framePadding";
export const frameSize = "frameSize";
export const inputSampleRate = "inputSampleRate";
export const pageChecksum = "pageChecksum";
export const pageSegmentTable = "pageSegmentTable";
export const pageSequenceNumber = "pageSequenceNumber";
export const sampleNumber = "sampleNumber";
export const sampleRate = "sampleRate";
export const samples = "samples";
export const streamCount = "streamCount";
export const streamInfo = "streamInfo";
export const streamSerialNumber = "streamSerialNumber";
export const streamStructureVersion = "streamStructureVersion";
export const totalBytesOut = "totalBytesOut";
export const totalDuration = "totalDuration";
export const totalSamples = "totalSamples";