forked from shaka-project/shaka-player
-
Notifications
You must be signed in to change notification settings - Fork 0
/
player.js
1291 lines (1234 loc) · 48.8 KB
/
player.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*! @license
* Shaka Player
* Copyright 2016 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @externs
*/
/**
* @typedef {{
* timestamp: number,
* id: number,
* type: string,
* fromAdaptation: boolean,
* bandwidth: ?number
* }}
*
* @property {number} timestamp
* The timestamp the choice was made, in seconds since 1970
* (i.e. <code>Date.now() / 1000</code>).
* @property {number} id
* The id of the track that was chosen.
* @property {string} type
* The type of track chosen (<code>'variant'</code> or <code>'text'</code>).
* @property {boolean} fromAdaptation
* <code>true</code> if the choice was made by AbrManager for adaptation;
* <code>false</code> if it was made by the application through
* <code>selectTrack</code>.
* @property {?number} bandwidth
* The bandwidth of the chosen track (<code>null</code> for text).
* @exportDoc
*/
shaka.extern.TrackChoice;
/**
* @typedef {{
* timestamp: number,
* state: string,
* duration: number
* }}
*
* @property {number} timestamp
* The timestamp the state was entered, in seconds since 1970
* (i.e. <code>Date.now() / 1000</code>).
* @property {string} state
* The state the player entered. This could be <code>'buffering'</code>,
* <code>'playing'</code>, <code>'paused'</code>, or <code>'ended'</code>.
* @property {number} duration
* The number of seconds the player was in this state. If this is the last
* entry in the list, the player is still in this state, so the duration will
* continue to increase.
* @exportDoc
*/
shaka.extern.StateChange;
/**
* @typedef {{
* width: number,
* height: number,
* streamBandwidth: number,
*
* decodedFrames: number,
* droppedFrames: number,
* corruptedFrames: number,
* estimatedBandwidth: number,
*
* completionPercent: number,
* loadLatency: number,
* manifestTimeSeconds: number,
* drmTimeSeconds: number,
* playTime: number,
* pauseTime: number,
* bufferingTime: number,
* licenseTime: number,
* liveLatency: number,
*
* maxSegmentDuration: number,
*
* switchHistory: !Array.<shaka.extern.TrackChoice>,
* stateHistory: !Array.<shaka.extern.StateChange>
* }}
*
* @description
* Contains statistics and information about the current state of the player.
* This is meant for applications that want to log quality-of-experience (QoE)
* or other stats. These values will reset when <code>load()</code> is called
* again.
*
* @property {number} width
* The width of the current video track.
* @property {number} height
* The height of the current video track.
* @property {number} streamBandwidth
* The bandwidth required for the current streams (total, in bit/sec).
* It takes into account the playbackrate.
*
* @property {number} decodedFrames
* The total number of frames decoded by the Player. This may be
* <code>NaN</code> if this is not supported by the browser.
* @property {number} droppedFrames
* The total number of frames dropped by the Player. This may be
* <code>NaN</code> if this is not supported by the browser.
* @property {number} corruptedFrames
* The total number of corrupted frames dropped by the browser. This may be
* <code>NaN</code> if this is not supported by the browser.
* @property {number} estimatedBandwidth
* The current estimated network bandwidth (in bit/sec).
*
* @property {number} completionPercent
* This is the greatest completion percent that the user has experienced in
* playback. Also known as the "high water mark". Is NaN when there is no
* known duration, such as for livestreams.
* @property {number} loadLatency
* This is the number of seconds it took for the video element to have enough
* data to begin playback. This is measured from the time load() is called to
* the time the <code>'loadeddata'</code> event is fired by the media element.
* @property {number} manifestTimeSeconds
* The amount of time it took to download and parse the manifest.
* @property {number} drmTimeSeconds
* The amount of time it took to download the first drm key.
* @property {number} playTime
* The total time spent in a playing state in seconds.
* @property {number} pauseTime
* The total time spent in a paused state in seconds.
* @property {number} bufferingTime
* The total time spent in a buffering state in seconds.
* @property {number} licenseTime
* The time spent on license requests during this session in seconds, or NaN.
* @property {number} liveLatency
* The time between the capturing of a frame and the end user having it
* displayed on their screen.
*
* @property {number} maxSegmentDuration
* The presentation's max segment duration in seconds, or NaN.
*
* @property {!Array.<shaka.extern.TrackChoice>} switchHistory
* A history of the stream changes.
* @property {!Array.<shaka.extern.StateChange>} stateHistory
* A history of the state changes.
* @exportDoc
*/
shaka.extern.Stats;
/**
* @typedef {{
* start: number,
* end: number
* }}
*
* @description
* Contains the times of a range of buffered content.
*
* @property {number} start
* The start time of the range, in seconds.
* @property {number} end
* The end time of the range, in seconds.
* @exportDoc
*/
shaka.extern.BufferedRange;
/**
* @typedef {{
* total: !Array.<shaka.extern.BufferedRange>,
* audio: !Array.<shaka.extern.BufferedRange>,
* video: !Array.<shaka.extern.BufferedRange>,
* text: !Array.<shaka.extern.BufferedRange>
* }}
*
* @description
* Contains information about the current buffered ranges.
*
* @property {!Array.<shaka.extern.BufferedRange>} total
* The combined audio/video buffered ranges, reported by
* <code>video.buffered</code>.
* @property {!Array.<shaka.extern.BufferedRange>} audio
* The buffered ranges for audio content.
* @property {!Array.<shaka.extern.BufferedRange>} video
* The buffered ranges for video content.
* @property {!Array.<shaka.extern.BufferedRange>} text
* The buffered ranges for text content.
* @exportDoc
*/
shaka.extern.BufferedInfo;
/**
* @typedef {{
* id: number,
* active: boolean,
*
* type: string,
* bandwidth: number,
*
* language: string,
* label: ?string,
* kind: ?string,
* width: ?number,
* height: ?number,
* frameRate: ?number,
* pixelAspectRatio: ?string,
* hdr: ?string,
* mimeType: ?string,
* audioMimeType: ?string,
* videoMimeType: ?string,
* codecs: ?string,
* audioCodec: ?string,
* videoCodec: ?string,
* primary: boolean,
* roles: !Array.<string>,
* audioRoles: Array.<string>,
* forced: boolean,
* videoId: ?number,
* audioId: ?number,
* channelsCount: ?number,
* audioSamplingRate: ?number,
* tilesLayout: ?string,
* audioBandwidth: ?number,
* videoBandwidth: ?number,
* spatialAudio: boolean,
* originalVideoId: ?string,
* originalAudioId: ?string,
* originalTextId: ?string,
* originalImageId: ?string
* }}
*
* @description
* An object describing a media track. This object should be treated as
* read-only as changing any values does not have any effect. This is the
* public view of an audio/video paring (variant type) or text track (text
* type) or image track (image type).
*
* @property {number} id
* The unique ID of the track.
* @property {boolean} active
* If true, this is the track being streamed (another track may be
* visible/audible in the buffer).
*
* @property {string} type
* The type of track, either <code>'variant'</code> or <code>'text'</code>
* or <code>'image'</code>.
* @property {number} bandwidth
* The bandwidth required to play the track, in bits/sec.
*
* @property {string} language
* The language of the track, or <code>'und'</code> if not given. This is the
* exact value provided in the manifest; it may need to be normalized.
* @property {?string} label
* The track label, which is unique text that should describe the track.
* @property {?string} kind
* (only for text tracks) The kind of text track, either
* <code>'caption'</code> or <code>'subtitle'</code>.
* @property {?number} width
* The video width provided in the manifest, if present.
* @property {?number} height
* The video height provided in the manifest, if present.
* @property {?number} frameRate
* The video framerate provided in the manifest, if present.
* @property {?string} pixelAspectRatio
* The video pixel aspect ratio provided in the manifest, if present.
* @property {?string} hdr
* The video HDR provided in the manifest, if present.
* @property {?string} mimeType
* The MIME type of the content provided in the manifest.
* @property {?string} audioMimeType
* The audio MIME type of the content provided in the manifest.
* @property {?string} videoMimeType
* The video MIME type of the content provided in the manifest.
* @property {?string} codecs
* The audio/video codecs string provided in the manifest, if present.
* @property {?string} audioCodec
* The audio codecs string provided in the manifest, if present.
* @property {?string} videoCodec
* The video codecs string provided in the manifest, if present.
* @property {boolean} primary
* True indicates that this in the primary language for the content.
* This flag is based on signals from the manifest.
* This can be a useful hint about which language should be the default, and
* indicates which track Shaka will use when the user's language preference
* cannot be satisfied.
* @property {!Array.<string>} roles
* The roles of the track, e.g. <code>'main'</code>, <code>'caption'</code>,
* or <code>'commentary'</code>.
* @property {Array.<string>} audioRoles
* The roles of the audio in the track, e.g. <code>'main'</code> or
* <code>'commentary'</code>. Will be null for text tracks or variant tracks
* without audio.
* @property {boolean} forced
* True indicates that this in the forced text language for the content.
* This flag is based on signals from the manifest.
* @property {?number} videoId
* (only for variant tracks) The video stream id.
* @property {?number} audioId
* (only for variant tracks) The audio stream id.
* @property {?number} channelsCount
* The count of the audio track channels.
* @property {?number} audioSamplingRate
* Specifies the maximum sampling rate of the content.
* @property {?string} tilesLayout
* The value is a grid-item-dimension consisting of two positive decimal
* integers in the format: column-x-row ('4x3'). It describes the arrangement
* of Images in a Grid. The minimum valid LAYOUT is '1x1'.
* @property {boolean} spatialAudio
* True indicates that the content has spatial audio.
* This flag is based on signals from the manifest.
* @property {?number} audioBandwidth
* (only for variant tracks) The audio stream's bandwidth if known.
* @property {?number} videoBandwidth
* (only for variant tracks) The video stream's bandwidth if known.
* @property {?string} originalVideoId
* (variant tracks only) The original ID of the video part of the track, if
* any, as it appeared in the original manifest.
* @property {?string} originalAudioId
* (variant tracks only) The original ID of the audio part of the track, if
* any, as it appeared in the original manifest.
* @property {?string} originalTextId
* (text tracks only) The original ID of the text track, if any, as it
* appeared in the original manifest.
* @property {?string} originalImageId
* (image tracks only) The original ID of the image track, if any, as it
* appeared in the original manifest.
* @exportDoc
*/
shaka.extern.Track;
/**
* @typedef {!Array.<!shaka.extern.Track>}
*/
shaka.extern.TrackList;
/**
* @typedef {{
* minWidth: number,
* maxWidth: number,
* minHeight: number,
* maxHeight: number,
* minPixels: number,
* maxPixels: number,
*
* minFrameRate: number,
* maxFrameRate: number,
*
* minBandwidth: number,
* maxBandwidth: number
* }}
*
* @description
* An object describing application restrictions on what tracks can play. All
* restrictions must be fulfilled for a track to be playable/selectable.
* The restrictions system behaves somewhat differently at the ABR level and the
* player level, so please refer to the documentation for those specific
* settings.
*
* @see shaka.extern.PlayerConfiguration
* @see shaka.extern.AbrConfiguration
*
* @property {number} minWidth
* The minimum width of a video track, in pixels.
* @property {number} maxWidth
* The maximum width of a video track, in pixels.
* @property {number} minHeight
* The minimum height of a video track, in pixels.
* @property {number} maxHeight
* The maximum height of a video track, in pixels.
* @property {number} minPixels
* The minimum number of total pixels in a video track (i.e.
* <code>width * height</code>).
* @property {number} maxPixels
* The maximum number of total pixels in a video track (i.e.
* <code>width * height</code>).
*
* @property {number} minFrameRate
* The minimum framerate of a variant track.
* @property {number} maxFrameRate
* The maximum framerate of a variant track.
*
* @property {number} minBandwidth
* The minimum bandwidth of a variant track, in bit/sec.
* @property {number} maxBandwidth
* The maximum bandwidth of a variant track, in bit/sec.
* @exportDoc
*/
shaka.extern.Restrictions;
/**
* @typedef {{
* persistentState: boolean
* }}
*
* @property {boolean} persistentState
* Whether this key system supports persistent state.
* @exportDoc
*/
shaka.extern.DrmSupportType;
/**
* @typedef {{
* manifest: !Object.<string, boolean>,
* media: !Object.<string, boolean>,
* drm: !Object.<string, ?shaka.extern.DrmSupportType>
* }}
*
* @description
* An object detailing browser support for various features.
*
* @property {!Object.<string, boolean>} manifest
* A map of supported manifest types.
* The keys are manifest MIME types and file extensions.
* @property {!Object.<string, boolean>} media
* A map of supported media types.
* The keys are media MIME types.
* @property {!Object.<string, ?shaka.extern.DrmSupportType>} drm
* A map of supported key systems.
* The keys are the key system names. The value is <code>null</code> if it is
* not supported. Key systems not probed will not be in this dictionary.
*
* @exportDoc
*/
shaka.extern.SupportType;
/**
* @typedef {!Object.<string, ?>}
*
* @description
* ID3 metadata in format defined by
* https://id3.org/id3v2.3.0#Declared_ID3v2_frames
* The content of the field.
*
* @exportDoc
*/
shaka.extern.ID3Metadata;
/**
* @typedef {{
* schemeIdUri: string,
* value: string,
* startTime: number,
* endTime: number,
* id: string,
* eventElement: Element
* }}
*
* @description
* Contains information about a region of the timeline that will cause an event
* to be raised when the playhead enters or exits it. In DASH this is the
* EventStream element.
*
* @property {string} schemeIdUri
* Identifies the message scheme.
* @property {string} value
* Specifies the value for the region.
* @property {number} startTime
* The presentation time (in seconds) that the region should start.
* @property {number} endTime
* The presentation time (in seconds) that the region should end.
* @property {string} id
* Specifies an identifier for this instance of the region.
* @property {Element} eventElement
* The XML element that defines the Event.
* @exportDoc
*/
shaka.extern.TimelineRegionInfo;
/**
* @typedef {{
* audioSamplingRate: ?number,
* bandwidth: number,
* codecs: string,
* contentType: string,
* frameRate: ?number,
* height: ?number,
* mimeType: ?string,
* channelsCount: ?number,
* pixelAspectRatio: ?string,
* width: ?number
* }}
*
* @description
* Contains information about the quality of an audio or video media stream.
*
* @property {?number} audioSamplingRate
* Specifies the maximum sampling rate of the content.
* @property {number} bandwidth
* The bandwidth in bits per second.
* @property {string} codecs
* The Stream's codecs, e.g., 'avc1.4d4015' or 'vp9', which must be
* compatible with the Stream's MIME type.
* @property {string} contentType
* The type of content, which may be "video" or "audio".
* @property {?number} frameRate
* The video frame rate.
* @property {?number} height
* The video height in pixels.
* @property {string} mimeType
* The MIME type.
* @property {?number} channelsCount
* The number of audio channels, or null if unknown.
* @property {?string} pixelAspectRatio
* The pixel aspect ratio value; e.g "1:1".
* @property {?number} width
* The video width in pixels.
* @exportDoc
*/
shaka.extern.MediaQualityInfo;
/**
* @typedef {{
* schemeIdUri: string,
* value: string,
* startTime: number,
* endTime: number,
* timescale: number,
* presentationTimeDelta: number,
* eventDuration: number,
* id: number,
* messageData: Uint8Array
* }}
*
* @description
* Contains information about an EMSG MP4 box.
*
* @property {string} schemeIdUri
* Identifies the message scheme.
* @property {string} value
* Specifies the value for the event.
* @property {number} startTime
* The time that the event starts (in presentation time).
* @property {number} endTime
* The time that the event ends (in presentation time).
* @property {number} timescale
* Provides the timescale, in ticks per second.
* @property {number} presentationTimeDelta
* The offset that the event starts, relative to the start of the segment
* this is contained in (in units of timescale).
* @property {number} eventDuration
* The duration of the event (in units of timescale).
* @property {number} id
* A field identifying this instance of the message.
* @property {Uint8Array} messageData
* Body of the message.
* @exportDoc
*/
shaka.extern.EmsgInfo;
/**
* @typedef {{
* distinctiveIdentifierRequired: boolean,
* persistentStateRequired: boolean,
* videoRobustness: string,
* audioRobustness: string,
* serverCertificate: Uint8Array,
* serverCertificateUri: string,
* individualizationServer: string,
* sessionType: string
* }}
*
* @property {boolean} distinctiveIdentifierRequired
* <i>Defaults to false.</i> <br>
* True if the application requires the key system to support distinctive
* identifiers.
* @property {boolean} persistentStateRequired
* <i>Defaults to false.</i> <br>
* True if the application requires the key system to support persistent
* state, e.g., for persistent license storage.
* @property {string} videoRobustness
* A key-system-specific string that specifies a required security level for
* video.
* <i>Defaults to <code>''</code>, i.e., no specific robustness required.</i>
* @property {string} audioRobustness
* A key-system-specific string that specifies a required security level for
* audio.
* <i>Defaults to <code>''</code>, i.e., no specific robustness required.</i>
* @property {Uint8Array} serverCertificate
* <i>Defaults to null.</i> <br>
* <i>An empty certificate (<code>byteLength==0</code>) will be treated as
* <code>null</code>.</i> <br>
* <i>A certificate will be requested from the license server if
* required.</i> <br>
* A key-system-specific server certificate used to encrypt license requests.
* Its use is optional and is meant as an optimization to avoid a round-trip
* to request a certificate.
* @property {string} serverCertificateUri
* <i>Defaults to <code>''</code>.</i><br>
* If given, will make a request to the given URI to get the server
* certificate. This is ignored if <code>serverCertificate</code> is set.
* @property {string} individualizationServer
* The server that handles an <code>'individualiation-request'</code>. If the
* server isn't given, it will default to the license server.
* @property {string} sessionType
* <i>Defaults to <code>'temporary'</code> for streaming.</i> <br>
* The MediaKey session type to create streaming licenses with. This doesn't
* affect offline storage.
*
* @exportDoc
*/
shaka.extern.AdvancedDrmConfiguration;
/**
* @typedef {{
* retryParameters: shaka.extern.RetryParameters,
* servers: !Object.<string, string>,
* clearKeys: !Object.<string, string>,
* delayLicenseRequestUntilPlayed: boolean,
* advanced: Object.<string, shaka.extern.AdvancedDrmConfiguration>,
* initDataTransform:
* ((function(!Uint8Array, string, ?shaka.extern.DrmInfo):!Uint8Array)|
* undefined),
* logLicenseExchange: boolean,
* updateExpirationTime: number,
* preferredKeySystems: !Array.<string>,
* keySystemsMapping: !Object.<string, string>
* }}
*
* @property {shaka.extern.RetryParameters} retryParameters
* Retry parameters for license requests.
* @property {!Object.<string, string>} servers
* <i>Required for all but the clear key CDM.</i> <br>
* A dictionary which maps key system IDs to their license servers.
* For example,
* <code>{'com.widevine.alpha': 'https://example.com/drm'}</code>.
* @property {!Object.<string, string>} clearKeys
* <i>Forces the use of the Clear Key CDM.</i>
* A map of key IDs (hex) to keys (hex).
* @property {boolean} delayLicenseRequestUntilPlayed
* <i>Defaults to false.</i> <br>
* True to configure drm to delay sending a license request until a user
* actually starts playing content.
* @property {Object.<string, shaka.extern.AdvancedDrmConfiguration>} advanced
* <i>Optional.</i> <br>
* A dictionary which maps key system IDs to advanced DRM configuration for
* those key systems.
* @property
* {((function(!Uint8Array, string, ?shaka.extern.DrmInfo):!Uint8Array)|
* undefined)}
* initDataTransform
* <i>Optional.</i><br>
* If given, this function is called with the init data from the
* manifest/media and should return the (possibly transformed) init data to
* pass to the browser.
* @property {boolean} logLicenseExchange
* <i>Optional.</i><br>
* If set to <code>true</code>, prints logs containing the license exchange.
* This includes the init data, request, and response data, printed as base64
* strings. Don't use in production, for debugging only; has no affect in
* release builds as logging is removed.
* @property {number} updateExpirationTime
* <i>Defaults to 1.</i> <br>
* The frequency in seconds with which to check the expiration of a session.
* @property {!Array.<string>} preferredKeySystems
* <i>Defaults to an empty array. </i> <br>
* Specifies the priorties of available DRM key systems.
* @property {Object.<string, string>} keySystemsMapping
* A map of key system name to key system name.
*
* @exportDoc
*/
shaka.extern.DrmConfiguration;
/**
* @typedef {{
* clockSyncUri: string,
* ignoreDrmInfo: boolean,
* disableXlinkProcessing: boolean,
* xlinkFailGracefully: boolean,
* ignoreMinBufferTime: boolean,
* autoCorrectDrift: boolean,
* initialSegmentLimit: number,
* ignoreSuggestedPresentationDelay: boolean,
* ignoreEmptyAdaptationSet: boolean,
* ignoreMaxSegmentDuration: boolean,
* keySystemsByURI: !Object.<string, string>,
* manifestPreprocessor: function(!Element)
* }}
*
* @property {string} clockSyncUri
* A default clock sync URI to be used with live streams which do not
* contain any clock sync information. The <code>Date</code> header from this
* URI will be used to determine the current time.
* @property {boolean} ignoreDrmInfo
* If true will cause DASH parser to ignore DRM information specified
* by the manifest and treat it as if it signaled no particular key
* system and contained no init data. Defaults to false if not provided.
* @property {boolean} disableXlinkProcessing
* If true, xlink-related processing will be disabled. Defaults to
* <code>false</code> if not provided.
* @property {boolean} xlinkFailGracefully
* If true, xlink-related errors will result in a fallback to the tag's
* existing contents. If false, xlink-related errors will be propagated
* to the application and will result in a playback failure. Defaults to
* false if not provided.
* @property {boolean} ignoreMinBufferTime
* If true will cause DASH parser to ignore <code>minBufferTime</code> from
* manifest. It allows player config to take precedence over manifest for
* <code>rebufferingGoal</code>. Defaults to <code>false</code> if not
* provided.
* @property {boolean} autoCorrectDrift
* If <code>true</code>, ignore the <code>availabilityStartTime</code> in the
* manifest and instead use the segments to determine the live edge. This
* allows us to play streams that have a lot of drift. If <code>false</code>,
* we can't play content where the manifest specifies segments in the future.
* Defaults to <code>true</code>.
* @property {number} initialSegmentLimit
* The maximum number of initial segments to generate for
* <code>SegmentTemplate</code> with fixed-duration segments. This is limited
* to avoid excessive memory consumption with very large
* <code>timeShiftBufferDepth</code> values.
* @property {boolean} ignoreSuggestedPresentationDelay
* If true will cause DASH parser to ignore
* <code>suggestedPresentationDelay</code> from manifest. Defaults to
* <code>false</code> if not provided.
* @property {boolean} ignoreEmptyAdaptationSet
* If true will cause DASH parser to ignore
* empty <code>AdaptationSet</code> from manifest. Defaults to
* <code>false</code> if not provided.
* @property {boolean} ignoreMaxSegmentDuration
* If true will cause DASH parser to ignore
* <code>maxSegmentDuration</code> from manifest. Defaults to
* <code>false</code> if not provided.
* @property {Object.<string, string>} keySystemsByURI
* A map of scheme URI to key system name. Defaults to default key systems
* mapping handled by Shaka.
* @property {function(!Element)} manifestPreprocessor
* Called immediately after the DASH manifest has been parsed into an
* XMLDocument. Provides a way for applications to perform efficient
* preprocessing of the manifest.
* @exportDoc
*/
shaka.extern.DashManifestConfiguration;
/**
* @typedef {{
* ignoreTextStreamFailures: boolean,
* ignoreImageStreamFailures: boolean,
* defaultAudioCodec: string,
* defaultVideoCodec: string,
* ignoreManifestProgramDateTime: boolean,
* mediaPlaylistFullMimeType: string
* }}
*
* @property {boolean} ignoreTextStreamFailures
* If <code>true</code>, ignore any errors in a text stream and filter out
* those streams.
* @property {boolean} ignoreImageStreamFailures
* If <code>true</code>, ignore any errors in a image stream and filter out
* those streams.
* @property {string} defaultAudioCodec
* The default audio codec if it is not specified in the HLS playlist.
* <i>Defaults to <code>'mp4a.40.2'</code>.</i>
* @property {string} defaultVideoCodec
* The default video codec if it is not specified in the HLS playlist.
* <i>Defaults to <code>'avc1.42E01E'</code>.</i>
* @property {boolean} ignoreManifestProgramDateTime
* If <code>true</code>, the HLS parser will ignore the
* <code>EXT-X-PROGRAM-DATE-TIME</code> tags in the manifest.
* Meant for tags that are incorrect or malformed.
* <i>Defaults to <code>false</code>.</i>
* @property {string} mediaPlaylistFullMimeType
* A string containing a full mime type, including both the basic mime type
* and also the codecs. Used when the HLS parser parses a media playlist
* directly, required since all of the mime type and codecs information is
* contained within the master playlist.
* You can use the <code>shaka.util.MimeUtils.getFullType()</code> utility to
* format this value.
* <i>Defaults to
* <code>'video/mp2t; codecs="avc1.42E01E, mp4a.40.2"'</code>.</i>
* @exportDoc
*/
shaka.extern.HlsManifestConfiguration;
/**
* @typedef {{
* retryParameters: shaka.extern.RetryParameters,
* availabilityWindowOverride: number,
* disableAudio: boolean,
* disableVideo: boolean,
* disableText: boolean,
* disableThumbnails: boolean,
* defaultPresentationDelay: number,
* segmentRelativeVttTiming: boolean,
* dash: shaka.extern.DashManifestConfiguration,
* hls: shaka.extern.HlsManifestConfiguration
* }}
*
* @property {shaka.extern.RetryParameters} retryParameters
* Retry parameters for manifest requests.
* @property {number} availabilityWindowOverride
* A number, in seconds, that overrides the availability window in the
* manifest, or <code>NaN</code> if the default value should be used. This is
* enforced by the manifest parser, so custom manifest parsers should take
* care to honor this parameter.
* @property {boolean} disableAudio
* If <code>true</code>, the audio tracks are ignored.
* Defaults to <code>false</code>.
* @property {boolean} disableVideo
* If <code>true</code>, the video tracks are ignored.
* Defaults to <code>false</code>.
* @property {boolean} disableText
* If <code>true</code>, the text tracks are ignored.
* Defaults to <code>false</code>.
* @property {boolean} disableThumbnails
* If <code>true</code>, the image tracks are ignored.
* Defaults to <code>false</code>.
* @property {number} defaultPresentationDelay
* A default <code>presentationDelay</code> value.
* For DASH, it's a default <code>presentationDelay</code> value if
* <code>suggestedPresentationDelay</code> is missing in the MPEG DASH
* manifest. The default value is <code>1.5 * minBufferTime</code> if not
* configured or set as 0.
* For HLS, the default value is 3 segments duration if not configured or
* set as 0.
* @property {boolean} segmentRelativeVttTiming
* Option to calculate VTT text timings relative to the segment start
* instead of relative to the period start (which is the default).
* Defaults to <code>false</code>.
* @property {shaka.extern.DashManifestConfiguration} dash
* Advanced parameters used by the DASH manifest parser.
* @property {shaka.extern.HlsManifestConfiguration} hls
* Advanced parameters used by the HLS manifest parser.
*
* @exportDoc
*/
shaka.extern.ManifestConfiguration;
/**
* @typedef {{
* retryParameters: shaka.extern.RetryParameters,
* failureCallback: function(!shaka.util.Error),
* rebufferingGoal: number,
* bufferingGoal: number,
* bufferBehind: number,
* ignoreTextStreamFailures: boolean,
* alwaysStreamText: boolean,
* startAtSegmentBoundary: boolean,
* gapDetectionThreshold: number,
* durationBackoff: number,
* forceTransmuxTS: boolean,
* safeSeekOffset: number,
* stallEnabled: boolean,
* stallThreshold: number,
* stallSkip: number,
* useNativeHlsOnSafari: boolean,
* inaccurateManifestTolerance: number,
* lowLatencyMode: boolean,
* autoLowLatencyMode: boolean,
* forceHTTPS: boolean,
* preferNativeHls: boolean,
* updateIntervalSeconds: number,
* dispatchAllEmsgBoxes: boolean,
* observeQualityChanges: boolean,
* maxDisabledTime: number
* }}
*
* @description
* The StreamingEngine's configuration options.
*
* @property {shaka.extern.RetryParameters} retryParameters
* Retry parameters for segment requests.
* @property {function(!shaka.util.Error)} failureCallback
* A callback to decide what to do on a streaming failure. Default behavior
* is to retry on live streams and not on VOD.
* @property {number} rebufferingGoal
* The minimum number of seconds of content that the StreamingEngine must
* buffer before it can begin playback or can continue playback after it has
* entered into a buffering state (i.e., after it has depleted one more
* more of its buffers).
* @property {number} bufferingGoal
* The number of seconds of content that the StreamingEngine will attempt to
* buffer ahead of the playhead. This value must be greater than or equal to
* the rebuffering goal.
* @property {number} bufferBehind
* The maximum number of seconds of content that the StreamingEngine will keep
* in buffer behind the playhead when it appends a new media segment.
* The StreamingEngine will evict content to meet this limit.
* @property {boolean} ignoreTextStreamFailures
* If <code>true</code>, the player will ignore text stream failures and
* continue playing other streams.
* @property {boolean} alwaysStreamText
* If <code>true</code>, always stream text tracks, regardless of whether or
* not they are shown. This is necessary when using the browser's built-in
* controls, which are not capable of signaling display state changes back to
* Shaka Player.
* Defaults to <code>false</code>.
* @property {boolean} startAtSegmentBoundary
* If <code>true</code>, adjust the start time backwards so it is at the start
* of a segment. This affects both explicit start times and calculated start
* time for live streams. This can put us further from the live edge. Defaults
* to <code>false</code>.
* @property {number} gapDetectionThreshold
* TThe maximum distance (in seconds) before a gap when we'll automatically
* jump. This value defaults to <code>0.1</code>, except in Edge Legacy,
* Tizen, Chromecast that value defaults value is <code>0.5</code>
* @property {number} durationBackoff
* By default, we will not allow seeking to exactly the duration of a
* presentation. This field is the number of seconds before duration we will
* seek to when the user tries to seek to or start playback at the duration.
* To disable this behavior, the config can be set to 0. We recommend using
* the default value unless you have a good reason not to.
* @property {boolean} forceTransmuxTS
* If this is <code>true</code>, we will transmux TS content even if not
* strictly necessary for the assets to be played. Shaka Player currently
* only supports CEA 708 captions by transmuxing, so this value is necessary
* for enabling them on platforms with native TS support like Edge or
* Chromecast. This value defaults to <code>false</code>.
* @property {number} safeSeekOffset
* The amount of seconds that should be added when repositioning the playhead
* after falling out of the availability window or seek. This gives the player
* more time to buffer before falling outside again, but increases the forward
* jump in the stream skipping more content. This is helpful for lower
* bandwidth scenarios. Defaults to 5 if not provided.
* @property {boolean} stallEnabled
* When set to <code>true</code>, the stall detector logic will run. If the
* playhead stops moving for <code>stallThreshold</code> seconds, the player
* will either seek or pause/play to resolve the stall, depending on the value
* of <code>stallSkip</code>.
* @property {number} stallThreshold
* The maximum number of seconds that may elapse without the playhead moving
* (when playback is expected) before it will be labeled as a stall.
* @property {number} stallSkip
* The number of seconds that the player will skip forward when a stall has
* been detected. If 0, the player will pause and immediately play instead of
* seeking. A value of 0 is recommended and provided as default on TV
* platforms (WebOS, Tizen, Chromecast, etc).
* @property {boolean} useNativeHlsOnSafari
* Desktop Safari has both MediaSource and their native HLS implementation.
* Depending on the application's needs, it may prefer one over the other.
* Warning when disabled: Where single-key DRM streams work fine, multi-keys
* streams is showing unexpected behaviours (stall, audio playing with video
* freezes, ...). Use with care.
* @property {number} inaccurateManifestTolerance
* The maximum difference, in seconds, between the times in the manifest and
* the times in the segments. Larger values allow us to compensate for more
* drift (up to one segment duration). Smaller values reduce the incidence of
* extra segment requests necessary to compensate for drift.
* @property {boolean} lowLatencyMode
* If <code>true</code>, low latency streaming mode is enabled. If
* lowLatencyMode is set to true, inaccurateManifestTolerance is set to 0
* unless specified, and rebufferingGoal to 0.01 unless specified at the same
* time.
* @property {boolean} autoLowLatencyMode
* If the stream is low latency and the user has not configured the
* lowLatencyMode, but if it has been configured to activate the
* lowLatencyMode if a stream of this type is detected, we automatically
* activate the lowLatencyMode. Defaults to false.
* @property {boolean} forceHTTPS
* If true, if the protocol is HTTP change it to HTTPs.
* @property {boolean} preferNativeHls
* If true, prefer native HLS playback when possible, regardless of platform.
* @property {number} updateIntervalSeconds
* The minimum number of seconds to see if the manifest has changes.
* @property {boolean} dispatchAllEmsgBoxes
* If true, all emsg boxes are parsed and dispatched.
* @property {boolean} observeQualityChanges
* If true, monitor media quality changes and emit
* <code.shaka.Player.MediaQualityChangedEvent</code>.
* @property {number} maxDisabledTime
* The maximum time a variant can be disabled when NETWORK HTTP_ERROR
* is reached, in seconds.
* If all variants are disabled this way, NETWORK HTTP_ERROR will be thrown.
* @exportDoc
*/
shaka.extern.StreamingConfiguration;
/**
* @typedef {{
* enabled: boolean,
* useNetworkInformation: boolean,
* defaultBandwidthEstimate: number,
* restrictions: shaka.extern.Restrictions,
* switchInterval: number,
* bandwidthUpgradeTarget: number,
* bandwidthDowngradeTarget: number,
* advanced: shaka.extern.AdvancedAbrConfiguration
* }}
*
* @property {boolean} enabled
* If true, enable adaptation by the current AbrManager. Defaults to true.
* @property {boolean} useNetworkInformation
* If true, use Network Information API in the current AbrManager.
* Defaults to true.