shaka-player 3.1.4 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.md +1 -1
  2. package/.github/ISSUE_TEMPLATE/feature_request.md +1 -1
  3. package/.github/ISSUE_TEMPLATE/question.md +1 -1
  4. package/AUTHORS +6 -5
  5. package/CHANGELOG.md +363 -0
  6. package/CONTRIBUTORS +4 -2
  7. package/README.md +4 -4
  8. package/build/types/core +3 -0
  9. package/build/types/offline +1 -0
  10. package/build/types/polyfill +2 -0
  11. package/build/types/ui +2 -0
  12. package/demo/common/asset.js +9 -7
  13. package/demo/common/assets.js +28 -1
  14. package/demo/common/message_ids.js +15 -2
  15. package/demo/config.js +35 -2
  16. package/demo/index.html +1 -1
  17. package/demo/locales/en.json +14 -1
  18. package/demo/locales/source.json +56 -4
  19. package/demo/main.js +2 -1
  20. package/dist/controls.css +26 -2
  21. package/dist/controls.css.map +1 -1
  22. package/dist/demo.compiled.debug.js +24 -21
  23. package/dist/demo.compiled.debug.map +3 -3
  24. package/dist/demo.compiled.js +24 -21
  25. package/dist/demo.compiled.map +3 -3
  26. package/dist/deps.js +33 -25
  27. package/dist/locales.js +31 -29
  28. package/dist/receiver.compiled.debug.js +14 -12
  29. package/dist/receiver.compiled.debug.map +3 -3
  30. package/dist/receiver.compiled.js +14 -12
  31. package/dist/receiver.compiled.map +3 -3
  32. package/dist/shaka-player.compiled.d.ts +258 -20
  33. package/dist/shaka-player.compiled.debug.d.ts +258 -20
  34. package/dist/shaka-player.compiled.debug.externs.js +1005 -695
  35. package/dist/shaka-player.compiled.debug.js +720 -640
  36. package/dist/shaka-player.compiled.debug.map +4 -4
  37. package/dist/shaka-player.compiled.externs.js +1005 -695
  38. package/dist/shaka-player.compiled.js +850 -817
  39. package/dist/shaka-player.compiled.map +4 -4
  40. package/dist/shaka-player.ui.d.ts +274 -21
  41. package/dist/shaka-player.ui.debug.d.ts +274 -21
  42. package/dist/shaka-player.ui.debug.externs.js +766 -429
  43. package/dist/shaka-player.ui.debug.js +863 -765
  44. package/dist/shaka-player.ui.debug.map +4 -4
  45. package/dist/shaka-player.ui.externs.js +766 -429
  46. package/dist/shaka-player.ui.js +1042 -996
  47. package/dist/shaka-player.ui.map +4 -4
  48. package/docs/design/bg-fetch-after.gv +29 -0
  49. package/docs/design/bg-fetch-after.gv.png +0 -0
  50. package/docs/design/bg-fetch-before.gv +18 -0
  51. package/docs/design/bg-fetch-before.gv.png +0 -0
  52. package/docs/design/bg-fetch.md +134 -0
  53. package/docs/tutorials/blob-url.md +15 -0
  54. package/docs/tutorials/index.json +1 -0
  55. package/docs/tutorials/ui-customization.md +66 -0
  56. package/docs/tutorials/ui.md +5 -5
  57. package/externs/aria.js +6 -0
  58. package/externs/ima.js +3 -0
  59. package/externs/shaka/ads.js +29 -1
  60. package/externs/shaka/manifest.js +18 -2
  61. package/externs/shaka/manifest_parser.js +10 -1
  62. package/externs/shaka/net.js +20 -4
  63. package/externs/shaka/offline.js +36 -2
  64. package/externs/shaka/player.js +182 -13
  65. package/externs/shaka/text.js +24 -10
  66. package/externs/texttrack.js +3 -0
  67. package/externs/webcrypto.js +18 -0
  68. package/lib/abr/ewma.js +14 -0
  69. package/lib/abr/ewma_bandwidth_estimator.js +16 -2
  70. package/lib/abr/simple_abr_manager.js +6 -0
  71. package/lib/ads/ad_manager.js +16 -15
  72. package/lib/ads/client_side_ad.js +8 -0
  73. package/lib/ads/client_side_ad_manager.js +14 -6
  74. package/lib/ads/server_side_ad.js +7 -0
  75. package/lib/ads/server_side_ad_manager.js +19 -2
  76. package/lib/cast/cast_proxy.js +8 -0
  77. package/lib/cast/cast_utils.js +7 -1
  78. package/lib/cea/cea608_data_channel.js +56 -56
  79. package/lib/cea/cea608_memory.js +33 -33
  80. package/lib/cea/cea708_service.js +43 -43
  81. package/lib/cea/cea708_window.js +38 -38
  82. package/lib/cea/cea_decoder.js +13 -14
  83. package/lib/cea/cea_utils.js +23 -23
  84. package/lib/cea/dtvcc_packet_builder.js +7 -7
  85. package/lib/cea/i_caption_decoder.js +2 -3
  86. package/lib/cea/i_cea_parser.js +2 -2
  87. package/lib/cea/mp4_cea_parser.js +6 -6
  88. package/lib/dash/dash_parser.js +53 -14
  89. package/lib/dash/segment_base.js +25 -1
  90. package/lib/dash/segment_list.js +18 -9
  91. package/lib/dash/segment_template.js +23 -10
  92. package/lib/hls/hls_parser.js +210 -30
  93. package/lib/media/closed_caption_parser.js +1 -2
  94. package/lib/media/drm_engine.js +162 -192
  95. package/lib/media/quality_observer.js +291 -0
  96. package/lib/media/segment_index.js +9 -1
  97. package/lib/media/segment_reference.js +37 -5
  98. package/lib/media/streaming_engine.js +48 -10
  99. package/lib/net/http_fetch_plugin.js +31 -11
  100. package/lib/net/http_plugin_utils.js +1 -0
  101. package/lib/net/http_xhr_plugin.js +40 -14
  102. package/lib/net/networking_engine.js +82 -18
  103. package/lib/offline/download_info.js +68 -0
  104. package/lib/offline/download_manager.js +14 -7
  105. package/lib/offline/indexeddb/base_storage_cell.js +35 -0
  106. package/lib/offline/indexeddb/storage_mechanism.js +1 -1
  107. package/lib/offline/indexeddb/v1_storage_cell.js +1 -0
  108. package/lib/offline/indexeddb/v2_storage_cell.js +1 -0
  109. package/lib/offline/indexeddb/v5_storage_cell.js +5 -0
  110. package/lib/offline/manifest_converter.js +3 -1
  111. package/lib/offline/storage.js +404 -297
  112. package/lib/offline/stored_content_utils.js +2 -0
  113. package/lib/player.js +622 -153
  114. package/lib/polyfill/aria.js +82 -0
  115. package/lib/polyfill/random_uuid.js +52 -0
  116. package/lib/routing/walker.js +2 -3
  117. package/lib/text/cue.js +12 -0
  118. package/lib/text/srt_text_parser.js +4 -4
  119. package/lib/text/text_engine.js +2 -2
  120. package/lib/text/ttml_text_parser.js +25 -2
  121. package/lib/text/ui_text_displayer.js +2 -2
  122. package/lib/text/vtt_text_parser.js +2 -2
  123. package/lib/text/web_vtt_generator.js +55 -12
  124. package/lib/util/cmcd_manager.js +826 -0
  125. package/lib/util/error.js +12 -0
  126. package/lib/util/language_utils.js +12 -0
  127. package/lib/util/manifest_parser_utils.js +1 -0
  128. package/lib/util/mp4_box_parsers.js +20 -20
  129. package/lib/util/multi_map.js +8 -0
  130. package/lib/util/mutex.js +52 -0
  131. package/lib/util/periods.js +98 -64
  132. package/lib/util/player_configuration.js +31 -1
  133. package/lib/util/stream_utils.js +140 -85
  134. package/lib/util/xml_utils.js +31 -12
  135. package/package.json +1 -1
  136. package/roadmap.md +24 -22
  137. package/shaka-player.uncompiled.js +4 -0
  138. package/test/cast/cast_utils_unit.js +1 -0
  139. package/test/cea/cea608_memory_unit.js +1 -1
  140. package/test/cea/cea708_service_unit.js +8 -8
  141. package/test/cea/cea708_window_unit.js +6 -6
  142. package/test/cea/cea_decoder_unit.js +1 -1
  143. package/test/cea/dtvcc_packet_builder_unit.js +2 -2
  144. package/test/dash/dash_parser_content_protection_unit.js +2 -0
  145. package/test/dash/dash_parser_live_unit.js +101 -1
  146. package/test/dash/dash_parser_manifest_unit.js +78 -2
  147. package/test/dash/dash_parser_segment_base_unit.js +2 -0
  148. package/test/dash/dash_parser_segment_list_unit.js +2 -1
  149. package/test/dash/dash_parser_segment_template_unit.js +2 -1
  150. package/test/hls/hls_live_unit.js +2 -0
  151. package/test/hls/hls_parser_unit.js +252 -0
  152. package/test/media/drm_engine_integration.js +86 -12
  153. package/test/media/drm_engine_unit.js +310 -450
  154. package/test/media/quality_observer_unit.js +139 -0
  155. package/test/media/segment_reference_unit.js +16 -1
  156. package/test/media/streaming_engine_integration.js +2 -1
  157. package/test/media/streaming_engine_unit.js +2 -0
  158. package/test/net/http_plugin_unit.js +20 -15
  159. package/test/offline/manifest_convert_unit.js +2 -0
  160. package/test/offline/storage_integration.js +117 -23
  161. package/test/player_integration.js +151 -0
  162. package/test/player_src_equals_integration.js +52 -0
  163. package/test/player_unit.js +11 -33
  164. package/test/test/assets/chapters.srt +11 -0
  165. package/test/test/assets/chapters.vtt +10 -0
  166. package/test/test/util/cea_utils.js +12 -12
  167. package/test/test/util/dash_parser_util.js +4 -0
  168. package/test/test/util/fake_ad.js +7 -0
  169. package/test/test/util/fake_ad_manager.js +7 -0
  170. package/test/test/util/fake_drm_engine.js +9 -2
  171. package/test/test/util/manifest_generator.js +5 -2
  172. package/test/test/util/manifest_parser_util.js +3 -1
  173. package/test/test/util/test_scheme.js +14 -1
  174. package/test/text/ttml_text_parser_unit.js +47 -0
  175. package/test/text/web_vtt_generator_unit.js +81 -7
  176. package/test/ui/ui_unit.js +250 -0
  177. package/test/util/cmcd_manager_unit.js +277 -0
  178. package/test/util/stream_utils_unit.js +118 -10
  179. package/ui/airplay_button.js +2 -1
  180. package/ui/audio_language_selection.js +9 -5
  181. package/ui/cast_button.js +5 -6
  182. package/ui/constants.js +0 -3
  183. package/ui/context_menu.js +109 -0
  184. package/ui/controls.js +41 -7
  185. package/ui/controls.less +1 -0
  186. package/ui/enums.js +4 -0
  187. package/ui/externs/ui.js +28 -1
  188. package/ui/fast_forward_button.js +16 -8
  189. package/ui/fullscreen_button.js +2 -3
  190. package/ui/language_utils.js +1 -1
  191. package/ui/less/buttons.less +0 -4
  192. package/ui/less/containers.less +74 -0
  193. package/ui/less/overflow_menu.less +0 -10
  194. package/ui/less/tooltip.less +97 -0
  195. package/ui/locales/en.json +1 -0
  196. package/ui/locales/source.json +4 -0
  197. package/ui/loop_button.js +6 -3
  198. package/ui/mute_button.js +3 -4
  199. package/ui/overflow_menu.js +7 -28
  200. package/ui/pip_button.js +10 -7
  201. package/ui/play_button.js +2 -2
  202. package/ui/playback_rate_selection.js +11 -15
  203. package/ui/presentation_time.js +1 -3
  204. package/ui/resolution_selection.js +11 -7
  205. package/ui/rewind_button.js +17 -9
  206. package/ui/seek_bar.js +6 -6
  207. package/ui/settings_menu.js +36 -4
  208. package/ui/small_play_button.js +1 -0
  209. package/ui/spacer.js +1 -1
  210. package/ui/statistics_button.js +253 -0
  211. package/ui/text_selection.js +19 -15
  212. package/ui/ui.js +30 -0
  213. package/ui/ui_utils.js +1 -1
  214. package/ui/volume_bar.js +2 -4
