@vindral/web-sdk 4.0.0 → 4.1.0-1-g31205a30

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/legacy.d.ts CHANGED
@@ -1,3 +1,50 @@
1
+ /**
2
+ * Channel
3
+ */
4
+ export interface Channel {
5
+ /**
6
+ * Channel ID for the channel
7
+ */
8
+ channelId: string;
9
+ /**
10
+ * Display name
11
+ */
12
+ name: string;
13
+ /**
14
+ * Indicates whether there is an incoming source feed for the channel
15
+ */
16
+ isLive: boolean;
17
+ /**
18
+ * URLs to fetch thumbnail from
19
+ */
20
+ thumbnailUrls: string[];
21
+ }
22
+ interface ClientOverrides {
23
+ maxVideoBitRate?: number;
24
+ minBufferTime?: number;
25
+ maxBufferTime?: number;
26
+ burstEnabled?: boolean;
27
+ sizeBasedResolutionCapEnabled?: boolean;
28
+ separateVideoSocketEnabled?: boolean;
29
+ videoCodecs?: string[];
30
+ }
31
+ export type AudioCodec = "aac" | "opus" | "mp3";
32
+ export type VideoCodec = "h264" | "av1";
33
+ interface MinMaxAverage {
34
+ last: number;
35
+ /**
36
+ * Average value over a given interval.
37
+ */
38
+ average: number;
39
+ /**
40
+ * Maximum value over a given interval.
41
+ */
42
+ max: number;
43
+ /**
44
+ * Minimum value over a given interval.
45
+ */
46
+ min: number;
47
+ }
1
48
  type MatchingKeys<TRecord, TMatch, K extends keyof TRecord = keyof TRecord> = K extends (TRecord[K] extends TMatch ? K : never) ? K : never;
2
49
  type VoidKeys<Record> = MatchingKeys<Record, void>;
3
50
  type EventListenerReturnType = (() => void) | void;
@@ -5,6 +52,9 @@ declare class Emitter<TEvents, TEmits = TEvents, ArgLessEvents extends VoidKeys<
5
52
  private listeners;
6
53
  emit<T extends ArgLessEmits>(eventName: T): void;
7
54
  emit<T extends ArgEmits>(eventName: T, args: TEmits[T]): void;
55
+ /**
56
+ * Remove an event listener from `eventName`
57
+ */
8
58
  off<T extends ArgLessEvents>(eventName: T, fn: () => EventListenerReturnType): void;
9
59
  off<T extends ArgEvents>(eventName: T, fn: (args: TEvents[T]) => EventListenerReturnType): void;
10
60
  /**
@@ -23,10 +73,13 @@ declare class Emitter<TEvents, TEmits = TEvents, ArgLessEvents extends VoidKeys<
23
73
  */
24
74
  once<T extends ArgLessEvents>(eventName: T, fn: () => void): void;
25
75
  once<T extends ArgEvents>(eventName: T, fn: (args: TEvents[T]) => void): void;
76
+ /**
77
+ * Reset the event emitter
78
+ */
26
79
  reset(): void;
27
80
  private add;
28
81
  }
