@vindral/web-sdk 3.4.3 → 4.0.0
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/B7jz034g.js +147 -0
- package/BTxJOjm9.js +32 -0
- package/BzSm3HsC.js +312 -0
- package/C291RiDK.js +127 -0
- package/DwDXQwR0.js +6037 -0
- package/README.md +74 -30
- package/api-client.d.ts +151 -0
- package/api-client.js +4 -0
- package/cast-sender.d.ts +396 -0
- package/cast-sender.js +230 -0
- package/core.d.ts +1364 -0
- package/core.js +14 -0
- package/{index.d.ts → legacy.d.ts} +222 -216
- package/legacy.es.js +7724 -0
- package/legacy.umd.js +59 -0
- package/package.json +25 -9
- package/player.d.ts +1583 -0
- package/player.js +3310 -0
- package/style.css +1 -1
- package/vindral-player-component.js +2 -0
- package/index.js +0 -7674
- package/index.umd.cjs +0 -59
package/core.d.ts
ADDED
|
@@ -0,0 +1,1364 @@
|
|
|
1
|
+
type MatchingKeys<TRecord, TMatch, K extends keyof TRecord = keyof TRecord> = K extends (TRecord[K] extends TMatch ? K : never) ? K : never;
|
|
2
|
+
type VoidKeys<Record> = MatchingKeys<Record, void>;
|
|
3
|
+
type EventListenerReturnType = (() => void) | void;
|
|
4
|
+
declare class Emitter<TEvents, TEmits = TEvents, ArgLessEvents extends VoidKeys<TEvents> = VoidKeys<TEvents>, ArgEvents extends Exclude<keyof TEvents, ArgLessEvents> = Exclude<keyof TEvents, ArgLessEvents>, ArgLessEmits extends VoidKeys<TEmits> = VoidKeys<TEmits>, ArgEmits extends Exclude<keyof TEmits, ArgLessEmits> = Exclude<keyof TEmits, ArgLessEmits>> {
|
|
5
|
+
private listeners;
|
|
6
|
+
emit<T extends ArgLessEmits>(eventName: T): void;
|
|
7
|
+
emit<T extends ArgEmits>(eventName: T, args: TEmits[T]): void;
|
|
8
|
+
off<T extends ArgLessEvents>(eventName: T, fn: () => EventListenerReturnType): void;
|
|
9
|
+
off<T extends ArgEvents>(eventName: T, fn: (args: TEvents[T]) => EventListenerReturnType): void;
|
|
10
|
+
/**
|
|
11
|
+
* Add an event listener to `eventName`
|
|
12
|
+
*
|
|
13
|
+
* Event listeners may optionally return a "defer function" that will be called once all other listeners have been called.
|
|
14
|
+
* This is useful when one listener may want everone to have reacted to an event before calling something.
|
|
15
|
+
*/
|
|
16
|
+
on<T extends ArgLessEvents>(eventName: T, fn: () => void): void;
|
|
17
|
+
on<T extends ArgEvents>(eventName: T, fn: (args: TEvents[T]) => void): void;
|
|
18
|
+
/**
|
|
19
|
+
* Add an event listener to `eventName` that will be called once only
|
|
20
|
+
*
|
|
21
|
+
* Event listeners may optionally return a "defer function" that will be called once all other listeners have been called.
|
|
22
|
+
* This is useful when one listener may want everone to have reacted to an event before calling something.
|
|
23
|
+
*/
|
|
24
|
+
once<T extends ArgLessEvents>(eventName: T, fn: () => void): void;
|
|
25
|
+
once<T extends ArgEvents>(eventName: T, fn: (args: TEvents[T]) => void): void;
|
|
26
|
+
reset(): void;
|
|
27
|
+
private add;
|
|
28
|
+
}
|
|
29
|
+
declare const Levels: readonly [
|
|
30
|
+
"off",
|
|
31
|
+
"error",
|
|
32
|
+
"warn",
|
|
33
|
+
"info",
|
|
34
|
+
"debug",
|
|
35
|
+
"trace"
|
|
36
|
+
];
|
|
37
|
+
export type Level = (typeof Levels)[number];
|
|
38
|
+
export declare const Level: {
|
|
39
|
+
ERROR: "error";
|
|
40
|
+
WARN: "warn";
|
|
41
|
+
INFO: "info";
|
|
42
|
+
DEBUG: "debug";
|
|
43
|
+
TRACE: "trace";
|
|
44
|
+
OFF: "off";
|
|
45
|
+
};
|
|
46
|
+
interface MinMaxAverage {
|
|
47
|
+
last: number;
|
|
48
|
+
/**
|
|
49
|
+
* Average value over a given interval.
|
|
50
|
+
*/
|
|
51
|
+
average: number;
|
|
52
|
+
/**
|
|
53
|
+
* Maximum value over a given interval.
|
|
54
|
+
*/
|
|
55
|
+
max: number;
|
|
56
|
+
/**
|
|
57
|
+
* Minimum value over a given interval.
|
|
58
|
+
*/
|
|
59
|
+
min: number;
|
|
60
|
+
}
|
|
61
|
+
type AudioCodec = "aac" | "opus" | "mp3";
|
|
62
|
+
type VideoCodec = "h264" | "av1";
|
|
63
|
+
/**
|
|
64
|
+
* Represents a timed metadata event
|
|
65
|
+
*/
|
|
66
|
+
export interface Metadata {
|
|
67
|
+
/**
|
|
68
|
+
* The raw string content as it was ingested (if using JSON, it needs to be parsed on your end)
|
|
69
|
+
*/
|
|
70
|
+
content: string;
|
|
71
|
+
/**
|
|
72
|
+
* Timestamp in ms
|
|
73
|
+
*/
|
|
74
|
+
timestamp: number;
|
|
75
|
+
}
|
|
76
|
+
export interface TimeRange {
|
|
77
|
+
start: number;
|
|
78
|
+
end: number;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The current reconnect state to use to decide whether to kep reconnecting or not
|
|
82
|
+
*/
|
|
83
|
+
export interface ReconnectState {
|
|
84
|
+
/**
|
|
85
|
+
* The number or retry attempts so far.
|
|
86
|
+
* This gets reset on every successful connect, so it will start from zero every
|
|
87
|
+
* time the client instance gets disconnected and will increment until the
|
|
88
|
+
* client instance makes a connection attempt is successful.
|
|
89
|
+
*/
|
|
90
|
+
reconnectRetries: number;
|
|
91
|
+
}
|
|
92
|
+
interface RenditionProps {
|
|
93
|
+
id: number;
|
|
94
|
+
bitRate: number;
|
|
95
|
+
codecString?: string;
|
|
96
|
+
language?: string;
|
|
97
|
+
meta?: Record<string, string>;
|
|
98
|
+
}
|
|
99
|
+
interface VideoRenditionProps {
|
|
100
|
+
codec: VideoCodec;
|
|
101
|
+
frameRate: [
|
|
102
|
+
number,
|
|
103
|
+
number
|
|
104
|
+
];
|
|
105
|
+
width: number;
|
|
106
|
+
height: number;
|
|
107
|
+
}
|
|
108
|
+
interface AudioRenditionProps {
|
|
109
|
+
codec: AudioCodec;
|
|
110
|
+
channels: number;
|
|
111
|
+
sampleRate: number;
|
|
112
|
+
}
|
|
113
|
+
interface TextRenditionProps {
|
|
114
|
+
codec: "webvtt";
|
|
115
|
+
kind: "subtitles" | "captions";
|
|
116
|
+
label?: string;
|
|
117
|
+
}
|
|
118
|
+
type VideoRendition = VideoRenditionProps & RenditionProps;
|
|
119
|
+
type AudioRendition = AudioRenditionProps & RenditionProps;
|
|
120
|
+
type TextRendition = TextRenditionProps & RenditionProps;
|
|
121
|
+
type Rendition = VideoRendition | AudioRendition | TextRendition;
|
|
122
|
+
interface Size {
|
|
123
|
+
width: number;
|
|
124
|
+
height: number;
|
|
125
|
+
}
|
|
126
|
+
interface VideoConstraint {
|
|
127
|
+
width: number;
|
|
128
|
+
height: number;
|
|
129
|
+
bitRate: number;
|
|
130
|
+
codec?: VideoCodec;
|
|
131
|
+
codecString?: string;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Advanced options to override default behaviour.
|
|
135
|
+
*/
|
|
136
|
+
export interface AdvancedOptions {
|
|
137
|
+
/**
|
|
138
|
+
* Constrains wasm decoding to this resolution.
|
|
139
|
+
* By default it is set to 1280 in width and height.
|
|
140
|
+
* This guarantees better performance on older devices and reduces battery drain in general.
|
|
141
|
+
*/
|
|
142
|
+
wasmDecodingConstraint: Partial<VideoConstraint>;
|
|
143
|
+
}
|
|
144
|
+
type Media = "audio" | "video" | "audio+video";
|
|
145
|
+
/**
|
|
146
|
+
* Options for the Vindral instance
|
|
147
|
+
*
|
|
148
|
+
*/
|
|
149
|
+
export interface Options {
|
|
150
|
+
/**
|
|
151
|
+
* URL to use when connecting to the stream
|
|
152
|
+
*/
|
|
153
|
+
url: string;
|
|
154
|
+
/**
|
|
155
|
+
* Channel ID to connect to initially - can be changed later mid-stream when connected to a channel group.
|
|
156
|
+
*/
|
|
157
|
+
channelId: string;
|
|
158
|
+
/**
|
|
159
|
+
* Channel group to connect to
|
|
160
|
+
* Note: Only needed for fast channel switching
|
|
161
|
+
*/
|
|
162
|
+
channelGroupId?: string;
|
|
163
|
+
/**
|
|
164
|
+
* A container to attach the video view in - can be provided later with .attach() on the vindral core instance
|
|
165
|
+
*/
|
|
166
|
+
container?: HTMLElement;
|
|
167
|
+
/**
|
|
168
|
+
* An authentication token to provide to the server when connecting - only needed for channels with authentication enabled
|
|
169
|
+
* Note: If not supplied when needed, an "Authentication Failed" error will be raised.
|
|
170
|
+
*/
|
|
171
|
+
authenticationToken?: string;
|
|
172
|
+
/**
|
|
173
|
+
* Language to use initially - can be changed during during runtime on the vindral instance
|
|
174
|
+
* Note: Only needed when multiple languages are provided - if no language is specified, one will be automatically selected.
|
|
175
|
+
*/
|
|
176
|
+
language?: string;
|
|
177
|
+
/**
|
|
178
|
+
* TextTrack to use initially - can be changed during during runtime on the vindral instance
|
|
179
|
+
*/
|
|
180
|
+
textTrack?: string;
|
|
181
|
+
/**
|
|
182
|
+
* Sets the log level - defaults to info
|
|
183
|
+
*/
|
|
184
|
+
logLevel?: Level;
|
|
185
|
+
/**
|
|
186
|
+
* Sets the minimum and initial buffer time
|
|
187
|
+
*/
|
|
188
|
+
minBufferTime?: number;
|
|
189
|
+
/**
|
|
190
|
+
* Sets the maximum buffer time allowed. The vindral instance will automatically slowly increase
|
|
191
|
+
* the buffer time if the use experiences to much buffering with the initial buffer time.
|
|
192
|
+
*/
|
|
193
|
+
maxBufferTime?: number;
|
|
194
|
+
/**
|
|
195
|
+
* Enables or disables user bandwidth savings by capping the video resolution to the size of the video element.
|
|
196
|
+
*
|
|
197
|
+
* Is enabled by default.
|
|
198
|
+
*
|
|
199
|
+
* Note: This is automatically set to false when abrEnabled is set to false.
|
|
200
|
+
*/
|
|
201
|
+
sizeBasedResolutionCapEnabled?: boolean;
|
|
202
|
+
/**
|
|
203
|
+
* Enables or disables picture in picture support.
|
|
204
|
+
*/
|
|
205
|
+
pictureInPictureEnabled?: boolean;
|
|
206
|
+
/**
|
|
207
|
+
* Enable bursting for initial connection and channel switches. This makes time to first frame faster at the
|
|
208
|
+
* cost of stability (more demanding due to the sudden burst of live content)
|
|
209
|
+
*
|
|
210
|
+
* Is disabled by default.
|
|
211
|
+
*
|
|
212
|
+
*/
|
|
213
|
+
burstEnabled?: boolean;
|
|
214
|
+
/**
|
|
215
|
+
* Enable usage of the MediaSource API on supported browsers.
|
|
216
|
+
*
|
|
217
|
+
* Is enabled by default.
|
|
218
|
+
*
|
|
219
|
+
* Note: We recommend to keep this at the default value unless you have very specific needs.
|
|
220
|
+
*/
|
|
221
|
+
mseEnabled?: boolean;
|
|
222
|
+
/**
|
|
223
|
+
* Enable Opus with the MediaSource API on supported browsers.
|
|
224
|
+
*
|
|
225
|
+
* Is enabled by default.
|
|
226
|
+
*
|
|
227
|
+
*/
|
|
228
|
+
mseOpusEnabled?: boolean;
|
|
229
|
+
/**
|
|
230
|
+
* Enable or disable support for playing audio in the background for iOS devices.
|
|
231
|
+
*
|
|
232
|
+
* Is false (disabled) by default.
|
|
233
|
+
*
|
|
234
|
+
* Note: This may be enabled by default in a future (major) release
|
|
235
|
+
*/
|
|
236
|
+
iosBackgroundPlayEnabled?: boolean;
|
|
237
|
+
/**
|
|
238
|
+
* Enable or disable Adaptive Bit Rate. This allows for automatically adapting the incoming bit rate based on
|
|
239
|
+
* the viewers bandwidth and thus avoiding buffering events. This also disables the
|
|
240
|
+
* sizeBasedResolutionCapEnabled option.
|
|
241
|
+
*
|
|
242
|
+
* Is enabled by default.
|
|
243
|
+
*
|
|
244
|
+
* Note: It is strongly recommended to keep this enabled as user experience can greatly suffer without ABR.
|
|
245
|
+
*/
|
|
246
|
+
abrEnabled?: boolean;
|
|
247
|
+
/**
|
|
248
|
+
* Enable or disable telemetry. This allows for telemetry and errors being collected.
|
|
249
|
+
*
|
|
250
|
+
* Is enabled by default.
|
|
251
|
+
*
|
|
252
|
+
* We appreciate you turning it off during development/staging to not bloat real telemetry data.
|
|
253
|
+
*
|
|
254
|
+
* Note: It is strongly recommended to keep this enabled in production as it is required for insights and KPIs.
|
|
255
|
+
*/
|
|
256
|
+
telemetryEnabled?: boolean;
|
|
257
|
+
/**
|
|
258
|
+
* Set a cap on the maximum video size.
|
|
259
|
+
* This can be used to provide user options to limit the video bandwidth usage.
|
|
260
|
+
*
|
|
261
|
+
* Note: This takes presedence over any size based resolution caps.
|
|
262
|
+
*/
|
|
263
|
+
maxSize?: Size;
|
|
264
|
+
/**
|
|
265
|
+
* Maximum audio bit rate allowed.
|
|
266
|
+
* This can be used to provide user options to limit the audio bandwidth usage.
|
|
267
|
+
*/
|
|
268
|
+
maxAudioBitRate?: number;
|
|
269
|
+
/**
|
|
270
|
+
* Maximum video bit rate allowed.
|
|
271
|
+
* This can be used to provide user options to limit the video bandwidth usage.
|
|
272
|
+
*/
|
|
273
|
+
maxVideoBitRate?: number;
|
|
274
|
+
/**
|
|
275
|
+
* Controls video element background behaviour while loading.
|
|
276
|
+
* - If `false`, a black background will be shown.
|
|
277
|
+
* - If undefined or `true`, a live thumbnail will be shown.
|
|
278
|
+
* - If set to a string containing a URL (https://urltoimage), use that.
|
|
279
|
+
* Default `true` - meaning a live thumbnail is shown
|
|
280
|
+
*/
|
|
281
|
+
poster?: boolean | string;
|
|
282
|
+
/**
|
|
283
|
+
* Whether to start the player muted or to try to start playing audio automatically.
|
|
284
|
+
*/
|
|
285
|
+
muted?: boolean;
|
|
286
|
+
/**
|
|
287
|
+
* Provide a custom reconnect handler to control when the instance should stop trying to
|
|
288
|
+
* reconnect. The reconnect handler should either return true to allow the reconnect or
|
|
289
|
+
* false to stop reconnecting. It can also return a promise with true or false if it needs
|
|
290
|
+
* to make any async calls before determining wether to reconnect.
|
|
291
|
+
*
|
|
292
|
+
* The default reconnect handler allows 30 reconnects before stopping.
|
|
293
|
+
*
|
|
294
|
+
* Note: the ReconnectState gets reset every time the client instance makes a successful connection.
|
|
295
|
+
* This means the default reconnect handler will only stop reconnecting after 30 _consecutive_ failed connections.
|
|
296
|
+
*
|
|
297
|
+
* ```typescript
|
|
298
|
+
* // An example reconnect handler that will reconnect forever
|
|
299
|
+
* const reconnectHandler = (state: ReconnectState) => true
|
|
300
|
+
*
|
|
301
|
+
* // An example reconnect handler that will fetch an url and determine whether to reconnect
|
|
302
|
+
* const reconnectHandler = async (state: ReconnectState) => {
|
|
303
|
+
* const result = await fetch("https://should-i-reconnect-now.com")
|
|
304
|
+
* return result.ok
|
|
305
|
+
* },
|
|
306
|
+
* ```
|
|
307
|
+
*/
|
|
308
|
+
reconnectHandler?: (state: ReconnectState) => Promise<boolean> | boolean;
|
|
309
|
+
tags?: string[];
|
|
310
|
+
ownerSessionId?: string;
|
|
311
|
+
edgeUrl?: string;
|
|
312
|
+
logShippingEnabled?: boolean;
|
|
313
|
+
statsShippingEnabled?: boolean;
|
|
314
|
+
/**
|
|
315
|
+
* Enable wake lock for iOS devices.
|
|
316
|
+
* The wake lock requires that the audio has been activated at least once for the instance, othwerwise it will not work.
|
|
317
|
+
* Other devices already provide wake lock by default.
|
|
318
|
+
*
|
|
319
|
+
* This option is redundant and has no effect if iosMediaElementEnabled is enabled since that automatically enables wake lock.
|
|
320
|
+
*
|
|
321
|
+
* Disabled by default.
|
|
322
|
+
*/
|
|
323
|
+
iosWakeLockEnabled?: boolean;
|
|
324
|
+
/**
|
|
325
|
+
* Disabling this will revert to legacy behaviour where Vindral will try to always keep the video element playing.
|
|
326
|
+
*/
|
|
327
|
+
pauseSupportEnabled?: boolean;
|
|
328
|
+
/**
|
|
329
|
+
* Enables iOS devices to use a media element for playback. This enables fullscreen and picture in picture support on iOS.
|
|
330
|
+
*/
|
|
331
|
+
iosMediaElementEnabled?: boolean;
|
|
332
|
+
/**
|
|
333
|
+
* Advanced options to override default behaviour.
|
|
334
|
+
*/
|
|
335
|
+
advanced?: AdvancedOptions;
|
|
336
|
+
media?: Media;
|
|
337
|
+
videoCodecs?: VideoCodec[];
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Represents a rendition (quality level).
|
|
341
|
+
*/
|
|
342
|
+
export interface RenditionLevel {
|
|
343
|
+
audio?: AudioRendition;
|
|
344
|
+
video?: VideoRendition;
|
|
345
|
+
}
|
|
346
|
+
type RenditionLevelChangedReason = "abr" | "manual";
|
|
347
|
+
/**
|
|
348
|
+
* Contextual information about the rendition level change.
|
|
349
|
+
*/
|
|
350
|
+
export interface RenditionLevelChanged {
|
|
351
|
+
from?: RenditionLevel;
|
|
352
|
+
to?: RenditionLevel;
|
|
353
|
+
reason: RenditionLevelChangedReason;
|
|
354
|
+
}
|
|
355
|
+
interface Channel {
|
|
356
|
+
/**
|
|
357
|
+
* Channel ID for the channel
|
|
358
|
+
*/
|
|
359
|
+
channelId: string;
|
|
360
|
+
/**
|
|
361
|
+
* Display name
|
|
362
|
+
*/
|
|
363
|
+
name: string;
|
|
364
|
+
/**
|
|
365
|
+
* Indicates whether there is an incoming source feed for the channel
|
|
366
|
+
*/
|
|
367
|
+
isLive: boolean;
|
|
368
|
+
/**
|
|
369
|
+
* URLs to fetch thumbnail from
|
|
370
|
+
*/
|
|
371
|
+
thumbnailUrls: string[];
|
|
372
|
+
}
|
|
373
|
+
interface ClientOverrides {
|
|
374
|
+
maxVideoBitRate?: number;
|
|
375
|
+
minBufferTime?: number;
|
|
376
|
+
maxBufferTime?: number;
|
|
377
|
+
burstEnabled?: boolean;
|
|
378
|
+
sizeBasedResolutionCapEnabled?: boolean;
|
|
379
|
+
separateVideoSocketEnabled?: boolean;
|
|
380
|
+
videoCodecs?: string[];
|
|
381
|
+
}
|
|
382
|
+
interface ChannelWithRenditionsAndOverrides extends Channel {
|
|
383
|
+
renditions: Rendition[];
|
|
384
|
+
overrides?: ClientOverrides;
|
|
385
|
+
}
|
|
386
|
+
interface ConnectOptions {
|
|
387
|
+
channelGroupId?: string;
|
|
388
|
+
channelId: string;
|
|
389
|
+
}
|
|
390
|
+
interface Telemetry {
|
|
391
|
+
url: string;
|
|
392
|
+
probability?: number;
|
|
393
|
+
includeErrors?: boolean;
|
|
394
|
+
includeEvents?: boolean;
|
|
395
|
+
includeStats?: boolean;
|
|
396
|
+
maxRetries?: number;
|
|
397
|
+
maxErrorReports?: number;
|
|
398
|
+
interval?: number;
|
|
399
|
+
}
|
|
400
|
+
interface ConnectResponse {
|
|
401
|
+
logsUrl?: string;
|
|
402
|
+
statsUrl?: string;
|
|
403
|
+
telemetry?: Telemetry;
|
|
404
|
+
channels: ChannelWithRenditionsAndOverrides[];
|
|
405
|
+
edges: string[];
|
|
406
|
+
}
|
|
407
|
+
interface ApiClientOptions {
|
|
408
|
+
/**
|
|
409
|
+
* String representing the URL to the public CDN API.
|
|
410
|
+
*/
|
|
411
|
+
publicEndpoint: string;
|
|
412
|
+
/**
|
|
413
|
+
* Function that should return a string containing a signed authentication token.
|
|
414
|
+
*/
|
|
415
|
+
tokenFactory?: AuthorizationTokenFactory;
|
|
416
|
+
}
|
|
417
|
+
interface AuthorizationContext {
|
|
418
|
+
/**
|
|
419
|
+
* The channelGroupId that might need authorization.
|
|
420
|
+
*/
|
|
421
|
+
channelGroupId?: string;
|
|
422
|
+
/**
|
|
423
|
+
* The channelId that might need authorization.
|
|
424
|
+
*/
|
|
425
|
+
channelId?: string;
|
|
426
|
+
}
|
|
427
|
+
type AuthorizationTokenFactory = (context: AuthorizationContext) => string | undefined;
|
|
428
|
+
declare class ApiClient {
|
|
429
|
+
private baseUrl;
|
|
430
|
+
private tokenFactory?;
|
|
431
|
+
constructor(options: ApiClientOptions);
|
|
432
|
+
/**
|
|
433
|
+
* Returns everything needed to setup the connection of Vindral instance.
|
|
434
|
+
*/
|
|
435
|
+
connect(options: ConnectOptions): Promise<ConnectResponse>;
|
|
436
|
+
/**
|
|
437
|
+
* Fetches information regarding a single channel.
|
|
438
|
+
*
|
|
439
|
+
* @param channelId the channel to fetch
|
|
440
|
+
* @returns a [[Channel]] containing information about the requested channel.
|
|
441
|
+
*/
|
|
442
|
+
getChannel(channelId: string): Promise<Channel>;
|
|
443
|
+
/**
|
|
444
|
+
* Fetches channels within a channel group
|
|
445
|
+
*
|
|
446
|
+
* Note: The returned list includes inactive channels - check isLive to filter out only active channels
|
|
447
|
+
*
|
|
448
|
+
* @param channelGroup the channel group to fetch channels from
|
|
449
|
+
* @returns an array of [[Channel]] that belong to the channel group
|
|
450
|
+
*/
|
|
451
|
+
getChannels(channelGroupId: string): Promise<Channel[]>;
|
|
452
|
+
private getHeaders;
|
|
453
|
+
private getAuthToken;
|
|
454
|
+
private toChannels;
|
|
455
|
+
private toChannel;
|
|
456
|
+
}
|
|
457
|
+
interface VindralErrorProps {
|
|
458
|
+
isFatal: boolean;
|
|
459
|
+
type?: ErrorType;
|
|
460
|
+
code: string;
|
|
461
|
+
source?: Error | MediaError;
|
|
462
|
+
}
|
|
463
|
+
export declare const CONNECTION_FAILED_CODE = "connection_failed";
|
|
464
|
+
export declare const CONNECTION_FAILED_AFTER_RETRIES_CODE = "connection_failed_will_not_attempt_again";
|
|
465
|
+
export declare const AUTHENTICATION_FAILED_CODE = "authentication_error";
|
|
466
|
+
export declare const AUTHENTICATION_EXPIRED_CODE = "authentication_expired";
|
|
467
|
+
export declare const CHANNEL_NOT_FOUND_CODE = "channel_not_found";
|
|
468
|
+
export declare const NO_INCOMING_DATA = "no_incoming_data_error";
|
|
469
|
+
export declare const INACTIVITY_CODE = "connection_inactivity";
|
|
470
|
+
export declare const DISCONNECTED_BY_EDGE = "disconnected_by_edge";
|
|
471
|
+
type ErrorType = "internal" | "external";
|
|
472
|
+
/**
|
|
473
|
+
* Represents a vindral error - all errors emitted from the Vindral instance inherit from this class.
|
|
474
|
+
*/
|
|
475
|
+
export declare class VindralError extends Error {
|
|
476
|
+
private props;
|
|
477
|
+
private extra;
|
|
478
|
+
constructor(message: string, props: VindralErrorProps, extra?: {});
|
|
479
|
+
/**
|
|
480
|
+
* The error code is a stable string that represents the error type - this should be treated as an
|
|
481
|
+
* opaque string that can be used as a key for looking up localized strings for displaying error messages.
|
|
482
|
+
* @returns the error code
|
|
483
|
+
*/
|
|
484
|
+
code: () => string;
|
|
485
|
+
/**
|
|
486
|
+
* Indicates whether the error is fatal - if it is that means the Vindral instance will be unloaded because of this error.
|
|
487
|
+
*/
|
|
488
|
+
isFatal: () => boolean;
|
|
489
|
+
/**
|
|
490
|
+
* The underlying error that caused the Vindral error
|
|
491
|
+
* @returns the underlying error
|
|
492
|
+
*/
|
|
493
|
+
source: () => Error | MediaError | undefined;
|
|
494
|
+
type: () => ErrorType;
|
|
495
|
+
/**
|
|
496
|
+
* @returns a stringifiable represenation of the error
|
|
497
|
+
*/
|
|
498
|
+
toStringifiable: () => Record<string, unknown>;
|
|
499
|
+
}
|
|
500
|
+
type PlaybackState = "buffering" | "playing" | "paused";
|
|
501
|
+
type BufferStateEvent = "filled" | "drained";
|
|
502
|
+
interface PlaybackModuleStatistics {
|
|
503
|
+
/**
|
|
504
|
+
* Current target buffer time if using dynamic buffer. Otherwise, this is the statically set buffer time from instantiation.
|
|
505
|
+
*/
|
|
506
|
+
bufferTime: number;
|
|
507
|
+
needsInputForAudioCount: number;
|
|
508
|
+
needsInputForVideoCount: number;
|
|
509
|
+
}
|
|
510
|
+
interface NeedsUserInputContext {
|
|
511
|
+
/**
|
|
512
|
+
* True if user input is needed for audio
|
|
513
|
+
*/
|
|
514
|
+
forAudio: boolean;
|
|
515
|
+
/**
|
|
516
|
+
* True if user input is needed for video
|
|
517
|
+
*/
|
|
518
|
+
forVideo: boolean;
|
|
519
|
+
}
|
|
520
|
+
type State = "connected" | "disconnected" | "connecting";
|
|
521
|
+
type ContextSwitchState = "completed" | "started";
|
|
522
|
+
interface ConnectionStatistics {
|
|
523
|
+
/**
|
|
524
|
+
* RTT (round trip time) between client and server(s).
|
|
525
|
+
*/
|
|
526
|
+
rtt: MinMaxAverage;
|
|
527
|
+
/**
|
|
528
|
+
* A very rough initial estimation of minimum available bandwidth.
|
|
529
|
+
*/
|
|
530
|
+
estimatedBandwidth: number;
|
|
531
|
+
edgeUrl?: string;
|
|
532
|
+
/**
|
|
533
|
+
* Total number of connections that have been established since instantiation.
|
|
534
|
+
*/
|
|
535
|
+
connectCount: number;
|
|
536
|
+
/**
|
|
537
|
+
* Total number of connection attempts since instantiation.
|
|
538
|
+
*/
|
|
539
|
+
connectionAttemptCount: number;
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Contextual information about the language switch
|
|
543
|
+
*/
|
|
544
|
+
export interface LanguageSwitchContext {
|
|
545
|
+
/**
|
|
546
|
+
* The new language that was switched to
|
|
547
|
+
*/
|
|
548
|
+
language: string;
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* Contextual information about the channel switch
|
|
552
|
+
*/
|
|
553
|
+
export interface ChannelSwitchContext {
|
|
554
|
+
/**
|
|
555
|
+
* The new channel id that was switched to
|
|
556
|
+
*/
|
|
557
|
+
channelId: string;
|
|
558
|
+
}
|
|
559
|
+
interface VolumeState {
|
|
560
|
+
/**
|
|
561
|
+
* Wether the audio is muted
|
|
562
|
+
*/
|
|
563
|
+
isMuted: boolean;
|
|
564
|
+
/**
|
|
565
|
+
* The volume level
|
|
566
|
+
*/
|
|
567
|
+
volume: number;
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* The events that can be emitted from the Vindral instance
|
|
571
|
+
*/
|
|
572
|
+
export interface PublicVindralEvents {
|
|
573
|
+
/**
|
|
574
|
+
* When an error that requires action has occured
|
|
575
|
+
*
|
|
576
|
+
* Can be a fatal error that will unload the Vindral instance - this is indicated by `isFatal()` on the error object returning true.
|
|
577
|
+
*
|
|
578
|
+
* In case of a fatal error it is appropriate to indicate what the error was to the user, either by displaying the error.message or
|
|
579
|
+
* by using the error.code() as a key to look up a localization string. To resume streaming it is required to create a new Vindral instance.
|
|
580
|
+
*/
|
|
581
|
+
["error"]: Readonly<VindralError>;
|
|
582
|
+
/**
|
|
583
|
+
* When the instance needs user input to activate audio or sometimes video playback.
|
|
584
|
+
* Is called with an object
|
|
585
|
+
* ```javascript
|
|
586
|
+
* {
|
|
587
|
+
* forAudio: boolean // true if user input is needed for audio playback
|
|
588
|
+
* forVideo: boolean // true if user input is needed for video playback
|
|
589
|
+
* }
|
|
590
|
+
* ```
|
|
591
|
+
*/
|
|
592
|
+
["needs user input"]: NeedsUserInputContext;
|
|
593
|
+
/**
|
|
594
|
+
* When a timed metadata event has been triggered
|
|
595
|
+
*/
|
|
596
|
+
["metadata"]: Readonly<Metadata>;
|
|
597
|
+
/**
|
|
598
|
+
* When the playback state changes
|
|
599
|
+
*/
|
|
600
|
+
["playback state"]: Readonly<PlaybackState>;
|
|
601
|
+
/**
|
|
602
|
+
* When the connection state changes
|
|
603
|
+
*/
|
|
604
|
+
["connection state"]: Readonly<State>;
|
|
605
|
+
/**
|
|
606
|
+
* When the available rendition levels is changed
|
|
607
|
+
*/
|
|
608
|
+
["rendition levels"]: ReadonlyArray<RenditionLevel>;
|
|
609
|
+
/**
|
|
610
|
+
* When the rendition level is changed
|
|
611
|
+
*/
|
|
612
|
+
["rendition level"]: Readonly<RenditionLevel>;
|
|
613
|
+
/**
|
|
614
|
+
* When the available languages is changed
|
|
615
|
+
*/
|
|
616
|
+
["languages"]: ReadonlyArray<string>;
|
|
617
|
+
/**
|
|
618
|
+
* When the available text tracks are changed
|
|
619
|
+
*/
|
|
620
|
+
["text tracks"]: ReadonlyArray<string>;
|
|
621
|
+
/**
|
|
622
|
+
* When the available channels is changed
|
|
623
|
+
*/
|
|
624
|
+
["channels"]: ReadonlyArray<Channel>;
|
|
625
|
+
/**
|
|
626
|
+
* When a context switch state change has occured.
|
|
627
|
+
* E.g. when a channel change has been requested, or quality is changed.
|
|
628
|
+
*/
|
|
629
|
+
["context switch"]: Readonly<ContextSwitchState>;
|
|
630
|
+
/**
|
|
631
|
+
* Emitted when a wallclock time message has been received from the server.
|
|
632
|
+
*
|
|
633
|
+
* Note: This is the edge server wallclock time and thus may differ slightly
|
|
634
|
+
* between two viewers if they are connected to different edge servers.
|
|
635
|
+
*/
|
|
636
|
+
["server wallclock time"]: Readonly<number>;
|
|
637
|
+
/**
|
|
638
|
+
* Is emitted during connection whether the channel is live or not.
|
|
639
|
+
*
|
|
640
|
+
* If the channel is not live, the Vindral instance will try to reconnect until the `reconnectHandler`
|
|
641
|
+
* determines that no more retries should be made.
|
|
642
|
+
*
|
|
643
|
+
* Note: If the web-sdk is instantiated at the same time as you are starting the stream it is possible
|
|
644
|
+
* that this emits false until the started state has propagated through the system.
|
|
645
|
+
*/
|
|
646
|
+
["is live"]: boolean;
|
|
647
|
+
/**
|
|
648
|
+
* Emitted when a channel switch has been completed and the first frame of the new channel is rendered.
|
|
649
|
+
* A string containing the channel id of the new channel is provided as an argument.
|
|
650
|
+
*/
|
|
651
|
+
["channel switch"]: Readonly<ChannelSwitchContext>;
|
|
652
|
+
/**
|
|
653
|
+
* Emitted when a language switch has been completed and the new language starts playing.
|
|
654
|
+
*/
|
|
655
|
+
["language switch"]: Readonly<LanguageSwitchContext>;
|
|
656
|
+
/**
|
|
657
|
+
* Emitted when the volume state changes.
|
|
658
|
+
*
|
|
659
|
+
* This is triggered triggered both when the user changes the volume through the Vindral instance, but also
|
|
660
|
+
* from external sources such as OS media shortcuts or other native UI outside of the browser.
|
|
661
|
+
*/
|
|
662
|
+
["volume state"]: Readonly<VolumeState>;
|
|
663
|
+
["buffer state event"]: Readonly<BufferStateEvent>;
|
|
664
|
+
["initialized media"]: void;
|
|
665
|
+
}
|
|
666
|
+
declare const defaultOptions: {
|
|
667
|
+
sizeBasedResolutionCapEnabled: boolean;
|
|
668
|
+
pictureInPictureEnabled: boolean;
|
|
669
|
+
abrEnabled: boolean;
|
|
670
|
+
burstEnabled: boolean;
|
|
671
|
+
mseEnabled: boolean;
|
|
672
|
+
mseOpusEnabled: boolean;
|
|
673
|
+
muted: boolean;
|
|
674
|
+
minBufferTime: number;
|
|
675
|
+
maxBufferTime: number;
|
|
676
|
+
logLevel: Level;
|
|
677
|
+
maxSize: Size;
|
|
678
|
+
maxVideoBitRate: number;
|
|
679
|
+
maxAudioBitRate: number;
|
|
680
|
+
tags: string[];
|
|
681
|
+
media: Media;
|
|
682
|
+
poster: string | boolean;
|
|
683
|
+
reconnectHandler: (state: ReconnectState) => Promise<boolean> | boolean;
|
|
684
|
+
iosWakeLockEnabled: boolean;
|
|
685
|
+
telemetryEnabled: boolean;
|
|
686
|
+
iosMediaElementEnabled: boolean;
|
|
687
|
+
pauseSupportEnabled: boolean;
|
|
688
|
+
advanced: {
|
|
689
|
+
wasmDecodingConstraint: Partial<VideoConstraint>;
|
|
690
|
+
};
|
|
691
|
+
videoCodecs: VideoCodec[];
|
|
692
|
+
};
|
|
693
|
+
interface AdaptivityStatistics {
|
|
694
|
+
/**
|
|
695
|
+
* True if adaptive bitrate (ABR) is enabled.
|
|
696
|
+
*/
|
|
697
|
+
isAbrEnabled: boolean;
|
|
698
|
+
}
|
|
699
|
+
interface BufferTimeStatistics {
|
|
700
|
+
/**
|
|
701
|
+
* Number of time buffer time has been adjusted. This will only happen when using dynamic buffer time
|
|
702
|
+
* (different min/max values of bufferTime).
|
|
703
|
+
*/
|
|
704
|
+
bufferTimeAdjustmentCount: number;
|
|
705
|
+
}
|
|
706
|
+
interface RenditionsModuleStatistics {
|
|
707
|
+
/**
|
|
708
|
+
* Id of current video rendition subscribed to.
|
|
709
|
+
*/
|
|
710
|
+
videoRenditionId?: number;
|
|
711
|
+
/**
|
|
712
|
+
* Id of current audio rendition subscribed to.
|
|
713
|
+
*/
|
|
714
|
+
audioRenditionId?: number;
|
|
715
|
+
/**
|
|
716
|
+
* Current video codec being used.
|
|
717
|
+
*/
|
|
718
|
+
videoCodec?: string;
|
|
719
|
+
/**
|
|
720
|
+
* Current audio codec being used.
|
|
721
|
+
*/
|
|
722
|
+
audioCodec?: string;
|
|
723
|
+
/**
|
|
724
|
+
* Width of current video rendition (if any).
|
|
725
|
+
*/
|
|
726
|
+
videoWidth?: number;
|
|
727
|
+
/**
|
|
728
|
+
* Height of current video rendition (if any).
|
|
729
|
+
*/
|
|
730
|
+
videoHeight?: number;
|
|
731
|
+
/**
|
|
732
|
+
* Currently expected video bit rate according to metadata in bits/s.
|
|
733
|
+
*/
|
|
734
|
+
expectedVideoBitRate?: number;
|
|
735
|
+
/**
|
|
736
|
+
* Currently expected audio bit rate according to metadata in bits/s.
|
|
737
|
+
*/
|
|
738
|
+
expectedAudioBitRate?: number;
|
|
739
|
+
/**
|
|
740
|
+
* Current language. For non-multi language streams, this will often be unset.
|
|
741
|
+
*/
|
|
742
|
+
language?: string;
|
|
743
|
+
/**
|
|
744
|
+
* Frame rate. Example: `"frameRate": [24000, 1001]`.
|
|
745
|
+
*/
|
|
746
|
+
frameRate?: [
|
|
747
|
+
number,
|
|
748
|
+
number
|
|
749
|
+
];
|
|
750
|
+
/**
|
|
751
|
+
* Total count of rendition level changes (quality downgrades/upgrades).
|
|
752
|
+
*/
|
|
753
|
+
renditionLevelChangeCount: number;
|
|
754
|
+
}
|
|
755
|
+
interface VideoConstraintCap {
|
|
756
|
+
width: number;
|
|
757
|
+
height: number;
|
|
758
|
+
bitRate: number;
|
|
759
|
+
}
|
|
760
|
+
interface AudioConstraintCap {
|
|
761
|
+
bitRate: number;
|
|
762
|
+
}
|
|
763
|
+
interface ConstraintCap {
|
|
764
|
+
video: VideoConstraintCap;
|
|
765
|
+
audio: AudioConstraintCap;
|
|
766
|
+
}
|
|
767
|
+
interface ConstraintCapStatistics {
|
|
768
|
+
constraintCap?: ConstraintCap;
|
|
769
|
+
windowInnerWidth: number;
|
|
770
|
+
windowInnerHeight: number;
|
|
771
|
+
elementWidth: number;
|
|
772
|
+
elementHeight: number;
|
|
773
|
+
pixelRatio: number;
|
|
774
|
+
}
|
|
775
|
+
interface DecoderStatistics {
|
|
776
|
+
videoDecodeRate: number;
|
|
777
|
+
videoDecodeTime: MinMaxAverage;
|
|
778
|
+
audioDecodeTime: MinMaxAverage;
|
|
779
|
+
videoTransportTime: MinMaxAverage;
|
|
780
|
+
}
|
|
781
|
+
interface DocumentStateModulesStatistics {
|
|
782
|
+
isVisible: boolean;
|
|
783
|
+
isOnline: boolean;
|
|
784
|
+
isVisibleCount: number;
|
|
785
|
+
isHiddenCount: number;
|
|
786
|
+
isOnlineCount: number;
|
|
787
|
+
isOfflineCount: number;
|
|
788
|
+
navigatorRtt?: number;
|
|
789
|
+
navigatorEffectiveType?: EffectiveConnectionType;
|
|
790
|
+
navigatorConnectionType?: ConnectionType;
|
|
791
|
+
navigatorSaveData?: boolean;
|
|
792
|
+
navigatorDownlink?: number;
|
|
793
|
+
}
|
|
794
|
+
interface IncomingDataModuleStatistics {
|
|
795
|
+
/**
|
|
796
|
+
* Current video bitrate in bits/second.
|
|
797
|
+
*/
|
|
798
|
+
videoBitRate?: number;
|
|
799
|
+
/**
|
|
800
|
+
* Current audio bitrate in bits/second.
|
|
801
|
+
*/
|
|
802
|
+
audioBitRate?: number;
|
|
803
|
+
/**
|
|
804
|
+
* Counter of number of bytes received.
|
|
805
|
+
*/
|
|
806
|
+
bytesReceived: number;
|
|
807
|
+
}
|
|
808
|
+
interface MseModuleStatistics {
|
|
809
|
+
quotaErrorCount: number;
|
|
810
|
+
mediaSourceOpenTime: number;
|
|
811
|
+
totalVideoFrames?: number;
|
|
812
|
+
droppedVideoFrames?: number;
|
|
813
|
+
successfulVideoAppendCalls?: number;
|
|
814
|
+
successfulAudioAppendsCalls?: number;
|
|
815
|
+
}
|
|
816
|
+
interface QualityOfServiceModuleStatistics {
|
|
817
|
+
/**
|
|
818
|
+
* Time in milliseconds spent in buffering state. Note that this value will increase while in background if
|
|
819
|
+
* buffering when leaving foreground.
|
|
820
|
+
*/
|
|
821
|
+
timeSpentBuffering: number;
|
|
822
|
+
/**
|
|
823
|
+
* Total number of buffering events since instantiation.
|
|
824
|
+
*/
|
|
825
|
+
bufferingEventsCount: number;
|
|
826
|
+
/**
|
|
827
|
+
* Number of fatal quality of service events.
|
|
828
|
+
*/
|
|
829
|
+
fatalQosCount: number;
|
|
830
|
+
/**
|
|
831
|
+
* Ratio of time being spent on different bitrates.
|
|
832
|
+
* Example: `"timeSpentRatio": { "1160000": 0.2, "2260000": 0.8 }` shows 20% spent on 1.16 Mbps, 80% spent on 2.26 Mbps.
|
|
833
|
+
*/
|
|
834
|
+
timeSpentRatio: {
|
|
835
|
+
[bitRate: string]: number;
|
|
836
|
+
};
|
|
837
|
+
}
|
|
838
|
+
interface SyncModuleStatistics {
|
|
839
|
+
drift: number | undefined;
|
|
840
|
+
driftAdjustmentCount: number;
|
|
841
|
+
timeshiftDriftAdjustmentCount: number;
|
|
842
|
+
seekTime: number;
|
|
843
|
+
}
|
|
844
|
+
interface TelemetryModuleStatistics {
|
|
845
|
+
/**
|
|
846
|
+
* The total amount of errors being spawned. Note that some media errors can trigger
|
|
847
|
+
* thousands of errors for a single client in a few seconds before recovering. Therefore,
|
|
848
|
+
* consider the number of viewers with errors, not just the total amount. Also, consider the median
|
|
849
|
+
* instead of the mean for average calculation.
|
|
850
|
+
*/
|
|
851
|
+
errorCount: number;
|
|
852
|
+
}
|
|
853
|
+
interface VideoPlayerStatistics {
|
|
854
|
+
renderedFrameCount: number;
|
|
855
|
+
rendererDroppedFrameCount: number;
|
|
856
|
+
contextLostCount: number;
|
|
857
|
+
contextRestoredCount: number;
|
|
858
|
+
}
|
|
859
|
+
declare class UserAgentInformation {
|
|
860
|
+
private highEntropyValues?;
|
|
861
|
+
constructor();
|
|
862
|
+
getUserAgentInformation(): {
|
|
863
|
+
locationOrigin: string;
|
|
864
|
+
locationPath: string;
|
|
865
|
+
ancestorOrigins: string[] | undefined;
|
|
866
|
+
hardwareConcurrency: number;
|
|
867
|
+
deviceMemory: number | undefined;
|
|
868
|
+
userAgentLegacy: string;
|
|
869
|
+
ua: {
|
|
870
|
+
browser: {
|
|
871
|
+
brands: string[];
|
|
872
|
+
fullVersionBrands: string[];
|
|
873
|
+
majorVersions: string[];
|
|
874
|
+
};
|
|
875
|
+
device: string;
|
|
876
|
+
os: {
|
|
877
|
+
family: string;
|
|
878
|
+
version: string;
|
|
879
|
+
major_version: number;
|
|
880
|
+
};
|
|
881
|
+
};
|
|
882
|
+
} | {
|
|
883
|
+
locationOrigin: string;
|
|
884
|
+
locationPath: string;
|
|
885
|
+
ancestorOrigins: string[] | undefined;
|
|
886
|
+
hardwareConcurrency: number;
|
|
887
|
+
deviceMemory: number | undefined;
|
|
888
|
+
userAgent: string;
|
|
889
|
+
};
|
|
890
|
+
}
|
|
891
|
+
type ModuleStatistics = AdaptivityStatistics & BufferTimeStatistics & ConnectionStatistics & ConstraintCapStatistics & DecoderStatistics & DocumentStateModulesStatistics & IncomingDataModuleStatistics & MseModuleStatistics & PlaybackModuleStatistics & QualityOfServiceModuleStatistics & RenditionsModuleStatistics & SyncModuleStatistics & TelemetryModuleStatistics & VideoPlayerStatistics;
|
|
892
|
+
/**
|
|
893
|
+
* Contains internal statistics.
|
|
894
|
+
*
|
|
895
|
+
* Note that this object will have some undocumented properties, used internally or temporarily,
|
|
896
|
+
* for monitoring and improving the performance of the service.
|
|
897
|
+
*
|
|
898
|
+
* @interface
|
|
899
|
+
*/
|
|
900
|
+
export type Statistics = ModuleStatistics & ReturnType<UserAgentInformation["getUserAgentInformation"]> & {
|
|
901
|
+
/**
|
|
902
|
+
* Version of the @vindral/web-sdk being used.
|
|
903
|
+
*/
|
|
904
|
+
version: string;
|
|
905
|
+
/**
|
|
906
|
+
* IP of the client.
|
|
907
|
+
*/
|
|
908
|
+
ip?: string;
|
|
909
|
+
/**
|
|
910
|
+
* URL being used for connecting to the stream.
|
|
911
|
+
*/
|
|
912
|
+
url: string;
|
|
913
|
+
/**
|
|
914
|
+
* A session is bound to a connection. If the client reconnects for any reason (e.g. coming back from inactivity
|
|
915
|
+
* or a problem with network on client side), a new sessionId will be used.
|
|
916
|
+
*
|
|
917
|
+
*/
|
|
918
|
+
sessionId?: string;
|
|
919
|
+
/**
|
|
920
|
+
* Unlike `sessionId`, `clientId` will remain the same even after reconnections and represents this unique Vindral instance.
|
|
921
|
+
*/
|
|
922
|
+
clientId: string;
|
|
923
|
+
/**
|
|
924
|
+
* How long in milliseconds since the instance was created.
|
|
925
|
+
*/
|
|
926
|
+
uptime: number;
|
|
927
|
+
/**
|
|
928
|
+
* Current channel ID being subscribed to.
|
|
929
|
+
*/
|
|
930
|
+
channelId: string;
|
|
931
|
+
/**
|
|
932
|
+
* Channel group being subscribed to.
|
|
933
|
+
*/
|
|
934
|
+
channelGroupId?: string;
|
|
935
|
+
/**
|
|
936
|
+
* Time in milliseconds from instantiation to playback of video and audio being started.
|
|
937
|
+
* Note that an actual frame render often happens much quicker, but that is not counted as TTFF.
|
|
938
|
+
*/
|
|
939
|
+
timeToFirstFrame?: number;
|
|
940
|
+
iosMediaElementEnabled?: boolean;
|
|
941
|
+
};
|
|
942
|
+
/**
|
|
943
|
+
* Represents a Vindral client instance
|
|
944
|
+
*
|
|
945
|
+
* The most most essential methods when using the Vindral class are:
|
|
946
|
+
*
|
|
947
|
+
* - connect() - this has to be called to actually start connecting
|
|
948
|
+
* - attach() - to attach the Vindral video view to the DOM so that users can see it
|
|
949
|
+
* - userInput() - to activate audio on browsers that require a user gesture to play audio
|
|
950
|
+
* - unload() - unloads the instance, its very important that this is called when cleaning up the Vindral instance, otherwise background timers may leak.
|
|
951
|
+
*
|
|
952
|
+
* The Vindral instance will emit a variety of events during its lifetime. Use .on("event-name", callback) to listen to these events.
|
|
953
|
+
* See [[PublicVindralEvents]] for the events types that can be emitted.
|
|
954
|
+
*
|
|
955
|
+
* ```typescript
|
|
956
|
+
* // minimal configuration of a Vindral client instance
|
|
957
|
+
* const instance = new Vindral({
|
|
958
|
+
* url: "https://lb.cdn.vindral.com",
|
|
959
|
+
* channelId: "vindral_demo1_ci_099ee1fa-80f3-455e-aa23-3d184e93e04f",
|
|
960
|
+
* })
|
|
961
|
+
*
|
|
962
|
+
* // Will be called when timed metadata is received
|
|
963
|
+
* instance.on("metadata", console.log)
|
|
964
|
+
*
|
|
965
|
+
* // Will be called when a user interaction is needed to activate audio
|
|
966
|
+
* instance.on("needs user input", console.log)
|
|
967
|
+
*
|
|
968
|
+
* // Start connecting to the cdn
|
|
969
|
+
* instance.connect()
|
|
970
|
+
*
|
|
971
|
+
* // Attach the video view to the DOM
|
|
972
|
+
* instance.attach(document.getElementById("root"))
|
|
973
|
+
*
|
|
974
|
+
* // When done with the instance
|
|
975
|
+
* instance.unload()
|
|
976
|
+
* ```
|
|
977
|
+
*/
|
|
978
|
+
export declare class Vindral extends Emitter<PublicVindralEvents> {
|
|
979
|
+
#private;
|
|
980
|
+
private static MAX_POOL_SIZE;
|
|
981
|
+
private static INITIAL_MAX_BIT_RATE;
|
|
982
|
+
private static PING_TIMEOUT;
|
|
983
|
+
private static DISCONNECT_TIMEOUT;
|
|
984
|
+
private static REMOVE_CUE_THRESHOLD;
|
|
985
|
+
/**
|
|
986
|
+
* Picture in picture
|
|
987
|
+
*/
|
|
988
|
+
readonly pictureInPicture: {
|
|
989
|
+
/**
|
|
990
|
+
* Enters picture in picture
|
|
991
|
+
* @returns a promise that resolves if successful
|
|
992
|
+
*/
|
|
993
|
+
enter: () => Promise<void>;
|
|
994
|
+
/**
|
|
995
|
+
* Exits picture in picture
|
|
996
|
+
* @returns a promise that resolves if successful
|
|
997
|
+
*/
|
|
998
|
+
exit: () => Promise<void>;
|
|
999
|
+
/**
|
|
1000
|
+
* returns whether picture in picture is currently active
|
|
1001
|
+
*/
|
|
1002
|
+
isActive: () => boolean;
|
|
1003
|
+
/**
|
|
1004
|
+
* returns whether picture in picture is supported
|
|
1005
|
+
*/
|
|
1006
|
+
isSupported: () => boolean;
|
|
1007
|
+
};
|
|
1008
|
+
private browser;
|
|
1009
|
+
private options;
|
|
1010
|
+
private element;
|
|
1011
|
+
private playbackSource;
|
|
1012
|
+
private emitter;
|
|
1013
|
+
private logger;
|
|
1014
|
+
private modules;
|
|
1015
|
+
private clientIp?;
|
|
1016
|
+
private sessionId?;
|
|
1017
|
+
private clientId;
|
|
1018
|
+
private _channels;
|
|
1019
|
+
private createdAt;
|
|
1020
|
+
private hasCalledConnect;
|
|
1021
|
+
private apiClient;
|
|
1022
|
+
private latestEmittedLanguages;
|
|
1023
|
+
private wakeLock;
|
|
1024
|
+
private cachedEdges;
|
|
1025
|
+
private shiftedEdges;
|
|
1026
|
+
private pool;
|
|
1027
|
+
private userAgentInformation;
|
|
1028
|
+
private sampleProcessingSesssions;
|
|
1029
|
+
private sizes;
|
|
1030
|
+
private isSuspended;
|
|
1031
|
+
private disconnectTimeout;
|
|
1032
|
+
constructor(options: Options);
|
|
1033
|
+
/**
|
|
1034
|
+
* Attaches the video view to a DOM element. The Vindral video view will be sized to fill this element while
|
|
1035
|
+
* maintaining the correct aspect ratio.
|
|
1036
|
+
* @param container the container element to append the video view to. Often a div element.
|
|
1037
|
+
* @returns
|
|
1038
|
+
*/
|
|
1039
|
+
attach: (container: HTMLElement) => void;
|
|
1040
|
+
/**
|
|
1041
|
+
* Set the current volume.
|
|
1042
|
+
* Setting this to 0 is not equivalent to muting the audio.
|
|
1043
|
+
* Setting this to >0 is not equivalent to unmuting the audio.
|
|
1044
|
+
*
|
|
1045
|
+
* Note that setting volume is not allowed on iPadOS and iOS devices.
|
|
1046
|
+
* This is an OS/browser limitation on the video element.
|
|
1047
|
+
*
|
|
1048
|
+
* [Read more about it on Apple docs](https://developer.apple.com/library/archive/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Device-SpecificConsiderations/Device-SpecificConsiderations.html)
|
|
1049
|
+
* for iOS-Specific Considerations. The following section is the important part:
|
|
1050
|
+
* On iOS devices, the audio level is always under the user's physical control. The volume property is not settable in JavaScript. Reading the volume property always returns 1.
|
|
1051
|
+
*/
|
|
1052
|
+
set volume(volume: number);
|
|
1053
|
+
/**
|
|
1054
|
+
* The current volume. Note that if the playback is muted volume can still be set.
|
|
1055
|
+
*/
|
|
1056
|
+
get volume(): number;
|
|
1057
|
+
/**
|
|
1058
|
+
* Set playback to muted/unmuted
|
|
1059
|
+
*/
|
|
1060
|
+
set muted(muted: boolean);
|
|
1061
|
+
/**
|
|
1062
|
+
* Whether the playback is muted or not
|
|
1063
|
+
*/
|
|
1064
|
+
get muted(): boolean;
|
|
1065
|
+
/**
|
|
1066
|
+
* Media (audio | video | audio+video)
|
|
1067
|
+
*/
|
|
1068
|
+
get media(): Media;
|
|
1069
|
+
/**
|
|
1070
|
+
* The current average video bit rate in bits/s
|
|
1071
|
+
*/
|
|
1072
|
+
get videoBitRate(): number;
|
|
1073
|
+
/**
|
|
1074
|
+
* The current average audio bit rate in bits/s
|
|
1075
|
+
*/
|
|
1076
|
+
get audioBitRate(): number;
|
|
1077
|
+
/**
|
|
1078
|
+
* The current connection state
|
|
1079
|
+
*/
|
|
1080
|
+
get connectionState(): Readonly<State>;
|
|
1081
|
+
/**
|
|
1082
|
+
* The current playback state
|
|
1083
|
+
*/
|
|
1084
|
+
get playbackState(): Readonly<PlaybackState>;
|
|
1085
|
+
/**
|
|
1086
|
+
* The current buffer fullness as a floating point value between 0-1, where 1 is full and 0 i empty.
|
|
1087
|
+
*/
|
|
1088
|
+
get bufferFullness(): number;
|
|
1089
|
+
/**
|
|
1090
|
+
* Whether user bandwidth savings by capping the video resolution to the size of the video element is enabled
|
|
1091
|
+
*/
|
|
1092
|
+
get sizeBasedResolutionCapEnabled(): boolean;
|
|
1093
|
+
/**
|
|
1094
|
+
* Enables or disables user bandwidth savings by capping the video resolution to the size of the video element.
|
|
1095
|
+
*/
|
|
1096
|
+
set sizeBasedResolutionCapEnabled(enabled: boolean);
|
|
1097
|
+
/**
|
|
1098
|
+
* Whether ABR is currently enabled
|
|
1099
|
+
*/
|
|
1100
|
+
get abrEnabled(): boolean;
|
|
1101
|
+
/**
|
|
1102
|
+
* Enable or disable ABR
|
|
1103
|
+
*
|
|
1104
|
+
* The client will immediatly stop changing renditon level based on QoS metrics
|
|
1105
|
+
*
|
|
1106
|
+
* Note: It is strongly recommended to keep this enabled as it can severly increase
|
|
1107
|
+
* the number of buffering events for viewers.
|
|
1108
|
+
*/
|
|
1109
|
+
set abrEnabled(enabled: boolean);
|
|
1110
|
+
/**
|
|
1111
|
+
* Estimated live edge time for the current channel
|
|
1112
|
+
*/
|
|
1113
|
+
get serverEdgeTime(): number | undefined;
|
|
1114
|
+
/**
|
|
1115
|
+
* @returns Estimated wallclock time on the edge server in milliseconds
|
|
1116
|
+
*/
|
|
1117
|
+
get serverWallclockTime(): number | undefined;
|
|
1118
|
+
/**
|
|
1119
|
+
* Local current time normalized between all channels in the channel group
|
|
1120
|
+
*/
|
|
1121
|
+
get currentTime(): number;
|
|
1122
|
+
/**
|
|
1123
|
+
* Current time for the channel. This is the actual stream time, passed on from your ingress.
|
|
1124
|
+
* Integer overflow could make this value differ from your encoder timestamps if it has been rolling for more
|
|
1125
|
+
* than 42 days with RTMP as target.
|
|
1126
|
+
*
|
|
1127
|
+
* Note: This is not normalized between channels, thus it can make jumps when switching channels
|
|
1128
|
+
*/
|
|
1129
|
+
get channelCurrentTime(): number;
|
|
1130
|
+
/**
|
|
1131
|
+
* The current target buffer time in milliseconds
|
|
1132
|
+
*/
|
|
1133
|
+
get targetBufferTime(): number;
|
|
1134
|
+
/**
|
|
1135
|
+
* Set the current target buffer time in milliseconds
|
|
1136
|
+
*/
|
|
1137
|
+
set targetBufferTime(bufferTimeMs: number);
|
|
1138
|
+
/**
|
|
1139
|
+
* The estimated playback latency based on target buffer time, the connection rtt and local playback drift
|
|
1140
|
+
*/
|
|
1141
|
+
get playbackLatency(): number | undefined;
|
|
1142
|
+
/**
|
|
1143
|
+
* The estimated utc timestamp (in ms) for the playhead.
|
|
1144
|
+
*/
|
|
1145
|
+
get playbackWallclockTime(): number | undefined;
|
|
1146
|
+
/**
|
|
1147
|
+
* Channels that can be switched between
|
|
1148
|
+
*/
|
|
1149
|
+
get channels(): ReadonlyArray<Channel>;
|
|
1150
|
+
/**
|
|
1151
|
+
* Languages available
|
|
1152
|
+
*/
|
|
1153
|
+
get languages(): ReadonlyArray<string>;
|
|
1154
|
+
/**
|
|
1155
|
+
* The current language
|
|
1156
|
+
*/
|
|
1157
|
+
get language(): string | undefined;
|
|
1158
|
+
/**
|
|
1159
|
+
* Set the current language
|
|
1160
|
+
*/
|
|
1161
|
+
set language(language: string | undefined);
|
|
1162
|
+
/**
|
|
1163
|
+
* Set the active text track
|
|
1164
|
+
*/
|
|
1165
|
+
set textTrack(label: string | undefined);
|
|
1166
|
+
/**
|
|
1167
|
+
* Get the available text tracks
|
|
1168
|
+
*/
|
|
1169
|
+
get textTracks(): string[];
|
|
1170
|
+
/**
|
|
1171
|
+
* Get the active text track
|
|
1172
|
+
*/
|
|
1173
|
+
get textTrack(): string | undefined;
|
|
1174
|
+
/**
|
|
1175
|
+
* The current channelId
|
|
1176
|
+
*/
|
|
1177
|
+
get channelId(): string;
|
|
1178
|
+
/**
|
|
1179
|
+
* Set the current channelId
|
|
1180
|
+
*
|
|
1181
|
+
* Possible channels to set are available from [[channels]]
|
|
1182
|
+
*
|
|
1183
|
+
* Note that the following scenarios are not possible right now:
|
|
1184
|
+
* - switching channel from a channel with audio to a channel without audio (unless audio only mode is active)
|
|
1185
|
+
* - switching channel from a channel with video to a channel without video (unless video only mode is active)
|
|
1186
|
+
*/
|
|
1187
|
+
set channelId(channelId: string);
|
|
1188
|
+
/**
|
|
1189
|
+
* Max size that will be subcribed to
|
|
1190
|
+
*/
|
|
1191
|
+
get maxSize(): Size;
|
|
1192
|
+
/**
|
|
1193
|
+
* Set max size that will be subscribed to
|
|
1194
|
+
*
|
|
1195
|
+
* Note: If ABR is disabled, setting this will make the client instantly subscribe to this size
|
|
1196
|
+
*/
|
|
1197
|
+
set maxSize(size: Size);
|
|
1198
|
+
/**
|
|
1199
|
+
* The max video bit rate that will be subscribed to
|
|
1200
|
+
*
|
|
1201
|
+
* Note: Returns Number.MAX_SAFE_INTEGER if no limits have been set
|
|
1202
|
+
*/
|
|
1203
|
+
get maxVideoBitRate(): number;
|
|
1204
|
+
/**
|
|
1205
|
+
* Set max video bit rate that will be subscribed to
|
|
1206
|
+
*
|
|
1207
|
+
* Note: If ABR is disabled, setting this will make the client instantly subscribe to this bitrate
|
|
1208
|
+
*/
|
|
1209
|
+
set maxVideoBitRate(bitRate: number);
|
|
1210
|
+
/**
|
|
1211
|
+
* The max audio bit rate that will be subscribed to
|
|
1212
|
+
*
|
|
1213
|
+
* Note: Returns Number.MAX_SAFE_INTEGER if no limits have been set
|
|
1214
|
+
*/
|
|
1215
|
+
get maxAudioBitRate(): number;
|
|
1216
|
+
/**
|
|
1217
|
+
* Set max audio bit rate that will be subscribed to
|
|
1218
|
+
*
|
|
1219
|
+
* Note: If ABR is disabled, setting this will make the client instantly subscribe to this bit rate
|
|
1220
|
+
*/
|
|
1221
|
+
set maxAudioBitRate(bitRate: number);
|
|
1222
|
+
/**
|
|
1223
|
+
* The rendition levels available.
|
|
1224
|
+
*/
|
|
1225
|
+
get renditionLevels(): ReadonlyArray<RenditionLevel>;
|
|
1226
|
+
/**
|
|
1227
|
+
* The current rendition level
|
|
1228
|
+
*/
|
|
1229
|
+
get currentRenditionLevel(): Readonly<RenditionLevel> | undefined;
|
|
1230
|
+
/**
|
|
1231
|
+
* The target rendition level that the client is currently switching to
|
|
1232
|
+
*/
|
|
1233
|
+
get targetRenditionLevel(): Readonly<RenditionLevel> | undefined;
|
|
1234
|
+
/**
|
|
1235
|
+
* True if the client is currently switching from one rendition level to another
|
|
1236
|
+
*/
|
|
1237
|
+
get isSwitchingRenditionLevel(): boolean;
|
|
1238
|
+
/**
|
|
1239
|
+
* The time ranges buffered for video.
|
|
1240
|
+
* The ranges are specified in milliseconds.
|
|
1241
|
+
*/
|
|
1242
|
+
get videoBufferedRanges(): ReadonlyArray<TimeRange>;
|
|
1243
|
+
/**
|
|
1244
|
+
* The time ranges buffered for audio.
|
|
1245
|
+
* The ranges are specified in milliseconds.
|
|
1246
|
+
*/
|
|
1247
|
+
get audioBufferedRanges(): ReadonlyArray<TimeRange>;
|
|
1248
|
+
/**
|
|
1249
|
+
* The API client for calls to the public available endpoints of the Vindral Live CDN.
|
|
1250
|
+
*/
|
|
1251
|
+
getApiClient(): ApiClient;
|
|
1252
|
+
get lastBufferEvent(): Readonly<BufferStateEvent>;
|
|
1253
|
+
get activeRatios(): Map<string, number>;
|
|
1254
|
+
get bufferingRatios(): Map<string, number>;
|
|
1255
|
+
get timeSpentBuffering(): number;
|
|
1256
|
+
get timeActive(): number;
|
|
1257
|
+
get mediaElement(): HTMLMediaElement | HTMLCanvasElement;
|
|
1258
|
+
/**
|
|
1259
|
+
* Get active Vindral Options
|
|
1260
|
+
*/
|
|
1261
|
+
getOptions: () => Options & typeof defaultOptions;
|
|
1262
|
+
/**
|
|
1263
|
+
* Get url for fetching thumbnail. Note that fetching thumbnails only works for an active channel.
|
|
1264
|
+
*/
|
|
1265
|
+
getThumbnailUrl: () => string;
|
|
1266
|
+
/**
|
|
1267
|
+
* Update authentication token on an already established and authenticated connection
|
|
1268
|
+
*/
|
|
1269
|
+
updateAuthenticationToken: (token: string) => void;
|
|
1270
|
+
/**
|
|
1271
|
+
* @deprecated since 3.0.0 Use play instead.
|
|
1272
|
+
* Connects to the configured channel and starts streaming
|
|
1273
|
+
*/
|
|
1274
|
+
connect: () => void;
|
|
1275
|
+
private _connect;
|
|
1276
|
+
/**
|
|
1277
|
+
* Get options that can be used for CastSender
|
|
1278
|
+
*/
|
|
1279
|
+
getCastOptions: () => Options;
|
|
1280
|
+
private connectionInfo;
|
|
1281
|
+
private estimateRTT;
|
|
1282
|
+
private connectHandler;
|
|
1283
|
+
private emitLanguagesIfChanged;
|
|
1284
|
+
private updateTextTracks;
|
|
1285
|
+
private cleanupTextTracks;
|
|
1286
|
+
private filterRenditions;
|
|
1287
|
+
/**
|
|
1288
|
+
* Patch the subscription with properties from the channel that isn't known until connection
|
|
1289
|
+
* @param channel Channel with the renditions to patch the subscription based on
|
|
1290
|
+
*/
|
|
1291
|
+
private patchSubscription;
|
|
1292
|
+
private isSupportedVideoCodecProfile;
|
|
1293
|
+
private supportedAudioCodecs;
|
|
1294
|
+
private initializeDecodingModule;
|
|
1295
|
+
/**
|
|
1296
|
+
* Fully unloads the instance. This disconnects the clients and stops any background tasks.
|
|
1297
|
+
* This client instance can not be used after this has been called.
|
|
1298
|
+
*/
|
|
1299
|
+
unload: () => Promise<void>;
|
|
1300
|
+
/**
|
|
1301
|
+
* @deprecated since 3.0.0 Use play instead.
|
|
1302
|
+
*
|
|
1303
|
+
* Activates audio or video on web browsers that require a user gesture to enable media playback.
|
|
1304
|
+
* The Vindral instance will emit a "needs user input" event to indicate when this is needed.
|
|
1305
|
+
* But it is also safe to pre-emptively call this if it is more convenient - such as in cases where
|
|
1306
|
+
* the Vindral instance itself is created in a user input event.
|
|
1307
|
+
*
|
|
1308
|
+
* Requirements: This method needs to be called within an user-input event handler to function properly, such as
|
|
1309
|
+
* an onclick handler.
|
|
1310
|
+
*
|
|
1311
|
+
* Note: Even if you pre-emptively call this it is still recommended to listen to "needs user input"
|
|
1312
|
+
* and handle that event gracefully.
|
|
1313
|
+
*/
|
|
1314
|
+
userInput: () => void;
|
|
1315
|
+
/**
|
|
1316
|
+
* Pauses the stream. Call .play() to resume playback again.
|
|
1317
|
+
*/
|
|
1318
|
+
pause: () => void;
|
|
1319
|
+
private registerDebugInstance;
|
|
1320
|
+
/**
|
|
1321
|
+
*
|
|
1322
|
+
* Start playing the stream.
|
|
1323
|
+
*
|
|
1324
|
+
* This method also activates audio or video on web browsers that require a user gesture to enable media playback.
|
|
1325
|
+
* The Vindral instance will emit a "needs user input" event to indicate when this is needed.
|
|
1326
|
+
* But it is also safe to pre-emptively call this if it is more convenient - such as in cases where
|
|
1327
|
+
* the Vindral instance itself is created in a user input event.
|
|
1328
|
+
*
|
|
1329
|
+
* Note: In most browsers this method needs to be called within an user-input event handler, such as
|
|
1330
|
+
* an onclick handler in order to activate audio. Most implementations call this directly after constructing the Vindral
|
|
1331
|
+
* instance once in order to start playing, and then listen to a user-event in order to allow audio to be activated.
|
|
1332
|
+
*
|
|
1333
|
+
* Note 2: Even if you pre-emptively call this it is still recommended to listen to "needs user input"
|
|
1334
|
+
* and handle that event gracefully.
|
|
1335
|
+
*/
|
|
1336
|
+
play: () => void;
|
|
1337
|
+
/**
|
|
1338
|
+
* How long in milliseconds since the instance was created
|
|
1339
|
+
*/
|
|
1340
|
+
get uptime(): number;
|
|
1341
|
+
/**
|
|
1342
|
+
* This method collects a statistics report from internal modules. While many of the report's properties are documented, the report may also contain undocumented
|
|
1343
|
+
* properties used internally or temporarily for monitoring and improving the performance of the service.
|
|
1344
|
+
*
|
|
1345
|
+
* Use undocumented properties at your own risk.
|
|
1346
|
+
*/
|
|
1347
|
+
getStatistics: () => Statistics;
|
|
1348
|
+
private resetModules;
|
|
1349
|
+
private suspend;
|
|
1350
|
+
private unsuspend;
|
|
1351
|
+
private getRuntimeInfo;
|
|
1352
|
+
private onMediaElementState;
|
|
1353
|
+
private onBufferEvent;
|
|
1354
|
+
/**
|
|
1355
|
+
* Aligns size and bitrate to match a rendition level correctly
|
|
1356
|
+
*/
|
|
1357
|
+
private alignSizeAndBitRate;
|
|
1358
|
+
private get currentSubscription();
|
|
1359
|
+
private get targetSubscription();
|
|
1360
|
+
private timeToFirstFrame;
|
|
1361
|
+
private willUseMediaSource;
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1364
|
+
export {};
|