@@ -468,6 +468,48 @@ shaka.extern.ID3Metadata;
468
468
  */
469
469
  shaka.extern.TimelineRegionInfo;
470
470
 
471
+ /**
472
+ * @typedef {{
473
+ * audioSamplingRate: ?number,
474
+ * bandwidth: number,
475
+ * codecs: string,
476
+ * contentType: string,
477
+ * frameRate: ?number,
478
+ * height: ?number,
479
+ * mimeType: ?string,
480
+ * channelsCount: ?number,
481
+ * pixelAspectRatio: ?string,
482
+ * width: ?number
483
+ * }}
484
+ *
485
+ * @description
486
+ * Contains information about the quality of an audio or video media stream.
487
+ *
488
+ * @property {?number} audioSamplingRate
489
+ * Specifies the maximum sampling rate of the content.
490
+ * @property {number} bandwidth
491
+ * The bandwidth in bits per second.
492
+ * @property {string} codecs
493
+ * The Stream's codecs, e.g., 'avc1.4d4015' or 'vp9', which must be
494
+ * compatible with the Stream's MIME type.
495
+ * @property {string} contentType
496
+ * The type of content, which may be "video" or "audio".
497
+ * @property {?number} frameRate
498
+ * The video frame rate.
499
+ * @property {?number} height
500
+ * The video height in pixels.
501
+ * @property {string} mimeType
502
+ * The MIME type.
503
+ * @property {?number} channelsCount
504
+ * The number of audio channels, or null if unknown.
505
+ * @property {?string} pixelAspectRatio
506
+ * The pixel aspect ratio value; e.g "1:1".
507
+ * @property {?number} width
508
+ * The video width in pixels.
509
+ * @exportDoc
510
+ */
511
+ shaka.extern.MediaQualityInfo;
512
+
471
513
 
