@vindral/web-sdk 4.0.0 → 4.1.0-2-gc61db412

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 CHANGED
@@ -1,3 +1,47 @@
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
+ interface MinMaxAverage {
31
+ last: number;
32
+ /**
33
+ * Average value over a given interval.
34
+ */
35
+ average: number;
36
+ /**
37
+ * Maximum value over a given interval.
38
+ */
39
+ max: number;
40
+ /**
41
+ * Minimum value over a given interval.
42
+ */
43
+ min: number;
44
+ }
1
45
  type MatchingKeys<TRecord, TMatch, K extends keyof TRecord = keyof TRecord> = K extends (TRecord[K] extends TMatch ? K : never) ? K : never;
2
46
  type VoidKeys<Record> = MatchingKeys<Record, void>;
3
47
  type EventListenerReturnType = (() => void) | void;
@@ -5,6 +49,9 @@ declare class Emitter<TEvents, TEmits = TEvents, ArgLessEvents extends VoidKeys<
5
49
  private listeners;
6
50
  emit<T extends ArgLessEmits>(eventName: T): void;
7
51
  emit<T extends ArgEmits>(eventName: T, args: TEmits[T]): void;
52
+ /**
53
+ * Remove an event listener from `eventName`
54
+ */
8
55
  off<T extends ArgLessEvents>(eventName: T, fn: () => EventListenerReturnType): void;
9
56
  off<T extends ArgEvents>(eventName: T, fn: (args: TEvents[T]) => EventListenerReturnType): void;
10
57
  /**
@@ -23,10 +70,13 @@ declare class Emitter<TEvents, TEmits = TEvents, ArgLessEvents extends VoidKeys<
23
70
  */
24
71
  once<T extends ArgLessEvents>(eventName: T, fn: () => void): void;
25
72
  once<T extends ArgEvents>(eventName: T, fn: (args: TEvents[T]) => void): void;
73
+ /**
74
+ * Reset the event emitter
75
+ */
26
76
  reset(): void;
27
77
  private add;
28
78
  }