29
- declare const Levels: readonly [
82
+ declare const LogLevels: readonly [
30
83
  "off",
31
84
  "error",
32
85
  "warn",
@@ -34,8 +87,8 @@ declare const Levels: readonly [
34
87
  "debug",
35
88
  "trace"
36
89
  ];
37
- export type Level = (typeof Levels)[number];
38
- export declare const Level: {
90
+ type LogLevel = (typeof LogLevels)[number];
91
+ declare const LogLevel: {
39
92
  ERROR: "error";
40
93
  WARN: "warn";
41
94
  INFO: "info";
@@ -43,71 +96,81 @@ export declare const Level: {
43
96
  TRACE: "trace";
44
97
  OFF: "off";
45
98
  };
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;
99
+ declare const tags: unique symbol;
100
+ type Tagged<BaseType, Tag extends PropertyKey> = BaseType & {
101
+ [tags]: {
102
+ [K in Tag]: void;
103
+ };
104
+ };
105
+ type Namespace = Tagged<Array<string>, "Namespace">;
106
+ interface TrackObject {
107
+ namespace?: Namespace;
108
+ name: string;
109
+ format: string;
110
+ label?: string;
111
+ renderGroup?: number;
112
+ altGroup?: number;
113
+ initData?: string;
114
+ initTrack?: string;
115
+ depends?: Array<string>;
116
+ temporalId?: number;
117
+ spatialId?: number;
118
+ codec?: string;
119
+ mimeType?: string;
120
+ framerate?: [
121
+ number,
122
+ number
123
+ ];
124
+ bitrate?: number;
125
+ width?: number;
126
+ height?: number;
127
+ samplerate?: number;
128
+ channelConfig?: string;
129
+ displayWidth?: number;
130
+ displayHeight?: number;
131
+ language?: string;
132
+ ["com.vindral.variant_uid"]?: string;
133
+ ["com.vindral.drm"]?: string;
75
134
  }
76
- export interface TimeRange {
77
- start: number;
78
- end: number;
135
+ interface CatalogRoot {
136
+ version: number;
137
+ streamingFormat?: number;
138
+ streamingFormatVersion?: string;
79
139
  }
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;
140
+ interface TracksCatalog extends CatalogRoot {
141
+ namespace: Namespace;
142
+ tracks: Array<TrackObject>;
91
143
  }
92
144
  interface RenditionProps {
93
145
  id: number;
146
+ /** */
94
147
  bitRate: number;
148
+ /** */
95
149
  codecString?: string;
150
+ /** */
96
151
  language?: string;
152
+ /** */
97
153
  meta?: Record<string, string>;
98
154
  }
99
155
  interface VideoRenditionProps {
156
+ /** */
100
157
  codec: VideoCodec;
158
+ /** */
101
159
  frameRate: [
102
160
  number,
103
161
  number
104
162
  ];
163
+ /** */
105
164
  width: number;
165
+ /** */
106
166
  height: number;
107
167
  }
108
168
  interface AudioRenditionProps {
169
+ /** */
109
170
  codec: AudioCodec;
171
+ /** */
110
172
  channels: number;
173
+ /** */
111
174
  sampleRate: number;
112
175
  }
113
176
  interface TextRenditionProps {
@@ -115,19 +178,110 @@ interface TextRenditionProps {
115
178
  kind: "subtitles" | "captions";
116
179
  label?: string;
117
180
  }
118
- type VideoRendition = VideoRenditionProps & RenditionProps;
119
- type AudioRendition = AudioRenditionProps & RenditionProps;
181
+ /**
182
+ * @interface
183
+ */
184
+ export type VideoRendition = VideoRenditionProps & RenditionProps;
185
+ /**
186
+ * @interface
187
+ */
188
+ export type AudioRendition = AudioRenditionProps & RenditionProps;
120
189
  type TextRendition = TextRenditionProps & RenditionProps;
121
190
  type Rendition = VideoRendition | AudioRendition | TextRendition;
122
- interface Size {
191
+ interface Telemetry {
192
+ url: string;
193
+ probability?: number;
194
+ includeErrors?: boolean;
195
+ includeEvents?: boolean;
196
+ includeStats?: boolean;
197
+ maxRetries?: number;
198
+ maxErrorReports?: number;
199
+ interval?: number;
200
+ }
201
+ interface ChannelWithCatalog extends Channel {
202
+ catalog: TracksCatalog;
203
+ renditions: Rendition[];
204
+ overrides?: ClientOverrides;
205
+ }
206
+ interface ChannelWithRenditions extends Channel {
207
+ renditions: Rendition[];
208
+ overrides?: ClientOverrides;
209
+ }
210
+ interface ServerCertificateHash {
211
+ algorithm: string;
212
+ value: string;
213
+ }
214
+ interface Edge {
215
+ moqUrl?: string;
216
+ moqWsUrl: string;
217
+ serverCertificateHashes?: ServerCertificateHash[];
218
+ }
219
+ interface MoQConnectInfo {
220
+ logsUrl?: string;
221
+ statsUrl?: string;
222
+ telemetry?: Telemetry;
223
+ channels: ChannelWithCatalog[];
224
+ edges: Edge[];
225
+ }
226
+ interface VindralConnectInfo {
227
+ logsUrl?: string;
228
+ statsUrl?: string;
229
+ telemetry?: Telemetry;
230
+ channels: ChannelWithRenditions[];
231
+ edges: string[];
232
+ }
233
+ export type ConnectInfo = VindralConnectInfo | MoQConnectInfo;
234
+ /**
235
+ * Represents a timed metadata event
236
+ */
237
+ export interface Metadata {
238
+ /**
239
+ * The raw string content as it was ingested (if using JSON, it needs to be parsed on your end)
240
+ */
241
+ content: string;
242
+ /**
243
+ * Timestamp in ms
244
+ */
245
+ timestamp: number;
246
+ }
247
+ /** */
248
+ export interface TimeRange {
249
+ /** */
250
+ start: number;
251
+ /** */
252
+ end: number;
253
+ }
254
+ /**
255
+ * The current reconnect state to use to decide whether to kep reconnecting or not
256
+ */
257
+ export interface ReconnectState {
258
+ /**
259
+ * The number or retry attempts so far.
260
+ * This gets reset on every successful connect, so it will start from zero every
261
+ * time the client instance gets disconnected and will increment until the
262
+ * client instance makes a connection attempt is successful.
263
+ */
264
+ reconnectRetries: number;
265
+ }
266
+ /**
267
+ * Represents a size with a width and height.
268
+ */
269
+ export interface Size {
270
+ /** */
123
271
  width: number;
272
+ /** */
124
273
  height: number;
125
274
  }
126
- interface VideoConstraint {
275
+ export interface VideoConstraint {
276
+ /** */
127
277
  width: number;
278
+ /** */
128
279
  height: number;
280
+ /** */
129
281
  bitRate: number;
282
+ /** */
130
283
  codec?: VideoCodec;
284
+ /** */
131
285
  codecString?: string;
132
286
  }
133
287
  /**
@@ -141,7 +295,23 @@ export interface AdvancedOptions {
141
295
  */
142
296
  wasmDecodingConstraint: Partial<VideoConstraint>;
143
297
  }
144
- type Media = "audio" | "video" | "audio+video";
298
+ /**
299
+ * DRM options to provide to the Vindral instance
300
+ */
301
+ export interface DrmOptions {
302
+ /**
303
+ * Headers to be added to requests to license servers
304
+ */
305
+ headers?: Record<string, string>;
306
+ /**
307
+ * Query parameters to be added to requests to license servers
308
+ */
309
+ queryParams?: Record<string, string>;
310
+ }
311
+ /**
312
+ * Type of media.
313
+ */
314
+ export type Media = "audio" | "video" | "audio+video";
145
315
  /**
146
316
  * Options for the Vindral instance
147
317
  *
@@ -181,7 +351,7 @@ export interface Options {
181
351
  /**
182
352
  * Sets the log level - defaults to info
183
353
  */
184
- logLevel?: Level;
354
+ logLevel?: LogLevel;
185
355
  /**
186
356
  * Sets the minimum and initial buffer time
187
357
  */
@@ -311,6 +481,7 @@ export interface Options {
311
481
  edgeUrl?: string;
312
482
  logShippingEnabled?: boolean;
313
483
  statsShippingEnabled?: boolean;
484
+ webtransportEnabled?: boolean;
314
485
  /**
315
486
  * Enable wake lock for iOS devices.
316
487
  * The wake lock requires that the audio has been activated at least once for the instance, othwerwise it will not work.
@@ -335,140 +506,35 @@ export interface Options {
335
506
  advanced?: AdvancedOptions;
336
507
  media?: Media;
337
508
  videoCodecs?: VideoCodec[];
509
+ /**
510
+ * DRM options to provide to the Vindral instance
511
+ */
512
+ drm?: DrmOptions;
338
513
  }
339
514
  /**
340
515
  * Represents a rendition (quality level).
341
516
  */
342
517
  export interface RenditionLevel {
518
+ /** */
343
519
  audio?: AudioRendition;
520
+ /** */
344
521
  video?: VideoRendition;
345
522
  }
346
- type RenditionLevelChangedReason = "abr" | "manual";
523
+ /**
524
+ * Reason for the rendition level change.
525
+ */
526
+ export type RenditionLevelChangedReason = "abr" | "manual";
347
527
  /**
348
528
  * Contextual information about the rendition level change.
349
529
  */
350
530
  export interface RenditionLevelChanged {
531
+ /** */
351
532
  from?: RenditionLevel;
533
+ /** */
352
534
  to?: RenditionLevel;
535
+ /** */
353
536
  reason: RenditionLevelChangedReason;
354
537
  }
355
- /**
356
- * Channel
357
- */
358
- export interface Channel {
359
- /**
360
- * Channel ID for the channel
361
- */
362
- channelId: string;
363
- /**
364
- * Display name
365
- */
366
- name: string;
367
- /**
368
- * Indicates whether there is an incoming source feed for the channel
369
- */
370
- isLive: boolean;
371
- /**
372
- * URLs to fetch thumbnail from
373
- */
374
- thumbnailUrls: string[];
375
- }
376
- interface ClientOverrides {
377
- maxVideoBitRate?: number;
378
- minBufferTime?: number;
379
- maxBufferTime?: number;
380
- burstEnabled?: boolean;
381
- sizeBasedResolutionCapEnabled?: boolean;
382
- separateVideoSocketEnabled?: boolean;
383
- videoCodecs?: string[];
384
- }
385
- interface ChannelWithRenditionsAndOverrides extends Channel {
386
- renditions: Rendition[];
387
- overrides?: ClientOverrides;
388
- }
389
- interface ConnectOptions {
390
- channelGroupId?: string;
391
- channelId: string;
392
- }
393
- interface Telemetry {
394
- url: string;
395
- probability?: number;
396
- includeErrors?: boolean;
397
- includeEvents?: boolean;
398
- includeStats?: boolean;
399
- maxRetries?: number;
400
- maxErrorReports?: number;
401
- interval?: number;
402
- }
403
- export interface ConnectResponse {
404
- logsUrl?: string;
405
- statsUrl?: string;
406
- telemetry?: Telemetry;
407
- channels: ChannelWithRenditionsAndOverrides[];
408
- edges: string[];
409
- }
410
- /**
411
- * ApiClientOptions
412
- */
413
- export interface ApiClientOptions {
414
- /**
415
- * String representing the URL to the public CDN API.
416
- */
417
- publicEndpoint: string;
418
- /**
419
- * Function that should return a string containing a signed authentication token.
420
- */
421
- tokenFactory?: AuthorizationTokenFactory;
422
- }
423
- /**
424
- * Represents what authorization that will be requested.
425
- */
426
- export interface AuthorizationContext {
427
- /**
428
- * The channelGroupId that might need authorization.
429
- */
430
- channelGroupId?: string;
431
- /**
432
- * The channelId that might need authorization.
433
- */
434
- channelId?: string;
435
- }
436
- /**
437
- * AuthorizationTokenFactory
438
- */
439
- export type AuthorizationTokenFactory = (context: AuthorizationContext) => string | undefined;
440
- /**
441
- * Convenience class to call the public available endpoints of the Vindral Live CDN.
442
- */
443
- export declare class ApiClient {
444
- private baseUrl;
445
- private tokenFactory?;
446
- constructor(options: ApiClientOptions);
447
- /**
448
- * Returns everything needed to setup the connection of Vindral instance.
449
- */
450
- connect(options: ConnectOptions): Promise<ConnectResponse>;
451
- /**
452
- * Fetches information regarding a single channel.
453
- *
454
- * @param channelId the channel to fetch
455
- * @returns a [[Channel]] containing information about the requested channel.
456
- */
457
- getChannel(channelId: string): Promise<Channel>;
458
- /**
459
- * Fetches channels within a channel group
460
- *
461
- * Note: The returned list includes inactive channels - check isLive to filter out only active channels
462
- *
463
- * @param channelGroup the channel group to fetch channels from
464
- * @returns an array of [[Channel]] that belong to the channel group
465
- */
466
- getChannels(channelGroupId: string): Promise<Channel[]>;
467
- private getHeaders;
468
- private getAuthToken;
469
- private toChannels;
470
- private toChannel;
471
- }
472
538
  interface VindralErrorProps {
473
539
  isFatal: boolean;
474
540
  type?: ErrorType;
@@ -483,7 +549,7 @@ export declare const CHANNEL_NOT_FOUND_CODE = "channel_not_found";
483
549
  export declare const NO_INCOMING_DATA = "no_incoming_data_error";
484
550
  export declare const INACTIVITY_CODE = "connection_inactivity";
485
551
  export declare const DISCONNECTED_BY_EDGE = "disconnected_by_edge";
486
- type ErrorType = "internal" | "external";
552
+ export type ErrorType = "internal" | "external";
487
553
  /**
488
554
  * Represents a vindral error - all errors emitted from the Vindral instance inherit from this class.
489
555
  */
@@ -512,8 +578,11 @@ export declare class VindralError extends Error {
512
578
  */
513
579
  toStringifiable: () => Record<string, unknown>;
514
580
  }
515
- type PlaybackState = "buffering" | "playing" | "paused";
516
- type BufferStateEvent = "filled" | "drained";
581
+ /**
582
+ * Represents a playback state.
583
+ */
584
+ export type PlaybackState = "buffering" | "playing" | "paused";
585
+ export type BufferStateEvent = "filled" | "drained";
517
586
  interface PlaybackModuleStatistics {
518
587
  /**
519
588
  * Current target buffer time if using dynamic buffer. Otherwise, this is the statically set buffer time from instantiation.
@@ -522,189 +591,86 @@ interface PlaybackModuleStatistics {
522
591
  needsInputForAudioCount: number;
523
592
  needsInputForVideoCount: number;
524
593
  }
525
- interface NeedsUserInputContext {
526
- /**
527
- * True if user input is needed for audio
528
- */
529
- forAudio: boolean;
530
- /**
531
- * True if user input is needed for video
532
- */
533
- forVideo: boolean;
534
- }
535
- type State = "connected" | "disconnected" | "connecting";
536
- type ContextSwitchState = "completed" | "started";
537
- interface ConnectionStatistics {
538
- /**
539
- * RTT (round trip time) between client and server(s).
540
- */
541
- rtt: MinMaxAverage;
542
- /**
543
- * A very rough initial estimation of minimum available bandwidth.
544
- */
545
- estimatedBandwidth: number;
546
- edgeUrl?: string;
547
- /**
548
- * Total number of connections that have been established since instantiation.
549
- */
550
- connectCount: number;
551
- /**
552
- * Total number of connection attempts since instantiation.
553
- */
554
- connectionAttemptCount: number;
555
- }
556
- /**
557
- * Contextual information about the language switch
558
- */
559
- export interface LanguageSwitchContext {
560
- /**
561
- * The new language that was switched to
562
- */
563
- language: string;
564
- }
565
594
  /**
566
- * Contextual information about the channel switch
595
+ * Shows for what context the browser needs a user input event.
567
596
  */
568
- export interface ChannelSwitchContext {
597
+ export interface NeedsUserInputContext {
569
598
  /**
570
- * The new channel id that was switched to
571
- */
572
- channelId: string;
573
- }
574
- interface VolumeState {
575
- /**
576
- * Wether the audio is muted
577
- */
578
- isMuted: boolean;
579
- /**
580
- * The volume level
581
- */
582
- volume: number;
583
- }
584
- /**
585
- * The events that can be emitted from the Vindral instance
586
- */
587
- export interface PublicVindralEvents {
588
- /**
589
- * When an error that requires action has occured
590
- *
591
- * Can be a fatal error that will unload the Vindral instance - this is indicated by `isFatal()` on the error object returning true.
592
- *
593
- * 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
594
- * 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.
595
- */
596
- ["error"]: Readonly<VindralError>;
597
- /**
598
- * When the instance needs user input to activate audio or sometimes video playback.
599
- * Is called with an object
600
- * ```javascript
601
- * {
602
- * forAudio: boolean // true if user input is needed for audio playback
603
- * forVideo: boolean // true if user input is needed for video playback
604
- * }
605
- * ```
606
- */
607
- ["needs user input"]: NeedsUserInputContext;
608
- /**
609
- * When a timed metadata event has been triggered
610
- */
611
- ["metadata"]: Readonly<Metadata>;
612
- /**
613
- * When the playback state changes
614
- */
615
- ["playback state"]: Readonly<PlaybackState>;
616
- /**
617
- * When the connection state changes
618
- */
619
- ["connection state"]: Readonly<State>;
620
- /**
621
- * When the available rendition levels is changed
622
- */
623
- ["rendition levels"]: ReadonlyArray<RenditionLevel>;
624
- /**
625
- * When the rendition level is changed
626
- */
627
- ["rendition level"]: Readonly<RenditionLevel>;
628
- /**
629
- * When the available languages is changed
599
+ * True if user input is needed for audio
630
600
  */
631
- ["languages"]: ReadonlyArray<string>;
601
+ forAudio: boolean;
632
602
  /**
633
- * When the available text tracks are changed
603
+ * True if user input is needed for video
634
604
  */
635
- ["text tracks"]: ReadonlyArray<string>;
605
+ forVideo: boolean;
606
+ }
607
+ /**
608
+ * ApiClientOptions
609
+ */
610
+ export interface ApiClientOptions {
636
611
  /**
637
- * When the available channels is changed
612
+ * String representing the URL to the public CDN API.
638
613
  */
639
- ["channels"]: ReadonlyArray<Channel>;
614
+ publicEndpoint: string;
640
615
  /**
641
- * When a context switch state change has occured.
642
- * E.g. when a channel change has been requested, or quality is changed.
616
+ * Function that should return a string containing a signed authentication token.
643
617
  */
644
- ["context switch"]: Readonly<ContextSwitchState>;
618
+ tokenFactory?: AuthorizationTokenFactory;
619
+ }
620
+ /**
621
+ * Represents what authorization that will be requested.
622
+ */
623
+ export interface AuthorizationContext {
645
624
  /**
646
- * Emitted when a wallclock time message has been received from the server.
647
- *
648
- * Note: This is the edge server wallclock time and thus may differ slightly
649
- * between two viewers if they are connected to different edge servers.
625
+ * The channelGroupId that might need authorization.
650
626
  */
651
- ["server wallclock time"]: Readonly<number>;
627
+ channelGroupId?: string;
652
628
  /**
653
- * Is emitted during connection whether the channel is live or not.
654
- *
655
- * If the channel is not live, the Vindral instance will try to reconnect until the `reconnectHandler`
656
- * determines that no more retries should be made.
657
- *
658
- * Note: If the web-sdk is instantiated at the same time as you are starting the stream it is possible
659
- * that this emits false until the started state has propagated through the system.
629
+ * The channelId that might need authorization.
660
630
  */
661
- ["is live"]: boolean;
631
+ channelId?: string;
632
+ }
633
+ interface ConnectOptions {
634
+ channelGroupId?: string;
635
+ channelId: string;
636
+ }
637
+ /**
638
+ * AuthorizationTokenFactory
639
+ */
640
+ export type AuthorizationTokenFactory = (context: AuthorizationContext) => string | undefined;
641
+ /**
642
+ * Convenience class to call the public available endpoints of the Vindral Live CDN.
643
+ */
644
+ export declare class ApiClient {
645
+ private baseUrl;
646
+ private tokenFactory?;
647
+ constructor(options: ApiClientOptions);
662
648
  /**
663
- * Emitted when a channel switch has been completed and the first frame of the new channel is rendered.
664
- * A string containing the channel id of the new channel is provided as an argument.
649
+ * @ignore
650
+ * Returns everything needed to setup the connection of Vindral instance.
665
651
  */
666
- ["channel switch"]: Readonly<ChannelSwitchContext>;
652
+ connect(options: ConnectOptions): Promise<ConnectInfo>;
667
653
  /**
668
- * Emitted when a language switch has been completed and the new language starts playing.
654
+ * Fetches information regarding a single channel.
655
+ *
656
+ * @param channelId the channel to fetch
657
+ * @returns a [[Channel]] containing information about the requested channel.
669
658
  */
670
- ["language switch"]: Readonly<LanguageSwitchContext>;
659
+ getChannel(channelId: string): Promise<Channel>;
671
660
  /**
672
- * Emitted when the volume state changes.
661
+ * Fetches channels within a channel group
673
662
  *
674
- * This is triggered triggered both when the user changes the volume through the Vindral instance, but also
675
- * from external sources such as OS media shortcuts or other native UI outside of the browser.
663
+ * Note: The returned list includes inactive channels - check isLive to filter out only active channels
664
+ *
665
+ * @param channelGroupId the channel group to fetch channels from
666
+ * @returns an array of [[Channel]] that belong to the channel group
676
667
  */
677
- ["volume state"]: Readonly<VolumeState>;
678
- ["buffer state event"]: Readonly<BufferStateEvent>;
679
- ["initialized media"]: void;
668
+ getChannels(channelGroupId: string): Promise<Channel[]>;
669
+ private getHeaders;
670
+ private getAuthToken;
671
+ private toChannels;
672
+ private toChannel;
680
673
  }
681
- declare const defaultOptions: {
682
- sizeBasedResolutionCapEnabled: boolean;
683
- pictureInPictureEnabled: boolean;
684
- abrEnabled: boolean;
685
- burstEnabled: boolean;
686
- mseEnabled: boolean;
687
- mseOpusEnabled: boolean;
688
- muted: boolean;
689
- minBufferTime: number;
690
- maxBufferTime: number;
691
- logLevel: Level;
692
- maxSize: Size;
693
- maxVideoBitRate: number;
694
- maxAudioBitRate: number;
695
- tags: string[];
696
- media: Media;
697
- poster: string | boolean;
698
- reconnectHandler: (state: ReconnectState) => Promise<boolean> | boolean;
699
- iosWakeLockEnabled: boolean;
700
- telemetryEnabled: boolean;
701
- iosMediaElementEnabled: boolean;
702
- pauseSupportEnabled: boolean;
703
- advanced: {
704
- wasmDecodingConstraint: Partial<VideoConstraint>;
705
- };
706
- videoCodecs: VideoCodec[];
707
- };
708
674
  interface AdaptivityStatistics {
709
675
  /**
710
676
  * True if adaptive bitrate (ABR) is enabled.
@@ -856,15 +822,6 @@ interface SyncModuleStatistics {
856
822
  timeshiftDriftAdjustmentCount: number;
857
823
  seekTime: number;
858
824
  }
859
- interface TelemetryModuleStatistics {
860
- /**
861
- * The total amount of errors being spawned. Note that some media errors can trigger
862
- * thousands of errors for a single client in a few seconds before recovering. Therefore,
863
- * consider the number of viewers with errors, not just the total amount. Also, consider the median
864
- * instead of the mean for average calculation.
865
- */
866
- errorCount: number;
867
- }
868
825
  interface VideoPlayerStatistics {
869
826
  renderedFrameCount: number;
870
827
  rendererDroppedFrameCount: number;
@@ -994,7 +951,6 @@ export declare class Vindral extends Emitter<PublicVindralEvents> {
994
951
  #private;
995
952
  private static MAX_POOL_SIZE;
996
953
  private static INITIAL_MAX_BIT_RATE;
997
- private static PING_TIMEOUT;
998
954
  private static DISCONNECT_TIMEOUT;
999
955
  private static REMOVE_CUE_THRESHOLD;
1000
956
  /**
@@ -1020,6 +976,10 @@ export declare class Vindral extends Emitter<PublicVindralEvents> {
1020
976
  */
1021
977
  isSupported: () => boolean;
1022
978
  };
979
+ readonly drm: {
980
+ setHeaders: (headers: Record<string, string>) => void;
981
+ setQueryParams: (queryParams: Record<string, string>) => void;
982
+ };
1023
983
  private browser;
1024
984
  private options;
1025
985
  private element;
@@ -1033,13 +993,11 @@ export declare class Vindral extends Emitter<PublicVindralEvents> {
1033
993
  private _channels;
1034
994
  private createdAt;
1035
995
  private hasCalledConnect;
1036
- private apiClient;
1037
996
  private latestEmittedLanguages;
1038
997
  private wakeLock;
1039
- private cachedEdges;
1040
- private shiftedEdges;
1041
998
  private pool;
1042
999
  private userAgentInformation;
1000
+ private encryptedMediaExtensions;
1043
1001
  private sampleProcessingSesssions;
1044
1002
  private sizes;
1045
1003
  private isSuspended;
@@ -1063,6 +1021,9 @@ export declare class Vindral extends Emitter<PublicVindralEvents> {
1063
1021
  * [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)
1064
1022
  * for iOS-Specific Considerations. The following section is the important part:
1065
1023
  * 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.
1024
+ *
1025
+ * @param volume The volume to set. A floating point value between 0-1.
1026
+ *
1066
1027
  */
1067
1028
  set volume(volume: number);
1068
1029
  /**
@@ -1078,7 +1039,7 @@ export declare class Vindral extends Emitter<PublicVindralEvents> {
1078
1039
  */
1079
1040
  get muted(): boolean;
1080
1041
  /**
1081
- * Media (audio | video | audio+video)
1042
+ * Which media type is currently being played
1082
1043
  */
1083
1044
  get media(): Media;
1084
1045
  /**
@@ -1092,7 +1053,7 @@ export declare class Vindral extends Emitter<PublicVindralEvents> {
1092
1053
  /**
1093
1054
  * The current connection state
1094
1055
  */
1095
- get connectionState(): Readonly<State>;
1056
+ get connectionState(): Readonly<ConnectionState>;
1096
1057
  /**
1097
1058
  * The current playback state
1098
1059
  */
@@ -1201,7 +1162,7 @@ export declare class Vindral extends Emitter<PublicVindralEvents> {
1201
1162
  */
1202
1163
  set channelId(channelId: string);
1203
1164
  /**
1204
- * Max size that will be subcribed to
1165
+ * Max size that will be subscribed to
1205
1166
  */
1206
1167
  get maxSize(): Size;
1207
1168
  /**
@@ -1270,10 +1231,24 @@ export declare class Vindral extends Emitter<PublicVindralEvents> {
1270
1231
  get timeSpentBuffering(): number;
1271
1232
  get timeActive(): number;
1272
1233
  get mediaElement(): HTMLMediaElement | HTMLCanvasElement;
1234
+ get audioNode(): AudioNode | undefined;
1235
+ get drmStatistics(): {
1236
+ keySystem?: string | undefined;
1237
+ licenseServerUrl?: string | undefined;
1238
+ mediaKeySystemConfiguration?: MediaKeySystemConfiguration | undefined;
1239
+ provider?: string | undefined;
1240
+ clearkeys?: Record<string, string>;
1241
+ playreadyLicenseUrl?: string;
1242
+ widevineLicenseUrl?: string;
1243
+ fairplayLicenseUrl?: string;
1244
+ fairplayCertificate?: ArrayBuffer;
1245
+ videoCodec?: string;
1246
+ audioCodec?: string;
1247
+ } | null;
1273
1248
  /**
1274
1249
  * Get active Vindral Options
1275
1250
  */
1276
- getOptions: () => Options & typeof defaultOptions;
1251
+ getOptions: () => Options;
1277
1252
  /**
1278
1253
  * Get url for fetching thumbnail. Note that fetching thumbnails only works for an active channel.
1279
1254
  */
@@ -1292,9 +1267,7 @@ export declare class Vindral extends Emitter<PublicVindralEvents> {
1292
1267
  * Get options that can be used for CastSender
1293
1268
  */
1294
1269
  getCastOptions: () => Options;
1295
- private connectionInfo;
1296
- private estimateRTT;
1297
- private connectHandler;
1270
+ private onConnectInfo;
1298
1271
  private emitLanguagesIfChanged;
1299
1272
  private updateTextTracks;
1300
1273
  private cleanupTextTracks;
@@ -1375,6 +1348,177 @@ export declare class Vindral extends Emitter<PublicVindralEvents> {
1375
1348
  private timeToFirstFrame;
1376
1349
  private willUseMediaSource;
1377
1350
  }
1351
+ interface TelemetryModuleStatistics {
1352
+ /**
1353
+ * The total amount of errors being spawned. Note that some media errors can trigger
1354
+ * thousands of errors for a single client in a few seconds before recovering. Therefore,
1355
+ * consider the number of viewers with errors, not just the total amount. Also, consider the median
1356
+ * instead of the mean for average calculation.
1357
+ */
1358
+ errorCount: number;
1359
+ }
1360
+ /**
1361
+ * Represents a connection state.
1362
+ */
1363
+ export type ConnectionState = "connected" | "disconnected" | "connecting";
1364
+ /**
1365
+ * Represents state of a context switch. The state change starts when connection starts receiving a new
1366
+ * channel or quality and is completed when the new quality/channel has received its init segments and key frames.
1367
+ */
1368
+ export type ContextSwitchState = "completed" | "started";
1369
+ interface ConnectionStatistics {
1370
+ /**
1371
+ * RTT (round trip time) between client and server(s).
1372
+ */
1373
+ rtt: MinMaxAverage;
1374
+ /**
1375
+ * A very rough initial estimation of minimum available bandwidth.
1376
+ */
1377
+ estimatedBandwidth: number;
1378
+ edgeUrl?: string;
1379
+ /**
1380
+ * Total number of connections that have been established since instantiation.
1381
+ */
1382
+ connectCount: number;
1383
+ /**
1384
+ * Total number of connection attempts since instantiation.
1385
+ */
1386
+ connectionAttemptCount: number;
1387
+ connectionProtocol: "vindral_ws" | "moq" | undefined;
1388
+ }
1389
+ /**
1390
+ * Contextual information about the language switch
1391
+ */
1392
+ export interface LanguageSwitchContext {
1393
+ /**
1394
+ * The new language that was switched to
1395
+ */
1396
+ language: string;
1397
+ }
1398
+ /**
1399
+ * Contextual information about the channel switch
1400
+ */
1401
+ export interface ChannelSwitchContext {
1402
+ /**
1403
+ * The new channel id that was switched to
1404
+ */
1405
+ channelId: string;
1406
+ }
1407
+ /**
1408
+ * Volume state changes
1409
+ */
1410
+ export interface VolumeState {
1411
+ /**
1412
+ * Wether the audio is muted
1413
+ */
1414
+ isMuted: boolean;
1415
+ /**
1416
+ * The volume level
1417
+ */
1418
+ volume: number;
1419
+ }
1420
+ /**
1421
+ * The events that can be emitted from the Vindral instance
1422
+ */
1423
+ export interface PublicVindralEvents {
1424
+ /**
1425
+ * When an error that requires action has occured
1426
+ *
1427
+ * Can be a fatal error that will unload the Vindral instance - this is indicated by `isFatal()` on the error object returning true.
1428
+ *
1429
+ * 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
1430
+ * 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.
1431
+ */
1432
+ ["error"]: Readonly<VindralError>;
1433
+ /**
1434
+ * When the instance needs user input to activate audio or sometimes video playback.
1435
+ * Is called with an object
1436
+ * ```javascript
1437
+ * {
1438
+ * forAudio: boolean // true if user input is needed for audio playback
1439
+ * forVideo: boolean // true if user input is needed for video playback
1440
+ * }
1441
+ * ```
1442
+ */
1443
+ ["needs user input"]: NeedsUserInputContext;
1444
+ /**
1445
+ * When a timed metadata event has been triggered
1446
+ */
1447
+ ["metadata"]: Readonly<Metadata>;
1448
+ /**
1449
+ * When the playback state changes
1450
+ */
1451
+ ["playback state"]: Readonly<PlaybackState>;
1452
+ /**
1453
+ * When the connection state changes
1454
+ */
1455
+ ["connection state"]: Readonly<ConnectionState>;
1456
+ /**
1457
+ * When the available rendition levels is changed
1458
+ */
1459
+ ["rendition levels"]: ReadonlyArray<RenditionLevel>;
1460
+ /**
1461
+ * When the rendition level is changed
1462
+ */
1463
+ ["rendition level"]: Readonly<RenditionLevel>;
1464
+ /**
1465
+ * When the available languages is changed
1466
+ */
1467
+ ["languages"]: ReadonlyArray<string>;
1468
+ /**
1469
+ * When the available text tracks are changed
1470
+ */
1471
+ ["text tracks"]: ReadonlyArray<string>;
1472
+ /**
1473
+ * When the available channels is changed
1474
+ */
1475
+ ["channels"]: ReadonlyArray<Channel>;
1476
+ /**
1477
+ * When a context switch state change has occured.
1478
+ * E.g. when a channel change has been requested, or quality is changed.
1479
+ */
1480
+ ["context switch"]: Readonly<ContextSwitchState>;
1481
+ /**
1482
+ * Emitted when a wallclock time message has been received from the server.
1483
+ *
1484
+ * Note: This is the edge server wallclock time and thus may differ slightly
1485
+ * between two viewers if they are connected to different edge servers.
1486
+ */
1487
+ ["server wallclock time"]: Readonly<number>;
1488
+ /**
1489
+ * Is emitted during connection whether the channel is live or not.
1490
+ *
1491
+ * If the channel is not live, the Vindral instance will try to reconnect until the `reconnectHandler`
1492
+ * determines that no more retries should be made.
1493
+ *
1494
+ * Note: If the web-sdk is instantiated at the same time as you are starting the stream it is possible
1495
+ * that this emits false until the started state has propagated through the system.
1496
+ */
1497
+ ["is live"]: boolean;
1498
+ /**
1499
+ * Emitted when a channel switch has been completed and the first frame of the new channel is rendered.
1500
+ * A string containing the channel id of the new channel is provided as an argument.
1501
+ */
1502
+ ["channel switch"]: Readonly<ChannelSwitchContext>;
1503
+ /**
1504
+ * Emmitted when a channel switch fails.
1505
+ * A string containing the channel id of the current channel is provided as an argument.
1506
+ */
1507
+ ["channel switch failed"]: Readonly<ChannelSwitchContext>;
1508
+ /**
1509
+ * Emitted when a language switch has been completed and the new language starts playing.
1510
+ */
1511
+ ["language switch"]: Readonly<LanguageSwitchContext>;
1512
+ /**
1513
+ * Emitted when the volume state changes.
1514
+ *
1515
+ * This is triggered triggered both when the user changes the volume through the Vindral instance, but also
1516
+ * from external sources such as OS media shortcuts or other native UI outside of the browser.
1517
+ */
1518
+ ["volume state"]: Readonly<VolumeState>;
1519
+ ["buffer state event"]: Readonly<BufferStateEvent>;
1520
+ ["initialized media"]: void;
1521
+ }
1378
1522
  /**
1379
1523
  * Available events to listen to
1380
1524
  */
@@ -1409,7 +1553,7 @@ export interface CastSenderEvents {
1409
1553
  */
1410
1554
  export interface CastConfig {
1411
1555
  /**
1412
- * The [Vindral Options](./Options) to use for the Cast Receiver
1556
+ * The Vindral Options to use for the Cast Receiver
1413
1557
  */
1414
1558
  options: Options;
1415
1559
  /**