472
514
  /**
473
515
  * @typedef {{
@@ -516,6 +558,7 @@ shaka.extern.EmsgInfo;
516
558
  * videoRobustness: string,
517
559
  * audioRobustness: string,
518
560
  * serverCertificate: Uint8Array,
561
+ * serverCertificateUri: string,
519
562
  * individualizationServer: string,
520
563
  * sessionType: string
521
564
  * }}
@@ -545,6 +588,10 @@ shaka.extern.EmsgInfo;
545
588
  * A key-system-specific server certificate used to encrypt license requests.
546
589
  * Its use is optional and is meant as an optimization to avoid a round-trip
547
590
  * to request a certificate.
591
+ * @property {string} serverCertificateUri
592
+ * <i>Defaults to <code>''</code>.</i><br>
593
+ * If given, will make a request to the given URI to get the server
594
+ * certificate. This is ignored if <code>serverCertificate</code> is set.
548
595
  * @property {string} individualizationServer
549
596
  * The server that handles an <code>'individualiation-request'</code>. If the
550
597
  * server isn't given, it will default to the license server.
@@ -569,7 +616,8 @@ shaka.extern.AdvancedDrmConfiguration;
569
616
  * ((function(!Uint8Array, string, ?shaka.extern.DrmInfo):!Uint8Array)|
570
617
  * undefined),
571
618
  * logLicenseExchange: boolean,
572
- * updateExpirationTime: number
619
+ * updateExpirationTime: number,
620
+ * preferredKeySystems: !Array.<string>
573
621
  * }}
574
622
  *
575
623
  * @property {shaka.extern.RetryParameters} retryParameters
@@ -607,6 +655,9 @@ shaka.extern.AdvancedDrmConfiguration;
607
655
  * @property {number} updateExpirationTime
608
656
  * <i>Defaults to 1.</i> <br>
609
657
  * The frequency in seconds with which to check the expiration of a session.
658
+ * @property {!Array.<string>} preferredKeySystems
659
+ * <i>Defaults to an empty array. </i> <br>
660
+ * Specifies the priorties of available DRM key systems.
610
661
  *
611
662
  * @exportDoc
612
663
  */
