@audc/rtpengine-client 0.5.2 → 0.5.4
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.
- package/README.md +5 -2
- package/index.d.ts +321 -29
- package/lib/constants.js +1 -0
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -51,7 +51,9 @@ client.on('listening', () => {
|
|
|
51
51
|
```
|
|
52
52
|
|
|
53
53
|
## Making requests
|
|
54
|
-
The ng request verbs (`ping`, `offer`, `answer`, `delete`, `query`, `start recording`, `stop recording`,
|
|
54
|
+
The ng request verbs (`ping`, `offer`, `answer`, `delete`, `query`, `start recording`, `stop recording`,
|
|
55
|
+
`pause recording`, `block DTMF`, `unblock DTMF`, `block media`, `unblock media`)
|
|
56
|
+
are available as methods on the `client` object. The sytax for each is the same:
|
|
55
57
|
+ the destination of the request comes first, either as `port, host` or `{port, host}`
|
|
56
58
|
+ following that, if any options are required for the request, those come next in an object.
|
|
57
59
|
|
|
@@ -68,6 +70,7 @@ Function names are as follows:
|
|
|
68
70
|
|query | query |
|
|
69
71
|
|start recording | startRecording |
|
|
70
72
|
|stop recording | stopRecording |
|
|
73
|
+
|pause recording | pauseRecording |
|
|
71
74
|
|block DTMF | blockDTMF |
|
|
72
75
|
|unblock DTMF | unblockDTMF |
|
|
73
76
|
|play DTMF | playDTMF |
|
|
@@ -105,4 +108,4 @@ client.offer({port: 22222, host: '35.195.250.243}, {
|
|
|
105
108
|
'call-id': ..
|
|
106
109
|
'from-tag': ..
|
|
107
110
|
}) // ...etc
|
|
108
|
-
```
|
|
111
|
+
```
|
package/index.d.ts
CHANGED
|
@@ -31,34 +31,326 @@ export interface InternalMessage {
|
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
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
|
-
|
|
34
|
+
export interface HostAndPort {
|
|
35
|
+
host: string;
|
|
36
|
+
port: number;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Basic common types that are reused across messages
|
|
40
|
+
type NgBoolean = 'yes' | 'no' | 'on' | 'off';
|
|
41
|
+
type StringList = string | string[];
|
|
42
|
+
|
|
43
|
+
type MediaFlags = 'initialized' |
|
|
44
|
+
'asymmetric' |
|
|
45
|
+
'send' |
|
|
46
|
+
'recv' |
|
|
47
|
+
'rtcp-mux' |
|
|
48
|
+
'DTLS-SRTP' |
|
|
49
|
+
'DTLS role active' |
|
|
50
|
+
'DTLS role passive' |
|
|
51
|
+
'SDES' |
|
|
52
|
+
'passthrough' |
|
|
53
|
+
'ICE' |
|
|
54
|
+
'trickle ICE' |
|
|
55
|
+
'ICE controlling' |
|
|
56
|
+
'ICE-lite peer' |
|
|
57
|
+
'ICE-lite self' |
|
|
58
|
+
'unidirectional' |
|
|
59
|
+
'loop check' |
|
|
60
|
+
'generator/sink' |
|
|
61
|
+
'ptime-override' |
|
|
62
|
+
'RTCP feedback' |
|
|
63
|
+
'RTCP generator' |
|
|
64
|
+
'echo' |
|
|
65
|
+
'blackhole' |
|
|
66
|
+
'SDES reordered' |
|
|
67
|
+
'audio player' |
|
|
68
|
+
'legacy OSRTP' |
|
|
69
|
+
'reverse legacy OSRTP' |
|
|
70
|
+
'transcoding' |
|
|
71
|
+
'block egress';
|
|
72
|
+
|
|
73
|
+
interface PingResult {
|
|
74
|
+
result: 'pong'
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
interface BaseArgs {
|
|
78
|
+
flags?: StringList;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface OfferArgs extends BaseArgs {
|
|
82
|
+
sdp: string;
|
|
83
|
+
'call-id': string;
|
|
84
|
+
'from-tag': string;
|
|
85
|
+
all?: 'none' | 'all' | 'offer-answer' | 'except-offer-answer' | 'flows';
|
|
86
|
+
'address family'?: 'IP4' | 'IP6';
|
|
87
|
+
'audio player'?: 'default' | 'transcoding' | 'off' | 'always';
|
|
88
|
+
'delay-buffer'?: number;
|
|
89
|
+
'direction'?: StringList;
|
|
90
|
+
digit?: 'string';
|
|
91
|
+
'drop-traffic'?: 'start' | 'stop';
|
|
92
|
+
DTLS?: 'off' | 'no' | 'disable' | 'passive' | 'active';
|
|
93
|
+
'DTLS-reverse'?: 'passive' | 'active';
|
|
94
|
+
'DTLS-fingerprint'?: 'SHA-1' | 'SHA-224' | 'SHA-256' | 'SHA-384' | 'SHA-512';
|
|
95
|
+
'DTMF-security'?: 'drop' | 'silence' | 'tone' | 'random' | 'zero' | 'off';
|
|
96
|
+
'DTMF-security-trigger'?: string;
|
|
97
|
+
'DTMF-security-trigger-end'?: string;
|
|
98
|
+
'DTMF-delay'?: number;
|
|
99
|
+
'DTMF-log-dest'?: string;
|
|
100
|
+
'endpoint-learning'?: 'off' | 'immediate' | 'delayed' | 'heuristic';
|
|
101
|
+
'from-interface'?: string;
|
|
102
|
+
'frequencies'?: number | number[];
|
|
103
|
+
'frequency'?: number | number[];
|
|
104
|
+
'from-tags'?: StringList;
|
|
105
|
+
'generate RTCP'?: 'on' | 'off';
|
|
106
|
+
'ICE'?: 'remove' | 'force' | 'default' | 'force-relay' | 'optional';
|
|
107
|
+
'ICE-lite'?: 'forward' | 'backward' | 'both' | 'off';
|
|
108
|
+
'interface'?: string;
|
|
109
|
+
'label'?: string;
|
|
110
|
+
'from-label'?: string;
|
|
111
|
+
'media address'?: string;
|
|
112
|
+
'media echo'?: 'blackhole' | 'sinkhole' | 'forward' | 'backwards' | 'both';
|
|
113
|
+
'media-echo'?: 'blackhole' | 'sinkhole' | 'forward' | 'backwards' | 'both';
|
|
114
|
+
'metadata'?: string;
|
|
115
|
+
'OSRTP'?: 'offer' | 'offer-RFC' | 'offer-legacy' | 'accept-RFC' | 'accept-legacy' | 'accept';
|
|
116
|
+
'output-destination'?: string;
|
|
117
|
+
'ptime'?: number;
|
|
118
|
+
'ptime-reverse'?: number;
|
|
119
|
+
'received from'?: ['IP4' | 'IP6', string];
|
|
120
|
+
'record call'?: 'yes' | 'no' | 'on' | 'off';
|
|
121
|
+
'rtcp-mux'?: ('offer' | 'require' | 'demux' | 'accept' | 'reject')[];
|
|
122
|
+
'SIP message type'?: 'SIP request' | 'SIP response';
|
|
123
|
+
'SIP code'?: number;
|
|
124
|
+
'template'?: string;
|
|
125
|
+
'via-branch'?: string;
|
|
126
|
+
'set-label'?: string;
|
|
127
|
+
'SDES'?: StringList;
|
|
128
|
+
'supports'?: StringList;
|
|
129
|
+
'to-interface'?: string;
|
|
130
|
+
'to-label'?: string;
|
|
131
|
+
'TOS'?: number;
|
|
132
|
+
'transport protocol'?: 'RTP/AVP' | 'RTP/AVPF' | 'RTP/SAVP' | 'RTP/SAVPF' | 'accept';
|
|
133
|
+
'trigger'?: string;
|
|
134
|
+
'trigger-end'?: string;
|
|
135
|
+
'end trigger'?: string;
|
|
136
|
+
'trigger-end-time'?: number;
|
|
137
|
+
'trigger-end-digits'?: number;
|
|
138
|
+
'T.38'?: ('decode' | 'force' | 'stop' | 'no-ECM' | 'no-V.17' | 'no-V.27ter' | 'no-V.29' | 'no-V.34' | 'no-IAF' | 'FEC')[];
|
|
139
|
+
volume?: number;
|
|
140
|
+
'xmlrpc-callback'?: string;
|
|
141
|
+
replace?: ('force-increment-sdp-ver' | 'origin' | 'origin-full' | 'session-name' | 'SDP-version' | 'username' | 'zero-address')[];
|
|
142
|
+
codec?: Record<string, unknown>;
|
|
143
|
+
'sdp-attr'?: Record<string, unknown>;
|
|
144
|
+
'sdp-media-remove'?: StringList;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Answer specific parameters
|
|
148
|
+
export interface AnswerArgs extends Omit<OfferArgs, 'direction'> {
|
|
149
|
+
'to-tag'?: string;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
interface BaseResponse {
|
|
153
|
+
result: 'ok' | 'error' | 'load limit';
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export interface OfferResponse extends BaseResponse {
|
|
157
|
+
sdp: string;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Delete parameters (as you provided)
|
|
161
|
+
export interface DeleteArgs extends BaseArgs {
|
|
162
|
+
'call-id': string;
|
|
163
|
+
'from-tag': string;
|
|
164
|
+
'to-tag'?: string;
|
|
165
|
+
'via-branch'?: string;
|
|
166
|
+
fatal?: boolean;
|
|
167
|
+
'delete-delay'?: number;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Query parameters
|
|
171
|
+
export interface QueryArgs extends BaseArgs {
|
|
172
|
+
'call-id': string;
|
|
173
|
+
'from-tag'?: string;
|
|
174
|
+
'to-tag'?: string;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
interface StreamEndpoint {
|
|
178
|
+
family: 'IPv4' | 'IPv6';
|
|
179
|
+
address: string;
|
|
180
|
+
port: number;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
type StreamFlag = 'RTP' |
|
|
184
|
+
'RTCP' |
|
|
185
|
+
'fallback RTCP' |
|
|
186
|
+
'filled' |
|
|
187
|
+
'confirmed' |
|
|
188
|
+
'kernelized' |
|
|
189
|
+
'no kernel support' |
|
|
190
|
+
'DTLS fingerprint verified' |
|
|
191
|
+
'strict source address' |
|
|
192
|
+
'media handover' |
|
|
193
|
+
'ICE';
|
|
194
|
+
|
|
195
|
+
interface CallStats {
|
|
196
|
+
created: number;
|
|
197
|
+
tag: string;
|
|
198
|
+
label: string;
|
|
199
|
+
'in dialogue with': string;
|
|
200
|
+
medias: {
|
|
201
|
+
index: number;
|
|
202
|
+
type: string;
|
|
203
|
+
protocol?: string;
|
|
204
|
+
flags: MediaFlags[];
|
|
205
|
+
streams: {
|
|
206
|
+
'local port'?: number;
|
|
207
|
+
'local address'?: string;
|
|
208
|
+
family?: string;
|
|
209
|
+
endpoint?: StreamEndpoint;
|
|
210
|
+
'advertised endpoint'?: StreamEndpoint;
|
|
211
|
+
'crypto suite'?: 'string';
|
|
212
|
+
'last packet': number;
|
|
213
|
+
'last kernel packet': number;
|
|
214
|
+
'last user packet': number;
|
|
215
|
+
flags: StreamFlag[];
|
|
216
|
+
stats: {
|
|
217
|
+
bytes: number;
|
|
218
|
+
packets: number;
|
|
219
|
+
errors: number;
|
|
220
|
+
}
|
|
221
|
+
}[]
|
|
222
|
+
}[]
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export interface QueryResponse extends BaseResponse {
|
|
226
|
+
created: number;
|
|
227
|
+
'last signal': number;
|
|
228
|
+
tags: Record<string, CallStats>;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// List parameters
|
|
232
|
+
export interface ListArgs {
|
|
233
|
+
limit?: number;
|
|
234
|
+
'call-id'?: string;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export interface ListResponse extends BaseResponse {
|
|
238
|
+
calls: string[];
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export interface StopRecordingArgs extends BaseArgs {
|
|
242
|
+
'call-id': string;
|
|
243
|
+
'from-tag'?: string;
|
|
244
|
+
'to-tag'?: string;
|
|
245
|
+
'via-branch'?: string;
|
|
246
|
+
metadata?: string;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// Start recording parameters
|
|
250
|
+
export interface StartRecordingArgs extends StopRecordingArgs {
|
|
251
|
+
'recording-file'?: string;
|
|
252
|
+
'recording-dir'?: string;
|
|
253
|
+
'recording-pattern'?: string;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export interface MediaOpArgs extends BaseArgs {
|
|
257
|
+
'call-id': string;
|
|
258
|
+
'from-tag'?: string;
|
|
259
|
+
address?: string;
|
|
260
|
+
label?: string;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// Play Media parameters
|
|
264
|
+
export interface PlayMediaArgs extends MediaOpArgs {
|
|
265
|
+
file?: string;
|
|
266
|
+
blob?: string;
|
|
267
|
+
'db-id'?: number;
|
|
268
|
+
'repeat-times'?: number;
|
|
269
|
+
'repeat-duration'?: number;
|
|
270
|
+
'start-pos'?: number;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export interface PlayMediaResponse extends BaseResponse {
|
|
274
|
+
duration?: number;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// Stop Media parameters
|
|
278
|
+
export interface StopMediaResponse extends BaseResponse {
|
|
279
|
+
'last-frame-pos': number;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
type DTMFDigit = number | '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' |
|
|
283
|
+
'*' | '#' | 'A' | 'B' | 'C' | 'D';
|
|
284
|
+
|
|
285
|
+
export interface PlayDTMFArgs extends MediaOpArgs {
|
|
286
|
+
code?: DTMFDigit;
|
|
287
|
+
digit?: DTMFDigit;
|
|
288
|
+
duration?: number;
|
|
289
|
+
volume?: number;
|
|
290
|
+
pause?: number;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export interface StatisticsResponse extends BaseResponse {
|
|
294
|
+
statistics: Record<string, unknown>;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
type MediaMode = 'sendrecv' | 'sendonly' | 'recvonly' | 'inactive';
|
|
298
|
+
|
|
299
|
+
interface TagLabel {
|
|
300
|
+
tag: string;
|
|
301
|
+
index: number;
|
|
302
|
+
type: string;
|
|
303
|
+
label?: string;
|
|
304
|
+
mode: MediaMode;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
interface SubscribeRequest {
|
|
308
|
+
sdp: string;
|
|
309
|
+
'from-tag'?: string;
|
|
310
|
+
'to-tag': string;
|
|
311
|
+
'from-tags'?: string[];
|
|
312
|
+
'tag-medias'?: Record<string, unknown>[];
|
|
313
|
+
'tag-labels'?: Record<string, TagLabel>;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export type SubscribeRequestResponse = SubscribeRequest & BaseResponse;
|
|
317
|
+
export type SubscribeAnswerArgs = SubscribeRequest & BaseArgs;
|
|
318
|
+
|
|
319
|
+
export interface UnsubscribeArgs extends BaseArgs {
|
|
320
|
+
'call-id': string;
|
|
321
|
+
'to-tag': string;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// Generic base class with a fixed optional `opts` argument
|
|
325
|
+
declare class CommandHandler<Args extends unknown[]> extends EventEmitter {
|
|
326
|
+
answer(...args: [...Args, opts: AnswerArgs]): Promise<OfferResponse>;
|
|
327
|
+
delete(...args: [...Args, opts: DeleteArgs]): Promise<QueryResponse>;
|
|
328
|
+
list(...args: [...Args, opts?: ListArgs]): Promise<ListResponse>;
|
|
329
|
+
offer(...args: [...Args, opts: OfferArgs]): Promise<OfferResponse>;
|
|
330
|
+
ping(...args: [...Args]): Promise<PingResult>;
|
|
331
|
+
query(...args: [...Args, opts: QueryArgs]): Promise<QueryResponse>;
|
|
332
|
+
startRecording(...args: [...Args, opts: StartRecordingArgs]): Promise<BaseResponse>;
|
|
333
|
+
stopRecording(...args: [...Args, opts: StopRecordingArgs]): Promise<BaseResponse>;
|
|
334
|
+
pauseRecording(...args: [...Args, opts: StopRecordingArgs]): Promise<BaseResponse>;
|
|
335
|
+
blockDTMF(...args: [...Args, opts: MediaOpArgs]): Promise<BaseResponse>;
|
|
336
|
+
unblockDTMF(...args: [...Args, opts: MediaOpArgs]): Promise<BaseResponse>;
|
|
337
|
+
blockMedia(...args: [...Args, opts: MediaOpArgs]): Promise<BaseResponse>;
|
|
338
|
+
unblockMedia(...args: [...Args, opts: MediaOpArgs]): Promise<BaseResponse>;
|
|
339
|
+
silenceMedia(...args: [...Args, opts: MediaOpArgs]): Promise<BaseResponse>;
|
|
340
|
+
unsilenceMedia(...args: [...Args, opts: MediaOpArgs]): Promise<BaseResponse>;
|
|
341
|
+
startForwarding(...args: [...Args, opts: MediaOpArgs]): Promise<BaseResponse>;
|
|
342
|
+
stopForwarding(...args: [...Args, opts: MediaOpArgs]): Promise<BaseResponse>;
|
|
343
|
+
playMedia(...args: [...Args, opts: PlayMediaArgs]): Promise<PlayMediaResponse>;
|
|
344
|
+
stopMedia(...args: [...Args, opts: MediaOpArgs]): Promise<StopMediaResponse>;
|
|
345
|
+
playDTMF(...args: [...Args, opts: PlayDTMFArgs]): Promise<BaseResponse>;
|
|
346
|
+
statistics(...args: [...Args]): Promise<StatisticsResponse>;
|
|
347
|
+
publish(...args: [...Args, opts: OfferArgs]): Promise<OfferResponse>;
|
|
348
|
+
subscribeRequest(...args: [...Args, opts: MediaOpArgs]): Promise<SubscribeRequestResponse>;
|
|
349
|
+
subscribeAnswer(...args: [...Args, opts: SubscribeAnswerArgs]): Promise<BaseResponse>;
|
|
350
|
+
unsubscribe(...args: [...Args, opts: UnsubscribeArgs]): Promise<BaseResponse>;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
declare class BaseClient<Args extends unknown[] = []> extends CommandHandler<Args> {
|
|
62
354
|
messages: Map<string, (err?: any) => void>;
|
|
63
355
|
|
|
64
356
|
constructor(options: BaseClientOptions);
|
|
@@ -68,7 +360,7 @@ declare class BaseClient extends CommandHandler {
|
|
|
68
360
|
static encodeMessage(id: string, data: any): string;
|
|
69
361
|
}
|
|
70
362
|
|
|
71
|
-
export class Client extends BaseClient {
|
|
363
|
+
export class Client extends BaseClient<[remote: HostAndPort] | [port: number, host: string]> {
|
|
72
364
|
constructor(options: ClientOptions);
|
|
73
365
|
constructor(port?: number, host?: string);
|
|
74
366
|
declare socket: UdpSocket;
|
package/lib/constants.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@audc/rtpengine-client",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"description": "node client for rtpengine daemon",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -16,28 +16,28 @@
|
|
|
16
16
|
"lib/"
|
|
17
17
|
],
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@eslint/js": "^9.
|
|
19
|
+
"@eslint/js": "^9.39.2",
|
|
20
20
|
"@types/bencode": "^2.0.4",
|
|
21
21
|
"@types/tape": "^5.8.1",
|
|
22
|
-
"@types/ws": "^8.
|
|
22
|
+
"@types/ws": "^8.18.1",
|
|
23
23
|
"c8": "^10.1.3",
|
|
24
|
-
"debug": "^4.4.
|
|
25
|
-
"eslint": "^9.
|
|
24
|
+
"debug": "^4.4.3",
|
|
25
|
+
"eslint": "^9.39.2",
|
|
26
26
|
"eslint-plugin-promise": "^7.2.1",
|
|
27
|
-
"globals": "^
|
|
28
|
-
"sinon": "^
|
|
27
|
+
"globals": "^17.0.0",
|
|
28
|
+
"sinon": "^21.0.1",
|
|
29
29
|
"tape": "^5.9.0"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"bencode": "^2.0.3",
|
|
33
33
|
"uuid-random": "^1.3.2",
|
|
34
|
-
"ws": "^8.
|
|
34
|
+
"ws": "^8.19.0"
|
|
35
35
|
},
|
|
36
36
|
"keywords": [
|
|
37
37
|
"rtpengine"
|
|
38
38
|
],
|
|
39
39
|
"repository": {
|
|
40
40
|
"type": "git",
|
|
41
|
-
"url": "https://github.com/
|
|
41
|
+
"url": "https://github.com/audiocodes/rtpengine-client"
|
|
42
42
|
}
|
|
43
43
|
}
|