1
+ declare global {
2
+ const jQuery : any
3
+ }
4
+
1
5
declare namespace JanusJS {
2
6
interface Dependencies {
3
7
adapter : any ;
4
8
WebSocket : ( server : string , protocol : string ) => WebSocket ;
5
9
isArray : ( array : any ) => array is Array < any > ;
6
- extension : ( ) => boolean ;
7
- httpAPICall : ( url : string , options : any ) => void ;
10
+ extension : ChromeExtension ;
11
+ httpAPICall : ( url : string , options : HttpApiCallOption ) => void ;
12
+ }
13
+
14
+ interface DefaultDependencies extends Dependencies {
15
+ fetch : typeof fetch ;
16
+ Promise : PromiseConstructorLike ;
17
+ }
18
+
19
+ interface OldDependencies extends Dependencies {
20
+ jQuery : typeof jQuery ;
8
21
}
9
22
10
23
interface DependenciesResult {
11
24
adapter : any ;
12
25
newWebSocket : ( server : string , protocol : string ) => WebSocket ;
13
26
isArray : ( array : any ) => array is Array < any > ;
14
- extension : ( ) => boolean ;
15
- httpAPICall : ( url : string , options : any ) => void ;
27
+ extension : ChromeExtension ;
28
+ httpAPICall : ( url : string , options : HttpApiCallOption ) => void ;
29
+ }
30
+
31
+ type ChromeExtension = {
32
+ cache ?: { [ key in string ] : GetScreenCallback } ,
33
+ extensionId : string ;
34
+ isInstalled : ( ) => boolean ;
35
+ getScreen : ( callback : GetScreenCallback ) => void ;
36
+ init : ( ) => void ;
37
+ }
38
+
39
+ type GetScreenCallback = ( error ?, sourceId ?) => void
40
+
41
+ type HttpApiCallOption = {
42
+ async : boolean ,
43
+ verb : string ,
44
+ body : JanusRequest ,
45
+ timeout : number ,
46
+ withCredentials : boolean ,
47
+ success : ( result : unknown ) => void ,
48
+ error : ( error : string , reason ?: unknown ) => void ,
49
+ }
50
+
51
+ type JanusRequest = {
52
+ plugin ?: string ,
53
+ token ?: string ,
54
+ apisecret ?: string ,
55
+ session_id ?: number ,
56
+ handle_id ?: number ,
57
+ opaque_id ?: string ,
58
+ loop_index ?: number ,
59
+ janus : string ,
60
+ transaction : string ,
61
+ body ?: any ,
62
+ jsep ?: JSEP ,
16
63
}
17
64
18
65
enum DebugLevel {
19
66
Trace = 'trace' ,
67
+ vDebug = 'vdebug' ,
20
68
Debug = 'debug' ,
21
69
Log = 'log' ,
22
70
Warning = 'warn' ,
23
- Error = 'error'
71
+ Error = 'error' ,
24
72
}
25
73
26
74
interface JSEP {
27
- ee2e ?: boolean ;
75
+ e2ee ?: boolean ;
28
76
sdp ?: string ;
29
77
type ?: string ;
30
78
rid_order ?: "hml" | "lmh" ;
@@ -49,6 +97,10 @@ declare namespace JanusJS {
49
97
success ?: Function ;
50
98
error ?: ( error : any ) => void ;
51
99
destroyed ?: Function ;
100
+ iceTransportPolicy ?: RTCIceTransportPolicy ;
101
+ bundlePolicy ?: RTCBundlePolicy ;
102
+ keepAlivePeriod ?: number ;
103
+ longPollTimeout ?: number ;
52
104
}
53
105
54
106
interface ReconnectOptions {
@@ -110,9 +162,19 @@ declare namespace JanusJS {
110
162
interface PluginOptions extends PluginCallbacks {
111
163
plugin : string ;
112
164
opaqueId ?: string ;
165
+ token ?: string ;
166
+ loopIndex ?: number ;
113
167
}
114
168
115
169
interface OfferParams {
170
+ tracks ?: TrackOption [ ] ;
171
+ trickle ?: boolean ;
172
+ iceRestart ?: boolean ;
173
+ success ?: ( jsep : JSEP ) => void ;
174
+ error ?: ( error : Error ) => void ;
175
+ customizeSdp ?: ( jsep : JSEP ) => void ;
176
+
177
+ /** @deprecated use tracks instead */
116
178
media ?: {
117
179
audioSend ?: boolean ;
118
180
audioRecv ?: boolean ;
@@ -133,10 +195,6 @@ declare namespace JanusJS {
133
195
failIfNoVideo ?: boolean ;
134
196
screenshareFrameRate ?: number ;
135
197
} ;
136
- trickle ?: boolean ;
137
- stream ?: MediaStream ;
138
- success : Function ;
139
- error : ( error : any ) => void ;
140
198
}
141
199
142
200
interface PluginMessage {
@@ -158,10 +216,10 @@ declare namespace JanusJS {
158
216
tsnow : string | null ;
159
217
value : string | null ;
160
218
} ;
161
- dataChannel : Array < RTCDataChannel > ;
219
+ dataChannel : { [ key in string ] : RTCDataChannel } ;
162
220
dataChannelOptions : RTCDataChannelInit ;
163
221
164
- dtmfSender : string | null ;
222
+ dtmfSender : RTCDTMFSender
165
223
iceDone : boolean ;
166
224
mediaConstraints : any ;
167
225
mySdp : {
@@ -187,12 +245,91 @@ declare namespace JanusJS {
187
245
value : number ;
188
246
timer : number ;
189
247
} ;
248
+
249
+ sdpSent : boolean ,
250
+ insertableStreams ?: any ,
251
+ candidates : RTCIceCandidateInit [ ] ,
252
+ }
253
+
254
+ type PluginCreateAnswerParam = {
255
+ jsep : JSEP ;
256
+ tracks ?: TrackOption [ ] ;
257
+
258
+ /** @deprecated use tracks instead */
259
+ media ?: { audioSend : any , videoSend : any } ;
260
+ success ?: ( data : JSEP ) => void ;
261
+ error ?: ( error : string ) => void ;
262
+ }
263
+
264
+ type PluginHandleRemoteJsepParam = {
265
+ jsep : JSEP ;
266
+ success ?: ( data : JSEP ) => void ;
267
+ error ?: ( error : string ) => void ;
268
+ }
269
+
270
+ type PluginReplaceTracksParam = {
271
+ tracks : TrackOption [ ] ;
272
+ success ?: ( data : unknown ) => void ;
273
+ error ?: ( error : string ) => void ;
274
+ }
275
+
276
+ type TrackOption = {
277
+ add ?: boolean ;
278
+ replace ?: boolean ;
279
+ remove ?: boolean ;
280
+ type : 'video' | 'screen' | 'audio' | 'data' ;
281
+ mid ?: string ;
282
+ capture : boolean | MediaStreamTrack ;
283
+ recv ?: boolean ;
284
+ group ?: 'default' | string ;
285
+ gumGroup ?: TrackOption [ 'group' ] ;
286
+ simulcast ?: boolean ;
287
+ svc ?: string ;
288
+ simulcastMaxBitrates ?: {
289
+ low : number ;
290
+ medium : number ;
291
+ high : number ;
292
+ } ;
293
+ sendEncodings ?: RTCRtpEncodingParameters ;
294
+ framerate ?: number ;
295
+ bitrate ?: number ;
296
+ dontStop ?: boolean ;
297
+ transforms ?: {
298
+ sender : ReadableWritablePair ;
299
+ receiver : ReadableWritablePair ;
300
+ } ;
301
+ }
302
+
303
+ type PluginDtmfParam = {
304
+ dtmf : Dtmf ;
305
+ success ?: ( data : unknown ) => void ;
306
+ error ?: ( error : string ) => void ;
307
+ }
308
+
309
+ type Dtmf = {
310
+ tones : string ;
311
+ duration : number ;
312
+ gap : number ;
313
+ }
314
+
315
+ type PluginDataParam = {
316
+ success ?: ( data : unknown ) => void ;
317
+ error ?: ( error : string ) => void ;
318
+ }
319
+
320
+ type TrackDesc = {
321
+ mid ?: string
322
+ type ?: string
323
+ id ?: string
324
+ label ?: string
190
325
}
326
+
191
327
interface DetachOptions {
192
328
success ?: ( ) => void ;
193
329
error ?: ( error : string ) => void ;
194
330
noRequest ?: boolean ;
195
331
}
332
+
196
333
interface PluginHandle {
197
334
plugin : string ;
198
335
id : string ;
@@ -201,28 +338,35 @@ declare namespace JanusJS {
201
338
webrtcStuff : WebRTCInfo ;
202
339
getId ( ) : string ;
203
340
getPlugin ( ) : string ;
204
- send ( message : PluginMessage ) : void ;
205
- createOffer ( params : OfferParams ) : void ;
206
- createAnswer ( params : any ) : void ;
207
- handleRemoteJsep ( params : { jsep : JSEP } ) : void ;
208
- dtmf ( params : any ) : void ;
209
- data ( params : any ) : void ;
341
+ getVolume ( mid : string , callback : ( result : number ) => void ) : void ;
342
+ getRemoteVolume ( mid : string , callback : ( result : number ) => void ) : void ;
343
+ getLocalVolume ( mid : string , callback : ( result : number ) => void ) : void ;
210
344
isAudioMuted ( ) : boolean ;
211
345
muteAudio ( ) : void ;
212
346
unmuteAudio ( ) : void ;
213
347
isVideoMuted ( ) : boolean ;
214
348
muteVideo ( ) : void ;
215
349
unmuteVideo ( ) : void ;
216
350
getBitrate ( ) : string ;
351
+ setMaxBitrate ( bitrate : number ) : void ;
352
+ send ( message : PluginMessage ) : void ;
353
+ data ( params : PluginDataParam ) : void ;
354
+ dtmf ( params : PluginDtmfParam ) : void ;
355
+ createOffer ( params : OfferParams ) : void ;
356
+ createAnswer ( params : PluginCreateAnswerParam ) : void ;
357
+ handleRemoteJsep ( params : PluginHandleRemoteJsepParam ) : void ;
358
+ replaceTracks ( params : PluginReplaceTracksParam ) : void ;
359
+ getLocalTracks ( ) : TrackDesc [ ] ;
360
+ getRemoteTracks ( ) : TrackDesc [ ] ;
217
361
hangup ( sendRequest ?: boolean ) : void ;
218
362
detach ( params ?: DetachOptions ) : void ;
219
363
}
220
364
221
365
class Janus {
222
366
static webRTCAdapter : any ;
223
367
static safariVp8 : boolean ;
224
- static useDefaultDependencies ( deps : Partial < Dependencies > ) : DependenciesResult ;
225
- static useOldDependencies ( deps : Partial < Dependencies > ) : DependenciesResult ;
368
+ static useDefaultDependencies ( deps ? : Partial < DefaultDependencies > ) : DependenciesResult ;
369
+ static useOldDependencies ( deps ? : Partial < OldDependencies > ) : DependenciesResult ;
226
370
static init ( options : InitOptions ) : void ;
227
371
static isWebrtcSupported ( ) : boolean ;
228
372
static debug ( ...args : any [ ] ) : void ;
0 commit comments