shaka-player 4.6.3 → 4.7.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 (608) hide show
  1. package/README.md +1 -0
  2. package/dist/controls.css +1 -1
  3. package/dist/controls.css.map +1 -1
  4. package/dist/deps.js +13 -9
  5. package/dist/locales.js +33 -33
  6. package/dist/shaka-player.compiled.d.ts +47 -4
  7. package/dist/shaka-player.compiled.debug.d.ts +47 -4
  8. package/dist/shaka-player.compiled.debug.externs.js +50 -2
  9. package/dist/shaka-player.compiled.debug.js +408 -376
  10. package/dist/shaka-player.compiled.debug.map +4 -4
  11. package/dist/shaka-player.compiled.externs.js +50 -2
  12. package/dist/shaka-player.compiled.js +1134 -1118
  13. package/dist/shaka-player.compiled.map +4 -4
  14. package/dist/shaka-player.ui.d.ts +69 -5
  15. package/dist/shaka-player.ui.debug.d.ts +69 -5
  16. package/dist/shaka-player.ui.debug.externs.js +82 -2
  17. package/dist/shaka-player.ui.debug.js +457 -420
  18. package/dist/shaka-player.ui.debug.map +4 -4
  19. package/dist/shaka-player.ui.externs.js +82 -2
  20. package/dist/shaka-player.ui.js +1305 -1289
  21. package/dist/shaka-player.ui.map +4 -4
  22. package/externs/mediasession.js +7 -0
  23. package/externs/shaka/abr_manager.js +8 -0
  24. package/externs/shaka/manifest.js +3 -3
  25. package/externs/shaka/player.js +59 -4
  26. package/lib/abr/simple_abr_manager.js +41 -15
  27. package/lib/ads/client_side_ad_manager.js +4 -0
  28. package/lib/ads/media_tailor_ad_manager.js +5 -0
  29. package/lib/ads/server_side_ad_manager.js +4 -0
  30. package/lib/cea/cea708_service.js +1 -1
  31. package/lib/cea/cea708_window.js +95 -7
  32. package/lib/dash/dash_parser.js +55 -11
  33. package/lib/hls/hls_parser.js +17 -5
  34. package/lib/media/adaptation_set_criteria.js +76 -10
  35. package/lib/media/drm_engine.js +0 -3
  36. package/lib/media/media_source_engine.js +42 -18
  37. package/lib/media/segment_reference.js +12 -0
  38. package/lib/media/streaming_engine.js +58 -5
  39. package/lib/media/video_wrapper.js +4 -3
  40. package/lib/player.js +95 -11
  41. package/lib/text/simple_text_displayer.js +8 -7
  42. package/lib/text/text_utils.js +39 -13
  43. package/lib/text/ui_text_displayer.js +20 -11
  44. package/lib/text/web_vtt_generator.js +1 -1
  45. package/lib/util/cmsd_manager.js +269 -0
  46. package/lib/util/content_steering_manager.js +5 -1
  47. package/lib/util/mime_utils.js +6 -2
  48. package/lib/util/periods.js +108 -39
  49. package/lib/util/player_configuration.js +19 -5
  50. package/lib/util/stream_utils.js +82 -13
  51. package/package.json +1 -1
  52. package/ui/audio_language_selection.js +3 -0
  53. package/ui/controls.js +60 -0
  54. package/ui/externs/ui.js +12 -1
  55. package/ui/hidden_fast_forward_button.js +32 -0
  56. package/ui/hidden_rewind_button.js +32 -0
  57. package/ui/hidden_seek_button.js +121 -0
  58. package/ui/less/buttons.less +50 -0
  59. package/ui/less/containers.less +18 -0
  60. package/ui/resolution_selection.js +2 -0
  61. package/ui/ui.js +2 -0
  62. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -75
  63. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -26
  64. package/.github/ISSUE_TEMPLATE/question.md +0 -26
  65. package/.github/config.yml +0 -1
  66. package/.github/workflows/appspot.yaml +0 -39
  67. package/.github/workflows/build-and-test.yaml +0 -222
  68. package/.github/workflows/compute-incremental-coverage.py +0 -265
  69. package/.github/workflows/custom-actions/prep-for-appspot/action.yaml +0 -56
  70. package/.github/workflows/custom-actions/set-commit-status/action.yaml +0 -37
  71. package/.github/workflows/deflake.yaml +0 -31
  72. package/.github/workflows/demo-version-index.yaml +0 -43
  73. package/.github/workflows/nightly-demo.yaml +0 -42
  74. package/.github/workflows/release-please.yaml +0 -193
  75. package/.github/workflows/report-incremental-coverage.yaml +0 -39
  76. package/.github/workflows/safari-homedir-launcher.sh +0 -18
  77. package/.github/workflows/selenium-lab-tests.yaml +0 -370
  78. package/.github/workflows/shaka-bot-commands/command-help.sh +0 -27
  79. package/.github/workflows/shaka-bot-commands/command-test.sh +0 -56
  80. package/.github/workflows/shaka-bot-commands/lib.sh +0 -83
  81. package/.github/workflows/shaka-bot-commands/main.sh +0 -51
  82. package/.github/workflows/sync-labels.yaml +0 -33
  83. package/.github/workflows/talk-to-shaka-bot.yaml +0 -29
  84. package/.github/workflows/update-issues.yaml +0 -31
  85. package/.github/workflows/update-screenshots.yaml +0 -142
  86. package/.github/workflows/validate-pr-title.yaml +0 -27
  87. package/CHANGELOG.md +0 -5764
  88. package/CODE_OF_CONDUCT.md +0 -93
  89. package/CONTRIBUTING.md +0 -76
  90. package/demo/TengwarTelcontar.woff2 +0 -0
  91. package/demo/app_logo_144.png +0 -0
  92. package/demo/app_logo_192.png +0 -0
  93. package/demo/app_logo_256.png +0 -0
  94. package/demo/app_logo_384.png +0 -0
  95. package/demo/app_logo_512.png +0 -0
  96. package/demo/app_manifest.json +0 -29
  97. package/demo/asset_card.js +0 -410
  98. package/demo/autoTemplate.txt +0 -61
  99. package/demo/cast_receiver/idle1.jpg +0 -0
  100. package/demo/cast_receiver/idle2.jpg +0 -0
  101. package/demo/cast_receiver/idle3.jpg +0 -0
  102. package/demo/cast_receiver/index.html +0 -75
  103. package/demo/cast_receiver/receiver_app.css +0 -111
  104. package/demo/cast_receiver/receiver_app.js +0 -158
  105. package/demo/close_button.js +0 -60
  106. package/demo/common/asset.js +0 -511
  107. package/demo/common/assets.js +0 -1635
  108. package/demo/config.js +0 -859
  109. package/demo/custom.js +0 -907
  110. package/demo/customWarning.txt +0 -8
  111. package/demo/demo.less +0 -591
  112. package/demo/demo_uncompiled.js +0 -11
  113. package/demo/demo_utils.js +0 -113
  114. package/demo/favicon.ico +0 -0
  115. package/demo/front.js +0 -156
  116. package/demo/icons/README.md +0 -4
  117. package/demo/icons/baseline-audiotrack-24px.svg +0 -1
  118. package/demo/icons/baseline-closed_caption-24px.svg +0 -1
  119. package/demo/icons/baseline-fast_forward-24px.svg +0 -1
  120. package/demo/icons/baseline-language-24px.svg +0 -1
  121. package/demo/icons/baseline-live_tv-24px.svg +0 -1
  122. package/demo/icons/baseline-subtitles-24px.svg +0 -1
  123. package/demo/icons/baseline-surround_sound-24px.svg +0 -1
  124. package/demo/icons/custom_ad.svg +0 -1
  125. package/demo/icons/custom_box_with_text.svg +0 -1
  126. package/demo/icons/custom_clear_key.svg +0 -1
  127. package/demo/icons/custom_high_definition.svg +0 -1
  128. package/demo/icons/custom_playready.svg +0 -1
  129. package/demo/icons/custom_ultra_high_definition.svg +0 -1
  130. package/demo/icons/custom_widevine.svg +0 -1
  131. package/demo/index.html +0 -173
  132. package/demo/input.js +0 -270
  133. package/demo/input_container.js +0 -218
  134. package/demo/load.js +0 -156
  135. package/demo/main.js +0 -1854
  136. package/demo/search.js +0 -452
  137. package/demo/service_worker.js +0 -355
  138. package/demo/shaka_logo_trans.png +0 -0
  139. package/demo/tooltip.js +0 -29
  140. package/demo/visualizer.js +0 -335
  141. package/demo/visualizer_button.js +0 -84
  142. package/dist/demo.compiled.debug.js +0 -340
  143. package/dist/demo.compiled.debug.map +0 -8
  144. package/dist/demo.compiled.js +0 -340
  145. package/dist/demo.compiled.map +0 -8
  146. package/dist/demo.css +0 -6
  147. package/dist/demo.css.map +0 -1
  148. package/dist/receiver.compiled.debug.js +0 -187
  149. package/dist/receiver.compiled.debug.map +0 -8
  150. package/dist/receiver.compiled.js +0 -187
  151. package/dist/receiver.compiled.map +0 -8
  152. package/docs/announcement-list-join-group.png +0 -0
  153. package/docs/api-mainpage.md +0 -28
  154. package/docs/design/REDESIGN.md +0 -283
  155. package/docs/design/architecture.md +0 -13
  156. package/docs/design/bg-fetch-after.gv +0 -29
  157. package/docs/design/bg-fetch-after.gv.png +0 -0
  158. package/docs/design/bg-fetch-before.gv +0 -18
  159. package/docs/design/bg-fetch-before.gv.png +0 -0
  160. package/docs/design/bg-fetch.md +0 -134
  161. package/docs/design/cast.gv +0 -35
  162. package/docs/design/cast.gv.png +0 -0
  163. package/docs/design/chromecast.md +0 -151
  164. package/docs/design/codec_preferences.md +0 -158
  165. package/docs/design/dash-audio-channels.md +0 -123
  166. package/docs/design/dash-manifests.md +0 -248
  167. package/docs/design/dash-timeline.svg +0 -4
  168. package/docs/design/dataflow.gv +0 -66
  169. package/docs/design/dataflow.gv.png +0 -0
  170. package/docs/design/export.md +0 -70
  171. package/docs/design/fuzzy-locale-matching.md +0 -40
  172. package/docs/design/gap-jumping.md +0 -151
  173. package/docs/design/lcevc-architecture.png +0 -0
  174. package/docs/design/lcevc-demo.png +0 -0
  175. package/docs/design/lcevc-integration.md +0 -72
  176. package/docs/design/locale_compatibility.svg +0 -1
  177. package/docs/design/locales_tree.svg +0 -1
  178. package/docs/design/localization-design-principles.md +0 -158
  179. package/docs/design/newdemo.gv +0 -83
  180. package/docs/design/newdemo.gv.png +0 -0
  181. package/docs/design/offline.gv +0 -43
  182. package/docs/design/offline.gv.png +0 -0
  183. package/docs/design/offline.md +0 -153
  184. package/docs/design/ownership.gv +0 -76
  185. package/docs/design/ownership.gv.png +0 -0
  186. package/docs/design/preload.md +0 -299
  187. package/docs/design/preload.png +0 -0
  188. package/docs/design/talking-about-languages.md +0 -46
  189. package/docs/design/timeline.svg +0 -152
  190. package/docs/design/ui.md +0 -31
  191. package/docs/design/ui_player_relationships.svg +0 -1
  192. package/docs/jsdoc-plugin.js +0 -74
  193. package/docs/jsdoc-template/README.md +0 -1
  194. package/docs/jsdoc-template/publish.js +0 -879
  195. package/docs/jsdoc-template/static/fonts/OpenSans-Bold-webfont.eot +0 -0
  196. package/docs/jsdoc-template/static/fonts/OpenSans-Bold-webfont.svg +0 -1830
  197. package/docs/jsdoc-template/static/fonts/OpenSans-Bold-webfont.woff +0 -0
  198. package/docs/jsdoc-template/static/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  199. package/docs/jsdoc-template/static/fonts/OpenSans-BoldItalic-webfont.svg +0 -1830
  200. package/docs/jsdoc-template/static/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  201. package/docs/jsdoc-template/static/fonts/OpenSans-Italic-webfont.eot +0 -0
  202. package/docs/jsdoc-template/static/fonts/OpenSans-Italic-webfont.svg +0 -1830
  203. package/docs/jsdoc-template/static/fonts/OpenSans-Italic-webfont.woff +0 -0
  204. package/docs/jsdoc-template/static/fonts/OpenSans-Light-webfont.eot +0 -0
  205. package/docs/jsdoc-template/static/fonts/OpenSans-Light-webfont.svg +0 -1831
  206. package/docs/jsdoc-template/static/fonts/OpenSans-Light-webfont.woff +0 -0
  207. package/docs/jsdoc-template/static/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  208. package/docs/jsdoc-template/static/fonts/OpenSans-LightItalic-webfont.svg +0 -1835
  209. package/docs/jsdoc-template/static/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  210. package/docs/jsdoc-template/static/fonts/OpenSans-Regular-webfont.eot +0 -0
  211. package/docs/jsdoc-template/static/fonts/OpenSans-Regular-webfont.svg +0 -1831
  212. package/docs/jsdoc-template/static/fonts/OpenSans-Regular-webfont.woff +0 -0
  213. package/docs/jsdoc-template/static/scripts/linenumber.js +0 -44
  214. package/docs/jsdoc-template/static/scripts/show-widget.js +0 -55
  215. package/docs/jsdoc-template/static/styles/jsdoc-default.css +0 -438
  216. package/docs/jsdoc-template/tmpl/augments.tmpl +0 -10
  217. package/docs/jsdoc-template/tmpl/container.tmpl +0 -205
  218. package/docs/jsdoc-template/tmpl/details.tmpl +0 -152
  219. package/docs/jsdoc-template/tmpl/example.tmpl +0 -2
  220. package/docs/jsdoc-template/tmpl/examples.tmpl +0 -13
  221. package/docs/jsdoc-template/tmpl/exceptions.tmpl +0 -32
  222. package/docs/jsdoc-template/tmpl/layout.tmpl +0 -50
  223. package/docs/jsdoc-template/tmpl/mainpage.tmpl +0 -14
  224. package/docs/jsdoc-template/tmpl/members.tmpl +0 -47
  225. package/docs/jsdoc-template/tmpl/method.tmpl +0 -140
  226. package/docs/jsdoc-template/tmpl/modifies.tmpl +0 -14
  227. package/docs/jsdoc-template/tmpl/params.tmpl +0 -131
  228. package/docs/jsdoc-template/tmpl/properties.tmpl +0 -125
  229. package/docs/jsdoc-template/tmpl/returns.tmpl +0 -19
  230. package/docs/jsdoc-template/tmpl/source.tmpl +0 -8
  231. package/docs/jsdoc-template/tmpl/tutorial.tmpl +0 -21
  232. package/docs/jsdoc-template/tmpl/type.tmpl +0 -7
  233. package/docs/jsdoc.conf.json +0 -38
  234. package/docs/shaka-player-logo.png +0 -0
  235. package/docs/style.md +0 -174
  236. package/docs/tutorials/a11y.md +0 -64
  237. package/docs/tutorials/ad_monetization.md +0 -292
  238. package/docs/tutorials/application-level-redirects.md +0 -94
  239. package/docs/tutorials/architecture.md +0 -32
  240. package/docs/tutorials/basic-usage.md +0 -89
  241. package/docs/tutorials/blob-url.md +0 -15
  242. package/docs/tutorials/config.md +0 -148
  243. package/docs/tutorials/debugging.md +0 -189
  244. package/docs/tutorials/drm-config.md +0 -274
  245. package/docs/tutorials/errors.md +0 -95
  246. package/docs/tutorials/fairplay.md +0 -242
  247. package/docs/tutorials/faq.md +0 -252
  248. package/docs/tutorials/index.json +0 -29
  249. package/docs/tutorials/lcevc.md +0 -118
  250. package/docs/tutorials/license-server-auth.md +0 -248
  251. package/docs/tutorials/license-wrapping.md +0 -168
  252. package/docs/tutorials/manifest-parser.md +0 -365
  253. package/docs/tutorials/network-and-buffering-config.md +0 -119
  254. package/docs/tutorials/offline.md +0 -683
  255. package/docs/tutorials/plugins.md +0 -184
  256. package/docs/tutorials/selenium-grid-config.md +0 -174
  257. package/docs/tutorials/service-worker.md +0 -106
  258. package/docs/tutorials/ui-customization.md +0 -288
  259. package/docs/tutorials/ui.md +0 -230
  260. package/docs/tutorials/upgrade-manifest.md +0 -281
  261. package/docs/tutorials/upgrade.md +0 -104
  262. package/docs/tutorials/welcome.md +0 -108
  263. package/docs/tutorials/widevine-service-certs.md +0 -45
  264. package/karma.conf.js +0 -879
  265. package/maintained-branches.md +0 -15
  266. package/roadmap.md +0 -186
  267. package/test/abr/simple_abr_manager_unit.js +0 -398
  268. package/test/ads/ad_manager_unit.js +0 -260
  269. package/test/assumptions/uint8_array_unit.js +0 -22
  270. package/test/cast/cast_proxy_unit.js +0 -736
  271. package/test/cast/cast_receiver_integration.js +0 -488
  272. package/test/cast/cast_receiver_unit.js +0 -1183
  273. package/test/cast/cast_sender_unit.js +0 -973
  274. package/test/cast/cast_utils_unit.js +0 -311
  275. package/test/cea/cea608_memory_unit.js +0 -411
  276. package/test/cea/cea708_service_unit.js +0 -674
  277. package/test/cea/cea708_window_unit.js +0 -373
  278. package/test/cea/cea_decoder_unit.js +0 -615
  279. package/test/cea/dtvcc_packet_builder_unit.js +0 -158
  280. package/test/cea/dtvcc_packet_unit.js +0 -60
  281. package/test/cea/mp4_cea_parser_unit.js +0 -127
  282. package/test/codec_switching/codec_switching_integration.js +0 -182
  283. package/test/dash/dash_parser_content_protection_unit.js +0 -998
  284. package/test/dash/dash_parser_integration.js +0 -74
  285. package/test/dash/dash_parser_live_unit.js +0 -1542
  286. package/test/dash/dash_parser_manifest_unit.js +0 -3121
  287. package/test/dash/dash_parser_segment_base_unit.js +0 -421
  288. package/test/dash/dash_parser_segment_list_unit.js +0 -380
  289. package/test/dash/dash_parser_segment_template_unit.js +0 -910
  290. package/test/dash/mpd_utils_unit.js +0 -794
  291. package/test/demo/demo_unit.js +0 -108
  292. package/test/deprecate/enforcer_unit.js +0 -74
  293. package/test/deprecate/version_unit.js +0 -57
  294. package/test/hls/hls_live_unit.js +0 -1330
  295. package/test/hls/hls_parser_unit.js +0 -5276
  296. package/test/hls/manifest_text_parser_unit.js +0 -545
  297. package/test/media/adaptation_set_criteria_unit.js +0 -806
  298. package/test/media/adaptation_set_unit.js +0 -229
  299. package/test/media/buffering_observer_unit.js +0 -143
  300. package/test/media/closed_caption_parser_unit.js +0 -18
  301. package/test/media/content_workarounds_unit.js +0 -43
  302. package/test/media/drm_engine_integration.js +0 -356
  303. package/test/media/drm_engine_unit.js +0 -2778
  304. package/test/media/media_source_engine_integration.js +0 -691
  305. package/test/media/media_source_engine_unit.js +0 -1512
  306. package/test/media/mp4_segment_index_parser_unit.js +0 -80
  307. package/test/media/play_rate_controller_unit.js +0 -69
  308. package/test/media/playhead_unit.js +0 -1394
  309. package/test/media/presentation_timeline_unit.js +0 -477
  310. package/test/media/quality_observer_unit.js +0 -138
  311. package/test/media/region_observer_unit.js +0 -374
  312. package/test/media/region_timeline_unit.js +0 -139
  313. package/test/media/segment_index_unit.js +0 -1080
  314. package/test/media/segment_prefetch_unit.js +0 -243
  315. package/test/media/segment_reference_unit.js +0 -63
  316. package/test/media/stall_detector_unit.js +0 -184
  317. package/test/media/streaming_engine_integration.js +0 -632
  318. package/test/media/streaming_engine_unit.js +0 -4211
  319. package/test/media/time_ranges_utils_unit.js +0 -123
  320. package/test/media/webm_segment_index_parser_unit.js +0 -90
  321. package/test/mss/mss_parser_content_protection_unit.js +0 -49
  322. package/test/mss/mss_parser_unit.js +0 -474
  323. package/test/mss/mss_player_integration.js +0 -124
  324. package/test/net/data_uri_plugin_unit.js +0 -105
  325. package/test/net/http_plugin_unit.js +0 -439
  326. package/test/net/networking_engine_unit.js +0 -1236
  327. package/test/net/networking_utils_unit.js +0 -37
  328. package/test/offline/download_progress_estimator_unit.js +0 -90
  329. package/test/offline/indexeddb_storage_unit.js +0 -192
  330. package/test/offline/manifest_convert_unit.js +0 -622
  331. package/test/offline/offline_integration.js +0 -168
  332. package/test/offline/offline_manifest_parser_unit.js +0 -231
  333. package/test/offline/offline_scheme_unit.js +0 -154
  334. package/test/offline/offline_uri_unit.js +0 -59
  335. package/test/offline/storage_compatibility_unit.js +0 -344
  336. package/test/offline/storage_integration.js +0 -1858
  337. package/test/player_external.js +0 -237
  338. package/test/player_integration.js +0 -1371
  339. package/test/player_load_graph_integration.js +0 -865
  340. package/test/player_src_equals_external.js +0 -154
  341. package/test/player_src_equals_integration.js +0 -527
  342. package/test/player_unit.js +0 -4434
  343. package/test/polyfill/media_capabilities_unit.js +0 -277
  344. package/test/polyfill/patchedmediakeys_apple_unit.js +0 -130
  345. package/test/test/assets/3675/chunk-stream0-00001.m4s +0 -0
  346. package/test/test/assets/3675/chunk-stream0-00002.m4s +0 -0
  347. package/test/test/assets/3675/chunk-stream0-00003.m4s +0 -0
  348. package/test/test/assets/3675/chunk-stream0-00004.m4s +0 -0
  349. package/test/test/assets/3675/chunk-stream0-00005.m4s +0 -0
  350. package/test/test/assets/3675/chunk-stream0-00006.m4s +0 -0
  351. package/test/test/assets/3675/chunk-stream0-00007.m4s +0 -0
  352. package/test/test/assets/3675/dash_0.mpd +0 -30
  353. package/test/test/assets/3675/dash_1.mpd +0 -30
  354. package/test/test/assets/3675/dash_2.mpd +0 -30
  355. package/test/test/assets/3675/dash_3.mpd +0 -30
  356. package/test/test/assets/3675/dash_4.mpd +0 -30
  357. package/test/test/assets/3675/dash_5.mpd +0 -26
  358. package/test/test/assets/3675/init-stream0.m4s +0 -0
  359. package/test/test/assets/audio-xhe-aac.mp4 +0 -0
  360. package/test/test/assets/audio.ts +0 -0
  361. package/test/test/assets/captions-test.ts +0 -0
  362. package/test/test/assets/cea-init.mp4 +0 -0
  363. package/test/test/assets/cea-segment.mp4 +0 -0
  364. package/test/test/assets/chapters.srt +0 -11
  365. package/test/test/assets/chapters.vtt +0 -10
  366. package/test/test/assets/chapters2.vtt +0 -10
  367. package/test/test/assets/dash-aes-128/Fragments(video=0,format=mpd-time-csf) +0 -0
  368. package/test/test/assets/dash-aes-128/Fragments(video=20000000,format=mpd-time-csf) +0 -0
  369. package/test/test/assets/dash-aes-128/Fragments(video=40000000,format=mpd-time-csf) +0 -0
  370. package/test/test/assets/dash-aes-128/Fragments(video=60000000,format=mpd-time-csf) +0 -0
  371. package/test/test/assets/dash-aes-128/Fragments(video=i,format=mpd-time-csf) +0 -0
  372. package/test/test/assets/dash-aes-128/dash.mpd +0 -18
  373. package/test/test/assets/dash-aes-128/license +0 -1
  374. package/test/test/assets/dash-multi-codec/audio_en_2c_128k_aac.mp4 +0 -0
  375. package/test/test/assets/dash-multi-codec/audio_es_2c_64k_opus.webm +0 -0
  376. package/test/test/assets/dash-multi-codec/dash.mpd +0 -32
  377. package/test/test/assets/dash-multi-codec/video_144p_108k_h264.mp4 +0 -0
  378. package/test/test/assets/db-dump-v1.json +0 -1
  379. package/test/test/assets/db-dump-v2-broken.json +0 -1
  380. package/test/test/assets/db-dump-v2-clean.json +0 -1
  381. package/test/test/assets/db-dump-v3.json +0 -1
  382. package/test/test/assets/db-dump-v4-broken.json +0 -1
  383. package/test/test/assets/db-dump-v5.json +0 -1
  384. package/test/test/assets/empty_caption_video_init.mp4 +0 -0
  385. package/test/test/assets/empty_caption_video_segment.mp4 +0 -0
  386. package/test/test/assets/encrypted-sintel-audio-init.mp4 +0 -0
  387. package/test/test/assets/encrypted-sintel-audio-segment.mp4 +0 -0
  388. package/test/test/assets/encrypted-sintel-video-init.mp4 +0 -0
  389. package/test/test/assets/encrypted-sintel-video-segment.mp4 +0 -0
  390. package/test/test/assets/green-pixel.mp4 +0 -0
  391. package/test/test/assets/green-pixel.txt +0 -15
  392. package/test/test/assets/h265-cea-init.mp4 +0 -0
  393. package/test/test/assets/h265-cea-segment.mp4 +0 -0
  394. package/test/test/assets/hls-raw-aac/fileSequence0.aac +0 -0
  395. package/test/test/assets/hls-raw-aac/fileSequence1.aac +0 -0
  396. package/test/test/assets/hls-raw-aac/fileSequence2.aac +0 -0
  397. package/test/test/assets/hls-raw-aac/fileSequence3.aac +0 -0
  398. package/test/test/assets/hls-raw-aac/manifest.m3u8 +0 -4
  399. package/test/test/assets/hls-raw-aac/stream.m4a.m3u8 +0 -14
  400. package/test/test/assets/hls-raw-ac3/fileSequence0.ac3 +0 -0
  401. package/test/test/assets/hls-raw-ac3/fileSequence1.ac3 +0 -0
  402. package/test/test/assets/hls-raw-ac3/fileSequence2.ac3 +0 -0
  403. package/test/test/assets/hls-raw-ac3/fileSequence3.ac3 +0 -0
  404. package/test/test/assets/hls-raw-ac3/fileSequence4.ac3 +0 -0
  405. package/test/test/assets/hls-raw-ac3/fileSequence5.ac3 +0 -0
  406. package/test/test/assets/hls-raw-ac3/fileSequence6.ac3 +0 -0
  407. package/test/test/assets/hls-raw-ac3/fileSequence7.ac3 +0 -0
  408. package/test/test/assets/hls-raw-ac3/prog_index.m3u8 +0 -31
  409. package/test/test/assets/hls-raw-ec3/fileSequence0.ec3 +0 -0
  410. package/test/test/assets/hls-raw-ec3/fileSequence1.ec3 +0 -0
  411. package/test/test/assets/hls-raw-ec3/fileSequence2.ec3 +0 -0
  412. package/test/test/assets/hls-raw-ec3/fileSequence3.ec3 +0 -0
  413. package/test/test/assets/hls-raw-ec3/fileSequence4.ec3 +0 -0
  414. package/test/test/assets/hls-raw-ec3/fileSequence5.ec3 +0 -0
  415. package/test/test/assets/hls-raw-ec3/fileSequence6.ec3 +0 -0
  416. package/test/test/assets/hls-raw-ec3/fileSequence7.ec3 +0 -0
  417. package/test/test/assets/hls-raw-ec3/prog_index.m3u8 +0 -31
  418. package/test/test/assets/hls-raw-mp3/chunklist_w905519204.m3u8 +0 -13
  419. package/test/test/assets/hls-raw-mp3/media_w905519204_0.mp3 +0 -0
  420. package/test/test/assets/hls-raw-mp3/media_w905519204_1.mp3 +0 -0
  421. package/test/test/assets/hls-raw-mp3/media_w905519204_2.mp3 +0 -0
  422. package/test/test/assets/hls-raw-mp3/media_w905519204_3.mp3 +0 -0
  423. package/test/test/assets/hls-raw-mp3/playlist.m3u8 +0 -4
  424. package/test/test/assets/hls-ts-aac/playlist.m3u8 +0 -23
  425. package/test/test/assets/hls-ts-aac/segment_0.ts +0 -0
  426. package/test/test/assets/hls-ts-aac/segment_1.ts +0 -0
  427. package/test/test/assets/hls-ts-aac/segment_2.ts +0 -0
  428. package/test/test/assets/hls-ts-aac/segment_3.ts +0 -0
  429. package/test/test/assets/hls-ts-aac/segment_4.ts +0 -0
  430. package/test/test/assets/hls-ts-aac/segment_5.ts +0 -0
  431. package/test/test/assets/hls-ts-aac/segment_6.ts +0 -0
  432. package/test/test/assets/hls-ts-aac/segment_7.ts +0 -0
  433. package/test/test/assets/hls-ts-ac3/ChID_voices_6ch_640kbps_dd_sub_0000.ts +0 -0
  434. package/test/test/assets/hls-ts-ac3/ChID_voices_6ch_640kbps_dd_sub_0001.ts +0 -0
  435. package/test/test/assets/hls-ts-ac3/ChID_voices_6ch_640kbps_dd_sub_0002.ts +0 -0
  436. package/test/test/assets/hls-ts-ac3/ChID_voices_6ch_640kbps_dd_sub_0003.ts +0 -0
  437. package/test/test/assets/hls-ts-ac3/ChID_voices_6ch_640kbps_dd_sub_0004.ts +0 -0
  438. package/test/test/assets/hls-ts-ac3/ChID_voices_6ch_640kbps_dd_sub_0005.ts +0 -0
  439. package/test/test/assets/hls-ts-ac3/prog_index.m3u8 +0 -19
  440. package/test/test/assets/hls-ts-ec3/ChID_voices_6ch_256kbps_ddp_sub_0000.ts +0 -0
  441. package/test/test/assets/hls-ts-ec3/ChID_voices_6ch_256kbps_ddp_sub_0001.ts +0 -0
  442. package/test/test/assets/hls-ts-ec3/ChID_voices_6ch_256kbps_ddp_sub_0002.ts +0 -0
  443. package/test/test/assets/hls-ts-ec3/ChID_voices_6ch_256kbps_ddp_sub_0003.ts +0 -0
  444. package/test/test/assets/hls-ts-ec3/ChID_voices_6ch_256kbps_ddp_sub_0004.ts +0 -0
  445. package/test/test/assets/hls-ts-ec3/ChID_voices_6ch_256kbps_ddp_sub_0005.ts +0 -0
  446. package/test/test/assets/hls-ts-ec3/prog_index.m3u8 +0 -19
  447. package/test/test/assets/hls-ts-h264/fileSequence0.ts +0 -0
  448. package/test/test/assets/hls-ts-h264/fileSequence1.ts +0 -0
  449. package/test/test/assets/hls-ts-h264/fileSequence2.ts +0 -0
  450. package/test/test/assets/hls-ts-h264/fileSequence3.ts +0 -0
  451. package/test/test/assets/hls-ts-h264/fileSequence4.ts +0 -0
  452. package/test/test/assets/hls-ts-h264/fileSequence5.ts +0 -0
  453. package/test/test/assets/hls-ts-h264/prog_index.m3u8 +0 -25
  454. package/test/test/assets/hls-ts-h265/0.ts +0 -0
  455. package/test/test/assets/hls-ts-h265/hevc.m3u8 +0 -6
  456. package/test/test/assets/hls-ts-h265/index.m3u8 +0 -7
  457. package/test/test/assets/hls-ts-mp3/manifest.m3u8 +0 -13
  458. package/test/test/assets/hls-ts-mp3/media_w239891843_0.ts +0 -0
  459. package/test/test/assets/hls-ts-mp3/media_w239891843_1.ts +0 -0
  460. package/test/test/assets/hls-ts-mp3/media_w239891843_2.ts +0 -0
  461. package/test/test/assets/hls-ts-mp3/media_w239891843_3.ts +0 -0
  462. package/test/test/assets/hls-ts-muxed-aac-h264/chunk.m3u8 +0 -17
  463. package/test/test/assets/hls-ts-muxed-aac-h264/n_0_0_0.ts +0 -0
  464. package/test/test/assets/hls-ts-muxed-aac-h264/n_1_0_0.ts +0 -0
  465. package/test/test/assets/hls-ts-muxed-aac-h264/n_2_0_0.ts +0 -0
  466. package/test/test/assets/hls-ts-muxed-aac-h264/n_3_0_0.ts +0 -0
  467. package/test/test/assets/hls-ts-muxed-aac-h264/n_4_0_0.ts +0 -0
  468. package/test/test/assets/hls-ts-muxed-aac-h264/n_5_0_0.ts +0 -0
  469. package/test/test/assets/hls-ts-muxed-aac-h264/playlist.m3u8 +0 -4
  470. package/test/test/assets/hls-ts-muxed-aac-h265/0.ts +0 -0
  471. package/test/test/assets/hls-ts-muxed-aac-h265/1.ts +0 -0
  472. package/test/test/assets/hls-ts-muxed-aac-h265/media.m3u8 +0 -9
  473. package/test/test/assets/hls-ts-muxed-ac3-h264/media.m3u8 +0 -24
  474. package/test/test/assets/hls-ts-muxed-ac3-h264/s_00000.ts +0 -0
  475. package/test/test/assets/hls-ts-muxed-ac3-h264/s_00001.ts +0 -0
  476. package/test/test/assets/hls-ts-muxed-ac3-h264/s_00002.ts +0 -0
  477. package/test/test/assets/hls-ts-muxed-ac3-h264/s_00003.ts +0 -0
  478. package/test/test/assets/hls-ts-muxed-ac3-h264/s_00004.ts +0 -0
  479. package/test/test/assets/hls-ts-muxed-ac3-h264/s_00005.ts +0 -0
  480. package/test/test/assets/hls-ts-muxed-ec3-h264/ChID_voices_1280x720p_25fps_h264_6ch_256kbps_ddp_sub_0000.ts +0 -0
  481. package/test/test/assets/hls-ts-muxed-ec3-h264/ChID_voices_1280x720p_25fps_h264_6ch_256kbps_ddp_sub_0001.ts +0 -0
  482. package/test/test/assets/hls-ts-muxed-ec3-h264/ChID_voices_1280x720p_25fps_h264_6ch_256kbps_ddp_sub_0002.ts +0 -0
  483. package/test/test/assets/hls-ts-muxed-ec3-h264/ChID_voices_1280x720p_25fps_h264_6ch_256kbps_ddp_sub_0003.ts +0 -0
  484. package/test/test/assets/hls-ts-muxed-ec3-h264/prog_index.m3u8 +0 -14
  485. package/test/test/assets/hls-ts-muxed-mp3-h264/index.m3u8 +0 -23
  486. package/test/test/assets/hls-ts-muxed-mp3-h264/seg-1-v1-a1.ts +0 -0
  487. package/test/test/assets/hls-ts-muxed-mp3-h264/seg-2-v1-a1.ts +0 -0
  488. package/test/test/assets/hls-ts-muxed-mp3-h264/seg-3-v1-a1.ts +0 -0
  489. package/test/test/assets/hls-ts-muxed-mp3-h264/seg-4-v1-a1.ts +0 -0
  490. package/test/test/assets/hls-ts-muxed-mp3-h264/seg-5-v1-a1.ts +0 -0
  491. package/test/test/assets/hls-ts-muxed-mp3-h264/seg-6-v1-a1.ts +0 -0
  492. package/test/test/assets/hls-ts-muxed-mp3-h264/seg-7-v1-a1.ts +0 -0
  493. package/test/test/assets/hls-ts-muxed-mp3-h264/seg-8-v1-a1.ts +0 -0
  494. package/test/test/assets/id3-metadata.aac +0 -0
  495. package/test/test/assets/id3-metadata.ts +0 -0
  496. package/test/test/assets/index-segment.mp4 +0 -0
  497. package/test/test/assets/index-segment.webm +0 -0
  498. package/test/test/assets/init-segment.webm +0 -0
  499. package/test/test/assets/large_file.mpd +0 -4930
  500. package/test/test/assets/multidrm-audio-init.mp4 +0 -0
  501. package/test/test/assets/multidrm-audio-segment.mp4 +0 -0
  502. package/test/test/assets/multidrm-video-init.mp4 +0 -0
  503. package/test/test/assets/multidrm-video-segment.mp4 +0 -0
  504. package/test/test/assets/multiple-trun-init.mp4 +0 -0
  505. package/test/test/assets/multiple-trun-segment.mp4 +0 -0
  506. package/test/test/assets/sintel-audio-init.mp4 +0 -0
  507. package/test/test/assets/sintel-audio-segment.mp4 +0 -0
  508. package/test/test/assets/sintel-video-init.mp4 +0 -0
  509. package/test/test/assets/sintel-video-segment.mp4 +0 -0
  510. package/test/test/assets/small.mp4 +0 -0
  511. package/test/test/assets/text-clip-alt.vtt +0 -63
  512. package/test/test/assets/text-clip.vtt +0 -63
  513. package/test/test/assets/thumbnails-sprites.vtt +0 -10
  514. package/test/test/assets/thumbnails.vtt +0 -10
  515. package/test/test/assets/ttml-init.mp4 +0 -0
  516. package/test/test/assets/ttml-segment-multiplemdat.mp4 +0 -0
  517. package/test/test/assets/ttml-segment.mp4 +0 -0
  518. package/test/test/assets/video.ts +0 -0
  519. package/test/test/assets/vtt-init.mp4 +0 -0
  520. package/test/test/assets/vtt-segment-multi-payload.mp4 +0 -0
  521. package/test/test/assets/vtt-segment-no-duration.mp4 +0 -0
  522. package/test/test/assets/vtt-segment-settings.mp4 +0 -0
  523. package/test/test/assets/vtt-segment.mp4 +0 -0
  524. package/test/test/boot.js +0 -495
  525. package/test/test/externs/filters.js +0 -44
  526. package/test/test/externs/fontfaceonload.js +0 -29
  527. package/test/test/externs/jasmine.js +0 -670
  528. package/test/test/externs/karma.js +0 -26
  529. package/test/test/externs/require.js +0 -21
  530. package/test/test/externs/sprintf.js +0 -18
  531. package/test/test/namespace.js +0 -10
  532. package/test/test/util/canned_idb.js +0 -379
  533. package/test/test/util/cea_utils.js +0 -60
  534. package/test/test/util/dash_parser_util.js +0 -329
  535. package/test/test/util/fake_ad.js +0 -321
  536. package/test/test/util/fake_ad_manager.js +0 -122
  537. package/test/test/util/fake_demo_main.js +0 -144
  538. package/test/test/util/fake_drm_engine.js +0 -103
  539. package/test/test/util/fake_media_source_engine.js +0 -464
  540. package/test/test/util/fake_networking_engine.js +0 -381
  541. package/test/test/util/fake_segment_prefetch.js +0 -84
  542. package/test/test/util/fake_text_displayer.js +0 -60
  543. package/test/test/util/id3_generator.js +0 -100
  544. package/test/test/util/indexeddb_utils.js +0 -124
  545. package/test/test/util/jasmine_fetch.js +0 -382
  546. package/test/test/util/layout_tests.js +0 -434
  547. package/test/test/util/loader.js +0 -88
  548. package/test/test/util/manifest_generator.js +0 -705
  549. package/test/test/util/manifest_parser_util.js +0 -101
  550. package/test/test/util/mss_parser_util.js +0 -119
  551. package/test/test/util/offline_utils.js +0 -105
  552. package/test/test/util/simple_fakes.js +0 -535
  553. package/test/test/util/stream_generator.js +0 -676
  554. package/test/test/util/streaming_engine_util.js +0 -506
  555. package/test/test/util/test_scheme.js +0 -778
  556. package/test/test/util/ttml_utils.js +0 -77
  557. package/test/test/util/ui_utils.js +0 -183
  558. package/test/test/util/util.js +0 -374
  559. package/test/test/util/waiter.js +0 -406
  560. package/test/text/cue_integration.js +0 -51
  561. package/test/text/lrc_text_parser_unit.js +0 -98
  562. package/test/text/mp4_ttml_parser_unit.js +0 -171
  563. package/test/text/mp4_vtt_parser_unit.js +0 -195
  564. package/test/text/sbv_text_parser_unit.js +0 -81
  565. package/test/text/simple_text_displayer_unit.js +0 -468
  566. package/test/text/srt_text_parser_unit.js +0 -163
  567. package/test/text/ssa_text_parser_unit.js +0 -382
  568. package/test/text/text_displayer_layout_unit.js +0 -323
  569. package/test/text/text_engine_unit.js +0 -500
  570. package/test/text/text_track_integration.js +0 -186
  571. package/test/text/ttml_text_parser_unit.js +0 -2176
  572. package/test/text/ui_text_displayer_unit.js +0 -608
  573. package/test/text/vtt_text_parser_unit.js +0 -1363
  574. package/test/text/web_vtt_generator_unit.js +0 -144
  575. package/test/text/web_vtt_layout_integration.js +0 -524
  576. package/test/transmuxer/transmuxer_engine_integration.js +0 -69
  577. package/test/transmuxer/transmuxer_integration.js +0 -443
  578. package/test/ui/ad_ui_unit.js +0 -369
  579. package/test/ui/localization_unit.js +0 -508
  580. package/test/ui/ui_customization_unit.js +0 -208
  581. package/test/ui/ui_integration.js +0 -669
  582. package/test/ui/ui_unit.js +0 -902
  583. package/test/util/abortable_operation_unit.js +0 -624
  584. package/test/util/array_utils_unit.js +0 -58
  585. package/test/util/buffer_utils_unit.js +0 -185
  586. package/test/util/cmcd_manager_unit.js +0 -440
  587. package/test/util/content_steering_manager_unit.js +0 -427
  588. package/test/util/data_view_reader_unit.js +0 -254
  589. package/test/util/ebml_parser_unit.js +0 -297
  590. package/test/util/event_manager_unit.js +0 -185
  591. package/test/util/fake_event_target_unit.js +0 -123
  592. package/test/util/id3_utils_unit.js +0 -168
  593. package/test/util/iterables_unit.js +0 -68
  594. package/test/util/language_utils_unit.js +0 -240
  595. package/test/util/manifest_parser_utils_unit.js +0 -55
  596. package/test/util/mime_utils_unit.js +0 -64
  597. package/test/util/mp4_box_parsers_unit.js +0 -246
  598. package/test/util/mp4_parser_unit.js +0 -373
  599. package/test/util/multi_map_unit.js +0 -94
  600. package/test/util/object_utils_unit.js +0 -79
  601. package/test/util/periods_unit.js +0 -1623
  602. package/test/util/pssh_unit.js +0 -226
  603. package/test/util/state_history_unit.js +0 -101
  604. package/test/util/stream_utils_unit.js +0 -1068
  605. package/test/util/string_utils_unit.js +0 -166
  606. package/test/util/text_parser_unit.js +0 -165
  607. package/test/util/ts_parser_unit.js +0 -77
  608. package/test/util/xml_utils_unit.js +0 -444
