-
Notifications
You must be signed in to change notification settings - Fork 18
/
index.d.ts
100 lines (98 loc) · 2.49 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
declare module 'opusscript' {
/**
* Opus application type
*/
enum OpusApplication {
/**
* Voice Over IP
*/
VOIP = 2048,
/**
* Audio
*/
AUDIO = 2049,
/**
* Restricted Low-Delay
*/
RESTRICTED_LOWDELAY = 2051
}
enum OpusError {
"OK" = 0,
"Bad argument" = -1,
"Buffer too small" = -2,
"Internal error" = -3,
"Invalid packet" = -4,
"Unimplemented" = -5,
"Invalid state" = -6,
"Memory allocation fail" = -7
}
/**
* Valid audio sampling rates
*/
type VALID_SAMPLING_RATES = 8000 | 12000 | 16000 | 24000 | 48000;
/**
* Maximum bytes in a frame
*/
type MAX_FRAME_SIZE = 2880;
/**
* Maximum bytes in a packet
*/
type MAX_PACKET_SIZE = 3828;
/**
* Constructor options for OpusScript
*/
interface OpusScriptOptions {
/**
* Whether or not to use the WASM-compiled version of OpusScript. This is true by default.
*/
wasm?: boolean;
}
class OpusScript {
/**
* Different Opus application types
*/
static Application: typeof OpusApplication;
/**
* Opus Error codes
*/
static Error: typeof OpusError;
/**
* Array of sampling rates that Opus can use
*/
static VALID_SAMPLING_RATES: [8000, 12000, 16000, 24000, 48000];
/**
* The maximum size (in bytes) to send in a packet
*/
static MAX_PACKET_SIZE: MAX_PACKET_SIZE;
/**
* OpusScript options being used
*/
options: OpusScriptOptions;
/**
* Create a new Opus en/decoder
*/
constructor(samplingRate: VALID_SAMPLING_RATES, channels?: number, application?: OpusApplication, options?: OpusScriptOptions);
/**
* Encode a buffer into Opus
*/
encode(buffer: Buffer, frameSize: number): Buffer;
/**
* Decode an opus buffer
*/
decode(buffer: Buffer): Buffer;
/**
* Set the encoder bitrate
*/
setBitrate(bitrate: number): void;
/**
* Encoder/decoder parameters
*/
encoderCTL(ctl: number, arg: number): void;
decoderCTL(ctl: number, arg: number): void;
/**
* Delete the opus object
*/
delete(): void;
}
export = OpusScript;
}