@@ -625,7 +676,8 @@ shaka.extern.DrmConfiguration;
625
676
  * ignoreSuggestedPresentationDelay: boolean,
626
677
  * ignoreEmptyAdaptationSet: boolean,
627
678
  * ignoreMaxSegmentDuration: boolean,
628
- * keySystemsByURI: !Object.<string, string>
679
+ * keySystemsByURI: !Object.<string, string>,
680
+ * manifestPreprocessor: function(!Element)
629
681
  * }}
630
682
  *
631
683
  * @property {string} clockSyncUri
@@ -675,6 +727,10 @@ shaka.extern.DrmConfiguration;
675
727
  * @property {Object.<string, string>} keySystemsByURI
676
728
  * A map of scheme URI to key system name. Defaults to default key systems
677
729
  * mapping handled by Shaka.
730
+ * @property {function(!Element)} manifestPreprocessor
731
+ * Called immediately after the DASH manifest has been parsed into an
732
+ * XMLDocument. Provides a way for applications to perform efficient
733
+ * preprocessing of the manifest.
678
734
  * @exportDoc
679
735
  */
680
736
  shaka.extern.DashManifestConfiguration;
@@ -683,15 +739,27 @@ shaka.extern.DashManifestConfiguration;
683
739
  /**
684
740
  * @typedef {{
685
741
  * ignoreTextStreamFailures: boolean,
686
- * useFullSegmentsForStartTime: boolean
742
+ * ignoreImageStreamFailures: boolean,
743
+ * useFullSegmentsForStartTime: boolean,
744
+ * defaultAudioCodec: string,
745
+ * defaultVideoCodec: string
687
746
  * }}
688
747
  *
689
748
  * @property {boolean} ignoreTextStreamFailures
690
749
  * If <code>true</code>, ignore any errors in a text stream and filter out
691
750
  * those streams.
751
+ * @property {boolean} ignoreImageStreamFailures
752
+ * If <code>true</code>, ignore any errors in a image stream and filter out
753
+ * those streams.
692
754
  * @property {boolean} useFullSegmentsForStartTime
693
755
  * If <code>true</code>, force HlsParser to use a full segment request for
694
756
  * determining start time in case the server does not support partial requests
757
+ * @property {string} defaultAudioCodec
758
+ * The default audio codec if it is not specified in the HLS playlist.
759
+ * <i>Defaults to <code>'mp4a.40.2'</code>.</i>
760
+ * @property {string} defaultVideoCodec
761
+ * The default video codec if it is not specified in the HLS playlist.
762
+ * <i>Defaults to <code>'avc1.42E01E'</code>.</i>
695
763
  * @exportDoc
696
764
  */
697
765
  shaka.extern.HlsManifestConfiguration;
@@ -771,7 +839,10 @@ shaka.extern.ManifestConfiguration;
771
839
  * lowLatencyMode: boolean,
772
840
  * autoLowLatencyMode: boolean,
773
841
  * forceHTTPS: boolean,
774
- * preferNativeHls: boolean
842
+ * preferNativeHls: boolean,
843
+ * updateIntervalSeconds: number,
844
+ * dispatchAllEmsgBoxes: boolean,
845
+ * observeQualityChanges: boolean
775
846
  * }}
776
847
  *
777
848
  * @description
@@ -878,7 +949,13 @@ shaka.extern.ManifestConfiguration;
878
949
  * If true, if the protocol is HTTP change it to HTTPs.
879
950
  * @property {boolean} preferNativeHls
880
951
  * If true, prefer native HLS playback when possible, regardless of platform.
881
- *
952
+ * @property {number} updateIntervalSeconds
953
+ * The minimum number of seconds to see if the manifest has changes.
954
+ * @property {boolean} dispatchAllEmsgBoxes
955
+ * If true, all emsg boxes are parsed and dispatched.
956
+ * @property {boolean} observeQualityChanges
957
+ * If true, monitor media quality changes and emit
958
+ * <code.shaka.Player.MediaQualityChangedEvent</code>.
882
959
  * @exportDoc