29
- declare const Levels: readonly [
79
+ declare const LogLevels: readonly [
30
80
  "off",
31
81
  "error",
32
82
  "warn",
@@ -34,8 +84,8 @@ declare const Levels: readonly [
34
84
  "debug",
35
85
  "trace"
36
86
  ];
37
- export type Level = (typeof Levels)[number];
38
- export declare const Level: {
87
+ type LogLevel = (typeof LogLevels)[number];
88
+ declare const LogLevel: {
39
89
  ERROR: "error";
40
90
  WARN: "warn";
41
91
  INFO: "info";
@@ -43,71 +93,81 @@ export declare const Level: {
43
93
  TRACE: "trace";
44
94
  OFF: "off";
45
95
  };
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;
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
+ ["com.vindral.drm"]?: string;
60
131
  }
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;
132
+ interface CatalogRoot {
133
+ version: number;
134
+ streamingFormat?: number;
135
+ streamingFormatVersion?: string;
75
136
  }
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;
137
+ interface TracksCatalog extends CatalogRoot {
138
+ namespace: Namespace;
139
+ tracks: Array<TrackObject>;
91
140
  }
92
141
  interface RenditionProps {
93
142
  id: number;
143
+ /** */
94
144
  bitRate: number;
145
+ /** */
95
146
  codecString?: string;
147
+ /** */
96
148
  language?: string;
149
+ /** */
97
150
  meta?: Record<string, string>;
98
151
  }
99
152
  interface VideoRenditionProps {
153
+ /** */
100
154
  codec: VideoCodec;
155
+ /** */
101
156
  frameRate: [
102
157
  number,
103
158
  number
104
159
  ];
160
+ /** */
105
161
  width: number;
162
+ /** */
106
163
  height: number;
107
164
  }
108
165
  interface AudioRenditionProps {
166
+ /** */
109
167
  codec: AudioCodec;
168
+ /** */
110
169
  channels: number;
170
+ /** */
111
171
  sampleRate: number;
112
172
  }
113
173
  interface TextRenditionProps {
@@ -115,19 +175,110 @@ interface TextRenditionProps {
115
175
  kind: "subtitles" | "captions";
116
176
  label?: string;
117
177
  }
118
- type VideoRendition = VideoRenditionProps & RenditionProps;
119
- type AudioRendition = AudioRenditionProps & RenditionProps;
178
+ /**
179
+ * @interface
180
+ */
181
+ export type VideoRendition = VideoRenditionProps & RenditionProps;
182
+ /**
183
+ * @interface
184
+ */
185
+ export type AudioRendition = AudioRenditionProps & RenditionProps;
120
186
  type TextRendition = TextRenditionProps & RenditionProps;
121
187
  type Rendition = VideoRendition | AudioRendition | TextRendition;
122
- interface Size {
188
+ interface Telemetry {
189
+ url: string;
190
+ probability?: number;
191
+ includeErrors?: boolean;
192
+ includeEvents?: boolean;
193
+ includeStats?: boolean;
194
+ maxRetries?: number;
195
+ maxErrorReports?: number;
196
+ interval?: number;
197
+ }
198
+ interface ChannelWithCatalog extends Channel {
199
+ catalog: TracksCatalog;
200
+ renditions: Rendition[];
201
+ overrides?: ClientOverrides;
202
+ }
203
+ interface ChannelWithRenditions extends Channel {
204
+ renditions: Rendition[];
205
+ overrides?: ClientOverrides;
206
+ }
207
+ interface ServerCertificateHash {
208
+ algorithm: string;
209
+ value: string;
210
+ }
211
+ interface Edge {
212
+ moqUrl?: string;
213
+ moqWsUrl: string;
214
+ serverCertificateHashes?: ServerCertificateHash[];
215
+ }
216
+ interface MoQConnectInfo {
217
+ logsUrl?: string;
218
+ statsUrl?: string;
219
+ telemetry?: Telemetry;
220
+ channels: ChannelWithCatalog[];
221
+ edges: Edge[];
222
+ }
223
+ interface VindralConnectInfo {
224
+ logsUrl?: string;
225
+ statsUrl?: string;
226
+ telemetry?: Telemetry;
227
+ channels: ChannelWithRenditions[];
228
+ edges: string[];
229
+ }
230
+ type ConnectInfo = VindralConnectInfo | MoQConnectInfo;
231
+ /**
232
+ * Represents a timed metadata event
233
+ */
234
+ export interface Metadata {
235
+ /**
236
+ * The raw string content as it was ingested (if using JSON, it needs to be parsed on your end)
237
+ */
238
+ content: string;
239
+ /**
240
+ * Timestamp in ms
241
+ */
242
+ timestamp: number;
243
+ }
244
+ /** */
245
+ export interface TimeRange {
246
+ /** */
247
+ start: number;
248
+ /** */
249
+ end: number;
250
+ }
251
+ /**
252
+ * The current reconnect state to use to decide whether to kep reconnecting or not
253
+ */
254
+ export interface ReconnectState {
255
+ /**
256
+ * The number or retry attempts so far.
257
+ * This gets reset on every successful connect, so it will start from zero every
258
+ * time the client instance gets disconnected and will increment until the
259
+ * client instance makes a connection attempt is successful.
260
+ */
261
+ reconnectRetries: number;
262
+ }
263
+ /**
264
+ * Represents a size with a width and height.
265
+ */
266
+ export interface Size {
267
+ /** */
123
268
  width: number;
269
+ /** */
124
270
  height: number;
125
271
  }
126
- interface VideoConstraint {
272
+ export interface VideoConstraint {
273
+ /** */
127
274
  width: number;
275
+ /** */
128
276
  height: number;
277
+ /** */
129
278
  bitRate: number;
279
+ /** */
130
280
  codec?: VideoCodec;
281
+ /** */
131
282
  codecString?: string;
132
283
  }
133
284
  /**
@@ -141,7 +292,23 @@ export interface AdvancedOptions {
141
292
  */
142
293
  wasmDecodingConstraint: Partial<VideoConstraint>;
143
294
  }
144
- type Media = "audio" | "video" | "audio+video";
295
+ /**
296
+ * DRM options to provide to the Vindral instance
297
+ */
298
+ export interface DrmOptions {
299
+ /**
300
+ * Headers to be added to requests to license servers
301
+ */
302
+ headers?: Record<string, string>;
303
+ /**
304
+ * Query parameters to be added to requests to license servers
305
+ */
306
+ queryParams?: Record<string, string>;
307
+ }
308
+ /**
309
+ * Type of media.
310
+ */
311
+ export type Media = "audio" | "video" | "audio+video";
145
312
  /**
146
313
  * Options for the Vindral instance
147
314
  *
@@ -181,7 +348,7 @@ export interface Options {
181
348
  /**
182
349
  * Sets the log level - defaults to info
183
350
  */
184
- logLevel?: Level;
351
+ logLevel?: LogLevel;
185
352
  /**
186
353
  * Sets the minimum and initial buffer time
187
354
  */
@@ -311,6 +478,7 @@ export interface Options {
311
478
  edgeUrl?: string;
312
479
  logShippingEnabled?: boolean;
313
480
  statsShippingEnabled?: boolean;
481
+ webtransportEnabled?: boolean;
314
482
  /**
315
483
  * Enable wake lock for iOS devices.
316
484
  * The wake lock requires that the audio has been activated at least once for the instance, othwerwise it will not work.
@@ -335,125 +503,35 @@ export interface Options {
335
503
  advanced?: AdvancedOptions;
336
504
  media?: Media;
337
505
  videoCodecs?: VideoCodec[];
506
+ /**
507
+ * DRM options to provide to the Vindral instance
508
+ */
509
+ drm?: DrmOptions;
338
510
  }
339
511
  /**
340
512
  * Represents a rendition (quality level).
341
513
  */
342
514
  export interface RenditionLevel {
515
+ /** */
343
516
  audio?: AudioRendition;
517
+ /** */
344
518
  video?: VideoRendition;
345
519
  }
346
- type RenditionLevelChangedReason = "abr" | "manual";
520
+ /**
521
+ * Reason for the rendition level change.
522
+ */
523
+ export type RenditionLevelChangedReason = "abr" | "manual";
347
524
  /**
348
525
  * Contextual information about the rendition level change.
349
526
  */
350
527
  export interface RenditionLevelChanged {
528
+ /** */
351
529
  from?: RenditionLevel;
530
+ /** */
352
531
  to?: RenditionLevel;
532
+ /** */
353
533
  reason: RenditionLevelChangedReason;
354
534
  }
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
535
  interface VindralErrorProps {
458
536
  isFatal: boolean;
459
537
  type?: ErrorType;
@@ -468,7 +546,7 @@ export declare const CHANNEL_NOT_FOUND_CODE = "channel_not_found";
468
546
  export declare const NO_INCOMING_DATA = "no_incoming_data_error";
469
547
  export declare const INACTIVITY_CODE = "connection_inactivity";
470
548
  export declare const DISCONNECTED_BY_EDGE = "disconnected_by_edge";
471
- type ErrorType = "internal" | "external";
549
+ export type ErrorType = "internal" | "external";
472
550
  /**
473
551
  * Represents a vindral error - all errors emitted from the Vindral instance inherit from this class.
474
552
  */
@@ -497,199 +575,87 @@ export declare class VindralError extends Error {
497
575
  */
498
576
  toStringifiable: () => Record<string, unknown>;
499
577
  }
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
578
  /**
570
- * The events that can be emitted from the Vindral instance
579
+ * Represents a playback state.
571
580
  */
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>;
581
+ export type PlaybackState = "buffering" | "playing" | "paused";
582
+ export type BufferStateEvent = "filled" | "drained";
583
+ interface PlaybackModuleStatistics {
609
584
  /**
610
- * When the rendition level is changed
585
+ * Current target buffer time if using dynamic buffer. Otherwise, this is the statically set buffer time from instantiation.
611
586
  */
612
- ["rendition level"]: Readonly<RenditionLevel>;
587
+ bufferTime: number;
588
+ needsInputForAudioCount: number;
589
+ needsInputForVideoCount: number;
590
+ }
591
+ /**
592
+ * Shows for what context the browser needs a user input event.
593
+ */
594
+ export interface NeedsUserInputContext {
613
595
  /**
614
- * When the available languages is changed
596
+ * True if user input is needed for audio
615
597
  */
616
- ["languages"]: ReadonlyArray<string>;
598
+ forAudio: boolean;
617
599
  /**
618
- * When the available text tracks are changed
600
+ * True if user input is needed for video
619
601
  */
620
- ["text tracks"]: ReadonlyArray<string>;
602
+ forVideo: boolean;
603
+ }
604
+ interface ApiClientOptions {
621
605
  /**
622
- * When the available channels is changed
606
+ * String representing the URL to the public CDN API.
623
607
  */
624
- ["channels"]: ReadonlyArray<Channel>;
608
+ publicEndpoint: string;
625
609
  /**
626
- * When a context switch state change has occured.
627
- * E.g. when a channel change has been requested, or quality is changed.
610
+ * Function that should return a string containing a signed authentication token.
628
611
  */
629
- ["context switch"]: Readonly<ContextSwitchState>;
612
+ tokenFactory?: AuthorizationTokenFactory;
613
+ }
614
+ interface AuthorizationContext {
630
615
  /**
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.
616
+ * The channelGroupId that might need authorization.
635
617
  */
636
- ["server wallclock time"]: Readonly<number>;
618
+ channelGroupId?: string;
637
619
  /**
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.
620
+ * The channelId that might need authorization.
645
621
  */
646
- ["is live"]: boolean;
622
+ channelId?: string;
623
+ }
624
+ interface ConnectOptions {
625
+ channelGroupId?: string;
626
+ channelId: string;
627
+ }
628
+ type AuthorizationTokenFactory = (context: AuthorizationContext) => string | undefined;
629
+ declare class ApiClient {
630
+ private baseUrl;
631
+ private tokenFactory?;
632
+ constructor(options: ApiClientOptions);
647
633
  /**
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.
634
+ * @ignore
635
+ * Returns everything needed to setup the connection of Vindral instance.
650
636
  */
651
- ["channel switch"]: Readonly<ChannelSwitchContext>;
637
+ connect(options: ConnectOptions): Promise<ConnectInfo>;
652
638
  /**
653
- * Emitted when a language switch has been completed and the new language starts playing.
639
+ * Fetches information regarding a single channel.
640
+ *
641
+ * @param channelId the channel to fetch
642
+ * @returns a [[Channel]] containing information about the requested channel.
654
643
  */
655
- ["language switch"]: Readonly<LanguageSwitchContext>;
644
+ getChannel(channelId: string): Promise<Channel>;
656
645
  /**
657
- * Emitted when the volume state changes.
646
+ * Fetches channels within a channel group
658
647
  *
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.
648
+ * Note: The returned list includes inactive channels - check isLive to filter out only active channels
649
+ *
650
+ * @param channelGroupId the channel group to fetch channels from
651
+ * @returns an array of [[Channel]] that belong to the channel group
661
652
  */
662
- ["volume state"]: Readonly<VolumeState>;
663
- ["buffer state event"]: Readonly<BufferStateEvent>;
664
- ["initialized media"]: void;
653
+ getChannels(channelGroupId: string): Promise<Channel[]>;
654
+ private getHeaders;
655
+ private getAuthToken;
656
+ private toChannels;
657
+ private toChannel;
665
658
  }
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
659
  interface AdaptivityStatistics {
694
660
  /**
695
661
  * True if adaptive bitrate (ABR) is enabled.
@@ -841,15 +807,6 @@ interface SyncModuleStatistics {
841
807
  timeshiftDriftAdjustmentCount: number;
842
808
  seekTime: number;
843
809
  }
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
810
  interface VideoPlayerStatistics {
854
811
  renderedFrameCount: number;
855
812
  rendererDroppedFrameCount: number;
@@ -979,7 +936,6 @@ export declare class Vindral extends Emitter<PublicVindralEvents> {
979
936
  #private;
980
937
  private static MAX_POOL_SIZE;
981
938
  private static INITIAL_MAX_BIT_RATE;
982
- private static PING_TIMEOUT;
983
939
  private static DISCONNECT_TIMEOUT;
984
940
  private static REMOVE_CUE_THRESHOLD;
985
941
  /**
@@ -1005,6 +961,10 @@ export declare class Vindral extends Emitter<PublicVindralEvents> {
1005
961
  */
1006
962
  isSupported: () => boolean;
1007
963
  };
964
+ readonly drm: {
965
+ setHeaders: (headers: Record<string, string>) => void;
966
+ setQueryParams: (queryParams: Record<string, string>) => void;
967
+ };
1008
968
  private browser;
1009
969
  private options;
1010
970
  private element;
@@ -1018,13 +978,11 @@ export declare class Vindral extends Emitter<PublicVindralEvents> {
1018
978
  private _channels;
1019
979
  private createdAt;
1020
980
  private hasCalledConnect;
1021
- private apiClient;
1022
981
  private latestEmittedLanguages;
1023
982
  private wakeLock;
1024
- private cachedEdges;
1025
- private shiftedEdges;
1026
983
  private pool;
1027
984
  private userAgentInformation;
985
+ private encryptedMediaExtensions;
1028
986
  private sampleProcessingSesssions;
1029
987
  private sizes;
1030
988
  private isSuspended;
@@ -1048,6 +1006,9 @@ export declare class Vindral extends Emitter<PublicVindralEvents> {
1048
1006
  * [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
1007
  * for iOS-Specific Considerations. The following section is the important part:
1050
1008
  * 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.
1009
+ *
1010
+ * @param volume The volume to set. A floating point value between 0-1.
1011
+ *
1051
1012
  */
1052
1013
  set volume(volume: number);
1053
1014
  /**
@@ -1063,7 +1024,7 @@ export declare class Vindral extends Emitter<PublicVindralEvents> {
1063
1024
  */
1064
1025
  get muted(): boolean;
1065
1026
  /**
1066
- * Media (audio | video | audio+video)
1027
+ * Which media type is currently being played
1067
1028
  */
1068
1029
  get media(): Media;
1069
1030
  /**
@@ -1077,7 +1038,7 @@ export declare class Vindral extends Emitter<PublicVindralEvents> {
1077
1038
  /**
1078
1039
  * The current connection state
1079
1040
  */
1080
- get connectionState(): Readonly<State>;
1041
+ get connectionState(): Readonly<ConnectionState>;
1081
1042
  /**
1082
1043
  * The current playback state
1083
1044
  */
@@ -1186,7 +1147,7 @@ export declare class Vindral extends Emitter<PublicVindralEvents> {
1186
1147
  */
1187
1148
  set channelId(channelId: string);
1188
1149
  /**
1189
- * Max size that will be subcribed to
1150
+ * Max size that will be subscribed to
1190
1151
  */
1191
1152
  get maxSize(): Size;
1192
1153
  /**
@@ -1255,10 +1216,24 @@ export declare class Vindral extends Emitter<PublicVindralEvents> {
1255
1216
  get timeSpentBuffering(): number;
1256
1217
  get timeActive(): number;
1257
1218
  get mediaElement(): HTMLMediaElement | HTMLCanvasElement;
1219
+ get audioNode(): AudioNode | undefined;
1220
+ get drmStatistics(): {
1221
+ keySystem?: string | undefined;
1222
+ licenseServerUrl?: string | undefined;
1223
+ mediaKeySystemConfiguration?: MediaKeySystemConfiguration | undefined;
1224
+ provider?: string | undefined;
1225
+ clearkeys?: Record<string, string>;
1226
+ playreadyLicenseUrl?: string;
1227
+ widevineLicenseUrl?: string;
1228
+ fairplayLicenseUrl?: string;
1229
+ fairplayCertificate?: ArrayBuffer;
1230
+ videoCodec?: string;
1231
+ audioCodec?: string;
1232
+ } | null;
1258
1233
  /**
1259
1234
  * Get active Vindral Options
1260
1235
  */
1261
- getOptions: () => Options & typeof defaultOptions;
1236
+ getOptions: () => Options;
1262
1237
  /**
1263
1238
  * Get url for fetching thumbnail. Note that fetching thumbnails only works for an active channel.
1264
1239
  */
@@ -1277,9 +1252,7 @@ export declare class Vindral extends Emitter<PublicVindralEvents> {
1277
1252
  * Get options that can be used for CastSender
1278
1253
  */
1279
1254
  getCastOptions: () => Options;
1280
- private connectionInfo;
1281
- private estimateRTT;
1282
- private connectHandler;
1255
+ private onConnectInfo;
1283
1256
  private emitLanguagesIfChanged;
1284
1257
  private updateTextTracks;
1285
1258
  private cleanupTextTracks;
@@ -1360,5 +1333,176 @@ export declare class Vindral extends Emitter<PublicVindralEvents> {
1360
1333
  private timeToFirstFrame;
1361
1334
  private willUseMediaSource;
1362
1335
  }
1336
+ interface TelemetryModuleStatistics {
1337
+ /**
1338
+ * The total amount of errors being spawned. Note that some media errors can trigger
1339
+ * thousands of errors for a single client in a few seconds before recovering. Therefore,
1340
+ * consider the number of viewers with errors, not just the total amount. Also, consider the median
1341
+ * instead of the mean for average calculation.
1342
+ */
1343
+ errorCount: number;
1344
+ }
1345
+ /**
1346
+ * Represents a connection state.
1347
+ */
1348
+ export type ConnectionState = "connected" | "disconnected" | "connecting";
1349
+ /**
1350
+ * Represents state of a context switch. The state change starts when connection starts receiving a new
1351
+ * channel or quality and is completed when the new quality/channel has received its init segments and key frames.
1352
+ */
1353
+ export type ContextSwitchState = "completed" | "started";
1354
+ interface ConnectionStatistics {
1355
+ /**
1356
+ * RTT (round trip time) between client and server(s).
1357
+ */
1358
+ rtt: MinMaxAverage;
1359
+ /**
1360
+ * A very rough initial estimation of minimum available bandwidth.
1361
+ */
1362
+ estimatedBandwidth: number;
1363
+ edgeUrl?: string;
1364
+ /**
1365
+ * Total number of connections that have been established since instantiation.
1366
+ */
1367
+ connectCount: number;
1368
+ /**
1369
+ * Total number of connection attempts since instantiation.
1370
+ */
1371
+ connectionAttemptCount: number;
1372
+ connectionProtocol: "vindral_ws" | "moq" | undefined;
1373
+ }
1374
+ /**
1375
+ * Contextual information about the language switch
1376
+ */
1377
+ export interface LanguageSwitchContext {
1378
+ /**
1379
+ * The new language that was switched to
1380
+ */
1381
+ language: string;
1382
+ }
1383
+ /**
1384
+ * Contextual information about the channel switch
1385
+ */
1386
+ export interface ChannelSwitchContext {
1387
+ /**
1388
+ * The new channel id that was switched to
1389
+ */
1390
+ channelId: string;
1391
+ }
1392
+ /**
1393
+ * Volume state changes
1394
+ */
1395
+ export interface VolumeState {
1396
+ /**
1397
+ * Wether the audio is muted
1398
+ */
1399
+ isMuted: boolean;
1400
+ /**
1401
+ * The volume level
1402
+ */
1403
+ volume: number;
1404
+ }
1405
+ /**
1406
+ * The events that can be emitted from the Vindral instance
1407
+ */
1408
+ export interface PublicVindralEvents {
1409
+ /**
1410
+ * When an error that requires action has occured
1411
+ *
1412
+ * Can be a fatal error that will unload the Vindral instance - this is indicated by `isFatal()` on the error object returning true.
1413
+ *
1414
+ * 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
1415
+ * 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.
1416
+ */
1417
+ ["error"]: Readonly<VindralError>;
1418
+ /**
1419
+ * When the instance needs user input to activate audio or sometimes video playback.
1420
+ * Is called with an object
1421
+ * ```javascript
1422
+ * {
1423
+ * forAudio: boolean // true if user input is needed for audio playback
1424
+ * forVideo: boolean // true if user input is needed for video playback
1425
+ * }
1426
+ * ```
1427
+ */
1428
+ ["needs user input"]: NeedsUserInputContext;
1429
+ /**
1430
+ * When a timed metadata event has been triggered
1431
+ */
1432
+ ["metadata"]: Readonly<Metadata>;
1433
+ /**
1434
+ * When the playback state changes
1435
+ */
1436
+ ["playback state"]: Readonly<PlaybackState>;
1437
+ /**
1438
+ * When the connection state changes
1439
+ */
1440
+ ["connection state"]: Readonly<ConnectionState>;
1441
+ /**
1442
+ * When the available rendition levels is changed
1443
+ */
1444
+ ["rendition levels"]: ReadonlyArray<RenditionLevel>;
1445
+ /**
1446
+ * When the rendition level is changed
1447
+ */
1448
+ ["rendition level"]: Readonly<RenditionLevel>;
1449
+ /**
1450
+ * When the available languages is changed
1451
+ */
1452
+ ["languages"]: ReadonlyArray<string>;
1453
+ /**
1454
+ * When the available text tracks are changed
1455
+ */
1456
+ ["text tracks"]: ReadonlyArray<string>;
1457
+ /**
1458
+ * When the available channels is changed
1459
+ */
1460
+ ["channels"]: ReadonlyArray<Channel>;
1461
+ /**
1462
+ * When a context switch state change has occured.
1463
+ * E.g. when a channel change has been requested, or quality is changed.
1464
+ */
1465
+ ["context switch"]: Readonly<ContextSwitchState>;
1466
+ /**
1467
+ * Emitted when a wallclock time message has been received from the server.
1468
+ *
1469
+ * Note: This is the edge server wallclock time and thus may differ slightly
1470
+ * between two viewers if they are connected to different edge servers.
1471
+ */
1472
+ ["server wallclock time"]: Readonly<number>;
1473
+ /**
1474
+ * Is emitted during connection whether the channel is live or not.
1475
+ *
1476
+ * If the channel is not live, the Vindral instance will try to reconnect until the `reconnectHandler`
1477
+ * determines that no more retries should be made.
1478
+ *
1479
+ * Note: If the web-sdk is instantiated at the same time as you are starting the stream it is possible
1480
+ * that this emits false until the started state has propagated through the system.
1481
+ */
1482
+ ["is live"]: boolean;
1483
+ /**
1484
+ * Emitted when a channel switch has been completed and the first frame of the new channel is rendered.
1485
+ * A string containing the channel id of the new channel is provided as an argument.
1486
+ */
1487
+ ["channel switch"]: Readonly<ChannelSwitchContext>;
1488
+ /**
1489
+ * Emmitted when a channel switch fails.
1490
+ * A string containing the channel id of the current channel is provided as an argument.
1491
+ */
1492
+ ["channel switch failed"]: Readonly<ChannelSwitchContext>;
1493
+ /**
1494
+ * Emitted when a language switch has been completed and the new language starts playing.
1495
+ */
1496
+ ["language switch"]: Readonly<LanguageSwitchContext>;
1497
+ /**
1498
+ * Emitted when the volume state changes.
1499
+ *
1500
+ * This is triggered triggered both when the user changes the volume through the Vindral instance, but also
1501
+ * from external sources such as OS media shortcuts or other native UI outside of the browser.
1502
+ */
1503
+ ["volume state"]: Readonly<VolumeState>;
1504
+ ["buffer state event"]: Readonly<BufferStateEvent>;
1505
+ ["initialized media"]: void;
1506
+ }
1363
1507
 
1364
1508
  export {};