@vindral/web-sdk 3.4.4 → 4.0.0-100-g47797f66

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