883
960
  */
884
961
  shaka.extern.StreamingConfiguration;
@@ -892,7 +969,8 @@ shaka.extern.StreamingConfiguration;
892
969
  * restrictions: shaka.extern.Restrictions,
893
970
  * switchInterval: number,
894
971
  * bandwidthUpgradeTarget: number,
895
- * bandwidthDowngradeTarget: number
972
+ * bandwidthDowngradeTarget: number,
973
+ * advanced: shaka.extern.AdvancedAbrConfiguration
896
974
  * }}
897
975
  *
898
976
  * @property {boolean} enabled
@@ -909,7 +987,7 @@ shaka.extern.StreamingConfiguration;
909
987
  * automatically, but will still appear in the track list and can still be
910
988
  * selected via <code>selectVariantTrack()</code>. If no tracks meet these
911
989
  * restrictions, AbrManager should not fail, but choose a low-res or
912
- * low-bandwidth variant instead. It is the responsibiliy of AbrManager
990
+ * low-bandwidth variant instead. It is the responsibility of AbrManager
913
991
  * implementations to follow these rules and implement this behavior.
914
992
  * @property {number} switchInterval
915
993
  * The minimum amount of time that must pass between switches, in
@@ -920,11 +998,76 @@ shaka.extern.StreamingConfiguration;
920
998
  * @property {number} bandwidthDowngradeTarget
921
999
  * The largest fraction of the estimated bandwidth we should use. We should
922
1000
  * downgrade to avoid this.
1001
+ * @property {shaka.extern.AdvancedAbrConfiguration} advanced
1002
+ * Advanced ABR configuration.
923
1003
  * @exportDoc
924
1004
  */
925
1005
  shaka.extern.AbrConfiguration;
926
1006
 
927
1007
 
1008
+ /**
1009
+ * @typedef {{
1010
+ * minTotalBytes: number,
1011
+ * minBytes: number,
1012
+ * fastHalfLife: number,
1013
+ * slowHalfLife: number
1014
+ * }}
1015
+ *
1016
+ * @property {number} minTotalBytes
1017
+ * Minimum number of bytes sampled before we trust the estimate. If we have
1018
+ * not sampled much data, our estimate may not be accurate enough to trust.
1019
+ * @property {number} minBytes
1020
+ * Minimum number of bytes, under which samples are discarded. Our models
1021
+ * do not include latency information, so connection startup time (time to
1022
+ * first byte) is considered part of the download time. Because of this, we
1023
+ * should ignore very small downloads which would cause our estimate to be
1024
+ * too low.
1025
+ * @property {number} fastHalfLife
1026
+ * The quantity of prior samples (by weight) used when creating a new
1027
+ * estimate, in seconds. Those prior samples make up half of the
1028
+ * new estimate.
1029
+ * @property {number} slowHalfLife
1030
+ * The quantity of prior samples (by weight) used when creating a new
1031
+ * estimate, in seconds. Those prior samples make up half of the
1032
+ * new estimate.
1033
+ * @exportDoc
1034
+ */
1035
+ shaka.extern.AdvancedAbrConfiguration;
1036
+
1037
+
1038
+ /**
1039
+ * @typedef {{
1040
+ * enabled: boolean,
1041
+ * useHeaders: boolean,
1042
+ * sessionId: string,
1043
+ * contentId: string
1044
+ * }}
1045
+ *
1046
+ * @description
1047
+ * Common Media Client Data (CMCD) configuration.
1048
+ *
1049
+ * @property {boolean} enabled
1050
+ * If <code>true</code>, enable CMCD data to be sent with media requests.
1051
+ * Defaults to <code>false</code>.
1052
+ * @property {boolean} useHeaders
1053
+ * If <code>true</code>, send CMCD data using the header transmission mode
1054
+ * instead of query args. Defaults to <code>false</code>.
1055
+ * @property {string} sessionId
1056
+ * A GUID identifying the current playback session. A playback session
1057
+ * typically ties together segments belonging to a single media asset.
1058
+ * Maximum length is 64 characters. It is RECOMMENDED to conform to the UUID
1059
+ * specification. By default the sessionId is automatically generated on each
1060
+ * <code>load()</code> call.
1061
+ * @property {string} contentId
1062
+ * A unique string identifying the current content. Maximum length is 64
1063
+ * characters. This value is consistent across multiple different sessions and
1064
+ * devices and is defined and updated at the discretion of the service
1065
+ * provider.
1066
+ * @exportDoc
1067
+ */
1068
+ shaka.extern.CmcdConfiguration;
1069
+
1070
+
928
1071
  /**
929
1072
  * @typedef {{
930
1073
  * trackSelectionCallback:
@@ -966,18 +1109,21 @@ shaka.extern.OfflineConfiguration;
966
1109
  * streaming: shaka.extern.StreamingConfiguration,
967
1110
  * abrFactory: shaka.extern.AbrManager.Factory,
968
1111
  * abr: shaka.extern.AbrConfiguration,
1112
+ * cmcd: shaka.extern.CmcdConfiguration,
969
1113
  * offline: shaka.extern.OfflineConfiguration,
970
1114
  * preferredAudioLanguage: string,
971
1115
  * preferredTextLanguage: string,
972
1116
  * preferredVariantRole: string,
973
1117
  * preferredTextRole: string,
1118
+ * preferredVideoCodecs: !Array.<string>,
1119
+ * preferredAudioCodecs: !Array.<string>,
974
1120
  * preferredAudioChannelCount: number,
1121
+ * preferredDecodingAttributes: !Array.<string>,
975
1122
  * preferForcedSubs: boolean,
976
1123
  * restrictions: shaka.extern.Restrictions,
977
1124
  * playRangeStart: number,
978
1125
  * playRangeEnd: number,
979
- * textDisplayFactory: shaka.extern.TextDisplayer.Factory,
980
- * useMediaCapabilities: boolean
1126
+ * textDisplayFactory: shaka.extern.TextDisplayer.Factory
981
1127
  * }}
982
1128
  *
983
1129
  * @property {shaka.extern.DrmConfiguration} drm
@@ -990,6 +1136,8 @@ shaka.extern.OfflineConfiguration;
990
1136
  * A factory to construct an abr manager.
991
1137
  * @property {shaka.extern.AbrConfiguration} abr
992
1138
  * ABR configuration and settings.
1139
+ * @property {shaka.extern.CmcdConfiguration} cmcd
1140
+ * CMCD configuration and settings. (Common Media Client Data)
993
1141
  * @property {shaka.extern.OfflineConfiguration} offline
994
1142
  * Offline configuration and settings.
995
1143
  * @property {string} preferredAudioLanguage
@@ -1005,8 +1153,15 @@ shaka.extern.OfflineConfiguration;
1005
1153
  * The preferred role to use for variants.
1006
1154
  * @property {string} preferredTextRole
1007
1155
  * The preferred role to use for text tracks.
1156
+ * @property {!Array.<string>} preferredVideoCodecs
1157
+ * The list of preferred video codecs, in order of highest to lowest priority.
1158
+ * @property {!Array.<string>} preferredAudioCodecs
1159
+ * The list of preferred audio codecs, in order of highest to lowest priority.
1008
1160
  * @property {number} preferredAudioChannelCount
1009
1161
  * The preferred number of audio channels.
1162
+ * @property {!Array.<string>} preferredDecodingAttributes
1163
+ * The list of preferred attributes of decodingInfo, in the order of their
1164
+ * priorities.
1010
1165
  * @property {boolean} preferForcedSubs
1011
1166
  * If true, a forced text track is preferred. Defaults to false.
1012
1167
  * If the content has no forced captions and the value is true,
@@ -1026,10 +1181,6 @@ shaka.extern.OfflineConfiguration;
1026
1181
  * @property {shaka.extern.TextDisplayer.Factory} textDisplayFactory
1027
1182
  * A factory to construct a text displayer. Note that, if this is changed
1028
1183
  * during playback, it will cause the text tracks to be reloaded.
1029
- * @property {boolean} useMediaCapabilities
1030
- * If true, use MediaCapabilities.decodingInfo() to filter the manifest, and
1031
- * get MediaKeys information for encrypted content. Default to false.
1032
- * Shaka Player's integration with MediaCapabilities is now in BETA.
1033
1184
  * @exportDoc
1034
1185
  */