@@ -1,3121 +0,0 @@
1
- /*! @license
2
- * Shaka Player
3
- * Copyright 2016 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
-
7
- // Test basic manifest parsing functionality.
8
- describe('DashParser Manifest', () => {
9
- const ContentType = shaka.util.ManifestParserUtils.ContentType;
10
- const Dash = shaka.test.Dash;
11
- const mp4IndexSegmentUri = '/base/test/test/assets/index-segment.mp4';
12
-
13
- /** @type {!shaka.test.FakeNetworkingEngine} */
14
- let fakeNetEngine;
15
- /** @type {!shaka.dash.DashParser} */
16
- let parser;
17
- /** @type {!jasmine.Spy} */
18
- let onEventSpy;
19
- /** @type {shaka.extern.ManifestParser.PlayerInterface} */
20
- let playerInterface;
21
- /** @type {!ArrayBuffer} */
22
- let mp4Index;
23
-
24
- /** @type {string} */
25
- const thumbnailScheme = 'http://dashif.org/guidelines/thumbnail_tile';
26
- /**
27
- * CICP scheme. parameter must be one of the following: "ColourPrimaries",
28
- * "TransferCharacteristics", or "MatrixCoefficients".
29
- *
30
- * @param {string} parameter
31
- * @return {string}
32
- */
33
- const cicpScheme = (parameter) => `urn:mpeg:mpegB:cicp:${parameter}`;
34
-
35
- beforeAll(async () => {
36
- mp4Index = await shaka.test.Util.fetch(mp4IndexSegmentUri);
37
- });
38
-
39
- beforeEach(() => {
40
- fakeNetEngine = new shaka.test.FakeNetworkingEngine();
41
- parser = shaka.test.Dash.makeDashParser();
42
- onEventSpy = jasmine.createSpy('onEvent');
43
- playerInterface = {
44
- networkingEngine: fakeNetEngine,
45
- modifyManifestRequest: (request, manifestInfo) => {},
46
- modifySegmentRequest: (request, segmentInfo) => {},
47
- filter: (manifest) => Promise.resolve(),
48
- makeTextStreamsForClosedCaptions: (manifest) => {},
49
- onTimelineRegionAdded: fail, // Should not have any EventStream elements.
50
- onEvent: shaka.test.Util.spyFunc(onEventSpy),
51
- onError: fail,
52
- isLowLatencyMode: () => false,
53
- isAutoLowLatencyMode: () => false,
54
- enableLowLatencyMode: () => {},
55
- updateDuration: () => {},
56
- newDrmInfo: (stream) => {},
57
- onManifestUpdated: () => {},
58
- getBandwidthEstimate: () => 1e6,
59
- };
60
- });
61
-
62
- afterEach(() => {
63
- // Dash parser stop is synchronous.
64
- parser.stop();
65
- });
66
-
67
- /**
68
- * Makes a series of tests for the given manifest type.
69
- *
70
- * @param {!Array.<string>} startLines
71
- * @param {!Array.<string>} endLines
72
- * @param {shaka.extern.Manifest} expected
73
- */
74
- function makeTestsForEach(startLines, endLines, expected) {
75
- /**
76
- * Makes manifest text for testing.
77
- *
78
- * @param {!Array.<string>} lines
79
- * @return {string}
80
- */
81
- function makeTestManifest(lines) {
82
- return startLines.concat(lines, endLines).join('\n');
83
- }
84
-
85
- /**
86
- * Tests that the parser produces the correct results.
87
- *
88
- * @param {string} manifestText
89
- * @return {!Promise}
90
- */
91
- async function testDashParser(manifestText) {
92
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
93
- const actual = await parser.start('dummy://foo', playerInterface);
94
- expect(actual).toEqual(expected);
95
- }
96
-
97
- it('with SegmentBase', async () => {
98
- const source = makeTestManifest([
99
- ' <SegmentBase indexRange="100-200" timescale="9000">',
100
- ' <Initialization sourceURL="init.mp4" range="201-300" />',
101
- ' </SegmentBase>',
102
- ]);
103
- await testDashParser(source);
104
- });
105
-
106
- it('with SegmentList', async () => {
107
- const source = makeTestManifest([
108
- ' <SegmentList startNumber="1" duration="10">',
109
- ' <Initialization sourceURL="init.mp4" range="201-300" />',
110
- ' <SegmentURL media="s1.mp4" />',
111
- ' </SegmentList>',
112
- ]);
113
- await testDashParser(source);
114
- });
115
-
116
- it('with SegmentTemplate', async () => {
117
- const source = makeTestManifest([
118
- ' <SegmentTemplate startNumber="1" media="l-$Number$.mp4"',
119
- ' initialization="init.mp4">',
120
- ' <Initialization sourceURL="init.mp4" range="201-300" />',
121
- ' <SegmentTimeline>',
122
- ' <S t="0" d="30" />',
123
- ' </SegmentTimeline>',
124
- ' </SegmentTemplate>',
125
- ]);
126
- await testDashParser(source);
127
- });
128
- }
129
-
130
- describe('parses and inherits attributes with sequenceMode', () => {
131
- beforeEach(() => {
132
- const config = shaka.util.PlayerConfiguration.createDefault().manifest;
133
- config.dash.sequenceMode = true;
134
- parser.configure(config);
135
- });
136
-
137
- makeTestsForEach(
138
- [
139
- '<MPD minBufferTime="PT75S">',
140
- ' <Period id="1" duration="PT30S">',
141
- ' <BaseURL>http://example.com</BaseURL>',
142
- ],
143
- [
144
- ' <AdaptationSet contentType="video" mimeType="video/mp4"',
145
- ' codecs="avc1.4d401f" frameRate="1000000/42000">',
146
- ' <Representation bandwidth="100" width="768" height="576" />',
147
- ' <Representation bandwidth="50" width="576" height="432" />',
148
- ' </AdaptationSet>',
149
- ' <AdaptationSet mimeType="text/vtt"',
150
- ' lang="spa" label="spanish">',
151
- ' <Role value="caption" />',
152
- ' <Role value="main" />',
153
- ' <Representation bandwidth="100" />',
154
- ' </AdaptationSet>',
155
- ' <AdaptationSet mimeType="audio/mp4" lang="en" ',
156
- ' codecs="mp4a.40.29">',
157
- ' <Role value="main" />',
158
- ' <Representation bandwidth="100" />',
159
- ' </AdaptationSet>',
160
- ' </Period>',
161
- '</MPD>',
162
- ],
163
- shaka.test.ManifestGenerator.generate((manifest) => {
164
- manifest.sequenceMode = true;
165
- manifest.type = shaka.media.ManifestParser.DASH;
166
- manifest.anyTimeline();
167
- manifest.minBufferTime = 75;
168
- manifest.addPartialVariant((variant) => {
169
- variant.language = 'en';
170
- variant.bandwidth = 200;
171
- variant.primary = true;
172
- variant.addPartialStream(ContentType.VIDEO, (stream) => {
173
- stream.bandwidth = 100;
174
- stream.frameRate = 1000000 / 42000;
175
- stream.size(768, 576);
176
- stream.mime('video/mp4', 'avc1.4d401f');
177
- });
178
- variant.addPartialStream(ContentType.AUDIO, (stream) => {
179
- stream.bandwidth = 100;
180
- stream.primary = true;
181
- stream.roles = ['main'];
182
- stream.mime('audio/mp4', 'mp4a.40.29');
183
- });
184
- });
185
- manifest.addPartialVariant((variant) => {
186
- variant.language = 'en';
187
- variant.bandwidth = 150;
188
- variant.primary = true;
189
- variant.addPartialStream(ContentType.VIDEO, (stream) => {
190
- stream.bandwidth = 50;
191
- stream.frameRate = 1000000 / 42000;
192
- stream.size(576, 432);
193
- stream.mime('video/mp4', 'avc1.4d401f');
194
- });
195
- variant.addPartialStream(ContentType.AUDIO, (stream) => {
196
- stream.bandwidth = 100;
197
- stream.primary = true;
198
- stream.roles = ['main'];
199
- stream.mime('audio/mp4', 'mp4a.40.29');
200
- });
201
- });
202
- manifest.addPartialTextStream((stream) => {
203
- stream.language = 'es';
204
- stream.originalLanguage = 'spa';
205
- stream.label = 'spanish';
206
- stream.primary = true;
207
- stream.mimeType = 'text/vtt';
208
- stream.bandwidth = 100;
209
- stream.kind = 'caption';
210
- stream.roles = ['caption', 'main'];
211
- });
212
- }));
213
- });
214
-
215
- describe('parses and inherits attributes without sequenceMode', () => {
216
- beforeEach(() => {
217
- const config = shaka.util.PlayerConfiguration.createDefault().manifest;
218
- config.dash.sequenceMode = false;
219
- parser.configure(config);
220
- });
221
-
222
-
223
- makeTestsForEach(
224
- [
225
- '<MPD minBufferTime="PT75S">',
226
- ' <Period id="1" duration="PT30S">',
227
- ' <BaseURL>http://example.com</BaseURL>',
228
- ],
229
- [
230
- ' <AdaptationSet contentType="video" mimeType="video/mp4"',
231
- ' codecs="avc1.4d401f" frameRate="1000000/42000">',
232
- ' <Representation bandwidth="100" width="768" height="576" />',
233
- ' <Representation bandwidth="50" width="576" height="432" />',
234
- ' </AdaptationSet>',
235
- ' <AdaptationSet mimeType="text/vtt"',
236
- ' lang="es" label="spanish">',
237
- ' <Role value="caption" />',
238
- ' <Role value="main" />',
239
- ' <Representation bandwidth="100" />',
240
- ' </AdaptationSet>',
241
- ' <AdaptationSet mimeType="audio/mp4" lang="en" ',
242
- ' codecs="mp4a.40.29">',
243
- ' <Role value="main" />',
244
- ' <Representation bandwidth="100" />',
245
- ' </AdaptationSet>',
246
- ' </Period>',
247
- '</MPD>',
248
- ],
249
- shaka.test.ManifestGenerator.generate((manifest) => {
250
- manifest.sequenceMode = false;
251
- manifest.type = shaka.media.ManifestParser.DASH;
252
- manifest.anyTimeline();
253
- manifest.minBufferTime = 75;
254
- manifest.addPartialVariant((variant) => {
255
- variant.language = 'en';
256
- variant.bandwidth = 200;
257
- variant.primary = true;
258
- variant.addPartialStream(ContentType.VIDEO, (stream) => {
259
- stream.bandwidth = 100;
260
- stream.frameRate = 1000000 / 42000;
261
- stream.size(768, 576);
262
- stream.mime('video/mp4', 'avc1.4d401f');
263
- });
264
- variant.addPartialStream(ContentType.AUDIO, (stream) => {
265
- stream.bandwidth = 100;
266
- stream.primary = true;
267
- stream.roles = ['main'];
268
- stream.mime('audio/mp4', 'mp4a.40.29');
269
- });
270
- });
271
- manifest.addPartialVariant((variant) => {
272
- variant.language = 'en';
273
- variant.bandwidth = 150;
274
- variant.primary = true;
275
- variant.addPartialStream(ContentType.VIDEO, (stream) => {
276
- stream.bandwidth = 50;
277
- stream.frameRate = 1000000 / 42000;
278
- stream.size(576, 432);
279
- stream.mime('video/mp4', 'avc1.4d401f');
280
- });
281
- variant.addPartialStream(ContentType.AUDIO, (stream) => {
282
- stream.bandwidth = 100;
283
- stream.primary = true;
284
- stream.roles = ['main'];
285
- stream.mime('audio/mp4', 'mp4a.40.29');
286
- });
287
- });
288
- manifest.addPartialTextStream((stream) => {
289
- stream.language = 'es';
290
- stream.label = 'spanish';
291
- stream.primary = true;
292
- stream.mimeType = 'text/vtt';
293
- stream.bandwidth = 100;
294
- stream.kind = 'caption';
295
- stream.roles = ['caption', 'main'];
296
- });
297
- }));
298
- });
299
-
300
- it('calculates Period times when missing', async () => {
301
- const periodContents = [
302
- ' <AdaptationSet mimeType="video/mp4" lang="en" group="1">',
303
- ' <Representation bandwidth="100">',
304
- ' <SegmentTemplate duration="2" media="s$Number$.mp4" />',
305
- ' </Representation>',
306
- ' </AdaptationSet>',
307
- ].join('\n');
308
- const template = [
309
- '<MPD>',
310
- ' <Period id="1" start="PT10S">',
311
- '%(periodContents)s',
312
- ' </Period>',
313
- ' <Period id="2" start="PT20S" duration="PT10S">',
314
- '%(periodContents)s',
315
- ' </Period>',
316
- ' <Period id="3" duration="PT10S">',
317
- '%(periodContents)s',
318
- ' </Period>',
319
- '</MPD>',
320
- ].join('\n');
321
- const source = sprintf(template, {periodContents: periodContents});
322
-
323
- fakeNetEngine.setResponseText('dummy://foo', source);
324
- /** @type {shaka.extern.Manifest} */
325
- const manifest = await parser.start('dummy://foo', playerInterface);
326
- const timeline = manifest.presentationTimeline;
327
- expect(timeline.getDuration()).toBe(40);
328
- });
329
-
330
- it('defaults to SegmentBase with multiple Segment*', async () => {
331
- const source = Dash.makeSimpleManifestText([
332
- '<SegmentBase presentationTimeOffset="1" indexRange="100-200">',
333
- ' <Initialization sourceURL="init.mp4" range="201-300" />',
334
- '</SegmentBase>',
335
- '<SegmentList presentationTimeOffset="2" duration="10">',
336
- ' <Initialization sourceURL="init.mp4" range="201-300" />',
337
- ' <SegmentURL media="s1.mp4" />',
338
- '</SegmentList>',
339
- ]);
340
-
341
- fakeNetEngine.setResponseText('dummy://foo', source);
342
- fakeNetEngine.setResponseValue('http://example.com', mp4Index);
343
- /** @type {shaka.extern.Manifest} */
344
- const manifest = await parser.start('dummy://foo', playerInterface);
345
- const stream = manifest.variants[0].video;
346
- await stream.createSegmentIndex();
347
- goog.asserts.assert(stream.segmentIndex != null, 'Null segmentIndex!');
348
-
349
- const ref = Array.from(stream.segmentIndex)[0];
350
- expect(ref.timestampOffset).toBe(-1);
351
- });
352
-
353
- it('defaults to SegmentList with SegmentTemplate', async () => {
354
- const source = Dash.makeSimpleManifestText([
355
- '<SegmentList presentationTimeOffset="2" duration="10">',
356
- ' <Initialization sourceURL="init.mp4" range="201-300" />',
357
- ' <SegmentURL media="s1.mp4" />',
358
- '</SegmentList>',
359
- '<SegmentTemplate startNumber="1" media="l-$Number$.mp4"',
360
- ' presentationTimeOffset="3" initialization="init.mp4">',
361
- ' <Initialization sourceURL="init.mp4" range="201-300" />',
362
- ' <SegmentTimeline>',
363
- ' <S t="0" d="30" />',
364
- ' </SegmentTimeline>',
365
- '</SegmentTemplate>',
366
- ]);
367
-
368
- fakeNetEngine.setResponseText('dummy://foo', source);
369
- /** @type {shaka.extern.Manifest} */
370
- const manifest = await parser.start('dummy://foo', playerInterface);
371
- const stream = manifest.variants[0].video;
372
- await stream.createSegmentIndex();
373
- goog.asserts.assert(stream.segmentIndex != null, 'Null segmentIndex!');
374
-
375
- const ref = Array.from(stream.segmentIndex)[0];
376
- expect(ref.timestampOffset).toBe(-2);
377
- });
378
-
379
- it('generates a correct index for non-segmented text', async () => {
380
- const source = [
381
- '<MPD mediaPresentationDuration="PT30S">',
382
- ' <Period>',
383
- ' <AdaptationSet mimeType="video/mp4">',
384
- ' <Representation bandwidth="1">',
385
- ' <SegmentBase indexRange="100-200" />',
386
- ' </Representation>',
387
- ' </AdaptationSet>',
388
- ' <AdaptationSet mimeType="text/vtt" lang="de">',
389
- ' <Representation>',
390
- ' <BaseURL>http://example.com/de.vtt</BaseURL>',
391
- ' </Representation>',
392
- ' </AdaptationSet>',
393
- ' </Period>',
394
- '</MPD>',
395
- ].join('\n');
396
-
397
- fakeNetEngine.setResponseText('dummy://foo', source);
398
-
399
- /** @type {shaka.extern.Manifest} */
400
- const manifest = await parser.start('dummy://foo', playerInterface);
401
- const stream = manifest.textStreams[0];
402
- await stream.createSegmentIndex();
403
- goog.asserts.assert(stream.segmentIndex != null, 'Null segmentIndex!');
404
-
405
- const ref = Array.from(stream.segmentIndex)[0];
406
- expect(ref).toEqual(new shaka.media.SegmentReference(
407
- /* startTime= */ 0,
408
- /* endTime= */ 30,
409
- /* getUris= */ () => ['http://example.com/de.vtt'],
410
- /* startByte= */ 0,
411
- /* endBytes= */ null,
412
- /* initSegmentReference= */ null,
413
- /* timestampOffset= */ 0,
414
- /* appendWindowStart= */ 0,
415
- /* appendWindowEnd= */ 30));
416
- });
417
-
418
- it('correctly parses mixed captions with channels, services, and languages',
419
- async () => {
420
- const source = [
421
- '<MPD minBufferTime="PT75S">',
422
- ' <Period id="1" duration="PT30S">',
423
- ' <AdaptationSet mimeType="video/mp4" lang="en" group="1">',
424
- ' <Accessibility schemeIdUri="urn:scte:dash:cc:cea-608:2015"',
425
- ' value="CC1=eng;CC3=swe"/>',
426
- ' <Representation bandwidth="200">',
427
- ' <SegmentTemplate media="1.mp4" duration="1" />',
428
- ' </Representation>',
429
- ' </AdaptationSet>',
430
- ' <AdaptationSet mimeType="video/mp4" lang="ru" group="1">',
431
- ' <Accessibility schemeIdUri="urn:scte:dash:cc:cea-708:2015"',
432
- ' value="1=lang:bos;3=lang:cze,war:1,er:1"/>',
433
- ' <Representation bandwidth="200">',
434
- ' <SegmentTemplate media="1.mp4" duration="1" />',
435
- ' </Representation>',
436
- ' </AdaptationSet>',
437
- ' </Period>',
438
- '</MPD>',
439
- ].join('\n');
440
-
441
- fakeNetEngine.setResponseText('dummy://foo', source);
442
-
443
- /** @type {shaka.extern.Manifest} */
444
- const manifest = await parser.start('dummy://foo', playerInterface);
445
- const stream1 = manifest.variants[0].video;
446
- const stream2 = manifest.variants[1].video;
447
-
448
- const expectedClosedCaptions1 = new Map([
449
- ['CC1', shaka.util.LanguageUtils.normalize('eng')],
450
- ['CC3', shaka.util.LanguageUtils.normalize('swe')],
451
- ]);
452
-
453
- const expectedClosedCaptions2 = new Map([
454
- ['svc1', shaka.util.LanguageUtils.normalize('bos')],
455
- ['svc3', shaka.util.LanguageUtils.normalize('cze')],
456
- ]);
457
- expect(stream1.closedCaptions).toEqual(expectedClosedCaptions1);
458
- expect(stream2.closedCaptions).toEqual(expectedClosedCaptions2);
459
- });
460
-
461
- it('correctly parses CEA-708 caption tags with service numbers and languages',
462
- async () => {
463
- const source = [
464
- '<MPD minBufferTime="PT75S">',
465
- ' <Period id="1" duration="PT30S">',
466
- ' <AdaptationSet mimeType="video/mp4" lang="en" group="1">',
467
- ' <Accessibility schemeIdUri="urn:scte:dash:cc:cea-708:2015"',
468
- ' value="1=lang:eng;3=lang:swe,er"/>',
469
- ' <Representation bandwidth="200">',
470
- ' <SegmentTemplate media="1.mp4" duration="1" />',
471
- ' </Representation>',
472
- ' </AdaptationSet>',
473
- ' </Period>',
474
- '</MPD>',
475
- ].join('\n');
476
-
477
- fakeNetEngine.setResponseText('dummy://foo', source);
478
-
479
- /** @type {shaka.extern.Manifest} */
480
- const manifest = await parser.start('dummy://foo', playerInterface);
481
- const stream = manifest.variants[0].video;
482
- const expectedClosedCaptions = new Map([
483
- ['svc1', shaka.util.LanguageUtils.normalize('eng')],
484
- ['svc3', shaka.util.LanguageUtils.normalize('swe')],
485
- ]);
486
- expect(stream.closedCaptions).toEqual(expectedClosedCaptions);
487
- });
488
-
489
- it('correctly parses CEA-708 caption tags without service #s and languages',
490
- async () => {
491
- const source = [
492
- '<MPD minBufferTime="PT75S">',
493
- ' <Period id="1" duration="PT30S">',
494
- ' <AdaptationSet mimeType="video/mp4" lang="en" group="1">',
495
- ' <Accessibility schemeIdUri="urn:scte:dash:cc:cea-708:2015"',
496
- ' value="eng;swe"/>',
497
- ' <Representation bandwidth="200">',
498
- ' <SegmentTemplate media="1.mp4" duration="1" />',
499
- ' </Representation>',
500
- ' </AdaptationSet>',
501
- ' </Period>',
502
- '</MPD>',
503
- ].join('\n');
504
-
505
- fakeNetEngine.setResponseText('dummy://foo', source);
506
-
507
- /** @type {shaka.extern.Manifest} */
508
- const manifest = await parser.start('dummy://foo', playerInterface);
509
- const stream = manifest.variants[0].video;
510
- const expectedClosedCaptions = new Map([
511
- ['svc1', shaka.util.LanguageUtils.normalize('eng')],
512
- ['svc2', shaka.util.LanguageUtils.normalize('swe')],
513
- ]);
514
- expect(stream.closedCaptions).toEqual(expectedClosedCaptions);
515
- });
516
-
517
- it('Detects spatial audio', async () => {
518
- const idUri = 'tag:dolby.com,2018:dash:EC3_ExtensionType:2018';
519
- const source = [
520
- '<MPD>',
521
- ' <Period duration="PT30M">',
522
- ' <AdaptationSet mimeType="audio/mp4" lang="\u2603">',
523
- ' <Representation bandwidth="500">',
524
- ' <SupplementalProperty schemeIdUri="' + idUri + '" value="JOC"/>',
525
- ' <BaseURL>http://example.com</BaseURL>',
526
- ' <SegmentTemplate media="2.mp4" duration="1" />',
527
- ' </Representation>',
528
- ' </AdaptationSet>',
529
- ' </Period>',
530
- '</MPD>',
531
- ].join('\n');
532
-
533
- fakeNetEngine.setResponseText('dummy://foo', source);
534
-
535
- /** @type {shaka.extern.Manifest} */
536
- const manifest = await parser.start('dummy://foo', playerInterface);
537
- const stream = manifest.variants[0].audio;
538
- expect(stream.spatialAudio).toBe(true);
539
- });
540
-
541
- it('correctly parses CEA-608 closed caption tags without channel numbers',
542
- async () => {
543
- const source = [
544
- '<MPD minBufferTime="PT75S">',
545
- ' <Period id="1" duration="PT30S">',
546
- ' <AdaptationSet mimeType="video/mp4" lang="en" group="1">',
547
- ' <Accessibility schemeIdUri="urn:scte:dash:cc:cea-608:2015"',
548
- ' value="eng;swe"/>',
549
- ' <Representation bandwidth="200">',
550
- ' <SegmentTemplate media="1.mp4" duration="1" />',
551
- ' </Representation>',
552
- ' </AdaptationSet>',
553
- ' <AdaptationSet mimeType="video/mp4" lang="en" group="1">',
554
- ' <Accessibility schemeIdUri="urn:scte:dash:cc:cea-608:2015"',
555
- ' value="eng;swe;fre;pol"/>',
556
- ' <Representation bandwidth="200">',
557
- ' <SegmentTemplate media="1.mp4" duration="1" />',
558
- ' </Representation>',
559
- ' </AdaptationSet>',
560
- ' </Period>',
561
- '</MPD>',
562
- ].join('\n');
563
-
564
- fakeNetEngine.setResponseText('dummy://foo', source);
565
-
566
- /** @type {shaka.extern.Manifest} */
567
- const manifest = await parser.start('dummy://foo', playerInterface);
568
- const stream1 = manifest.variants[0].video;
569
- const stream2 = manifest.variants[1].video;
570
-
571
- const expectedClosedCaptions1 = new Map([
572
- ['CC1', shaka.util.LanguageUtils.normalize('eng')],
573
- ['CC3', shaka.util.LanguageUtils.normalize('swe')],
574
- ]);
575
-
576
- const expectedClosedCaptions2 = new Map([
577
- ['CC1', shaka.util.LanguageUtils.normalize('eng')],
578
- ['CC2', shaka.util.LanguageUtils.normalize('swe')],
579
- ['CC3', shaka.util.LanguageUtils.normalize('fre')],
580
- ['CC4', shaka.util.LanguageUtils.normalize('pol')],
581
- ]);
582
-
583
- expect(stream1.closedCaptions).toEqual(expectedClosedCaptions1);
584
- expect(stream2.closedCaptions).toEqual(expectedClosedCaptions2);
585
- });
586
-
587
- it('correctly parses CEA-608 caption tags with no channel and language info',
588
- async () => {
589
- const source = [
590
- '<MPD minBufferTime="PT75S">',
591
- ' <Period id="1" duration="PT30S">',
592
- ' <AdaptationSet mimeType="video/mp4" lang="en" group="1">',
593
- ' <Accessibility schemeIdUri="urn:scte:dash:cc:cea-608:2015"/>',
594
- ' <Representation bandwidth="200">',
595
- ' <SegmentTemplate media="1.mp4" duration="1" />',
596
- ' </Representation>',
597
- ' </AdaptationSet>',
598
- ' </Period>',
599
- '</MPD>',
600
- ].join('\n');
601
-
602
- fakeNetEngine.setResponseText('dummy://foo', source);
603
-
604
- /** @type {shaka.extern.Manifest} */
605
- const manifest = await parser.start('dummy://foo', playerInterface);
606
- const stream = manifest.variants[0].video;
607
- const expectedClosedCaptions = new Map([['CC1', 'und']]);
608
- expect(stream.closedCaptions).toEqual(expectedClosedCaptions);
609
- });
610
-
611
- it('correctly parses UTF-8', async () => {
612
- const source = [
613
- '<MPD>',
614
- ' <Period duration="PT30M">',
615
- ' <AdaptationSet mimeType="audio/mp4" lang="\u2603">',
616
- ' <Representation bandwidth="500">',
617
- ' <BaseURL>http://example.com</BaseURL>',
618
- ' <SegmentTemplate media="2.mp4" duration="1"',
619
- ' initialization="\u0227.mp4" />',
620
- ' </Representation>',
621
- ' </AdaptationSet>',
622
- ' </Period>',
623
- '</MPD>',
624
- ].join('\n');
625
-
626
- fakeNetEngine.setResponseText('dummy://foo', source);
627
-
628
- /** @type {shaka.extern.Manifest} */
629
- const manifest = await parser.start('dummy://foo', playerInterface);
630
- const variant = manifest.variants[0];
631
- const stream = variant.audio;
632
- await stream.createSegmentIndex();
633
- goog.asserts.assert(stream.segmentIndex != null, 'Null segmentIndex!');
634
-
635
- const segment = Array.from(stream.segmentIndex)[0];
636
- expect(segment.initSegmentReference.getUris()[0])
637
- .toBe('http://example.com/%C8%A7.mp4');
638
- expect(variant.language).toBe('\u2603');
639
- });
640
-
641
- describe('UTCTiming', () => {
642
- const originalNow = Date.now;
643
- const dateRequestType = shaka.net.NetworkingEngine.RequestType.TIMING;
644
-
645
- beforeAll(() => {
646
- Date.now = () => 10 * 1000;
647
- });
648
-
649
- beforeEach(() => {
650
- const config = shaka.util.PlayerConfiguration.createDefault().manifest;
651
- config.dash.autoCorrectDrift = false;
652
- parser.configure(config);
653
- });
654
-
655
- afterAll(() => {
656
- Date.now = originalNow;
657
- });
658
-
659
- /**
660
- * @param {!Array.<string>} lines
661
- * @return {string}
662
- */
663
- function makeManifest(lines) {
664
- const template = [
665
- '<MPD type="dynamic"',
666
- ' availabilityStartTime="1970-01-01T00:00:00Z"',
667
- ' timeShiftBufferDepth="PT60S"',
668
- ' maxSegmentDuration="PT5S"',
669
- ' suggestedPresentationDelay="PT0S">',
670
- ' %s',
671
- ' <Period>',
672
- ' <AdaptationSet mimeType="video/mp4">',
673
- ' <Representation bandwidth="500">',
674
- ' <BaseURL>http://example.com</BaseURL>',
675
- ' <SegmentList>',
676
- ' <SegmentURL media="s1.mp4" />',
677
- ' <SegmentTimeline>',
678
- ' <S d="5" t="0" />',
679
- ' </SegmentTimeline>',
680
- ' </SegmentList>',
681
- ' </Representation>',
682
- ' </AdaptationSet>',
683
- ' </Period>',
684
- '</MPD>',
685
- ].join('\n');
686
- return sprintf(template, lines.join('\n'));
687
- }
688
-
689
- /**
690
- * @param {number} expectedTime
691
- * @return {!Promise}
692
- */
693
- async function runTest(expectedTime) {
694
- /** @type {shaka.extern.Manifest} */
695
- const manifest = await parser.start(
696
- 'http://foo.bar/manifest', playerInterface);
697
- expect(manifest.presentationTimeline).toBeTruthy();
698
- expect(manifest.presentationTimeline.getSegmentAvailabilityEnd())
699
- .toBe(expectedTime);
700
- }
701
-
702
- it('with direct', async () => {
703
- const source = makeManifest([
704
- '<UTCTiming schemeIdUri="urn:mpeg:dash:utc:direct:2014"',
705
- ' value="1970-01-01T00:00:30Z" />',
706
- ]);
707
-
708
- fakeNetEngine.setResponseText('http://foo.bar/manifest', source);
709
- await runTest(25);
710
- });
711
-
712
- it('does not produce errors', async () => {
713
- const source = makeManifest([
714
- '<UTCTiming schemeIdUri="unknown scheme" value="foobar" />',
715
- ]);
716
-
717
- fakeNetEngine.setResponseText('http://foo.bar/manifest', source);
718
- await runTest(5);
719
- });
720
-
721
- it('tries multiple sources', async () => {
722
- const source = makeManifest([
723
- '<UTCTiming schemeIdUri="unknown scheme" value="foobar" />',
724
- '<UTCTiming schemeIdUri="urn:mpeg:dash:utc:direct:2014"',
725
- ' value="1970-01-01T00:00:55Z" />',
726
- ]);
727
-
728
- fakeNetEngine.setResponseText('http://foo.bar/manifest', source);
729
- await runTest(50);
730
- });
731
-
732
- it('with HEAD', async () => {
733
- const source = makeManifest([
734
- '<UTCTiming schemeIdUri="urn:mpeg:dash:utc:http-head:2014"',
735
- ' value="http://foo.bar/date" />',
736
- ]);
737
-
738
- fakeNetEngine.request.and.callFake((type, request, context) => {
739
- if (request.uris[0] == 'http://foo.bar/manifest') {
740
- const data = shaka.util.StringUtils.toUTF8(source);
741
- return shaka.util.AbortableOperation.completed({
742
- data: data,
743
- headers: {},
744
- uri: '',
745
- });
746
- } else {
747
- expect(request.uris[0]).toBe('http://foo.bar/date');
748
- return shaka.util.AbortableOperation.completed({
749
- data: new ArrayBuffer(0),
750
- headers: {'date': '1970-01-01T00:00:40Z'},
751
- uri: '',
752
- });
753
- }
754
- });
755
- await runTest(35);
756
- fakeNetEngine.expectRequest('http://foo.bar/date', dateRequestType);
757
- });
758
-
759
- it('with xsdate', async () => {
760
- const source = makeManifest([
761
- '<UTCTiming schemeIdUri="urn:mpeg:dash:utc:http-xsdate:2014"',
762
- ' value="http://foo.bar/date" />',
763
- ]);
764
-
765
- fakeNetEngine
766
- .setResponseText('http://foo.bar/manifest', source)
767
- .setResponseText('http://foo.bar/date', '1970-01-01T00:00:50Z');
768
- await runTest(45);
769
- fakeNetEngine.expectRequest('http://foo.bar/date', dateRequestType);
770
- });
771
-
772
- it('with relative paths', async () => {
773
- const source = makeManifest([
774
- '<UTCTiming schemeIdUri="urn:mpeg:dash:utc:http-xsdate:2014"',
775
- ' value="/date" />',
776
- ]);
777
-
778
- fakeNetEngine
779
- .setResponseText('http://foo.bar/manifest', source)
780
- .setResponseText('http://foo.bar/date', '1970-01-01T00:00:50Z');
781
- await runTest(45);
782
- fakeNetEngine.expectRequest('http://foo.bar/date', dateRequestType);
783
- });
784
-
785
- it('with paths relative to BaseURLs', async () => {
786
- const source = makeManifest([
787
- '<BaseURL>http://example.com</BaseURL>',
788
- '<UTCTiming schemeIdUri="urn:mpeg:dash:utc:http-xsdate:2014"',
789
- ' value="/date" />',
790
- ]);
791
-
792
- fakeNetEngine
793
- .setResponseText('http://foo.bar/manifest', source)
794
- .setResponseText('http://example.com/date', '1970-01-01T00:00:50Z');
795
- await runTest(45);
796
- fakeNetEngine.expectRequest('http://example.com/date', dateRequestType);
797
- });
798
-
799
- it('ignored with autoCorrectDrift', async () => {
800
- const config = shaka.util.PlayerConfiguration.createDefault().manifest;
801
- config.dash.autoCorrectDrift = true;
802
- parser.configure(config);
803
-
804
- const source = makeManifest([
805
- '<UTCTiming schemeIdUri="urn:mpeg:dash:utc:http-xsdate:2014"',
806
- ' value="http://foo.bar/date" />',
807
- ]);
808
-
809
- fakeNetEngine
810
- .setResponseText('http://foo.bar/manifest', source)
811
- .setResponseText('http://foo.bar/date', '1970-01-01T00:00:50Z');
812
- // Expect the presentation timeline to end at 5 based on the segments
813
- // instead of 45 based on the UTCTiming element.
814
- await runTest(5);
815
- });
816
- });
817
-
818
- it('handles missing Segment* elements', async () => {
819
- const source = [
820
- '<MPD minBufferTime="PT75S">',
821
- ' <Period id="1" duration="PT30S">',
822
- ' <AdaptationSet mimeType="video/mp4" lang="en" group="1">',
823
- ' <Representation bandwidth="100" />',
824
- ' <Representation bandwidth="200">',
825
- ' <SegmentTemplate media="1.mp4" duration="1" />',
826
- ' </Representation>',
827
- ' </AdaptationSet>',
828
- ' </Period>',
829
- '</MPD>',
830
- ].join('\n');
831
-
832
- fakeNetEngine.setResponseText('dummy://foo', source);
833
-
834
- /** @type {shaka.extern.Manifest} */
835
- const manifest = await parser.start('dummy://foo', playerInterface);
836
- // First Representation should be dropped.
837
- expect(manifest.variants.length).toBe(1);
838
- expect(manifest.variants[0].bandwidth).toBe(200);
839
- });
840
-
841
- describe('allows missing Segment* elements for text', () => {
842
- it('specified via AdaptationSet@contentType', async () => {
843
- const source = [
844
- '<MPD minBufferTime="PT75S">',
845
- ' <Period id="1" duration="PT30S">',
846
- ' <AdaptationSet mimeType="video/mp4">',
847
- ' <Representation bandwidth="1">',
848
- ' <SegmentBase indexRange="100-200" />',
849
- ' </Representation>',
850
- ' </AdaptationSet>',
851
- ' <AdaptationSet contentType="text" lang="en" group="1">',
852
- ' <Representation />',
853
- ' </AdaptationSet>',
854
- ' </Period>',
855
- '</MPD>',
856
- ].join('\n');
857
-
858
- fakeNetEngine.setResponseText('dummy://foo', source);
859
-
860
- /** @type {shaka.extern.Manifest} */
861
- const manifest = await parser.start('dummy://foo', playerInterface);
862
- expect(manifest.textStreams.length).toBe(1);
863
- });
864
-
865
- it('specified via AdaptationSet@mimeType', async () => {
866
- const source = [
867
- '<MPD minBufferTime="PT75S">',
868
- ' <Period id="1" duration="PT30S">',
869
- ' <AdaptationSet mimeType="video/mp4">',
870
- ' <Representation bandwidth="1">',
871
- ' <SegmentBase indexRange="100-200" />',
872
- ' </Representation>',
873
- ' </AdaptationSet>',
874
- ' <AdaptationSet mimeType="text/vtt" lang="en" group="1">',
875
- ' <Representation />',
876
- ' </AdaptationSet>',
877
- ' </Period>',
878
- '</MPD>',
879
- ].join('\n');
880
-
881
- fakeNetEngine.setResponseText('dummy://foo', source);
882
-
883
- /** @type {shaka.extern.Manifest} */
884
- const manifest = await parser.start('dummy://foo', playerInterface);
885
- expect(manifest.textStreams.length).toBe(1);
886
- });
887
-
888
- it('specified via Representation@mimeType', async () => {
889
- const source = [
890
- '<MPD minBufferTime="PT75S">',
891
- ' <Period id="1" duration="PT30S">',
892
- ' <AdaptationSet mimeType="video/mp4">',
893
- ' <Representation bandwidth="1">',
894
- ' <SegmentBase indexRange="100-200" />',
895
- ' </Representation>',
896
- ' </AdaptationSet>',
897
- ' <AdaptationSet>',
898
- ' <Representation mimeType="text/vtt" />',
899
- ' </AdaptationSet>',
900
- ' </Period>',
901
- '</MPD>',
902
- ].join('\n');
903
-
904
- fakeNetEngine.setResponseText('dummy://foo', source);
905
-
906
- /** @type {shaka.extern.Manifest} */
907
- const manifest = await parser.start('dummy://foo', playerInterface);
908
- expect(manifest.textStreams.length).toBe(1);
909
- });
910
- });
911
-
912
- describe('fails for', () => {
913
- it('invalid XML', async () => {
914
- const source = '<not XML';
915
- const error = new shaka.util.Error(
916
- shaka.util.Error.Severity.CRITICAL,
917
- shaka.util.Error.Category.MANIFEST,
918
- shaka.util.Error.Code.DASH_INVALID_XML,
919
- 'dummy://foo');
920
- await Dash.testFails(source, error);
921
- });
922
-
923
- it('XML with inner errors', async () => {
924
- const source = [
925
- '<MPD minBufferTime="PT75S">',
926
- ' <Period id="1" duration="PT30S">',
927
- ' <AdaptationSet mimeType="video/mp4">',
928
- ' <Representation bandwidth="1">',
929
- ' <SegmentBase indexRange="100-200" />',
930
- ' </Representation', // Missing a close bracket.
931
- ' </AdaptationSet>',
932
- ' </Period>',
933
- '</MPD>',
934
- ].join('\n');
935
- const error = new shaka.util.Error(
936
- shaka.util.Error.Severity.CRITICAL,
937
- shaka.util.Error.Category.MANIFEST,
938
- shaka.util.Error.Code.DASH_INVALID_XML,
939
- 'dummy://foo');
940
- await Dash.testFails(source, error);
941
- });
942
-
943
- it('xlink problems when xlinkFailGracefully is false', async () => {
944
- const source = [
945
- '<MPD minBufferTime="PT75S" xmlns="urn:mpeg:dash:schema:mpd:2011" ' +
946
- 'xmlns:xlink="http://www.w3.org/1999/xlink">',
947
- ' <Period id="1" duration="PT30S">',
948
- ' <AdaptationSet mimeType="video/mp4">',
949
- ' <Representation bandwidth="1" xlink:href="https://xlink1" ' +
950
- 'xlink:actuate="onInvalid">', // Incorrect actuate
951
- ' <SegmentBase indexRange="100-200" />',
952
- ' </Representation>',
953
- ' </AdaptationSet>',
954
- ' </Period>',
955
- '</MPD>',
956
- ].join('\n');
957
- const error = new shaka.util.Error(
958
- shaka.util.Error.Severity.CRITICAL,
959
- shaka.util.Error.Category.MANIFEST,
960
- shaka.util.Error.Code.DASH_UNSUPPORTED_XLINK_ACTUATE);
961
- await Dash.testFails(source, error);
962
- });
963
-
964
- it('failed network requests', async () => {
965
- const expectedError = new shaka.util.Error(
966
- shaka.util.Error.Severity.CRITICAL,
967
- shaka.util.Error.Category.NETWORK,
968
- shaka.util.Error.Code.BAD_HTTP_STATUS);
969
-
970
- fakeNetEngine.request.and.returnValue(
971
- shaka.util.AbortableOperation.failed(expectedError));
972
- await expectAsync(parser.start('', playerInterface))
973
- .toBeRejectedWith(shaka.test.Util.jasmineError(expectedError));
974
- });
975
-
976
- it('missing MPD element', async () => {
977
- const source = '<XML></XML>';
978
- const error = new shaka.util.Error(
979
- shaka.util.Error.Severity.CRITICAL,
980
- shaka.util.Error.Category.MANIFEST,
981
- shaka.util.Error.Code.DASH_INVALID_XML,
982
- 'dummy://foo');
983
- await Dash.testFails(source, error);
984
- });
985
-
986
- it('empty AdaptationSet', async () => {
987
- const source = [
988
- '<MPD minBufferTime="PT75S">',
989
- ' <Period id="1" duration="PT30S">',
990
- ' <AdaptationSet mimeType="video/mp4" lang="en" group="1" />',
991
- ' </Period>',
992
- '</MPD>',
993
- ].join('\n');
994
- const error = new shaka.util.Error(
995
- shaka.util.Error.Severity.CRITICAL,
996
- shaka.util.Error.Category.MANIFEST,
997
- shaka.util.Error.Code.DASH_EMPTY_ADAPTATION_SET);
998
- await Dash.testFails(source, error);
999
- });
1000
-
1001
- it('empty Period', async () => {
1002
- const source = [
1003
- '<MPD minBufferTime="PT75S">',
1004
- ' <Period id="1" duration="PT30S" />',
1005
- '</MPD>',
1006
- ].join('\n');
1007
- const error = new shaka.util.Error(
1008
- shaka.util.Error.Severity.CRITICAL,
1009
- shaka.util.Error.Category.MANIFEST,
1010
- shaka.util.Error.Code.DASH_EMPTY_PERIOD);
1011
- await Dash.testFails(source, error);
1012
- });
1013
-
1014
- it('duplicate Representation ids with live', async () => {
1015
- const source = [
1016
- '<MPD minBufferTime="PT75S" type="dynamic"',
1017
- ' availabilityStartTime="1970-01-01T00:00:00Z">',
1018
- ' <Period id="1" duration="PT30S">',
1019
- ' <AdaptationSet mimeType="video/mp4">',
1020
- ' <Representation id="1" bandwidth="1">',
1021
- ' <SegmentTemplate media="1.mp4" duration="1" />',
1022
- ' </Representation>',
1023
- ' </AdaptationSet>',
1024
- ' <AdaptationSet mimeType="video/mp4">',
1025
- ' <Representation id="1" bandwidth="1">',
1026
- ' <SegmentTemplate media="2.mp4" duration="1" />',
1027
- ' </Representation>',
1028
- ' </AdaptationSet>',
1029
- ' </Period>',
1030
- '</MPD>',
1031
- ].join('\n');
1032
- const error = new shaka.util.Error(
1033
- shaka.util.Error.Severity.CRITICAL,
1034
- shaka.util.Error.Category.MANIFEST,
1035
- shaka.util.Error.Code.DASH_DUPLICATE_REPRESENTATION_ID);
1036
- await Dash.testFails(source, error);
1037
- });
1038
- });
1039
-
1040
- it('parses trickmode tracks', async () => {
1041
- const manifestText = [
1042
- '<MPD minBufferTime="PT75S">',
1043
- ' <Period id="1" duration="PT30S">',
1044
- ' <AdaptationSet id="1" mimeType="video/mp4">',
1045
- ' <Representation bandwidth="1" codecs="avc1.4d401f">',
1046
- ' <SegmentTemplate media="1.mp4" duration="1" />',
1047
- ' </Representation>',
1048
- ' </AdaptationSet>',
1049
- ' <AdaptationSet id="2" mimeType="video/mp4">',
1050
- ' <EssentialProperty value="1" ',
1051
- ' schemeIdUri="http://dashif.org/guidelines/trickmode" />',
1052
- ' <Representation bandwidth="1" codecs="avc1.4d401f">',
1053
- ' <SegmentTemplate media="2.mp4" duration="1" />',
1054
- ' </Representation>',
1055
- ' </AdaptationSet>',
1056
- ' </Period>',
1057
- '</MPD>',
1058
- ].join('\n');
1059
-
1060
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
1061
- /** @type {shaka.extern.Manifest} */
1062
- const manifest = await parser.start('dummy://foo', playerInterface);
1063
- expect(manifest.variants.length).toBe(1);
1064
- expect(manifest.textStreams.length).toBe(0);
1065
-
1066
- const variant = manifest.variants[0];
1067
- const trickModeVideo = variant && variant.video &&
1068
- variant.video.trickModeVideo;
1069
- expect(trickModeVideo).toEqual(jasmine.objectContaining({
1070
- id: 2,
1071
- type: shaka.util.ManifestParserUtils.ContentType.VIDEO,
1072
- }));
1073
- });
1074
-
1075
- it('trick-mode track with multiple AdaptationSet elements', async () => {
1076
- const manifestText = [
1077
- '<MPD minBufferTime="PT75S">',
1078
- ' <Period id="1" duration="PT30S">',
1079
- ' <AdaptationSet id="1" mimeType="video/mp4">',
1080
- ' <Representation bandwidth="1" codecs="avc1.4d401f">',
1081
- ' <SegmentTemplate media="1.mp4" duration="1" />',
1082
- ' </Representation>',
1083
- ' </AdaptationSet>',
1084
- ' <AdaptationSet id="2" mimeType="video/mp4">',
1085
- ' <Representation bandwidth="2" codecs="avc1.4d401f">',
1086
- ' <SegmentTemplate media="1.mp4" duration="1" />',
1087
- ' </Representation>',
1088
- ' </AdaptationSet>',
1089
- ' <AdaptationSet id="3" mimeType="video/mp4">',
1090
- ' <EssentialProperty value="1 2" ',
1091
- ' schemeIdUri="http://dashif.org/guidelines/trickmode" />',
1092
- ' <Representation bandwidth="1" codecs="avc1.4d401f">',
1093
- ' <SegmentTemplate media="2.mp4" duration="1" />',
1094
- ' </Representation>',
1095
- ' </AdaptationSet>',
1096
- ' </Period>',
1097
- '</MPD>',
1098
- ].join('\n');
1099
-
1100
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
1101
- /** @type {shaka.extern.Manifest} */
1102
- const manifest = await parser.start('dummy://foo', playerInterface);
1103
- expect(manifest.variants.length).toBe(2);
1104
- expect(manifest.textStreams.length).toBe(0);
1105
-
1106
- const variant = manifest.variants[0];
1107
- const trickModeVideo = variant && variant.video &&
1108
- variant.video.trickModeVideo;
1109
- expect(trickModeVideo).toEqual(jasmine.objectContaining({
1110
- id: 3,
1111
- type: shaka.util.ManifestParserUtils.ContentType.VIDEO,
1112
- }));
1113
-
1114
- const variant2 = manifest.variants[1];
1115
- const trickModeVideo2 = variant2 && variant2.video &&
1116
- variant2.video.trickModeVideo;
1117
- expect(trickModeVideo2).toEqual(jasmine.objectContaining({
1118
- id: 3,
1119
- type: shaka.util.ManifestParserUtils.ContentType.VIDEO,
1120
- }));
1121
- });
1122
-
1123
- it('ignore incompatible trickmode tracks', async () => {
1124
- const manifestText = [
1125
- '<MPD minBufferTime="PT75S">',
1126
- ' <Period id="1" duration="PT30S">',
1127
- ' <AdaptationSet id="1" mimeType="video/mp4">',
1128
- ' <Representation bandwidth="1" codecs="avc1.4d401f">',
1129
- ' <SegmentTemplate media="1.mp4" duration="1" />',
1130
- ' </Representation>',
1131
- ' </AdaptationSet>',
1132
- ' <AdaptationSet id="2" mimeType="video/mp4">',
1133
- ' <EssentialProperty value="1" ',
1134
- ' schemeIdUri="http://dashif.org/guidelines/trickmode" />',
1135
- ' <Representation bandwidth="1" codecs="foo">',
1136
- ' <SegmentTemplate media="2.mp4" duration="1" />',
1137
- ' </Representation>',
1138
- ' </AdaptationSet>',
1139
- ' </Period>',
1140
- '</MPD>',
1141
- ].join('\n');
1142
-
1143
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
1144
- /** @type {shaka.extern.Manifest} */
1145
- const manifest = await parser.start('dummy://foo', playerInterface);
1146
- expect(manifest.variants.length).toBe(1);
1147
- expect(manifest.textStreams.length).toBe(0);
1148
- expect(manifest.variants[0].video.trickModeVideo).toBeUndefined();
1149
- });
1150
-
1151
- it('skips unrecognized EssentialProperty elements', async () => {
1152
- const manifestText = [
1153
- '<MPD minBufferTime="PT75S">',
1154
- ' <Period id="1" duration="PT30S">',
1155
- ' <AdaptationSet id="1" mimeType="video/mp4">',
1156
- ' <Representation bandwidth="1">',
1157
- ' <SegmentTemplate media="1.mp4" duration="1" />',
1158
- ' </Representation>',
1159
- ' </AdaptationSet>',
1160
- ' <AdaptationSet id="2" mimeType="video/mp4">',
1161
- ' <EssentialProperty schemeIdUri="http://foo.bar/" />',
1162
- ' <Representation bandwidth="1">',
1163
- ' <SegmentTemplate media="2.mp4" duration="1" />',
1164
- ' </Representation>',
1165
- ' </AdaptationSet>',
1166
- ' </Period>',
1167
- '</MPD>',
1168
- ].join('\n');
1169
-
1170
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
1171
- /** @type {shaka.extern.Manifest} */
1172
- const manifest = await parser.start('dummy://foo', playerInterface);
1173
-
1174
- // The bogus EssentialProperty did not result in a variant.
1175
- expect(manifest.variants.length).toBe(1);
1176
- expect(manifest.textStreams.length).toBe(0);
1177
-
1178
- // The bogus EssentialProperty did not result in a trick mode track.
1179
- const variant = manifest.variants[0];
1180
- const trickModeVideo = variant && variant.video &&
1181
- variant.video.trickModeVideo;
1182
- expect(trickModeVideo).toBe(null);
1183
- });
1184
-
1185
- it('populates groupId if configuration enabled', async () => {
1186
- const manifestText = [
1187
- '<MPD minBufferTime="PT75S">',
1188
- ' <Period id="1" duration="PT30S">',
1189
- ' <AdaptationSet id="1" contentType="text">',
1190
- ' <Representation id="text-en" mimeType="text/webvtt">',
1191
- ' <BaseURL>t-en.vtt</BaseURL>',
1192
- ' </Representation>',
1193
- ' </AdaptationSet>',
1194
- ' <AdaptationSet id="2" mimeType="video/mp4">',
1195
- ' <Representation id="video-sd" width="640" height="480">',
1196
- ' <BaseURL>v-sd.mp4</BaseURL>',
1197
- ' <SegmentBase indexRange="100-200" />',
1198
- ' </Representation>',
1199
- ' </AdaptationSet>',
1200
- ' <AdaptationSet id="3" mimeType="audio/mp4">',
1201
- ' <Representation id="audio-en">',
1202
- ' <BaseURL>a-en.mp4</BaseURL>',
1203
- ' <SegmentBase indexRange="100-200" />',
1204
- ' </Representation>',
1205
- ' </AdaptationSet>',
1206
- ' </Period>',
1207
- '</MPD>',
1208
- ].join('\n');
1209
-
1210
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
1211
-
1212
- const config = shaka.util.PlayerConfiguration.createDefault().manifest;
1213
- config.dash.enableAudioGroups = true;
1214
- parser.configure(config);
1215
-
1216
- /** @type {shaka.extern.Manifest} */
1217
- const manifest = await parser.start('dummy://foo', playerInterface);
1218
-
1219
-
1220
- expect(manifest.variants.length).toBe(1);
1221
- const variant = manifest.variants[0];
1222
- expect(variant.audio.groupId).toBe('3');
1223
- });
1224
-
1225
- it('sets contentType to text for embedded text mime types', async () => {
1226
- // One MIME type for embedded TTML, one for embedded WebVTT.
1227
- // One MIME type specified on AdaptationSet, on one Representation.
1228
- const manifestText = [
1229
- '<MPD minBufferTime="PT75S">',
1230
- ' <Period id="1" duration="PT30S">',
1231
- ' <AdaptationSet mimeType="video/mp4">',
1232
- ' <Representation bandwidth="1">',
1233
- ' <SegmentBase indexRange="100-200" />',
1234
- ' </Representation>',
1235
- ' </AdaptationSet>',
1236
- ' <AdaptationSet',
1237
- ' id="1"',
1238
- ' mimeType="application/mp4"',
1239
- ' codecs="stpp"',
1240
- ' lang="en"',
1241
- ' >',
1242
- ' <Representation>',
1243
- ' <SegmentTemplate media="1.mp4" duration="1" />',
1244
- ' </Representation>',
1245
- ' </AdaptationSet>',
1246
- ' <AdaptationSet id="2" lang="fr">',
1247
- ' <Representation mimeType="application/mp4" codecs="wvtt">',
1248
- ' <SegmentTemplate media="2.mp4" duration="1" />',
1249
- ' </Representation>',
1250
- ' </AdaptationSet>',
1251
- ' </Period>',
1252
- '</MPD>',
1253
- ].join('\n');
1254
-
1255
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
1256
- /** @type {shaka.extern.Manifest} */
1257
- const manifest = await parser.start('dummy://foo', playerInterface);
1258
- expect(manifest.textStreams.length).toBe(2);
1259
- // At one time, these came out as 'application' rather than 'text'.
1260
- const ContentType = shaka.util.ManifestParserUtils.ContentType;
1261
- expect(manifest.textStreams[0].type).toBe(ContentType.TEXT);
1262
- expect(manifest.textStreams[1].type).toBe(ContentType.TEXT);
1263
- });
1264
-
1265
- it('handles text with mime and codecs on different levels', async () => {
1266
- // Regression test for #875
1267
- const manifestText = [
1268
- '<MPD minBufferTime="PT75S">',
1269
- ' <Period id="1" duration="PT30S">',
1270
- ' <AdaptationSet mimeType="video/mp4">',
1271
- ' <Representation bandwidth="1">',
1272
- ' <SegmentBase indexRange="100-200" />',
1273
- ' </Representation>',
1274
- ' </AdaptationSet>',
1275
- ' <AdaptationSet id="1" mimeType="application/mp4">',
1276
- ' <Representation codecs="stpp">',
1277
- ' <SegmentTemplate media="1.mp4" duration="1" />',
1278
- ' </Representation>',
1279
- ' </AdaptationSet>',
1280
- ' </Period>',
1281
- '</MPD>',
1282
- ].join('\n');
1283
-
1284
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
1285
- /** @type {shaka.extern.Manifest} */
1286
- const manifest = await parser.start('dummy://foo', playerInterface);
1287
-
1288
- // In #875, this was an empty list.
1289
- expect(manifest.textStreams.length).toBe(1);
1290
- if (manifest.textStreams.length) {
1291
- const ContentType = shaka.util.ManifestParserUtils.ContentType;
1292
- expect(manifest.textStreams[0].type).toBe(ContentType.TEXT);
1293
- }
1294
- });
1295
-
1296
- it('ignores duplicate Representation IDs for VOD', async () => {
1297
- const source = [
1298
- '<MPD minBufferTime="PT75S">',
1299
- ' <Period id="1" duration="PT30S">',
1300
- ' <AdaptationSet mimeType="video/mp4">',
1301
- ' <Representation id="1" bandwidth="1">',
1302
- ' <SegmentTemplate media="1.mp4">',
1303
- ' <SegmentTimeline>',
1304
- ' <S t="0" d="30" />',
1305
- ' </SegmentTimeline>',
1306
- ' </SegmentTemplate>',
1307
- ' </Representation>',
1308
- ' </AdaptationSet>',
1309
- ' <AdaptationSet mimeType="video/mp4">',
1310
- ' <Representation id="1" bandwidth="2">',
1311
- ' <SegmentTemplate media="2.mp4">',
1312
- ' <SegmentTimeline>',
1313
- ' <S t="0" d="30" />',
1314
- ' </SegmentTimeline>',
1315
- ' </SegmentTemplate>',
1316
- ' </Representation>',
1317
- ' </AdaptationSet>',
1318
- ' </Period>',
1319
- '</MPD>',
1320
- ].join('\n');
1321
-
1322
- // See https://bit.ly/2tx7f7A
1323
- // The old error was that with SegmentTimeline, duplicate Representation IDs
1324
- // would use the same segment index, so they would have the same references.
1325
- // This test proves that duplicate Representation IDs are allowed for VOD
1326
- // and that error doesn't occur.
1327
- fakeNetEngine.setResponseText('dummy://foo', source);
1328
- /** @type {shaka.extern.Manifest} */
1329
- const manifest = await parser.start('dummy://foo', playerInterface);
1330
- expect(manifest.variants.length).toBe(2);
1331
-
1332
- const variant1 = manifest.variants[0];
1333
- const variant2 = manifest.variants[1];
1334
-
1335
- await variant1.video.createSegmentIndex();
1336
- await variant2.video.createSegmentIndex();
1337
- goog.asserts.assert(variant1.video.segmentIndex, 'Null segmentIndex!');
1338
- goog.asserts.assert(variant2.video.segmentIndex, 'Null segmentIndex!');
1339
-
1340
- const variant1Ref = Array.from(variant1.video.segmentIndex)[0];
1341
- const variant2Ref = Array.from(variant2.video.segmentIndex)[0];
1342
-
1343
- expect(variant1Ref.getUris()).toEqual(['dummy://foo/1.mp4']);
1344
- expect(variant2Ref.getUris()).toEqual(['dummy://foo/2.mp4']);
1345
- });
1346
-
1347
- it('handles bandwidth of 0 or missing', async () => {
1348
- // Regression test for
1349
- // https://github.com/shaka-project/shaka-player/issues/938
1350
- const source = [
1351
- '<MPD minBufferTime="PT75S">',
1352
- ' <Period id="1" duration="PT30S">',
1353
- ' <AdaptationSet mimeType="video/mp4">',
1354
- ' <Representation id="1" bandwidth="1">',
1355
- ' <SegmentTemplate media="1-$Number$.mp4" duration="1" />',
1356
- ' </Representation>',
1357
- ' </AdaptationSet>',
1358
- ' <AdaptationSet mimeType="audio/mp4" lang="en">',
1359
- ' <Representation id="2" bandwidth="0">',
1360
- ' <SegmentTemplate media="2-$Number$.mp4" duration="1" />',
1361
- ' </Representation>',
1362
- ' </AdaptationSet>',
1363
- ' <AdaptationSet mimeType="audio/mp4" lang="de">',
1364
- ' <Representation id="3" >',
1365
- ' <SegmentTemplate media="3-$Number$.mp4" duration="1" />',
1366
- ' </Representation>',
1367
- ' </AdaptationSet>',
1368
- ' </Period>',
1369
- '</MPD>',
1370
- ].join('\n');
1371
-
1372
- fakeNetEngine.setResponseText('dummy://foo', source);
1373
- /** @type {shaka.extern.Manifest} */
1374
- const manifest = await parser.start('dummy://foo', playerInterface);
1375
- expect(manifest.variants.length).toBe(2);
1376
-
1377
- const variant1 = manifest.variants[0];
1378
- expect(isNaN(variant1.bandwidth)).toBe(false);
1379
- expect(variant1.bandwidth).toBeGreaterThan(0);
1380
-
1381
- const variant2 = manifest.variants[1];
1382
- expect(isNaN(variant2.bandwidth)).toBe(false);
1383
- expect(variant2.bandwidth).toBeGreaterThan(0);
1384
- });
1385
-
1386
- describe('AudioChannelConfiguration', () => {
1387
- /**
1388
- * @param {?number} expectedNumChannels The expected number of channels
1389
- * @param {!Object.<string, string>} schemeMap A map where the map key is
1390
- * the AudioChannelConfiguration's schemeIdUri attribute, and the map
1391
- * value is the value attribute.
1392
- * @return {!Promise}
1393
- */
1394
- async function testAudioChannelConfiguration(
1395
- expectedNumChannels, schemeMap) {
1396
- const header = [
1397
- '<MPD minBufferTime="PT75S">',
1398
- ' <Period id="1" duration="PT30S">',
1399
- ' <AdaptationSet mimeType="audio/mp4">',
1400
- ' <Representation id="1" bandwidth="1">',
1401
- ].join('\n');
1402
-
1403
- const configs = [];
1404
- for (const scheme in schemeMap) {
1405
- const value = schemeMap[scheme];
1406
- configs.push('<AudioChannelConfiguration schemeIdUri="' + scheme +
1407
- '" value="' + value + '" />');
1408
- }
1409
-
1410
- const footer = [
1411
- ' <SegmentTemplate media="1-$Number$.mp4" duration="1" />',
1412
- ' </Representation>',
1413
- ' </AdaptationSet>',
1414
- ' </Period>',
1415
- '</MPD>',
1416
- ].join('\n');
1417
-
1418
- const source = header + configs.join('\n') + footer;
1419
-
1420
- // Create a fresh parser, to avoid issues when we chain multiple tests
1421
- // together.
1422
- parser = shaka.test.Dash.makeDashParser();
1423
-
1424
- fakeNetEngine.setResponseText('dummy://foo', source);
1425
- /** @type {shaka.extern.Manifest} */
1426
- const manifest = await parser.start('dummy://foo', playerInterface);
1427
- expect(manifest.variants.length).toBe(1);
1428
-
1429
- const variant = manifest.variants[0];
1430
- expect(variant.audio.channelsCount).toBe(expectedNumChannels);
1431
- }
1432
-
1433
- it('parses outputChannelPositionList scheme', async () => {
1434
- // Parses the space-separated list and finds 8 channels.
1435
- await testAudioChannelConfiguration(8,
1436
- {'urn:mpeg:dash:outputChannelPositionList:2012':
1437
- '2 0 1 4 5 3 17 1'});
1438
-
1439
- // Does not get confused about extra spaces.
1440
- await testAudioChannelConfiguration(7,
1441
- {'urn:mpeg:dash:outputChannelPositionList:2012':
1442
- ' 5 2 1 12 8 9 1 '});
1443
- });
1444
-
1445
- it('parses 23003:3 scheme', async () => {
1446
- // Parses a simple channel count.
1447
- await testAudioChannelConfiguration(2,
1448
- {'urn:mpeg:dash:23003:3:audio_channel_configuration:2011': '2'});
1449
-
1450
- // This scheme seems to use the same format.
1451
- await testAudioChannelConfiguration(6,
1452
- {'urn:dts:dash:audio_channel_configuration:2012': '6'});
1453
-
1454
- // Results in null if the value is not an integer.
1455
- await testAudioChannelConfiguration(null,
1456
- {'urn:mpeg:dash:23003:3:audio_channel_configuration:2011': 'foo'});
1457
- });
1458
-
1459
- it('parses dolby scheme', async () => {
1460
- // Parses a hex value in which each 1-bit is a channel.
1461
- await testAudioChannelConfiguration(6,
1462
- {'tag:dolby.com,2014:dash:audio_channel_configuration:2011':
1463
- 'F801'});
1464
-
1465
- // This scheme seems to use the same format.
1466
- await testAudioChannelConfiguration(8,
1467
- {'urn:dolby:dash:audio_channel_configuration:2011': '7037'});
1468
-
1469
- // Results in null if the value is not a valid hex number.
1470
- await testAudioChannelConfiguration(null,
1471
- {'urn:dolby:dash:audio_channel_configuration:2011': 'x'});
1472
- });
1473
-
1474
- it('parses MPEG channel configuration scheme', async () => {
1475
- // Parses a simple channel count.
1476
- await testAudioChannelConfiguration(2,
1477
- {'urn:mpeg:mpegB:cicp:ChannelConfiguration': '2'});
1478
-
1479
- // Parses a high channel count.
1480
- await testAudioChannelConfiguration(24,
1481
- {'urn:mpeg:mpegB:cicp:ChannelConfiguration': '13'});
1482
-
1483
- // Results in null if the value is not an integer.
1484
- await testAudioChannelConfiguration(null,
1485
- {'urn:mpeg:mpegB:cicp:ChannelConfiguration': 'foo'});
1486
-
1487
- // Results in null if the value is not in a spec range.
1488
- await testAudioChannelConfiguration(null,
1489
- {'urn:mpeg:mpegB:cicp:ChannelConfiguration': '100'});
1490
- });
1491
-
1492
- it('ignores unrecognized schemes', async () => {
1493
- await testAudioChannelConfiguration(null, {'foo': 'bar'});
1494
-
1495
- await testAudioChannelConfiguration(2, {
1496
- 'foo': 'bar',
1497
- 'urn:mpeg:dash:23003:3:audio_channel_configuration:2011': '2',
1498
- });
1499
- });
1500
- });
1501
-
1502
- it('does not fail on AdaptationSets without segment info', async () => {
1503
- const manifestText = [
1504
- '<MPD minBufferTime="PT75S">',
1505
- ' <Period id="1" duration="PT30S">',
1506
- ' <AdaptationSet id="1" contentType="text">',
1507
- ' <Representation mimeType="application/mp4" codecs="stpp">',
1508
- ' <SegmentTemplate media="$Number$.mp4" />',
1509
- ' </Representation>',
1510
- ' </AdaptationSet>',
1511
- ' <AdaptationSet id="2" mimeType="video/mp4">',
1512
- ' <Representation bandwidth="1">',
1513
- ' <SegmentTemplate media="2.mp4" duration="1" />',
1514
- ' </Representation>',
1515
- ' </AdaptationSet>',
1516
- ' </Period>',
1517
- '</MPD>',
1518
- ].join('\n');
1519
-
1520
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
1521
- await parser.start('dummy://foo', playerInterface);
1522
- });
1523
-
1524
- it('exposes Representation IDs', async () => {
1525
- const manifestText = [
1526
- '<MPD minBufferTime="PT75S">',
1527
- ' <Period id="1" duration="PT30S">',
1528
- ' <AdaptationSet id="1" contentType="text">',
1529
- ' <Representation id="text-en" mimeType="text/webvtt">',
1530
- ' <BaseURL>t-en.vtt</BaseURL>',
1531
- ' </Representation>',
1532
- ' </AdaptationSet>',
1533
- ' <AdaptationSet id="2" mimeType="video/mp4">',
1534
- ' <Representation id="video-sd" width="640" height="480">',
1535
- ' <BaseURL>v-sd.mp4</BaseURL>',
1536
- ' <SegmentBase indexRange="100-200" />',
1537
- ' </Representation>',
1538
- ' </AdaptationSet>',
1539
- ' <AdaptationSet id="3" mimeType="audio/mp4">',
1540
- ' <Representation id="audio-en">',
1541
- ' <BaseURL>a-en.mp4</BaseURL>',
1542
- ' <SegmentBase indexRange="100-200" />',
1543
- ' </Representation>',
1544
- ' </AdaptationSet>',
1545
- ' </Period>',
1546
- '</MPD>',
1547
- ].join('\n');
1548
-
1549
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
1550
- /** @type {shaka.extern.Manifest} */
1551
- const manifest = await parser.start('dummy://foo', playerInterface);
1552
- const variant = manifest.variants[0];
1553
- const textStream = manifest.textStreams[0];
1554
- expect(variant.audio.originalId).toBe('audio-en');
1555
- expect(variant.video.originalId).toBe('video-sd');
1556
- expect(textStream.originalId).toBe('text-en');
1557
- });
1558
-
1559
- it('Disable audio does not create audio streams', async () => {
1560
- const manifestText = [
1561
- '<MPD minBufferTime="PT75S">',
1562
- ' <Period id="1" duration="PT30S">',
1563
- ' <AdaptationSet id="2" mimeType="video/mp4">',
1564
- ' <Representation id="video-sd" width="640" height="480">',
1565
- ' <BaseURL>v-sd.mp4</BaseURL>',
1566
- ' <SegmentBase indexRange="100-200" />',
1567
- ' </Representation>',
1568
- ' </AdaptationSet>',
1569
- ' <AdaptationSet id="3" mimeType="audio/mp4">',
1570
- ' <Representation id="audio-en">',
1571
- ' <BaseURL>a-en.mp4</BaseURL>',
1572
- ' <SegmentBase indexRange="100-200" />',
1573
- ' </Representation>',
1574
- ' </AdaptationSet>',
1575
- ' </Period>',
1576
- '</MPD>',
1577
- ].join('\n');
1578
-
1579
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
1580
- const config = shaka.util.PlayerConfiguration.createDefault().manifest;
1581
- config.disableAudio = true;
1582
- parser.configure(config);
1583
-
1584
- /** @type {shaka.extern.Manifest} */
1585
- const manifest = await parser.start('dummy://foo', playerInterface);
1586
- const variant = manifest.variants[0];
1587
- expect(variant.audio).toBe(null);
1588
- expect(variant.video).toBeTruthy();
1589
- });
1590
-
1591
- it('Disable video does not create video streams', async () => {
1592
- const manifestText = [
1593
- '<MPD minBufferTime="PT75S">',
1594
- ' <Period id="1" duration="PT30S">',
1595
- ' <AdaptationSet id="2" mimeType="video/mp4">',
1596
- ' <Representation id="video-sd" width="640" height="480">',
1597
- ' <BaseURL>v-sd.mp4</BaseURL>',
1598
- ' <SegmentBase indexRange="100-200" />',
1599
- ' </Representation>',
1600
- ' </AdaptationSet>',
1601
- ' <AdaptationSet id="3" mimeType="audio/mp4">',
1602
- ' <Representation id="audio-en">',
1603
- ' <BaseURL>a-en.mp4</BaseURL>',
1604
- ' <SegmentBase indexRange="100-200" />',
1605
- ' </Representation>',
1606
- ' </AdaptationSet>',
1607
- ' </Period>',
1608
- '</MPD>',
1609
- ].join('\n');
1610
-
1611
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
1612
- const config = shaka.util.PlayerConfiguration.createDefault().manifest;
1613
- config.disableVideo = true;
1614
- parser.configure(config);
1615
-
1616
- /** @type {shaka.extern.Manifest} */
1617
- const manifest = await parser.start('dummy://foo', playerInterface);
1618
- const variant = manifest.variants[0];
1619
- expect(variant.audio).toBeTruthy();
1620
- expect(variant.video).toBe(null);
1621
- });
1622
-
1623
- it('Disable text does not create text streams', async () => {
1624
- const manifestText = [
1625
- '<MPD minBufferTime="PT75S">',
1626
- ' <Period id="1" duration="PT30S">',
1627
- ' <AdaptationSet id="2" mimeType="video/mp4">',
1628
- ' <Representation id="video-sd" width="640" height="480">',
1629
- ' <BaseURL>v-sd.mp4</BaseURL>',
1630
- ' <SegmentBase indexRange="100-200" />',
1631
- ' </Representation>',
1632
- ' </AdaptationSet>',
1633
- ' <AdaptationSet id="3" mimeType="audio/mp4">',
1634
- ' <Representation id="audio-en">',
1635
- ' <BaseURL>a-en.mp4</BaseURL>',
1636
- ' <SegmentBase indexRange="100-200" />',
1637
- ' </Representation>',
1638
- ' </AdaptationSet>',
1639
- ' <AdaptationSet mimeType="text/vtt" lang="de">',
1640
- ' <Representation>',
1641
- ' <BaseURL>http://example.com/de.vtt</BaseURL>',
1642
- ' </Representation>',
1643
- ' </AdaptationSet>',
1644
- ' </Period>',
1645
- '</MPD>',
1646
- ].join('\n');
1647
-
1648
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
1649
- const config = shaka.util.PlayerConfiguration.createDefault().manifest;
1650
- config.disableText = true;
1651
- parser.configure(config);
1652
-
1653
- /** @type {shaka.extern.Manifest} */
1654
- const manifest = await parser.start('dummy://foo', playerInterface);
1655
- const stream = manifest.textStreams[0];
1656
- expect(stream).toBeUndefined();
1657
- });
1658
-
1659
- it('override manifest value if ignoreMinBufferTime is true', async () => {
1660
- const manifestText = [
1661
- '<MPD minBufferTime="PT75S">',
1662
- ' <Period id="1" duration="PT30S">',
1663
- ' <AdaptationSet id="1" mimeType="video/mp4">',
1664
- ' <Representation id="video-sd" width="640" height="480">',
1665
- ' <BaseURL>v-sd.mp4</BaseURL>',
1666
- ' <SegmentBase indexRange="100-200" />',
1667
- ' </Representation>',
1668
- ' </AdaptationSet>',
1669
- ' </Period>',
1670
- '</MPD>',
1671
- ].join('\n');
1672
-
1673
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
1674
- const config = shaka.util.PlayerConfiguration.createDefault().manifest;
1675
- config.dash.ignoreMinBufferTime = true;
1676
- parser.configure(config);
1677
-
1678
- /** @type {shaka.extern.Manifest} */
1679
- const manifest = await parser.start('dummy://foo', playerInterface);
1680
- const minBufferTime = manifest.minBufferTime;
1681
- expect(minBufferTime).toBe(0);
1682
- });
1683
-
1684
- it('get manifest value if ignoreMinBufferTime is false', async () => {
1685
- const manifestText = [
1686
- '<MPD minBufferTime="PT75S">',
1687
- ' <Period id="1" duration="PT30S">',
1688
- ' <AdaptationSet id="1" mimeType="video/mp4">',
1689
- ' <Representation id="video-sd" width="640" height="480">',
1690
- ' <BaseURL>v-sd.mp4</BaseURL>',
1691
- ' <SegmentBase indexRange="100-200" />',
1692
- ' </Representation>',
1693
- ' </AdaptationSet>',
1694
- ' </Period>',
1695
- '</MPD>',
1696
- ].join('\n');
1697
-
1698
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
1699
- const config = shaka.util.PlayerConfiguration.createDefault().manifest;
1700
- config.dash.ignoreMinBufferTime = false;
1701
- parser.configure(config);
1702
-
1703
- /** @type {shaka.extern.Manifest} */
1704
- const manifest = await parser.start('dummy://foo', playerInterface);
1705
- const minBufferTime = manifest.minBufferTime;
1706
- expect(minBufferTime).toBe(75);
1707
- });
1708
-
1709
- it('honors the ignoreMaxSegmentDuration config', async () => {
1710
- const manifestText = [
1711
- '<MPD maxSegmentDuration="PT5S">',
1712
- ' <Period id="1" duration="PT30S">',
1713
- ' <AdaptationSet id="1" mimeType="video/mp4">',
1714
- ' <Representation id="video-sd" width="640" height="480">',
1715
- ' <BaseURL>v-sd.mp4</BaseURL>',
1716
- ' <SegmentBase indexRange="100-200" />',
1717
- ' </Representation>',
1718
- ' </AdaptationSet>',
1719
- ' </Period>',
1720
- '</MPD>',
1721
- ].join('\n');
1722
-
1723
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
1724
- const config = shaka.util.PlayerConfiguration.createDefault().manifest;
1725
- config.dash.ignoreMaxSegmentDuration = true;
1726
- parser.configure(config);
1727
-
1728
- /** @type {shaka.extern.Manifest} */
1729
- const manifest = await parser.start('dummy://foo', playerInterface);
1730
- const maxSegmentDuration =
1731
- manifest.presentationTimeline.getMaxSegmentDuration();
1732
- expect(maxSegmentDuration).toBe(1);
1733
- });
1734
-
1735
- it('gets manifest value if ignoreMaxSegmentDuration is false', async () => {
1736
- const manifestText = [
1737
- '<MPD maxSegmentDuration="PT5S">',
1738
- ' <Period id="1" duration="PT30S">',
1739
- ' <AdaptationSet id="1" mimeType="video/mp4">',
1740
- ' <Representation id="video-sd" width="640" height="480">',
1741
- ' <BaseURL>v-sd.mp4</BaseURL>',
1742
- ' <SegmentBase indexRange="100-200" />',
1743
- ' </Representation>',
1744
- ' </AdaptationSet>',
1745
- ' </Period>',
1746
- '</MPD>',
1747
- ].join('\n');
1748
-
1749
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
1750
- const config = shaka.util.PlayerConfiguration.createDefault().manifest;
1751
- config.dash.ignoreMaxSegmentDuration = false;
1752
- parser.configure(config);
1753
-
1754
- /** @type {shaka.extern.Manifest} */
1755
- const manifest = await parser.start('dummy://foo', playerInterface);
1756
- const maxSegmentDuration =
1757
- manifest.presentationTimeline.getMaxSegmentDuration();
1758
- expect(maxSegmentDuration).toBe(5);
1759
- });
1760
-
1761
- it('does not set presentationDelay to NaN', async () => {
1762
- // NOTE: This is a regression test for #2015. It ensures that, if
1763
- // ignoreMinBufferTime is true and there is no suggestedPresentationDelay,
1764
- // we do not erroneously set presentationDelay to NaN.
1765
- const manifestText = [
1766
- '<MPD minBufferTime="PT75S">',
1767
- ' <Period id="1" duration="PT30S">',
1768
- ' <AdaptationSet id="1" mimeType="video/mp4">',
1769
- ' <Representation id="video-sd" width="640" height="480">',
1770
- ' <BaseURL>v-sd.mp4</BaseURL>',
1771
- ' <SegmentBase indexRange="100-200" />',
1772
- ' </Representation>',
1773
- ' </AdaptationSet>',
1774
- ' </Period>',
1775
- '</MPD>',
1776
- ].join('\n');
1777
-
1778
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
1779
- const config = shaka.util.PlayerConfiguration.createDefault().manifest;
1780
- config.dash.ignoreMinBufferTime = true;
1781
- parser.configure(config);
1782
-
1783
- /** @type {shaka.extern.Manifest} */
1784
- const manifest = await parser.start('dummy://foo', playerInterface);
1785
- const presentationTimeline = manifest.presentationTimeline;
1786
- const presentationDelay = presentationTimeline.getDelay();
1787
- expect(presentationDelay).not.toBeNaN();
1788
- expect(presentationDelay).toBe(config.defaultPresentationDelay);
1789
- });
1790
-
1791
- it('Honors the ignoreSuggestedPresentationDelay config', async () => {
1792
- const manifestText = [
1793
- '<MPD minBufferTime="PT2S" suggestedPresentationDelay="PT25S">',
1794
- ' <Period id="1" duration="PT30S">',
1795
- ' <AdaptationSet id="1" mimeType="video/mp4">',
1796
- ' <Representation id="video-sd" width="640" height="480">',
1797
- ' <BaseURL>v-sd.mp4</BaseURL>',
1798
- ' <SegmentBase indexRange="100-200" />',
1799
- ' </Representation>',
1800
- ' </AdaptationSet>',
1801
- ' </Period>',
1802
- '</MPD>',
1803
- ].join('\n');
1804
-
1805
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
1806
- const config = shaka.util.PlayerConfiguration.createDefault().manifest;
1807
- config.dash.ignoreSuggestedPresentationDelay = true;
1808
- config.defaultPresentationDelay = 10;
1809
- parser.configure(config);
1810
-
1811
- /** @type {shaka.extern.Manifest} */
1812
- const manifest = await parser.start('dummy://foo', playerInterface);
1813
- const presentationTimeline = manifest.presentationTimeline;
1814
- const presentationDelay = presentationTimeline.getDelay();
1815
- expect(presentationDelay).toBe(config.defaultPresentationDelay);
1816
- });
1817
-
1818
- it('Uses 1.5 times minBufferTime as default presentation delay', async () => {
1819
- // When sugguestedPresentDelay should be ignored, and
1820
- // config.defaultpresentdelay is not set other than 0, use 1.5*minBufferTime
1821
- // as the presentationDelay.
1822
- const manifestText = [
1823
- '<MPD minBufferTime="PT2S" suggestedPresentationDelay="PT25S">',
1824
- ' <Period id="1" duration="PT30S">',
1825
- ' <AdaptationSet id="1" mimeType="video/mp4">',
1826
- ' <Representation id="video-sd" width="640" height="480">',
1827
- ' <BaseURL>v-sd.mp4</BaseURL>',
1828
- ' <SegmentBase indexRange="100-200" />',
1829
- ' </Representation>',
1830
- ' </AdaptationSet>',
1831
- ' </Period>',
1832
- '</MPD>',
1833
- ].join('\n');
1834
-
1835
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
1836
- const config = shaka.util.PlayerConfiguration.createDefault().manifest;
1837
- config.dash.ignoreSuggestedPresentationDelay = true;
1838
- parser.configure(config);
1839
-
1840
- /** @type {shaka.extern.Manifest} */
1841
- const manifest = await parser.start('dummy://foo', playerInterface);
1842
- const presentationTimeline = manifest.presentationTimeline;
1843
- const presentationDelay = presentationTimeline.getDelay();
1844
- expect(presentationDelay).toBe(1.5*manifest.minBufferTime);
1845
- });
1846
-
1847
- it('Honors the ignoreEmptyAdaptationSet config', async () => {
1848
- const manifestText = [
1849
- '<MPD minBufferTime="PT2S" suggestedPresentationDelay="PT25S">',
1850
- ' <Period id="1" duration="PT30S">',
1851
- ' <AdaptationSet id="1" mimeType="video/mp4">',
1852
- ' <Representation id="video-sd" width="640" height="480">',
1853
- ' <BaseURL>v-sd.mp4</BaseURL>',
1854
- ' <SegmentBase indexRange="100-200" />',
1855
- ' </Representation>',
1856
- ' </AdaptationSet>',
1857
- ' <AdaptationSet id="2" mimeType="audio/mp4">',
1858
- ' </AdaptationSet>',
1859
- ' </Period>',
1860
- '</MPD>',
1861
- ].join('\n');
1862
-
1863
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
1864
- const config = shaka.util.PlayerConfiguration.createDefault().manifest;
1865
- config.dash.ignoreEmptyAdaptationSet = true;
1866
- parser.configure(config);
1867
-
1868
- /** @type {shaka.extern.Manifest} */
1869
- const manifest = await parser.start('dummy://foo', playerInterface);
1870
- expect(manifest.presentationTimeline).toBeTruthy();
1871
- });
1872
-
1873
- it('Invokes manifestPreprocessor in config', async () => {
1874
- const manifestText = [
1875
- '<MPD minBufferTime="PT75S">',
1876
- ' <Period id="1" duration="PT30S">',
1877
- ' <AdaptationSet id="2" mimeType="video/mp4">',
1878
- ' <Representation id="video-sd" width="640" height="480">',
1879
- ' <BaseURL>v-sd.mp4</BaseURL>',
1880
- ' <SegmentBase indexRange="100-200" />',
1881
- ' </Representation>',
1882
- ' </AdaptationSet>',
1883
- ' <AdaptationSet id="3" mimeType="audio/mp4">',
1884
- ' <Representation id="audio-en">',
1885
- ' <BaseURL>a-en.mp4</BaseURL>',
1886
- ' <SegmentBase indexRange="100-200" />',
1887
- ' </Representation>',
1888
- ' </AdaptationSet>',
1889
- ' <AdaptationSet mimeType="text/vtt" lang="de">',
1890
- ' <Representation>',
1891
- ' <BaseURL>http://example.com/de.vtt</BaseURL>',
1892
- ' </Representation>',
1893
- ' </AdaptationSet>',
1894
- ' </Period>',
1895
- '</MPD>',
1896
- ].join('\n');
1897
-
1898
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
1899
- const config = shaka.util.PlayerConfiguration.createDefault().manifest;
1900
- config.dash.manifestPreprocessor = (mpd) => {
1901
- const selector = 'AdaptationSet[mimeType="text/vtt"';
1902
- const vttElements = mpd.querySelectorAll(selector);
1903
- for (const element of vttElements) {
1904
- element.parentNode.removeChild(element);
1905
- }
1906
- };
1907
- parser.configure(config);
1908
-
1909
- /** @type {shaka.extern.Manifest} */
1910
- const manifest = await parser.start('dummy://foo', playerInterface);
1911
- const stream = manifest.textStreams[0];
1912
- expect(stream).toBeUndefined();
1913
- });
1914
-
1915
- it('reads accessibility purpose elements', async () => {
1916
- const manifestText = [
1917
- '<MPD minBufferTime="PT75S">',
1918
- ' <Period id="1" duration="PT30S">',
1919
- ' <AdaptationSet id="1" contentType="text">',
1920
- ' <Accessibility ',
1921
- ' schemeIdUri="urn:tva:metadata:cs:AudioPurposeCS:2007"',
1922
- ' value="2" />',
1923
- ' <Representation id="text-en" mimeType="text/webvtt">',
1924
- ' <BaseURL>t-en.vtt</BaseURL>',
1925
- ' </Representation>',
1926
- ' </AdaptationSet>',
1927
- ' <AdaptationSet id="1" mimeType="video/mp4">',
1928
- ' <Representation id="video-sd" width="640" height="480">',
1929
- ' <BaseURL>v-sd.mp4</BaseURL>',
1930
- ' <SegmentBase indexRange="100-200" />',
1931
- ' </Representation>',
1932
- ' </AdaptationSet>',
1933
- ' <AdaptationSet id="1" mimeType="audio/mp4">',
1934
- ' <Accessibility ',
1935
- ' schemeIdUri="urn:tva:metadata:cs:AudioPurposeCS:2007"',
1936
- ' value="1" />',
1937
- ' <Representation id="audio-sd" width="640" height="480">',
1938
- ' <BaseURL>v-sd.mp4</BaseURL>',
1939
- ' <SegmentBase indexRange="100-200" />',
1940
- ' </Representation>',
1941
- ' </AdaptationSet>',
1942
- ' </Period>',
1943
- '</MPD>',
1944
- ].join('\n');
1945
-
1946
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
1947
- /** @type {shaka.extern.Manifest} */
1948
- const manifest = await parser.start('dummy://foo', playerInterface);
1949
- const textStream = manifest.textStreams[0];
1950
- expect(textStream.accessibilityPurpose).toBe(
1951
- shaka.media.ManifestParser.AccessibilityPurpose.HARD_OF_HEARING);
1952
- const variant = manifest.variants[0];
1953
- expect(variant.video.accessibilityPurpose).toBeUndefined();
1954
- expect(variant.audio.accessibilityPurpose).toBe(
1955
- shaka.media.ManifestParser.AccessibilityPurpose.VISUALLY_IMPAIRED);
1956
- });
1957
-
1958
- it('converts Accessibility element to "kind"', async () => {
1959
- const manifestText = [
1960
- '<MPD minBufferTime="PT75S">',
1961
- ' <Period id="1" duration="PT30S">',
1962
- ' <AdaptationSet id="1" contentType="text">',
1963
- ' <Accessibility schemeIdUri="urn:mpeg:dash:role:2011" ',
1964
- ' value="captions" />',
1965
- ' <Accessibility schemeIdUri="urn:mpeg:dash:role:2011" ',
1966
- ' value="foo" />',
1967
- ' <Accessibility schemeIdUri="foobar" value="bar" />',
1968
- ' <Representation id="text-en" mimeType="text/webvtt">',
1969
- ' <BaseURL>t-en.vtt</BaseURL>',
1970
- ' </Representation>',
1971
- ' </AdaptationSet>',
1972
- ' <AdaptationSet id="1" mimeType="video/mp4">',
1973
- ' <Representation id="video-sd" width="640" height="480">',
1974
- ' <BaseURL>v-sd.mp4</BaseURL>',
1975
- ' <SegmentBase indexRange="100-200" />',
1976
- ' </Representation>',
1977
- ' </AdaptationSet>',
1978
- ' </Period>',
1979
- '</MPD>',
1980
- ].join('\n');
1981
-
1982
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
1983
- /** @type {shaka.extern.Manifest} */
1984
- const manifest = await parser.start('dummy://foo', playerInterface);
1985
- const textStream = manifest.textStreams[0];
1986
- expect(textStream.roles).toEqual(['captions', 'foo']);
1987
- expect(textStream.kind).toBe('caption');
1988
- });
1989
-
1990
- it('converts Roles element to "forced" (old role)', async () => {
1991
- const manifestText = [
1992
- '<MPD minBufferTime="PT75S">',
1993
- ' <Period id="1" duration="PT30S">',
1994
- ' <AdaptationSet id="1" contentType="text">',
1995
- ' <Accessibility schemeIdUri="urn:mpeg:dash:role:2011" ',
1996
- ' value="captions" />',
1997
- ' <Accessibility schemeIdUri="urn:mpeg:dash:role:2011" ',
1998
- ' value="forced_subtitle" />',
1999
- ' <Accessibility schemeIdUri="foobar" value="bar" />',
2000
- ' <Representation id="text-en" mimeType="text/webvtt">',
2001
- ' <BaseURL>t-en.vtt</BaseURL>',
2002
- ' </Representation>',
2003
- ' </AdaptationSet>',
2004
- ' <AdaptationSet id="1" mimeType="video/mp4">',
2005
- ' <Representation id="video-sd" width="640" height="480">',
2006
- ' <BaseURL>v-sd.mp4</BaseURL>',
2007
- ' <SegmentBase indexRange="100-200" />',
2008
- ' </Representation>',
2009
- ' </AdaptationSet>',
2010
- ' </Period>',
2011
- '</MPD>',
2012
- ].join('\n');
2013
-
2014
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
2015
- /** @type {shaka.extern.Manifest} */
2016
- const manifest = await parser.start('dummy://foo', playerInterface);
2017
- const textStream = manifest.textStreams[0];
2018
- expect(textStream.roles).toEqual(['captions', 'forced_subtitle']);
2019
- expect(textStream.forced).toBe(true);
2020
- });
2021
-
2022
- it('converts Roles element to "forced"', async () => {
2023
- const manifestText = [
2024
- '<MPD minBufferTime="PT75S">',
2025
- ' <Period id="1" duration="PT30S">',
2026
- ' <AdaptationSet id="1" contentType="text">',
2027
- ' <Accessibility schemeIdUri="urn:mpeg:dash:role:2011" ',
2028
- ' value="captions" />',
2029
- ' <Accessibility schemeIdUri="urn:mpeg:dash:role:2011" ',
2030
- ' value="forced-subtitle" />',
2031
- ' <Accessibility schemeIdUri="foobar" value="bar" />',
2032
- ' <Representation id="text-en" mimeType="text/webvtt">',
2033
- ' <BaseURL>t-en.vtt</BaseURL>',
2034
- ' </Representation>',
2035
- ' </AdaptationSet>',
2036
- ' <AdaptationSet id="1" mimeType="video/mp4">',
2037
- ' <Representation id="video-sd" width="640" height="480">',
2038
- ' <BaseURL>v-sd.mp4</BaseURL>',
2039
- ' <SegmentBase indexRange="100-200" />',
2040
- ' </Representation>',
2041
- ' </AdaptationSet>',
2042
- ' </Period>',
2043
- '</MPD>',
2044
- ].join('\n');
2045
-
2046
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
2047
- /** @type {shaka.extern.Manifest} */
2048
- const manifest = await parser.start('dummy://foo', playerInterface);
2049
- const textStream = manifest.textStreams[0];
2050
- expect(textStream.roles).toEqual(['captions', 'forced-subtitle']);
2051
- expect(textStream.forced).toBe(true);
2052
- });
2053
-
2054
- it('supports HDR signaling via profiles', async () => {
2055
- // (DASH-IF IOP v4.3 10.3.3.)
2056
- const hdrProfile =
2057
- 'http://dashif.org/guidelines/dash-if-uhd#hevc-hdr-pq10';
2058
- const manifestText = [
2059
- `<MPD minBufferTime="PT75S" profiles="${hdrProfile}">`,
2060
- ' <Period id="1" duration="PT30S">',
2061
- ' <AdaptationSet id="2" mimeType="video/mp4">',
2062
- ' <Representation codecs="hvc1.2.4.L153.B0">',
2063
- ' <BaseURL>v-sd.mp4</BaseURL>',
2064
- ' <SegmentBase indexRange="100-200" />',
2065
- ' </Representation>',
2066
- ' </AdaptationSet>',
2067
- ' <AdaptationSet id="3" mimeType="audio/mp4">',
2068
- ' <Representation id="audio-en">',
2069
- ' <BaseURL>a-en.mp4</BaseURL>',
2070
- ' <SegmentBase indexRange="100-200" />',
2071
- ' </Representation>',
2072
- ' </AdaptationSet>',
2073
- ' </Period>',
2074
- '</MPD>',
2075
- ].join('\n');
2076
-
2077
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
2078
-
2079
- /** @type {shaka.extern.Manifest} */
2080
- const manifest = await parser.start('dummy://foo', playerInterface);
2081
- expect(manifest.variants.length).toBe(1);
2082
- const stream = manifest.variants[0].video;
2083
- expect(stream.hdr).toBe('PQ');
2084
- });
2085
-
2086
- it('supports HDR signaling via SupplementalProperty', async () => {
2087
- // (DASH-IF IOP v4.3 6.2.5.1.)
2088
- const hdrScheme = cicpScheme('TransferCharacteristics');
2089
- const pq = 16;
2090
- const manifestText = [
2091
- '<MPD minBufferTime="PT75S">',
2092
- ' <Period id="1" duration="PT30S">',
2093
- ' <AdaptationSet id="2" mimeType="video/mp4">',
2094
- ` <SupplementalProperty schemeIdUri="${hdrScheme}" value="${pq}" />`,
2095
- ' <Representation codecs="hvc1.2.4.L150.90">',
2096
- ' <BaseURL>v-sd.mp4</BaseURL>',
2097
- ' <SegmentBase indexRange="100-200" />',
2098
- ' </Representation>',
2099
- ' </AdaptationSet>',
2100
- ' <AdaptationSet id="3" mimeType="audio/mp4">',
2101
- ' <Representation id="audio-en">',
2102
- ' <BaseURL>a-en.mp4</BaseURL>',
2103
- ' <SegmentBase indexRange="100-200" />',
2104
- ' </Representation>',
2105
- ' </AdaptationSet>',
2106
- ' </Period>',
2107
- '</MPD>',
2108
- ].join('\n');
2109
-
2110
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
2111
-
2112
- /** @type {shaka.extern.Manifest} */
2113
- const manifest = await parser.start('dummy://foo', playerInterface);
2114
- expect(manifest.variants.length).toBe(1);
2115
- const stream = manifest.variants[0].video;
2116
- expect(stream.hdr).toBe('PQ');
2117
- });
2118
-
2119
- it('supports SupplementalProperty MatrixCoefficients', async () => {
2120
- // (DASH-IF IOP v4.3 6.2.5.1.)
2121
- const scheme = cicpScheme('MatrixCoefficients');
2122
- const manifestText = [
2123
- '<MPD minBufferTime="PT75S">',
2124
- ' <Period id="1" duration="PT30S">',
2125
- ' <AdaptationSet id="2" mimeType="video/mp4">',
2126
- ` <SupplementalProperty schemeIdUri="${scheme}" value="9" />`,
2127
- ' <Representation codecs="hvc1.2.4.L153.B0">',
2128
- ' <BaseURL>v-sd.mp4</BaseURL>',
2129
- ' <SegmentBase indexRange="100-200" />',
2130
- ' </Representation>',
2131
- ' </AdaptationSet>',
2132
- ' <AdaptationSet id="3" mimeType="audio/mp4">',
2133
- ' <Representation id="audio-en">',
2134
- ' <BaseURL>a-en.mp4</BaseURL>',
2135
- ' <SegmentBase indexRange="100-200" />',
2136
- ' </Representation>',
2137
- ' </AdaptationSet>',
2138
- ' </Period>',
2139
- '</MPD>',
2140
- ].join('\n');
2141
-
2142
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
2143
-
2144
- /** @type {shaka.extern.Manifest} */
2145
- const manifest = await parser.start('dummy://foo', playerInterface);
2146
- expect(manifest.variants.length).toBe(1);
2147
- });
2148
-
2149
- it('supports SupplementalProperty ColourPrimaries', async () => {
2150
- // (DASH-IF IOP v4.3 6.2.5.1.)
2151
- const scheme = cicpScheme('ColourPrimaries');
2152
- const manifestText = [
2153
- '<MPD minBufferTime="PT75S">',
2154
- ' <Period id="1" duration="PT30S">',
2155
- ' <AdaptationSet id="2" mimeType="video/mp4">',
2156
- ` <SupplementalProperty schemeIdUri="${scheme}" value="9" />`,
2157
- ' <Representation codecs="hvc1.2.4.L153.B0">',
2158
- ' <BaseURL>v-sd.mp4</BaseURL>',
2159
- ' <SegmentBase indexRange="100-200" />',
2160
- ' </Representation>',
2161
- ' </AdaptationSet>',
2162
- ' <AdaptationSet id="3" mimeType="audio/mp4">',
2163
- ' <Representation id="audio-en">',
2164
- ' <BaseURL>a-en.mp4</BaseURL>',
2165
- ' <SegmentBase indexRange="100-200" />',
2166
- ' </Representation>',
2167
- ' </AdaptationSet>',
2168
- ' </Period>',
2169
- '</MPD>',
2170
- ].join('\n');
2171
-
2172
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
2173
-
2174
- /** @type {shaka.extern.Manifest} */
2175
- const manifest = await parser.start('dummy://foo', playerInterface);
2176
- expect(manifest.variants.length).toBe(1);
2177
- });
2178
-
2179
- it('supports HDR signaling via EssentialProperty', async () => {
2180
- // (DASH-IF IOP v4.3 6.2.5.1.)
2181
- const hdrScheme = cicpScheme('TransferCharacteristics');
2182
- const hlg = 18;
2183
- const manifestText = [
2184
- '<MPD minBufferTime="PT75S">',
2185
- ' <Period id="1" duration="PT30S">',
2186
- ' <AdaptationSet id="2" mimeType="video/mp4">',
2187
- ` <EssentialProperty schemeIdUri="${hdrScheme}" value="${hlg}" />`,
2188
- ' <Representation codecs="hvc1.2.4.L153.B0">',
2189
- ' <BaseURL>v-sd.mp4</BaseURL>',
2190
- ' <SegmentBase indexRange="100-200" />',
2191
- ' </Representation>',
2192
- ' </AdaptationSet>',
2193
- ' <AdaptationSet id="3" mimeType="audio/mp4">',
2194
- ' <Representation id="audio-en">',
2195
- ' <BaseURL>a-en.mp4</BaseURL>',
2196
- ' <SegmentBase indexRange="100-200" />',
2197
- ' </Representation>',
2198
- ' </AdaptationSet>',
2199
- ' </Period>',
2200
- '</MPD>',
2201
- ].join('\n');
2202
-
2203
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
2204
-
2205
- /** @type {shaka.extern.Manifest} */
2206
- const manifest = await parser.start('dummy://foo', playerInterface);
2207
- expect(manifest.variants.length).toBe(1);
2208
- const stream = manifest.variants[0].video;
2209
- expect(stream.hdr).toBe('HLG');
2210
- });
2211
-
2212
- it('supports EssentialProperty MatrixCoefficients', async () => {
2213
- // (DASH-IF IOP v4.3 6.2.5.1.)
2214
- const hdrScheme = cicpScheme('MatrixCoefficients');
2215
- const manifestText = [
2216
- '<MPD minBufferTime="PT75S">',
2217
- ' <Period id="1" duration="PT30S">',
2218
- ' <AdaptationSet id="2" mimeType="video/mp4">',
2219
- ` <EssentialProperty schemeIdUri="${hdrScheme}" value="9" />`,
2220
- ' <Representation codecs="hvc1.2.4.L153.B0">',
2221
- ' <BaseURL>v-sd.mp4</BaseURL>',
2222
- ' <SegmentBase indexRange="100-200" />',
2223
- ' </Representation>',
2224
- ' </AdaptationSet>',
2225
- ' <AdaptationSet id="3" mimeType="audio/mp4">',
2226
- ' <Representation id="audio-en">',
2227
- ' <BaseURL>a-en.mp4</BaseURL>',
2228
- ' <SegmentBase indexRange="100-200" />',
2229
- ' </Representation>',
2230
- ' </AdaptationSet>',
2231
- ' </Period>',
2232
- '</MPD>',
2233
- ].join('\n');
2234
-
2235
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
2236
-
2237
- /** @type {shaka.extern.Manifest} */
2238
- const manifest = await parser.start('dummy://foo', playerInterface);
2239
- expect(manifest.variants.length).toBe(1);
2240
- });
2241
-
2242
- it('supports EssentialProperty ColourPrimaries', async () => {
2243
- // (DASH-IF IOP v4.3 6.2.5.1.)
2244
- const hdrScheme = cicpScheme('ColourPrimaries');
2245
- const manifestText = [
2246
- '<MPD minBufferTime="PT75S">',
2247
- ' <Period id="1" duration="PT30S">',
2248
- ' <AdaptationSet id="2" mimeType="video/mp4">',
2249
- ` <EssentialProperty schemeIdUri="${hdrScheme}" value="9" />`,
2250
- ' <Representation codecs="hvc1.2.4.L153.B0">',
2251
- ' <BaseURL>v-sd.mp4</BaseURL>',
2252
- ' <SegmentBase indexRange="100-200" />',
2253
- ' </Representation>',
2254
- ' </AdaptationSet>',
2255
- ' <AdaptationSet id="3" mimeType="audio/mp4">',
2256
- ' <Representation id="audio-en">',
2257
- ' <BaseURL>a-en.mp4</BaseURL>',
2258
- ' <SegmentBase indexRange="100-200" />',
2259
- ' </Representation>',
2260
- ' </AdaptationSet>',
2261
- ' </Period>',
2262
- '</MPD>',
2263
- ].join('\n');
2264
-
2265
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
2266
-
2267
- /** @type {shaka.extern.Manifest} */
2268
- const manifest = await parser.start('dummy://foo', playerInterface);
2269
- expect(manifest.variants.length).toBe(1);
2270
- });
2271
-
2272
- it('supports SDR signalling via EssentialProperty', async () => {
2273
- // (DASH-IF IOP v4.3 6.2.5.1.)
2274
- const scheme = cicpScheme('TransferCharacteristics');
2275
- const sdrValues = [1, 6, 13, 14, 15];
2276
- const manifestPromises = [];
2277
- for (const value of sdrValues) {
2278
- const manifestText = [
2279
- '<MPD minBufferTime="PT75S">',
2280
- ' <Period id="1" duration="PT30S">',
2281
- ' <AdaptationSet id="2" mimeType="video/mp4">',
2282
- ` <EssentialProperty schemeIdUri="${scheme}" value="${value}" />`,
2283
- ' <Representation codecs="avc1.640028">',
2284
- ' <BaseURL>v-sd.mp4</BaseURL>',
2285
- ' <SegmentBase indexRange="100-200" />',
2286
- ' </Representation>',
2287
- ' </AdaptationSet>',
2288
- ' <AdaptationSet id="3" mimeType="audio/mp4">',
2289
- ' <Representation id="audio-en">',
2290
- ' <BaseURL>a-en.mp4</BaseURL>',
2291
- ' <SegmentBase indexRange="100-200" />',
2292
- ' </Representation>',
2293
- ' </AdaptationSet>',
2294
- ' </Period>',
2295
- '</MPD>',
2296
- ].join('\n');
2297
-
2298
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
2299
-
2300
- manifestPromises.push(parser.start('dummy://foo', playerInterface));
2301
- }
2302
- const manifests = await Promise.all(manifestPromises);
2303
- for (const manifest of manifests) {
2304
- expect(manifest.variants.length).toBe(1);
2305
- const stream = manifest.variants[0].video;
2306
- expect(stream.hdr).toBe('SDR');
2307
- }
2308
- });
2309
-
2310
- it('Does not error when image adaptation sets are present', async () => {
2311
- const manifestText = [
2312
- '<MPD minBufferTime="PT75S">',
2313
- ' <Period id="1" duration="PT30S">',
2314
- ' <AdaptationSet id="2" mimeType="video/mp4">',
2315
- ' <Representation id="video-sd" width="640" height="480">',
2316
- ' <BaseURL>v-sd.mp4</BaseURL>',
2317
- ' <SegmentBase indexRange="100-200" />',
2318
- ' </Representation>',
2319
- ' </AdaptationSet>',
2320
- ' <AdaptationSet id="3" mimeType="audio/mp4">',
2321
- ' <Representation id="audio-en">',
2322
- ' <BaseURL>a-en.mp4</BaseURL>',
2323
- ' <SegmentBase indexRange="100-200" />',
2324
- ' </Representation>',
2325
- ' </AdaptationSet>',
2326
- ' <AdaptationSet contentType="image" id="3">',
2327
- ' <SegmentTemplate media="$Number$.jpg" ',
2328
- ' duration="2" startNumber="1"/>',
2329
- ' <Representation id="thumbnails" width="1024" height="1152">',
2330
- ` <EssentialProperty schemeIdUri="${thumbnailScheme}" value="10x20"/>`, // eslint-disable-line max-len
2331
- ' </Representation>',
2332
- ' </AdaptationSet>',
2333
- ' </Period>',
2334
- '</MPD>',
2335
- ].join('\n');
2336
-
2337
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
2338
-
2339
- /** @type {shaka.extern.Manifest} */
2340
- const manifest = await parser.start('dummy://foo', playerInterface);
2341
- const variant = manifest.variants[0];
2342
- expect(variant.audio).toBeTruthy();
2343
- expect(variant.video).toBeTruthy();
2344
- });
2345
-
2346
- it('parse single representation of image adaptation sets', async () => {
2347
- const manifestText = [
2348
- '<MPD minBufferTime="PT75S">',
2349
- ' <Period id="1" duration="PT30S">',
2350
- ' <AdaptationSet id="2" mimeType="video/mp4">',
2351
- ' <Representation id="video-sd" width="640" height="480">',
2352
- ' <BaseURL>v-sd.mp4</BaseURL>',
2353
- ' <SegmentBase indexRange="100-200" />',
2354
- ' </Representation>',
2355
- ' </AdaptationSet>',
2356
- ' <AdaptationSet id="3" mimeType="audio/mp4">',
2357
- ' <Representation id="audio-en">',
2358
- ' <BaseURL>a-en.mp4</BaseURL>',
2359
- ' <SegmentBase indexRange="100-200" />',
2360
- ' </Representation>',
2361
- ' </AdaptationSet>',
2362
- ' <AdaptationSet contentType="image" id="3">',
2363
- ' <SegmentTemplate media="$Number$.jpg" ',
2364
- ' duration="2" startNumber="1"/>',
2365
- ' <Representation id="thumbnails" width="1024" height="1152">',
2366
- ` <EssentialProperty schemeIdUri="${thumbnailScheme}" value="10x20"/>`, // eslint-disable-line max-len
2367
- ' </Representation>',
2368
- ' </AdaptationSet>',
2369
- ' </Period>',
2370
- '</MPD>',
2371
- ].join('\n');
2372
-
2373
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
2374
-
2375
- /** @type {shaka.extern.Manifest} */
2376
- const manifest = await parser.start('dummy://foo', playerInterface);
2377
- expect(manifest.imageStreams.length).toBe(1);
2378
- expect(manifest.presentationTimeline.getMaxSegmentDuration()).toBe(1);
2379
- const imageStream = manifest.imageStreams[0];
2380
- expect(imageStream.width).toBe(1024);
2381
- expect(imageStream.height).toBe(1152);
2382
- expect(imageStream.tilesLayout).toBe('10x20');
2383
- });
2384
-
2385
-
2386
- it('parse multiple representation of image adaptation sets', async () => {
2387
- const manifestText = [
2388
- '<MPD minBufferTime="PT75S">',
2389
- ' <Period id="1" duration="PT30S">',
2390
- ' <AdaptationSet id="2" mimeType="video/mp4">',
2391
- ' <Representation id="video-sd" width="640" height="480">',
2392
- ' <BaseURL>v-sd.mp4</BaseURL>',
2393
- ' <SegmentBase indexRange="100-200" />',
2394
- ' </Representation>',
2395
- ' </AdaptationSet>',
2396
- ' <AdaptationSet id="3" mimeType="audio/mp4">',
2397
- ' <Representation id="audio-en">',
2398
- ' <BaseURL>a-en.mp4</BaseURL>',
2399
- ' <SegmentBase indexRange="100-200" />',
2400
- ' </Representation>',
2401
- ' </AdaptationSet>',
2402
- ' <AdaptationSet contentType="image" id="3">',
2403
- ' <SegmentTemplate media="$Number$.jpg" ',
2404
- ' duration="2" startNumber="1"/>',
2405
- ' <Representation id="thumbnails" width="1024" height="1152">',
2406
- ` <EssentialProperty schemeIdUri="${thumbnailScheme}" value="10x20"/>`, // eslint-disable-line max-len
2407
- ' </Representation>',
2408
- ' <Representation id="thumbnails" width="2048" height="1152">',
2409
- ` <EssentialProperty schemeIdUri="${thumbnailScheme}" value="20x20"/>`, // eslint-disable-line max-len
2410
- ' </Representation>',
2411
- ' </AdaptationSet>',
2412
- ' </Period>',
2413
- '</MPD>',
2414
- ].join('\n');
2415
-
2416
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
2417
-
2418
- /** @type {shaka.extern.Manifest} */
2419
- const manifest = await parser.start('dummy://foo', playerInterface);
2420
- expect(manifest.imageStreams.length).toBe(2);
2421
- const firstImageStream = manifest.imageStreams[0];
2422
- expect(firstImageStream.width).toBe(1024);
2423
- expect(firstImageStream.height).toBe(1152);
2424
- expect(firstImageStream.tilesLayout).toBe('10x20');
2425
- const secondImageStream = manifest.imageStreams[1];
2426
- expect(secondImageStream.width).toBe(2048);
2427
- expect(secondImageStream.height).toBe(1152);
2428
- expect(secondImageStream.tilesLayout).toBe('20x20');
2429
- });
2430
-
2431
- // Regression #2650 in v3.0.0
2432
- // A later BaseURL was being applied to earlier Representations, specifically
2433
- // in the context of SegmentTimeline.
2434
- it('uses the correct BaseURL for SegmentTimeline', async () => {
2435
- const manifestText = [
2436
- '<MPD type="static">',
2437
- ' <Period id="1" duration="PT30S">',
2438
- ' <AdaptationSet id="2" mimeType="video/mp4">',
2439
- ' <SegmentTemplate media="$Number$.mp4" startNumber="1">',
2440
- ' <SegmentTimeline>',
2441
- ' <S t="0" d="30" />',
2442
- ' </SegmentTimeline>',
2443
- ' </SegmentTemplate>',
2444
- ' <Representation id="video-sd" width="640" height="480">',
2445
- ' <BaseURL>http://example.com/r0/</BaseURL>',
2446
- ' </Representation>',
2447
- ' <Representation id="video-hd" width="1920" height="1080">',
2448
- ' <BaseURL>http://example.com/r1/</BaseURL>',
2449
- ' </Representation>',
2450
- ' </AdaptationSet>',
2451
- ' </Period>',
2452
- '</MPD>',
2453
- ].join('\n');
2454
-
2455
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
2456
-
2457
- /** @type {shaka.extern.Manifest} */
2458
- const manifest = await parser.start('dummy://foo', playerInterface);
2459
-
2460
- const video0 = manifest.variants[0].video;
2461
- await video0.createSegmentIndex();
2462
- goog.asserts.assert(video0.segmentIndex, 'Null segmentIndex!');
2463
- const segment0 = Array.from(video0.segmentIndex)[0];
2464
- const uri0 = segment0.getUris()[0];
2465
-
2466
- const video1 = manifest.variants[1].video;
2467
- await video1.createSegmentIndex();
2468
- goog.asserts.assert(video1.segmentIndex, 'Null segmentIndex!');
2469
- const segment1 = Array.from(video1.segmentIndex)[0];
2470
- const uri1 = segment1.getUris()[0];
2471
-
2472
- expect(uri0).toBe('http://example.com/r0/1.mp4');
2473
- expect(uri1).toBe('http://example.com/r1/1.mp4');
2474
- });
2475
-
2476
- // b/179025415: A "future" period (past the segment availability window end)
2477
- // would cause us to generate bogus segment references for that period. This
2478
- // would happen upon update (once per segment duration), but not on initial
2479
- // load.
2480
- it('creates no references for future Periods', async () => {
2481
- // Pretend the live stream started 10 seconds ago. This is long enough to
2482
- // have segments (1s each), but not long enough to have segments in the
2483
- // second period (30s into the live stream).
2484
- const availabilityStartTimeMilliseconds = Date.now() - 10e3;
2485
- const availabilityStartTime =
2486
- (new Date(availabilityStartTimeMilliseconds)).toISOString();
2487
- const manifestText = [
2488
- `<MPD type="dynamic" availabilityStartTime="${availabilityStartTime}">`,
2489
- ' <Period id="1" duration="PT30S">',
2490
- ' <AdaptationSet id="2" mimeType="video/mp4">',
2491
- ' <SegmentTemplate media="$Number$.mp4" duration="1" />',
2492
- ' <Representation id="3" width="640" height="480">',
2493
- ' <BaseURL>http://example.com/p1/</BaseURL>',
2494
- ' </Representation>',
2495
- ' </AdaptationSet>',
2496
- ' </Period>',
2497
- ' <Period id="4" duration="PT30S">',
2498
- ' <AdaptationSet id="5" mimeType="video/mp4">',
2499
- ' <SegmentTemplate media="$Number$.mp4" duration="1" />',
2500
- ' <Representation id="6" width="640" height="480">',
2501
- ' <BaseURL>http://example.com/p2/</BaseURL>',
2502
- ' </Representation>',
2503
- ' </AdaptationSet>',
2504
- ' </Period>',
2505
- '</MPD>',
2506
- ].join('\n');
2507
-
2508
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
2509
-
2510
- /** @type {shaka.extern.Manifest} */
2511
- const manifest = await parser.start('dummy://foo', playerInterface);
2512
-
2513
- const video0 = manifest.variants[0].video;
2514
- await video0.createSegmentIndex();
2515
-
2516
- // Wait two segment durations, so that the updateEvery callback fires.
2517
- // In the original bug, we generated bogus references during update.
2518
- await shaka.test.Util.delay(2);
2519
-
2520
- goog.asserts.assert(video0.segmentIndex, 'Null segmentIndex!');
2521
- const segments = Array.from(video0.segmentIndex);
2522
-
2523
- // There should be some segments, but not more than the 30 that would appear
2524
- // in the complete first period.
2525
- expect(segments.length).toBeGreaterThan(0);
2526
- expect(segments.length).toBeLessThanOrEqual(30);
2527
-
2528
- // We should also not find /p2/ (the second period URL) in any of them.
2529
- const segmentUris = segments.map((s) => s.getUris()[0]);
2530
- for (const uri of segmentUris) {
2531
- expect(uri).not.toContain('/p2/');
2532
- }
2533
- });
2534
-
2535
- /**
2536
- * @param {!Array.<number>} periods Start time of multiple periods
2537
- * @return {string}
2538
- */
2539
- function buildManifestWithPeriodStartTime(periods) {
2540
- const mpdTemplate = [
2541
- `<MPD type="dynamic"`,
2542
- 'availabilityStartTime="1970-01-01T00:00:00Z"',
2543
- 'timeShiftBufferDepth="PT10H">',
2544
- ' %(periods)s',
2545
- '</MPD>',
2546
- ].join('\n');
2547
- const periodTemplate = (id, period, duration) => {
2548
- return [
2549
- ` <Period id="${id}" start="PT${period}S">`,
2550
- ' <AdaptationSet mimeType="video/mp4" lang="en" group="1">',
2551
- ' <SegmentTemplate startNumber="1" media="l-$Number$.mp4">',
2552
- ' <SegmentTimeline>',
2553
- ` <S t="0" d="${duration}" />`,
2554
- ' </SegmentTimeline>',
2555
- ' </SegmentTemplate>',
2556
- ' <Representation id="1"/>',
2557
- ' </AdaptationSet>',
2558
- ' </Period>',
2559
- ].join('\n');
2560
- };
2561
- const periodXmls = periods.map((period, i) => {
2562
- const duration = i+1 === periods.length ? 10 : periods[i+1] - period;
2563
- // Period start time as ID here. If we use index then there will be
2564
- // periods with same period ID and different start time which are invalid.
2565
- return periodTemplate(period, period, duration);
2566
- });
2567
- return sprintf(mpdTemplate, {
2568
- periods: periodXmls.join('\n'),
2569
- });
2570
- }
2571
-
2572
- // Bug description: Inconsistent period start time in the manifests due
2573
- // to failover triggered in backend servers
2574
-
2575
- // When one of the servers is down, the manifest will be served by other
2576
- // redundant servers. The period start time might become out of sync
2577
- // during the switch-over/recovery.
2578
-
2579
- it('skip periods that are earlier than max period start time', async () => {
2580
- const sources = [
2581
- buildManifestWithPeriodStartTime([5, 15]),
2582
- buildManifestWithPeriodStartTime([6, 15]), // simulate out-of-sync of +1s
2583
- buildManifestWithPeriodStartTime([4, 15]), // simulate out-of-sync of -1s
2584
- ];
2585
- const segments = [];
2586
-
2587
- for (const source of sources) {
2588
- fakeNetEngine.setResponseText('dummy://foo', source);
2589
- /** @type {shaka.extern.Manifest} */
2590
- // eslint-disable-next-line no-await-in-loop
2591
- const manifest = await parser.start('dummy://foo', playerInterface);
2592
- const video = manifest.variants[0].video;
2593
- // eslint-disable-next-line no-await-in-loop
2594
- await video.createSegmentIndex();
2595
- goog.asserts.assert(video.segmentIndex, 'Null segmentIndex!');
2596
- segments.push(Array.from(video.segmentIndex));
2597
- }
2598
-
2599
- // Expect identical segments
2600
- expect(segments[0].length).toBe(2);
2601
- expect(segments[1].length).toBe(2);
2602
- expect(segments[0][0].startTime).toBe(5);
2603
- expect(segments[1][0].startTime).toBe(5);
2604
- expect(segments[0][1].startTime).toBe(15);
2605
- expect(segments[1][1].startTime).toBe(15);
2606
- });
2607
-
2608
- describe('Parses ServiceDescription', () => {
2609
- it('with PlaybackRate and Latency', async () => {
2610
- const source = [
2611
- '<MPD minBufferTime="PT75S" type="dynamic"',
2612
- ' availabilityStartTime="1970-01-01T00:00:00Z">',
2613
- ' <ServiceDescription id="0">',
2614
- ' <Latency max="2000" min="1000" referenceId="0" target="4000" />',
2615
- ' <PlaybackRate max="1.10" min="0.95" />',
2616
- ' </ServiceDescription>',
2617
- '</MPD>',
2618
- ].join('\n');
2619
-
2620
- fakeNetEngine.setResponseText('dummy://foo', source);
2621
-
2622
- /** @type {shaka.extern.Manifest} */
2623
- const manifest = await parser.start('dummy://foo', playerInterface);
2624
-
2625
- expect(manifest.serviceDescription.maxLatency).toBe(2);
2626
- expect(manifest.serviceDescription.maxPlaybackRate).toBe(1.1);
2627
- expect(manifest.serviceDescription.minLatency).toBe(1);
2628
- expect(manifest.serviceDescription.minPlaybackRate).toBe(0.95);
2629
- });
2630
- });
2631
-
2632
- it('parses urn:mpeg:dash:ssr:2023', async () => { // eslint-disable-line max-len
2633
- const manifestText = [
2634
- '<MPD minBufferTime="PT75S">',
2635
- ' <Period id="1" duration="PT30S">',
2636
- ' <AdaptationSet id="1" mimeType="video/mp4">',
2637
- ' <Representation bandwidth="2" codecs="avc1.4d401f"',
2638
- ' height="1080" width="1920">',
2639
- ' <SegmentTemplate startNumber="1" media="l2-$Number$.mp4"',
2640
- ' initialization="init.mp4" timescale="50" duration="100">',
2641
- ' <SegmentTimeline>',
2642
- ' <S t="0" d="100"/>',
2643
- ' <S d="100"/>',
2644
- ' </SegmentTimeline>',
2645
- ' </SegmentTemplate>',
2646
- ' </Representation>',
2647
- ' </AdaptationSet>',
2648
- ' <AdaptationSet id="2" mimeType="video/mp4">',
2649
- ' <EssentialProperty value="video_primary" ',
2650
- ' schemeIdUri="urn:mpeg:dash:ssr:2023" />',
2651
- ' <Representation bandwidth="1" codecs="avc1.4d401f"',
2652
- ' height="720" width="1280">',
2653
- ' <SegmentTemplate startNumber="1"',
2654
- ' media="l-$Number$-p$SubNumber$.mp4"',
2655
- ' initialization="init.mp4" timescale="50" duration="100">',
2656
- ' <SegmentTimeline>',
2657
- ' <S t="0" d="100" k="4"/>',
2658
- ' <S d="100" k="4"/>',
2659
- ' </SegmentTimeline>',
2660
- ' </SegmentTemplate>',
2661
- ' </Representation>',
2662
- ' </AdaptationSet>',
2663
- ' </Period>',
2664
- '</MPD>',
2665
- ].join('\n');
2666
-
2667
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
2668
- /** @type {shaka.extern.Manifest} */
2669
- const manifest = await parser.start('dummy://foo', playerInterface);
2670
- expect(manifest.variants.length).toBe(2);
2671
-
2672
- const normalStream = manifest.variants[0].video;
2673
- expect(normalStream.width).toBe(1920);
2674
- expect(normalStream.height).toBe(1080);
2675
- expect(normalStream.fastSwitching).toBe(false);
2676
- await normalStream.createSegmentIndex();
2677
- goog.asserts.assert(normalStream.segmentIndex != null,
2678
- 'Null segmentIndex!');
2679
-
2680
- const firstNormalReference = normalStream.segmentIndex.get(0);
2681
- expect(firstNormalReference.partialReferences.length).toBe(0);
2682
-
2683
- const stream = manifest.variants[1].video;
2684
- expect(stream.width).toBe(1280);
2685
- expect(stream.height).toBe(720);
2686
- expect(stream.fastSwitching).toBe(true);
2687
- await stream.createSegmentIndex();
2688
- goog.asserts.assert(stream.segmentIndex != null,
2689
- 'Null segmentIndex!');
2690
-
2691
- const firstReference = stream.segmentIndex.get(0);
2692
- expect(firstReference.partialReferences.length).toBe(4);
2693
- });
2694
-
2695
- describe('parses partial segments correctly', () => {
2696
- it('whitout cadence', async () => {
2697
- const manifestText = [
2698
- '<MPD minBufferTime="PT75S">',
2699
- ' <Period id="1" duration="PT30S">',
2700
- ' <AdaptationSet id="1" mimeType="video/mp4">',
2701
- ' <Representation bandwidth="1" codecs="avc1.4d401f">',
2702
- ' <SegmentTemplate startNumber="1"',
2703
- ' media="l-$Number$-p$SubNumber$.mp4"',
2704
- ' initialization="init.mp4" timescale="50" duration="100">',
2705
- ' <SegmentTimeline>',
2706
- ' <S t="0" d="100" k="4"/>',
2707
- ' <S d="100" k="4"/>',
2708
- ' </SegmentTimeline>',
2709
- ' </SegmentTemplate>',
2710
- ' </Representation>',
2711
- ' </AdaptationSet>',
2712
- ' </Period>',
2713
- '</MPD>',
2714
- ].join('\n');
2715
-
2716
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
2717
- /** @type {shaka.extern.Manifest} */
2718
- const manifest = await parser.start('dummy://foo', playerInterface);
2719
- const stream = manifest.variants[0].video;
2720
- await stream.createSegmentIndex();
2721
- goog.asserts.assert(stream.segmentIndex != null, 'Null segmentIndex!');
2722
-
2723
- const firstReference = stream.segmentIndex.get(0);
2724
- expect(firstReference.startTime).toBe(0);
2725
- expect(firstReference.endTime).toBe(2);
2726
- expect(firstReference.getUris()).toEqual([]);
2727
- expect(firstReference.partialReferences.length).toBe(4);
2728
- const firstPartialReference = firstReference.partialReferences[0];
2729
- expect(firstPartialReference.startTime).toBe(0);
2730
- expect(firstPartialReference.endTime).toBe(0.5);
2731
- expect(firstPartialReference.getUris())
2732
- .toEqual(['dummy://foo/l-1-p1.mp4']);
2733
- const secondPartialReference = firstReference.partialReferences[1];
2734
- expect(secondPartialReference.startTime).toBe(0.5);
2735
- expect(secondPartialReference.endTime).toBe(1);
2736
- expect(secondPartialReference.getUris())
2737
- .toEqual(['dummy://foo/l-1-p2.mp4']);
2738
- const thirdPartialReference = firstReference.partialReferences[2];
2739
- expect(thirdPartialReference.startTime).toBe(1);
2740
- expect(thirdPartialReference.endTime).toBe(1.5);
2741
- expect(thirdPartialReference.getUris())
2742
- .toEqual(['dummy://foo/l-1-p3.mp4']);
2743
- const fourthPartialReference = firstReference.partialReferences[3];
2744
- expect(fourthPartialReference.startTime).toBe(1.5);
2745
- expect(fourthPartialReference.endTime).toBe(2);
2746
- expect(fourthPartialReference.getUris())
2747
- .toEqual(['dummy://foo/l-1-p4.mp4']);
2748
- });
2749
-
2750
- it('with cadence equal to 1', async () => {
2751
- const manifestText = [
2752
- '<MPD minBufferTime="PT75S">',
2753
- ' <Period id="1" duration="PT30S">',
2754
- ' <AdaptationSet id="1" mimeType="video/mp4">',
2755
- ' <Representation bandwidth="1" codecs="avc1.4d401f">',
2756
- ' <SegmentTemplate startNumber="1"',
2757
- ' media="l-$Number$-p$SubNumber$.mp4"',
2758
- ' initialization="init.mp4" timescale="50" duration="100">',
2759
- ' <SegmentTimeline>',
2760
- ' <S t="0" d="100" k="4"/>',
2761
- ' <S d="100" k="4"/>',
2762
- ' </SegmentTimeline>',
2763
- ' </SegmentTemplate>',
2764
- ' <SegmentSequenceProperties>',
2765
- ' <SAP type="1" cadence="1" />',
2766
- ' </SegmentSequenceProperties>',
2767
- ' </Representation>',
2768
- ' </AdaptationSet>',
2769
- ' </Period>',
2770
- '</MPD>',
2771
- ].join('\n');
2772
-
2773
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
2774
- /** @type {shaka.extern.Manifest} */
2775
- const manifest = await parser.start('dummy://foo', playerInterface);
2776
- const stream = manifest.variants[0].video;
2777
- await stream.createSegmentIndex();
2778
- goog.asserts.assert(stream.segmentIndex != null, 'Null segmentIndex!');
2779
-
2780
- const firstReference = stream.segmentIndex.get(0);
2781
- const firstPartialReference = firstReference.partialReferences[0];
2782
- expect(firstPartialReference.isIndependent()).toBeTruthy();
2783
- const secondPartialReference = firstReference.partialReferences[1];
2784
- expect(secondPartialReference.isIndependent()).toBeTruthy();
2785
- const thirdPartialReference = firstReference.partialReferences[2];
2786
- expect(thirdPartialReference.isIndependent()).toBeTruthy();
2787
- const fourthPartialReference = firstReference.partialReferences[3];
2788
- expect(fourthPartialReference.isIndependent()).toBeTruthy();
2789
- });
2790
-
2791
- it('with cadence equal to 2', async () => {
2792
- const manifestText = [
2793
- '<MPD minBufferTime="PT75S">',
2794
- ' <Period id="1" duration="PT30S">',
2795
- ' <AdaptationSet id="1" mimeType="video/mp4">',
2796
- ' <Representation bandwidth="1" codecs="avc1.4d401f">',
2797
- ' <SegmentTemplate startNumber="1"',
2798
- ' media="l-$Number$-p$SubNumber$.mp4"',
2799
- ' initialization="init.mp4" timescale="50" duration="100">',
2800
- ' <SegmentTimeline>',
2801
- ' <S t="0" d="100" k="4"/>',
2802
- ' <S d="100" k="4"/>',
2803
- ' </SegmentTimeline>',
2804
- ' </SegmentTemplate>',
2805
- ' <SegmentSequenceProperties>',
2806
- ' <SAP type="1" cadence="2" />',
2807
- ' </SegmentSequenceProperties>',
2808
- ' </Representation>',
2809
- ' </AdaptationSet>',
2810
- ' </Period>',
2811
- '</MPD>',
2812
- ].join('\n');
2813
-
2814
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
2815
- /** @type {shaka.extern.Manifest} */
2816
- const manifest = await parser.start('dummy://foo', playerInterface);
2817
- const stream = manifest.variants[0].video;
2818
- await stream.createSegmentIndex();
2819
- goog.asserts.assert(stream.segmentIndex != null, 'Null segmentIndex!');
2820
-
2821
- const firstReference = stream.segmentIndex.get(0);
2822
- const firstPartialReference = firstReference.partialReferences[0];
2823
- expect(firstPartialReference.isIndependent()).toBeTruthy();
2824
- const secondPartialReference = firstReference.partialReferences[1];
2825
- expect(secondPartialReference.isIndependent()).toBeFalsy();
2826
- const thirdPartialReference = firstReference.partialReferences[2];
2827
- expect(thirdPartialReference.isIndependent()).toBeTruthy();
2828
- const fourthPartialReference = firstReference.partialReferences[3];
2829
- expect(fourthPartialReference.isIndependent()).toBeFalsy();
2830
- });
2831
- });
2832
-
2833
- describe('supports ContentSteering', () => {
2834
- it('with defaultServiceLocation', async () => {
2835
- const manifestText = [
2836
- '<MPD type="static">',
2837
- ' <BaseURL serviceLocation="a">http://example.com/r0/</BaseURL>',
2838
- ' <BaseURL serviceLocation="b">http://example.com/r1/</BaseURL>',
2839
- ' <ContentSteering defaultServiceLocation="a,b" ',
2840
- 'queryBeforeStart="true">http://contentsteering</ContentSteering>',
2841
- ' <Period id="1" duration="PT30S">',
2842
- ' <AdaptationSet id="2" mimeType="video/mp4">',
2843
- ' <SegmentTemplate media="$Number$.mp4" startNumber="1">',
2844
- ' <SegmentTimeline>',
2845
- ' <S t="0" d="30" />',
2846
- ' </SegmentTimeline>',
2847
- ' </SegmentTemplate>',
2848
- ' <Representation id="video-sd" width="640" height="480">',
2849
- ' </Representation>',
2850
- ' </AdaptationSet>',
2851
- ' </Period>',
2852
- '</MPD>',
2853
- ].join('\n');
2854
-
2855
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
2856
-
2857
- const contentSteering = JSON.stringify({
2858
- 'VERSION': 1,
2859
- 'TTL': 1,
2860
- 'RELOAD-URI': 'http://contentsteering/update',
2861
- 'PATHWAY-PRIORITY': [],
2862
- });
2863
-
2864
- fakeNetEngine.setResponseText('http://contentsteering', contentSteering);
2865
-
2866
- /** @type {shaka.extern.Manifest} */
2867
- const manifest = await parser.start('dummy://foo', playerInterface);
2868
-
2869
- const video0 = manifest.variants[0].video;
2870
- await video0.createSegmentIndex();
2871
- goog.asserts.assert(video0.segmentIndex, 'Null segmentIndex!');
2872
- const segment0 = Array.from(video0.segmentIndex)[0];
2873
- const uri0 = segment0.getUris()[0];
2874
- const uri1 = segment0.getUris()[1];
2875
-
2876
- expect(uri0).toBe('http://example.com/r0/1.mp4');
2877
- expect(uri1).toBe('http://example.com/r1/1.mp4');
2878
- });
2879
-
2880
- it('without defaultServiceLocation', async () => {
2881
- const manifestText = [
2882
- '<MPD type="static">',
2883
- ' <BaseURL serviceLocation="a">http://example.com/r0/</BaseURL>',
2884
- ' <BaseURL serviceLocation="b">http://example.com/r1/</BaseURL>',
2885
- ' <ContentSteering',
2886
- 'queryBeforeStart="true">http://contentsteering</ContentSteering>',
2887
- ' <Period id="1" duration="PT30S">',
2888
- ' <AdaptationSet id="2" mimeType="video/mp4">',
2889
- ' <SegmentTemplate media="$Number$.mp4" startNumber="1">',
2890
- ' <SegmentTimeline>',
2891
- ' <S t="0" d="30" />',
2892
- ' </SegmentTimeline>',
2893
- ' </SegmentTemplate>',
2894
- ' <Representation id="video-sd" width="640" height="480">',
2895
- ' </Representation>',
2896
- ' </AdaptationSet>',
2897
- ' </Period>',
2898
- '</MPD>',
2899
- ].join('\n');
2900
-
2901
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
2902
-
2903
- const contentSteering = JSON.stringify({
2904
- 'VERSION': 1,
2905
- 'TTL': 1,
2906
- 'RELOAD-URI': 'http://contentsteering/update',
2907
- 'PATHWAY-PRIORITY': [
2908
- 'b',
2909
- 'a',
2910
- ],
2911
- });
2912
-
2913
- fakeNetEngine.setResponseText('http://contentsteering', contentSteering);
2914
-
2915
- /** @type {shaka.extern.Manifest} */
2916
- const manifest = await parser.start('dummy://foo', playerInterface);
2917
-
2918
- const video0 = manifest.variants[0].video;
2919
- await video0.createSegmentIndex();
2920
- goog.asserts.assert(video0.segmentIndex, 'Null segmentIndex!');
2921
- const segment0 = Array.from(video0.segmentIndex)[0];
2922
- const uri0 = segment0.getUris()[0];
2923
- const uri1 = segment0.getUris()[1];
2924
-
2925
- expect(uri0).toBe('http://example.com/r1/1.mp4');
2926
- expect(uri1).toBe('http://example.com/r0/1.mp4');
2927
- });
2928
-
2929
- it('with queryBeforeStart', async () => {
2930
- const manifestText = [
2931
- '<MPD type="static">',
2932
- ' <BaseURL serviceLocation="a">http://example.com/r0/</BaseURL>',
2933
- ' <BaseURL serviceLocation="b">http://example.com/r1/</BaseURL>',
2934
- ' <ContentSteering defaultServiceLocation="b" ',
2935
- 'queryBeforeStart="true">http://contentsteering</ContentSteering>',
2936
- ' <Period id="1" duration="PT30S">',
2937
- ' <AdaptationSet id="2" mimeType="video/mp4">',
2938
- ' <SegmentTemplate media="$Number$.mp4" startNumber="1">',
2939
- ' <SegmentTimeline>',
2940
- ' <S t="0" d="30" />',
2941
- ' </SegmentTimeline>',
2942
- ' </SegmentTemplate>',
2943
- ' <Representation id="video-sd" width="640" height="480">',
2944
- ' </Representation>',
2945
- ' </AdaptationSet>',
2946
- ' </Period>',
2947
- '</MPD>',
2948
- ].join('\n');
2949
-
2950
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
2951
-
2952
- const contentSteering = JSON.stringify({
2953
- 'VERSION': 1,
2954
- 'TTL': 1,
2955
- 'RELOAD-URI': 'http://contentsteering/update',
2956
- 'PATHWAY-PRIORITY': [
2957
- 'a',
2958
- ],
2959
- });
2960
-
2961
- fakeNetEngine.setResponseText('http://contentsteering', contentSteering);
2962
-
2963
- /** @type {shaka.extern.Manifest} */
2964
- const manifest = await parser.start('dummy://foo', playerInterface);
2965
-
2966
- const video0 = manifest.variants[0].video;
2967
- await video0.createSegmentIndex();
2968
- goog.asserts.assert(video0.segmentIndex, 'Null segmentIndex!');
2969
- const segment0 = Array.from(video0.segmentIndex)[0];
2970
- expect(segment0.getUris().length).toBe(1);
2971
- const uri0 = segment0.getUris()[0];
2972
-
2973
- expect(uri0).toBe('http://example.com/r0/1.mp4');
2974
- });
2975
-
2976
- it('without queryBeforeStart', async () => {
2977
- const manifestText = [
2978
- '<MPD type="static">',
2979
- ' <BaseURL serviceLocation="a">http://example.com/r0/</BaseURL>',
2980
- ' <BaseURL serviceLocation="b">http://example.com/r1/</BaseURL>',
2981
- ' <ContentSteering defaultServiceLocation="b">',
2982
- 'http://contentsteering</ContentSteering>',
2983
- ' <Period id="1" duration="PT30S">',
2984
- ' <AdaptationSet id="2" mimeType="video/mp4">',
2985
- ' <SegmentTemplate media="$Number$.mp4" startNumber="1">',
2986
- ' <SegmentTimeline>',
2987
- ' <S t="0" d="30" />',
2988
- ' </SegmentTimeline>',
2989
- ' </SegmentTemplate>',
2990
- ' <Representation id="video-sd" width="640" height="480">',
2991
- ' </Representation>',
2992
- ' </AdaptationSet>',
2993
- ' </Period>',
2994
- '</MPD>',
2995
- ].join('\n');
2996
-
2997
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
2998
-
2999
- fakeNetEngine.setResponseText('http://contentsteering', 'foo');
3000
-
3001
- /** @type {shaka.extern.Manifest} */
3002
- const manifest = await parser.start('dummy://foo', playerInterface);
3003
-
3004
- const video0 = manifest.variants[0].video;
3005
- await video0.createSegmentIndex();
3006
- goog.asserts.assert(video0.segmentIndex, 'Null segmentIndex!');
3007
- const segment0 = Array.from(video0.segmentIndex)[0];
3008
- expect(segment0.getUris().length).toBe(1);
3009
- const uri0 = segment0.getUris()[0];
3010
-
3011
- expect(uri0).toBe('http://example.com/r1/1.mp4');
3012
- });
3013
-
3014
- it('without serviceLocation in BaseURL', async () => {
3015
- const manifestText = [
3016
- '<MPD type="static">',
3017
- ' <BaseURL>http://example.com/r0/</BaseURL>',
3018
- ' <BaseURL>http://example.com/r1/</BaseURL>',
3019
- ' <ContentSteering',
3020
- 'queryBeforeStart="true">http://contentsteering</ContentSteering>',
3021
- ' <Period id="1" duration="PT30S">',
3022
- ' <AdaptationSet id="2" mimeType="video/mp4">',
3023
- ' <SegmentTemplate media="$Number$.mp4" startNumber="1">',
3024
- ' <SegmentTimeline>',
3025
- ' <S t="0" d="30" />',
3026
- ' </SegmentTimeline>',
3027
- ' </SegmentTemplate>',
3028
- ' <Representation id="video-sd" width="640" height="480">',
3029
- ' </Representation>',
3030
- ' </AdaptationSet>',
3031
- ' </Period>',
3032
- '</MPD>',
3033
- ].join('\n');
3034
-
3035
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
3036
-
3037
- fakeNetEngine.setResponseText('http://contentsteering', 'foo');
3038
-
3039
- /** @type {shaka.extern.Manifest} */
3040
- const manifest = await parser.start('dummy://foo', playerInterface);
3041
-
3042
- const video0 = manifest.variants[0].video;
3043
- await video0.createSegmentIndex();
3044
- goog.asserts.assert(video0.segmentIndex, 'Null segmentIndex!');
3045
- const segment0 = Array.from(video0.segmentIndex)[0];
3046
- const uri0 = segment0.getUris()[0];
3047
- const uri1 = segment0.getUris()[1];
3048
-
3049
- expect(uri0).toBe('http://example.com/r0/1.mp4');
3050
- expect(uri1).toBe('http://example.com/r1/1.mp4');
3051
- });
3052
-
3053
- it('specify MPD BaseURL and AdaptationSet BaseURL', async () => {
3054
- const manifestText = [
3055
- '<MPD type="static">',
3056
- ' <BaseURL serviceLocation="a">http://example.com/r0/</BaseURL>',
3057
- ' <BaseURL serviceLocation="b">http://example.com/r1/</BaseURL>',
3058
- ' <ContentSteering defaultServiceLocation="a,b" ',
3059
- 'queryBeforeStart="true">http://contentsteering</ContentSteering>',
3060
- ' <Period id="1" duration="PT30S">',
3061
- ' <AdaptationSet id="2" mimeType="video/mp4">',
3062
- ' <SegmentTemplate media="$Number$.mp4" startNumber="1">',
3063
- ' <SegmentTimeline>',
3064
- ' <S t="0" d="30" />',
3065
- ' </SegmentTimeline>',
3066
- ' </SegmentTemplate>',
3067
- ' <Representation id="video-sd" width="640" height="480">',
3068
- ' </Representation>',
3069
- ' </AdaptationSet>',
3070
- ' <AdaptationSet id="3" mimeType="audio/mp4">',
3071
- ' <BaseURL serviceLocation="c">http://example.foo/r0/</BaseURL>',
3072
- ' <BaseURL serviceLocation="d">http://example.foo/r1/</BaseURL>',
3073
- ' <SegmentTemplate media="$Number$.mp4" startNumber="1">',
3074
- ' <SegmentTimeline>',
3075
- ' <S t="0" d="30" />',
3076
- ' </SegmentTimeline>',
3077
- ' </SegmentTemplate>',
3078
- ' <Representation id="audio">',
3079
- ' </Representation>',
3080
- ' </AdaptationSet>',
3081
- ' </Period>',
3082
- '</MPD>',
3083
- ].join('\n');
3084
-
3085
- fakeNetEngine.setResponseText('dummy://foo', manifestText);
3086
-
3087
- const contentSteering = JSON.stringify({
3088
- 'VERSION': 1,
3089
- 'TTL': 1,
3090
- 'RELOAD-URI': 'http://contentsteering/update',
3091
- 'PATHWAY-PRIORITY': [
3092
- 'a',
3093
- 'c',
3094
- ],
3095
- });
3096
-
3097
- fakeNetEngine.setResponseText('http://contentsteering', contentSteering);
3098
-
3099
- /** @type {shaka.extern.Manifest} */
3100
- const manifest = await parser.start('dummy://foo', playerInterface);
3101
-
3102
- const video0 = manifest.variants[0].video;
3103
- await video0.createSegmentIndex();
3104
- goog.asserts.assert(video0.segmentIndex, 'Null segmentIndex!');
3105
- const videoSegment0 = Array.from(video0.segmentIndex)[0];
3106
- expect(videoSegment0.getUris().length).toBe(1);
3107
- const videoUri0 = videoSegment0.getUris()[0];
3108
-
3109
- expect(videoUri0).toBe('http://example.com/r0/1.mp4');
3110
-
3111
- const audio0 = manifest.variants[0].audio;
3112
- await audio0.createSegmentIndex();
3113
- goog.asserts.assert(audio0.segmentIndex, 'Null segmentIndex!');
3114
- const audioSegment0 = Array.from(audio0.segmentIndex)[0];
3115
- expect(audioSegment0.getUris().length).toBe(1);
3116
- const audioUri0 = audioSegment0.getUris()[0];
3117
-
3118
- expect(audioUri0).toBe('http://example.foo/r0/1.mp4');
3119
- });
3120
- });
3121
- });