@vonage/client-sdk-video 0.0.1
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 +63 -0
- package/dist/js/opentok.d.ts +596 -0
- package/dist/js/opentok.js +103374 -0
- package/dist/js/opentok.js.map +1 -0
- package/dist/js/opentok.min.js +40 -0
- package/dist/js/opentok.min.js.map +1 -0
- package/package.json +25 -0
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# OpenTok.js
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/js/%40opentok%2Fclient)
|
|
4
|
+
|
|
5
|
+
The OpenTok.js library lets you use OpenTok-powered video sessions on the web.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
yarn add @opentok/client
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
or
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm install --save @opentok/client
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
### As a module
|
|
22
|
+
|
|
23
|
+
The library is bundled as a standalone UMD module so it is CommonJS compatible.
|
|
24
|
+
|
|
25
|
+
Create your application file `app.js`:
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
const OT = require('@opentok/client');
|
|
29
|
+
const publisher = OT.initPublisher();
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Bundle the application with your favourite bundler. For browserify just run:
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
browserify app.js > bundle.js
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
And include the bundle in your webpage:
|
|
39
|
+
|
|
40
|
+
```html
|
|
41
|
+
<script src="bundle.js"></script>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Source maps can be found in `dist/js/`. Make sure your bundler is configured to include them if you need to generate source maps.
|
|
45
|
+
|
|
46
|
+
### As a global window object
|
|
47
|
+
|
|
48
|
+
Include the `dist/js/opentok.min.js` script in your webpage.
|
|
49
|
+
|
|
50
|
+
Then use the `OT` object exposed in the global scope.
|
|
51
|
+
|
|
52
|
+
```html
|
|
53
|
+
<script src="node_modules/@opentok/client/dist/js/opentok.min.js"></script>
|
|
54
|
+
<script>
|
|
55
|
+
const publisher = OT.initPublisher();
|
|
56
|
+
</script>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
*Note:* OpenTok.js automatically loads CSS and image files from the TokBox CDN when included in a webpage.
|
|
60
|
+
|
|
61
|
+
## Documentation
|
|
62
|
+
|
|
63
|
+
The API reference and tutorials can be found at https://tokbox.com/developer/sdks/js/
|
|
@@ -0,0 +1,596 @@
|
|
|
1
|
+
declare namespace OT {
|
|
2
|
+
type MediaProcessorConnector = {
|
|
3
|
+
setTrack: (track: MediaStreamTrack) => Promise<MediaStreamTrack>;
|
|
4
|
+
destroy: () => Promise<void>;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export type OTError = {
|
|
8
|
+
name: string;
|
|
9
|
+
message: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type Dimensions = {
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type ScreenSharingCapabilityResponse = {
|
|
18
|
+
extensionInstalled?: boolean;
|
|
19
|
+
supported: boolean;
|
|
20
|
+
supportedSources: {
|
|
21
|
+
application?: boolean;
|
|
22
|
+
screen?: boolean;
|
|
23
|
+
window?: boolean;
|
|
24
|
+
};
|
|
25
|
+
extensionRequired?: string;
|
|
26
|
+
extensionRegistered?: boolean;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export function checkScreenSharingCapability(
|
|
30
|
+
callback: (response: ScreenSharingCapabilityResponse) => void
|
|
31
|
+
): void;
|
|
32
|
+
|
|
33
|
+
export function checkSystemRequirements(): number;
|
|
34
|
+
|
|
35
|
+
export type Device = {
|
|
36
|
+
kind: 'audioInput' | 'videoInput';
|
|
37
|
+
deviceId: string;
|
|
38
|
+
label: string;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export type AudioOutputDevice = {
|
|
42
|
+
deviceId: string | null | undefined;
|
|
43
|
+
label: string | null;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export type IceConfig = {
|
|
47
|
+
includeServers: 'all' | 'custom';
|
|
48
|
+
transportPolicy: 'all' | 'relay';
|
|
49
|
+
customServers: Array<{
|
|
50
|
+
urls: string | string[];
|
|
51
|
+
username?: string;
|
|
52
|
+
credential?: string;
|
|
53
|
+
}>;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export function getDevices(
|
|
57
|
+
callback: (error: OTError | undefined, devices?: Device[]) => void
|
|
58
|
+
): void;
|
|
59
|
+
|
|
60
|
+
export function getAudioOutputDevices(): Promise<AudioOutputDevice[]>;
|
|
61
|
+
|
|
62
|
+
export function setProxyUrl(proxyUrl: string): void;
|
|
63
|
+
|
|
64
|
+
export function getSupportedCodecs(): Promise<{ videoEncoders: ('H264' | 'VP8' | 'VP9')[], videoDecoders: ('H264' | 'VP8' | 'VP9')[] }>;
|
|
65
|
+
|
|
66
|
+
export function hasMediaProcessorSupport(): boolean;
|
|
67
|
+
|
|
68
|
+
export function hasEndToEndEncryptionSupport(): boolean;
|
|
69
|
+
|
|
70
|
+
export type WidgetStyle = {
|
|
71
|
+
audioLevelDisplayMode: 'auto' | 'on' | 'off';
|
|
72
|
+
backgroundImageURI: string;
|
|
73
|
+
buttonDisplayMode: 'auto' | 'on' | 'off';
|
|
74
|
+
nameDisplayMode: 'auto' | 'on' | 'off';
|
|
75
|
+
videoDisabledDisplayMode: 'auto' | 'on' | 'off';
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export type WidgetProperties = {
|
|
79
|
+
fitMode?: 'cover' | 'contain';
|
|
80
|
+
insertDefaultUI?: boolean;
|
|
81
|
+
insertMode?: 'replace' | 'after' | 'before' | 'append';
|
|
82
|
+
showControls?: boolean;
|
|
83
|
+
width?: string | number;
|
|
84
|
+
height?: string | number;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export type PublisherStyle = WidgetStyle & {
|
|
88
|
+
archiveStatusDisplayMode: 'auto' | 'off';
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export type GetUserMediaProperties = {
|
|
92
|
+
audioSource?: string | null | boolean | MediaStreamTrack;
|
|
93
|
+
disableAudioProcessing?: boolean;
|
|
94
|
+
echoCancellation?: boolean;
|
|
95
|
+
noiseSuppression?: boolean;
|
|
96
|
+
autoGainControl?: boolean;
|
|
97
|
+
facingMode?: 'user' | 'environment' | 'left' | 'right';
|
|
98
|
+
frameRate?: 30 | 15 | 7 | 1;
|
|
99
|
+
maxResolution?: Dimensions;
|
|
100
|
+
resolution?: (
|
|
101
|
+
'1920x1080' |
|
|
102
|
+
'1280x960' |
|
|
103
|
+
'1280x720' |
|
|
104
|
+
'640x480' |
|
|
105
|
+
'640x360' |
|
|
106
|
+
'320x240' |
|
|
107
|
+
'320x180'
|
|
108
|
+
);
|
|
109
|
+
videoSource?: string | null | boolean | MediaStreamTrack;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export type VideoContentHint = "text" | "detail" | "motion" | "";
|
|
113
|
+
|
|
114
|
+
export type BackgroundBlurFilter = {
|
|
115
|
+
type: 'backgroundBlur';
|
|
116
|
+
blurStrength?: 'low' | 'high';
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export type BackgroundReplacementFilter = {
|
|
120
|
+
type: 'backgroundReplacement';
|
|
121
|
+
backgroundImgUrl: string;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export type VideoFilter = BackgroundBlurFilter | BackgroundReplacementFilter;
|
|
125
|
+
|
|
126
|
+
export type PublisherProperties = WidgetProperties & GetUserMediaProperties & {
|
|
127
|
+
audioBitrate?: number;
|
|
128
|
+
audioFallbackEnabled?: boolean;
|
|
129
|
+
audioFallback?: {
|
|
130
|
+
publisher?: boolean;
|
|
131
|
+
subscriber?: boolean;
|
|
132
|
+
};
|
|
133
|
+
initials?: string;
|
|
134
|
+
mirror?: boolean;
|
|
135
|
+
name?: string;
|
|
136
|
+
publishAudio?: boolean;
|
|
137
|
+
publishVideo?: boolean;
|
|
138
|
+
publishCaptions?: boolean;
|
|
139
|
+
scalableScreenshare?: boolean;
|
|
140
|
+
scalableVideo?: boolean;
|
|
141
|
+
style?: Partial<PublisherStyle>;
|
|
142
|
+
videoContentHint?: VideoContentHint;
|
|
143
|
+
enableDtx?: boolean;
|
|
144
|
+
enableStereo?: boolean;
|
|
145
|
+
videoFilter?: VideoFilter;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
export type SubscriberStyle = WidgetStyle & {
|
|
149
|
+
audioBlockedDisplayMode: 'auto' | 'on' | 'off';
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export type SubscriberProperties = WidgetProperties & {
|
|
153
|
+
audioVolume?: number;
|
|
154
|
+
preferredFrameRate?: number;
|
|
155
|
+
preferredResolution?: Dimensions;
|
|
156
|
+
style?: Partial<SubscriberStyle>;
|
|
157
|
+
subscribeToAudio?: boolean;
|
|
158
|
+
subscribeToVideo?: boolean;
|
|
159
|
+
testNetwork?: boolean;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
export class Connection {
|
|
163
|
+
connectionId: string;
|
|
164
|
+
creationTime: number;
|
|
165
|
+
data: string;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export class Stream {
|
|
169
|
+
connection: Connection;
|
|
170
|
+
creationTime: number;
|
|
171
|
+
frameRate: number;
|
|
172
|
+
hasAudio: boolean;
|
|
173
|
+
hasVideo: boolean;
|
|
174
|
+
initials: string;
|
|
175
|
+
name: string;
|
|
176
|
+
streamId: string;
|
|
177
|
+
videoDimensions: {
|
|
178
|
+
width: number;
|
|
179
|
+
height: number;
|
|
180
|
+
};
|
|
181
|
+
videoType: 'camera' | 'screen' | 'custom' | undefined;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export type Event<Type, Target> = {
|
|
185
|
+
type: Type;
|
|
186
|
+
cancelable: boolean;
|
|
187
|
+
target: Target;
|
|
188
|
+
|
|
189
|
+
isDefaultPrevented(): boolean;
|
|
190
|
+
preventDefault(): void;
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
export type ExceptionEvent = Event<'exception', {}> & {
|
|
194
|
+
code: number;
|
|
195
|
+
message: string;
|
|
196
|
+
title: string;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export type VideoDimensionsChangedEvent<Target> = Event<'videoDimensionsChanged', Target> & {
|
|
200
|
+
oldValue: Dimensions;
|
|
201
|
+
newValue: Dimensions;
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
class OTEventEmitter<EventMap> {
|
|
205
|
+
on<EventName extends keyof EventMap>(
|
|
206
|
+
eventName: EventName,
|
|
207
|
+
callback: (event: EventMap[EventName]) => void,
|
|
208
|
+
context?: object
|
|
209
|
+
): void;
|
|
210
|
+
|
|
211
|
+
on(
|
|
212
|
+
eventName: string,
|
|
213
|
+
callback: (event: Event<string, any>) => void,
|
|
214
|
+
context?: object
|
|
215
|
+
): void;
|
|
216
|
+
|
|
217
|
+
on(
|
|
218
|
+
eventMap: object,
|
|
219
|
+
context?: object
|
|
220
|
+
): void;
|
|
221
|
+
|
|
222
|
+
once<EventName extends keyof EventMap>(
|
|
223
|
+
eventName: EventName,
|
|
224
|
+
callback: (event: EventMap[EventName]) => void,
|
|
225
|
+
context?: object
|
|
226
|
+
): void;
|
|
227
|
+
|
|
228
|
+
once(
|
|
229
|
+
eventName: string,
|
|
230
|
+
callback: (event: Event<string, any>) => void,
|
|
231
|
+
context?: object
|
|
232
|
+
): void;
|
|
233
|
+
|
|
234
|
+
once(
|
|
235
|
+
eventMap: object,
|
|
236
|
+
context?: object
|
|
237
|
+
): void;
|
|
238
|
+
|
|
239
|
+
off<EventName extends keyof EventMap>(
|
|
240
|
+
eventName?: EventName,
|
|
241
|
+
callback?: (event: EventMap[EventName]) => void,
|
|
242
|
+
context?: object
|
|
243
|
+
): void;
|
|
244
|
+
|
|
245
|
+
off(
|
|
246
|
+
eventName?: string,
|
|
247
|
+
callback?: (event: Event<string, any>) => void,
|
|
248
|
+
context?: object
|
|
249
|
+
): void;
|
|
250
|
+
|
|
251
|
+
off(
|
|
252
|
+
eventMap: object,
|
|
253
|
+
context?: object
|
|
254
|
+
): void;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export class Publisher extends OTEventEmitter<{
|
|
258
|
+
accessAllowed: Event<'accessAllowed', Publisher>;
|
|
259
|
+
accessDenied: Event<'accessDenied', Publisher>;
|
|
260
|
+
accessDialogClosed: Event<'accessDialogClosed', Publisher>;
|
|
261
|
+
accessDialogOpened: Event<'accessDialogOpened', Publisher>;
|
|
262
|
+
|
|
263
|
+
audioLevelUpdated: Event<'audioLevelUpdated', Publisher> & {
|
|
264
|
+
audioLevel: number
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
destroyed: Event<'destroyed', Publisher>;
|
|
268
|
+
|
|
269
|
+
mediaStopped: Event<'mediaStopped', Publisher> & {
|
|
270
|
+
track: MediaStreamTrack | undefined
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
streamCreated: Event<'streamCreated', Publisher> & {
|
|
274
|
+
stream: Stream;
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
streamDestroyed: Event<'streamDestroyed', Publisher> & {
|
|
278
|
+
stream: Stream;
|
|
279
|
+
reason: string;
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
videoDimensionsChanged: VideoDimensionsChangedEvent<Publisher>;
|
|
283
|
+
|
|
284
|
+
videoElementCreated: Event<'videoElementCreated', Publisher> & {
|
|
285
|
+
element: HTMLVideoElement | HTMLObjectElement;
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
videoEnabled: Event<'videoEnabled', Publisher> & {
|
|
289
|
+
reason: 'quality';
|
|
290
|
+
};
|
|
291
|
+
videoDisabled: Event<'videoDisabled', Publisher> & {
|
|
292
|
+
reason: 'quality';
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
videoDisableWarning: Event<'videoDisableWarning', Publisher>;
|
|
296
|
+
videoDisableWarningLifted: Event<'videoDisableWarningLifted', Publisher>;
|
|
297
|
+
|
|
298
|
+
muteForced: Event<'muteForced', Publisher>;
|
|
299
|
+
}> {
|
|
300
|
+
accessAllowed: boolean;
|
|
301
|
+
element?: HTMLElement | undefined;
|
|
302
|
+
id?: string;
|
|
303
|
+
stream?: Stream;
|
|
304
|
+
session?: Session;
|
|
305
|
+
|
|
306
|
+
destroy(): void;
|
|
307
|
+
getImgData(): string | null;
|
|
308
|
+
getStats(callback: (error?: OTError, stats?: PublisherStatsArr) => void): void;
|
|
309
|
+
getRtcStatsReport(): Promise<PublisherRtcStatsReportArr>;
|
|
310
|
+
getStyle(): PublisherStyle;
|
|
311
|
+
applyVideoFilter(videoFilter: VideoFilter): Promise<void>;
|
|
312
|
+
getVideoFilter(): VideoFilter | null;
|
|
313
|
+
clearVideoFilter(): Promise<void>;
|
|
314
|
+
publishAudio(value: boolean): void;
|
|
315
|
+
publishVideo(value: boolean): void;
|
|
316
|
+
publishCaptions(value: boolean): void;
|
|
317
|
+
cycleVideo(): Promise<{ deviceId: string }>;
|
|
318
|
+
setAudioSource(audioSource:string | MediaStreamTrack): Promise<undefined>;
|
|
319
|
+
getAudioSource(): MediaStreamTrack;
|
|
320
|
+
setVideoSource(videoSourceId: string): Promise<undefined>;
|
|
321
|
+
getVideoContentHint(): VideoContentHint;
|
|
322
|
+
setVideoContentHint(hint: VideoContentHint): void;
|
|
323
|
+
getVideoSource(): {deviceId: string | null, type: string | null, track: MediaStreamTrack | null};
|
|
324
|
+
setStyle<Style extends keyof PublisherStyle>(style: Style, value: PublisherStyle[Style]): void;
|
|
325
|
+
videoWidth(): number | undefined;
|
|
326
|
+
videoHeight(): number | undefined;
|
|
327
|
+
setVideoMediaProcessorConnector(connector: MediaProcessorConnector | null): Promise<void>;
|
|
328
|
+
setAudioMediaProcessorConnector(connector: MediaProcessorConnector | null): Promise<void>;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export function getUserMedia(
|
|
332
|
+
properties?: GetUserMediaProperties
|
|
333
|
+
): Promise<MediaStream>;
|
|
334
|
+
|
|
335
|
+
export function initPublisher(
|
|
336
|
+
targetElement?: HTMLElement | string,
|
|
337
|
+
properties?: PublisherProperties,
|
|
338
|
+
callback?: (error?: OTError) => void
|
|
339
|
+
): Publisher;
|
|
340
|
+
|
|
341
|
+
export function log(message: string): void;
|
|
342
|
+
|
|
343
|
+
export function off(
|
|
344
|
+
eventName?: 'exception',
|
|
345
|
+
callback?: (event: ExceptionEvent) => void,
|
|
346
|
+
context?: object
|
|
347
|
+
): void;
|
|
348
|
+
|
|
349
|
+
export function on(
|
|
350
|
+
eventName: 'exception',
|
|
351
|
+
callback: (event: ExceptionEvent) => void,
|
|
352
|
+
context?: object
|
|
353
|
+
): void;
|
|
354
|
+
|
|
355
|
+
export function once(
|
|
356
|
+
eventName: 'exception',
|
|
357
|
+
callback: (event: ExceptionEvent) => void,
|
|
358
|
+
context?: object
|
|
359
|
+
): void;
|
|
360
|
+
|
|
361
|
+
export class Session extends OTEventEmitter<{
|
|
362
|
+
archiveStarted: Event<'archiveStarted', Session> & {
|
|
363
|
+
id: string;
|
|
364
|
+
name: string;
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
archiveStopped: Event<'archiveStopped', Session> & {
|
|
368
|
+
id: string;
|
|
369
|
+
name: string;
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
connectionCreated: Event<'connectionCreated', Session> & {
|
|
373
|
+
connection: Connection;
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
connectionDestroyed: Event<'connectionDestroyed', Session> & {
|
|
377
|
+
connection: Connection;
|
|
378
|
+
reason: string;
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
sessionConnected: Event<'sessionConnected', Session>;
|
|
382
|
+
|
|
383
|
+
sessionDisconnected: Event<'sessionDisconnected', Session> & {
|
|
384
|
+
reason: string;
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
sessionReconnected: Event<'sessionReconnected', Session>;
|
|
388
|
+
sessionReconnecting: Event<'sessionReconnecting', Session>;
|
|
389
|
+
|
|
390
|
+
signal: Event<'signal', Session> & {
|
|
391
|
+
type?: string;
|
|
392
|
+
data?: string;
|
|
393
|
+
from: Connection | null;
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
streamCreated: Event<'streamCreated', Session> & {
|
|
397
|
+
stream: Stream;
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
streamDestroyed: Event<'streamDestroyed', Session> & {
|
|
401
|
+
stream: Stream;
|
|
402
|
+
reason: string;
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
streamPropertyChanged: (
|
|
406
|
+
Event<'streamPropertyChanged', Session> & {
|
|
407
|
+
stream: Stream;
|
|
408
|
+
} & (
|
|
409
|
+
{ changedProperty: 'hasAudio'; oldValue: boolean; newValue: boolean; } |
|
|
410
|
+
{ changedProperty: 'hasVideo'; oldValue: boolean; newValue: boolean; } |
|
|
411
|
+
{ changedProperty: 'videoDimensions'; oldValue: Dimensions; newValue: Dimensions; }
|
|
412
|
+
)
|
|
413
|
+
);
|
|
414
|
+
|
|
415
|
+
muteForced: Event<'muteForced', Session>;
|
|
416
|
+
}> {
|
|
417
|
+
capabilities: {
|
|
418
|
+
forceDisconnect: number;
|
|
419
|
+
forceUnpublish: number;
|
|
420
|
+
forceMute: number;
|
|
421
|
+
publish: number;
|
|
422
|
+
subscribe: number;
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
connection?: Connection;
|
|
426
|
+
sessionId: string;
|
|
427
|
+
|
|
428
|
+
connect(token: string, callback: (error?: OTError) => void): void;
|
|
429
|
+
disconnect(): void;
|
|
430
|
+
forceDisconnect(connection: Connection, callback: (error?: OTError) => void): void;
|
|
431
|
+
forceUnpublish(stream: Stream, callback: (error?: OTError) => void): void;
|
|
432
|
+
forceMuteStream(stream: Stream): Promise<void>;
|
|
433
|
+
forceMuteAll(excludedStreams?: Stream[]): Promise<void>;
|
|
434
|
+
getPublisherForStream(stream: Stream): Publisher | undefined;
|
|
435
|
+
getSubscribersForStream(stream: Stream): [Subscriber];
|
|
436
|
+
publish(publisher: Publisher, callback?: (error?: OTError) => void): Publisher;
|
|
437
|
+
publish(targetElement: string | HTMLElement, properties?: PublisherProperties, callback?: (error?: OTError) => void): Publisher;
|
|
438
|
+
setEncryptionSecret(secret: string): Promise<void>;
|
|
439
|
+
setIceConfig(iceConfig: IceConfig): Promise <void>;
|
|
440
|
+
|
|
441
|
+
signal(
|
|
442
|
+
signal: { type?: string, data?: string, to?: Connection },
|
|
443
|
+
callback: (error?: OTError) => void
|
|
444
|
+
): void;
|
|
445
|
+
|
|
446
|
+
subscribe(
|
|
447
|
+
stream: Stream,
|
|
448
|
+
targetElement?: HTMLElement | string,
|
|
449
|
+
properties?: SubscriberProperties,
|
|
450
|
+
callback?: (error?: OTError) => void
|
|
451
|
+
): Subscriber;
|
|
452
|
+
|
|
453
|
+
unpublish(publisher: Publisher): void;
|
|
454
|
+
unsubscribe(subscriber: Subscriber): void;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
export function initSession(
|
|
458
|
+
partnerId: string,
|
|
459
|
+
sessionId: string,
|
|
460
|
+
options?: {
|
|
461
|
+
connectionEventsSuppressed?: boolean;
|
|
462
|
+
iceConfig?: IceConfig;
|
|
463
|
+
ipWhitelist?: boolean;
|
|
464
|
+
encryptionSecret?: string;
|
|
465
|
+
}
|
|
466
|
+
): Session;
|
|
467
|
+
|
|
468
|
+
export type IncomingTrackStats = {
|
|
469
|
+
bytesReceived: number;
|
|
470
|
+
packetsLost: number;
|
|
471
|
+
packetsReceived: number;
|
|
472
|
+
};
|
|
473
|
+
|
|
474
|
+
export type OutgoingTrackStats = {
|
|
475
|
+
bytesSent: number;
|
|
476
|
+
packetsLost: number;
|
|
477
|
+
packetsSent: number;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
export type SubscriberStats = {
|
|
481
|
+
audio: IncomingTrackStats;
|
|
482
|
+
video: IncomingTrackStats & { frameRate: number; };
|
|
483
|
+
timestamp: number;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
export type PublisherStats = {
|
|
487
|
+
audio: OutgoingTrackStats;
|
|
488
|
+
video: OutgoingTrackStats & { frameRate: number; };
|
|
489
|
+
timestamp: number;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
export type PublisherStatContainer = {
|
|
493
|
+
subscriberId?: string,
|
|
494
|
+
connectionId?: string,
|
|
495
|
+
stats: PublisherStats
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
export type PublisherStatsArr = PublisherStatContainer[];
|
|
499
|
+
|
|
500
|
+
export type PublisherRtcStatsReportContainer = {
|
|
501
|
+
subscriberId?: string,
|
|
502
|
+
connectionId?: string,
|
|
503
|
+
rtcStatsReport: RTCStatsReport
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
export type PublisherRtcStatsReportArr = PublisherRtcStatsReportContainer[];
|
|
507
|
+
|
|
508
|
+
export class Subscriber extends OTEventEmitter<{
|
|
509
|
+
audioLevelUpdated: Event<'audioLevelUpdated', Subscriber> & {
|
|
510
|
+
audioLevel: number
|
|
511
|
+
};
|
|
512
|
+
|
|
513
|
+
connected: Event<'connected', Subscriber>;
|
|
514
|
+
|
|
515
|
+
captionReceived: Event<'captionReceived', Subscriber> & {
|
|
516
|
+
streamId: string;
|
|
517
|
+
caption: string;
|
|
518
|
+
isFinal: boolean;
|
|
519
|
+
};
|
|
520
|
+
|
|
521
|
+
destroyed: Event<'destroyed', Subscriber> & {
|
|
522
|
+
reason: string;
|
|
523
|
+
};
|
|
524
|
+
|
|
525
|
+
encryptionSecretMismatch: Event<'encryptionSecretMismatch', Subscriber>;
|
|
526
|
+
|
|
527
|
+
encryptionSecretMatch: Event<'encryptionSecretMatch', Subscriber>;
|
|
528
|
+
|
|
529
|
+
videoDimensionsChanged: VideoDimensionsChangedEvent<Subscriber>;
|
|
530
|
+
|
|
531
|
+
videoDisabled: Event<'videoDisabled', Subscriber> & {
|
|
532
|
+
reason: string;
|
|
533
|
+
};
|
|
534
|
+
|
|
535
|
+
videoDisableWarning: Event<'videoDisableWarning', Subscriber>;
|
|
536
|
+
videoDisableWarningLifted: Event<'videoDisableWarningLifted', Subscriber>;
|
|
537
|
+
|
|
538
|
+
videoElementCreated: Event<'videoElementCreated', Subscriber> & {
|
|
539
|
+
element: HTMLVideoElement | HTMLObjectElement;
|
|
540
|
+
};
|
|
541
|
+
|
|
542
|
+
videoEnabled: Event<'videoEnabled', Subscriber> & {
|
|
543
|
+
reason: string;
|
|
544
|
+
};
|
|
545
|
+
}> {
|
|
546
|
+
element?: HTMLElement;
|
|
547
|
+
id?: string;
|
|
548
|
+
stream?: Stream;
|
|
549
|
+
|
|
550
|
+
getAudioVolume(): number;
|
|
551
|
+
getImgData(): string | null;
|
|
552
|
+
getStats(callback: (error?: OTError, stats?: SubscriberStats) => void): void;
|
|
553
|
+
getRtcStatsReport(): Promise<RTCStatsReport>;
|
|
554
|
+
subscribeToCaptions(value: boolean): Promise<void>;
|
|
555
|
+
isSubscribedToCaptions(): boolean;
|
|
556
|
+
isAudioBlocked(): boolean;
|
|
557
|
+
restrictFrameRate(value: boolean): void;
|
|
558
|
+
setAudioVolume(volume: number): void;
|
|
559
|
+
setPreferredFrameRate(frameRate: number): void;
|
|
560
|
+
setPreferredResolution(resolution: Dimensions): void;
|
|
561
|
+
setAudioMediaProcessorConnector(connector: MediaProcessorConnector | null): Promise<void>;
|
|
562
|
+
setVideoMediaProcessorConnector(connector: MediaProcessorConnector | null): Promise<void>;
|
|
563
|
+
subscribeToAudio(value: boolean): void;
|
|
564
|
+
subscribeToVideo(value: boolean): void;
|
|
565
|
+
|
|
566
|
+
setStyle<Style extends keyof SubscriberStyle>(
|
|
567
|
+
style: Style,
|
|
568
|
+
value: SubscriberStyle[Style]
|
|
569
|
+
): void;
|
|
570
|
+
|
|
571
|
+
videoHeight(): number | undefined;
|
|
572
|
+
videoWidth(): number | undefined;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
export function registerScreenSharingExtension(
|
|
576
|
+
kind: string,
|
|
577
|
+
id: string,
|
|
578
|
+
version: number
|
|
579
|
+
): void;
|
|
580
|
+
|
|
581
|
+
export function reportIssue(callback: (error?: OTError, reportId?: string) => void): void;
|
|
582
|
+
|
|
583
|
+
export function setAudioOutputDevice(deviceId: string): Promise<void>;
|
|
584
|
+
|
|
585
|
+
export function getActiveAudioOutputDevice(): Promise<AudioOutputDevice>;
|
|
586
|
+
|
|
587
|
+
export function setLogLevel(level: number): void;
|
|
588
|
+
|
|
589
|
+
export function upgradeSystemRequirements(): void;
|
|
590
|
+
|
|
591
|
+
export function unblockAudio(): Promise<undefined>;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
declare module "@opentok/client" {
|
|
595
|
+
export = OT;
|
|
596
|
+
}
|