1035
1186
  shaka.extern.PlayerConfiguration;
@@ -1083,3 +1234,21 @@ shaka.extern.LanguageRole;
1083
1234
  * @exportDoc
1084
1235
  */
1085
1236
  shaka.extern.Thumbnail;
1237
+
1238
+
1239
+ /**
1240
+ * @typedef {{
1241
+ * title: string,
1242
+ * startTime: number,
1243
+ * endTime: number
1244
+ * }}
1245
+ *
1246
+ * @property {string} title
1247
+ * The title of the chapter.
1248
+ * @property {number} startTime
1249
+ * The time that describes the beginning of the range of the chapter.
1250
+ * @property {number} endTime
1251
+ * The time that describes the end of the range of chapter.
1252
+ * @exportDoc
1253
+ */
1254
+ shaka.extern.Chapter;
@@ -128,7 +128,7 @@ shaka.extern.Cue = class {
128
128
  /**
129
129
  * The text payload of the cue. If nestedCues is non-empty, this should be
130
130
  * empty. Top-level block containers should have no payload of their own.
131
- * @type {!string}
131
+ * @type {string}
132
132
  * @exportDoc
133
133
  */
134
134
  this.payload;
@@ -234,14 +234,14 @@ shaka.extern.Cue = class {
234
234
 
235
235
  /**
236
236
  * Text color as a CSS color, e.g. "#FFFFFF" or "white".
237
- * @type {!string}
237
+ * @type {string}
238
238
  * @exportDoc
239
239
  */
240
240
  this.color;
241
241
 
242
242
  /**
243
243
  * Text background color as a CSS color, e.g. "#FFFFFF" or "white".
244
- * @type {!string}
244
+ * @type {string}
245
245
  * @exportDoc
246
246
  */
247
247
  this.backgroundColor;
@@ -257,14 +257,14 @@ shaka.extern.Cue = class {
257
257
 
258
258
  /**
259
259
  * The URL of the background image, e.g. "data:[mime type];base64,[data]".
260
- * @type {!string}
260
+ * @type {string}
261
261
  * @exportDoc
262
262
  */
263
263
  this.backgroundImage;
264
264
 
265
265
  /**
266
266
  * The border around this cue as a CSS border.
267
- * @type {!string}
267
+ * @type {string}
268
268
  * @exportDoc
269
269
  */
270
270
  this.border;
@@ -292,28 +292,42 @@ shaka.extern.Cue = class {
292
292
 
293
293
  /**
294
294
  * Text font family.
295
- * @type {!string}
295
+ * @type {string}
296
296
  * @exportDoc
297
297
  */
298
298
  this.fontFamily;
299
299
 
300
+ /**
301
+ * Text stroke color as a CSS color, e.g. "#FFFFFF" or "white".
302
+ * @type {string}
303
+ * @exportDoc
304
+ */
305
+ this.textStrokeColor;
306
+
307
+ /**
308
+ * Text stroke width as a CSS stroke-width value.
309
+ * @type {string}
310
+ * @exportDoc
311
+ */
312
+ this.textStrokeWidth;
313
+
300
314
  /**
301
315
  * Text letter spacing as a CSS letter-spacing value.
302
- * @type {!string}
316
+ * @type {string}
303
317
  * @exportDoc
304
318
  */
305
319
  this.letterSpacing;
306
320
 
307
321
  /**
308
322
  * Text line padding as a CSS line-padding value.
309
- * @type {!string}
323
+ * @type {string}
310
324
  * @exportDoc
311
325
  */
312
326
  this.linePadding;
313
327
 
314
328
  /**
315
329
  * Opacity of the cue element, from 0-1.
316
- * @type {!number}
330
+ * @type {number}
317
331
  * @exportDoc
318
332
  */
319
333
  this.opacity;
@@ -335,7 +349,7 @@ shaka.extern.Cue = class {
335
349
 
336
350
  /**
337
351
  * Id of the cue.
338
- * @type {!string}
352
+ * @type {string}
339
353
  * @exportDoc
340
354
  */
341
355
  this.id;
@@ -20,3 +20,6 @@ TextTrack.prototype.kind;
20
20
 
21
21
  /** @type {string} */
22
22
  TextTrack.prototype.label;
23
+
24
+ /** @type {string} */
25
+ TextTrack.prototype.language;
@@ -0,0 +1,18 @@
1
+ /*! @license
2
+ * Shaka Player
3
+ * Copyright 2016 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+
8
+ /**
9
+ * @fileoverview Externs for crypto properties not in the Closure compiler.
10
+ *
11
+ * @externs
12
+ */
13
+
14
+
15
+ /**
16
+ * @return {string}
17
+ */
18
+ webCrypto.Crypto.prototype.randomUUID = function() {};
package/lib/abr/ewma.js CHANGED
@@ -35,6 +35,20 @@ shaka.abr.Ewma = class {
35
35
  this.totalWeight_ = 0;
36
36
  }
37
37
 
38
+
39
+ /**
40
+ * Update the alpha with a new halfLife value.
41
+ *
42
+ * @param {number} halfLife The quantity of prior samples (by weight) used
43
+ * when creating a new estimate. Those prior samples make up half of the
44
+ * new estimate.
45
+ */
46
+ updateAlpha(halfLife) {
47
+ goog.asserts.assert(halfLife > 0, 'expected halfLife to be positive');
48
+ this.alpha_ = Math.exp(Math.log(0.5) / halfLife);
49
+ }
50
+
51
+
38
52
  /**
39
53
  * Takes a sample.
40
54
  *
@@ -47,7 +47,6 @@ shaka.abr.EwmaBandwidthEstimator = class {
47
47
  * This specific value is based on experimentation.
48
48
  *
49
49
  * @private {number}
50
- * @const
51
50
  */
52
51
  this.minTotalBytes_ = 128e3; // 128kB
53
52
 
@@ -60,11 +59,26 @@ shaka.abr.EwmaBandwidthEstimator = class {
60
59
  * This specific value is based on experimentation.
61
60
  *
62
61
  * @private {number}
63
- * @const
64
62
  */
65
63
  this.minBytes_ = 16e3; // 16kB
66
64
  }
67
65
 
66
+
67
+ /**
68
+ * Called by the Player to provide an updated configuration any time it
69
+ * changes.
70
+ * Must be called at least once before init().
71
+ *
72
+ * @param {shaka.extern.AdvancedAbrConfiguration} config
73
+ */
74
+ configure(config) {
75
+ this.minTotalBytes_ = config.minTotalBytes;
76
+ this.minBytes_ = config.minBytes;
77
+ this.fast_.updateAlpha(config.fastHalfLife);
78
+ this.slow_.updateAlpha(config.slowHalfLife);
79
+ }
80
+
81
+
68
82
  /**
69
83
  * Takes a bandwidth sample.
70
84
  *
@@ -54,6 +54,9 @@ shaka.abr.SimpleAbrManager = class {
54
54
  navigator.connection.addEventListener('change', () => {
55
55
  if (this.config_.useNetworkInformation && this.enabled_) {
56
56
  this.bandwidthEstimator_ = new shaka.abr.EwmaBandwidthEstimator();
57
+ if (this.config_) {
58
+ this.bandwidthEstimator_.configure(this.config_.advanced);
59
+ }
57
60
  const chosenVariant = this.chooseVariant();
58
61
  if (chosenVariant) {
59
62
  this.switch_(chosenVariant);
@@ -239,6 +242,9 @@ shaka.abr.SimpleAbrManager = class {
239
242
  */
240
243
  configure(config) {
241
244
  this.config_ = config;
245
+ if (this.bandwidthEstimator_ && this.config_) {
246
+ this.bandwidthEstimator_.configure(this.config_.advanced);
247
+ }
242
248
  }
243
249
 
244
250
 
@@ -6,7 +6,6 @@
6
6
 
7
7
 
8
8
  goog.provide('shaka.ads.AdManager');
9
- goog.provide('shaka.ads.CuePoint');
10
9
 
11
10
  goog.require('shaka.Player');
12
11
  goog.require('shaka.ads.AdsStats');
@@ -594,6 +593,22 @@ shaka.ads.AdManager = class extends shaka.util.FakeEventTarget {
594
593
  }
595
594
 
596
595
 
596
+ /**
597
+ * @return {!Array.<!shaka.extern.AdCuePoint>}
598
+ * @override
599
+ * @export
600
+ */
601
+ getServerSideCuePoints() {
602
+ if (!this.ssAdManager_) {
603
+ throw new shaka.util.Error(
604
+ shaka.util.Error.Severity.RECOVERABLE,
605
+ shaka.util.Error.Category.ADS,
606
+ shaka.util.Error.Code.SS_AD_MANAGER_NOT_INITIALIZED);
607
+ }
608
+ return this.ssAdManager_.getCuePoints();
609
+ }
610
+
611
+
597
612
  /**
598
613
  * @return {shaka.extern.AdsStats}
599
614
  * @override
@@ -646,20 +661,6 @@ shaka.ads.AdManager = class extends shaka.util.FakeEventTarget {
646
661
  }
647
662
  };
648
663
 
649
-
650
- shaka.ads.CuePoint = class {
651
- /**
652
- * @param {number} start
653
- * @param {?number=} end
654
- */
655
- constructor(start, end = null) {
656
- /** @public {number} */
657
- this.start = start;
658
- /** @public {?number} */
659
- this.end = end;
660
- }
661
- };
662
-
663
664
  /**
664
665
  * The event name for when a sequence of ads has been loaded.
665
666
  *
@@ -162,6 +162,14 @@ shaka.ads.ClientSideAd = class {
162
162
  return this.manager_.getVolume() == 0;
163
163
  }
164
164
 
165
+ /**
166
+ * @override
167
+ * @export
168
+ */
169
+ isLinear() {
170
+ return this.ad_.isLinear();
171
+ }
172
+
165
173
 
166
174
  /**
167
175
  * @override
@@ -162,10 +162,14 @@ shaka.ads.ClientSideAdManager = class {
162
162
 
163
163
  const cuePointStarts = this.imaAdsManager_.getCuePoints();
164
164
  if (cuePointStarts.length) {
165
- /** @type {!Array.<!shaka.ads.CuePoint>} */
165
+ /** @type {!Array.<!shaka.extern.AdCuePoint>} */
166
166
  const cuePoints = [];
167
167
  for (const start of cuePointStarts) {
168
- const shakaCuePoint = new shaka.ads.CuePoint(start);
168
+ /** @type {shaka.extern.AdCuePoint} */
169
+ const shakaCuePoint = {
170
+ start: start,
171
+ end: null,
172
+ };
169
173
  cuePoints.push(shakaCuePoint);
170
174
  }
171
175
 
@@ -392,8 +396,10 @@ shaka.ads.ClientSideAdManager = class {
392
396
  .set('originalEvent', e);
393
397
  this.onEvent_(new shaka.util.FakeEvent(
394
398
  shaka.ads.AdManager.AD_STARTED, data));
395
- this.adContainer_.setAttribute('ad-active', 'true');
396
- this.video_.pause();
399
+ if (this.ad_.isLinear()) {
400
+ this.adContainer_.setAttribute('ad-active', 'true');
401
+ this.video_.pause();
402
+ }
397
403
  }
398
404
 
399
405
  /**
@@ -403,7 +409,9 @@ shaka.ads.ClientSideAdManager = class {
403
409
  onAdComplete_(e) {
404
410
  this.onEvent_(new shaka.util.FakeEvent(shaka.ads.AdManager.AD_STOPPED,
405
411
  (new Map()).set('originalEvent', e)));
406
- this.adContainer_.removeAttribute('ad-active');
407
- this.video_.play();
412
+ if (this.ad_.isLinear()) {
413
+ this.adContainer_.removeAttribute('ad-active');
414
+ this.video_.play();
415
+ }
408
416
  }
409
417
  };
@@ -152,6 +152,13 @@ shaka.ads.ServerSideAd = class {
152
152
  return this.video_.muted;
153
153
  }
154
154
 
155
+ /**
156
+ * @override
157
+ * @export
158
+ */
159
+ isLinear() {
160
+ return true;
161
+ }
155
162
 
156
163
  /**
157
164
  * @override