rx-player 4.0.0-dev.2023111400 → 4.0.0-dev.2023120600

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 (407) hide show
  1. package/CHANGELOG.md +11 -227
  2. package/FILES.md +1 -1
  3. package/VERSION +1 -1
  4. package/dist/_esm5.processed/compat/add_text_track.d.ts +1 -3
  5. package/dist/_esm5.processed/compat/add_text_track.js +4 -7
  6. package/dist/_esm5.processed/compat/browser_compatibility_types.d.ts +0 -7
  7. package/dist/_esm5.processed/compat/event_listeners.d.ts +2 -15
  8. package/dist/_esm5.processed/compat/event_listeners.js +2 -37
  9. package/dist/_esm5.processed/compat/index.d.ts +1 -3
  10. package/dist/_esm5.processed/compat/index.js +1 -3
  11. package/dist/_esm5.processed/config.d.ts +9 -21
  12. package/dist/_esm5.processed/core/adaptive/adaptive_representation_selector.d.ts +0 -58
  13. package/dist/_esm5.processed/core/adaptive/adaptive_representation_selector.js +14 -54
  14. package/dist/_esm5.processed/core/adaptive/utils/select_optimal_representation.d.ts +2 -8
  15. package/dist/_esm5.processed/core/adaptive/utils/select_optimal_representation.js +2 -11
  16. package/dist/_esm5.processed/core/api/debug/buffer_graph.js +2 -6
  17. package/dist/_esm5.processed/core/api/debug/modules/general_info.js +13 -32
  18. package/dist/_esm5.processed/core/api/debug/modules/segment_buffer_content.js +3 -3
  19. package/dist/_esm5.processed/core/api/debug/modules/segment_buffer_size.js +1 -1
  20. package/dist/_esm5.processed/core/api/option_utils.d.ts +12 -35
  21. package/dist/_esm5.processed/core/api/option_utils.js +41 -230
  22. package/dist/_esm5.processed/core/api/public_api.d.ts +91 -266
  23. package/dist/_esm5.processed/core/api/public_api.js +439 -805
  24. package/dist/_esm5.processed/core/{segment_buffers/implementations/image → api/track_management}/index.d.ts +3 -2
  25. package/dist/_esm5.processed/core/{segment_buffers/implementations/image → api/track_management}/index.js +3 -2
  26. package/dist/_esm5.processed/core/api/{tracks_management/media_element_track_choice_manager.d.ts → track_management/media_element_tracks_store.d.ts} +15 -75
  27. package/dist/_esm5.processed/core/api/{tracks_management/media_element_track_choice_manager.js → track_management/media_element_tracks_store.js} +74 -193
  28. package/dist/_esm5.processed/core/api/track_management/track_dispatcher.d.ts +84 -0
  29. package/dist/_esm5.processed/core/api/track_management/track_dispatcher.js +158 -0
  30. package/dist/_esm5.processed/core/api/track_management/tracks_store.d.ts +406 -0
  31. package/dist/_esm5.processed/core/api/track_management/tracks_store.js +932 -0
  32. package/dist/_esm5.processed/core/api/utils.d.ts +1 -0
  33. package/dist/_esm5.processed/core/api/utils.js +28 -11
  34. package/dist/_esm5.processed/core/decrypt/content_decryptor.js +3 -3
  35. package/dist/_esm5.processed/core/decrypt/find_key_system.js +83 -71
  36. package/dist/_esm5.processed/core/decrypt/get_media_keys.js +6 -5
  37. package/dist/_esm5.processed/core/decrypt/session_events_listener.js +10 -72
  38. package/dist/_esm5.processed/core/decrypt/utils/persistent_sessions_store.d.ts +4 -4
  39. package/dist/_esm5.processed/core/decrypt/utils/persistent_sessions_store.js +6 -4
  40. package/dist/_esm5.processed/core/fetchers/manifest/manifest_fetcher.d.ts +1 -3
  41. package/dist/_esm5.processed/core/fetchers/manifest/manifest_fetcher.js +7 -26
  42. package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher.d.ts +3 -9
  43. package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher.js +16 -9
  44. package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher_creator.d.ts +1 -3
  45. package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher_creator.js +1 -1
  46. package/dist/_esm5.processed/core/fetchers/utils/schedule_request.d.ts +1 -6
  47. package/dist/_esm5.processed/core/fetchers/utils/schedule_request.js +4 -41
  48. package/dist/_esm5.processed/core/init/directfile_content_initializer.js +1 -1
  49. package/dist/_esm5.processed/core/init/media_source_content_initializer.d.ts +1 -8
  50. package/dist/_esm5.processed/core/init/media_source_content_initializer.js +5 -19
  51. package/dist/_esm5.processed/core/init/types.d.ts +5 -15
  52. package/dist/_esm5.processed/core/init/utils/rebuffering_controller.d.ts +2 -36
  53. package/dist/_esm5.processed/core/init/utils/rebuffering_controller.js +2 -82
  54. package/dist/_esm5.processed/core/segment_buffers/implementations/text/native/native_text_segment_buffer.d.ts +1 -2
  55. package/dist/_esm5.processed/core/segment_buffers/implementations/text/native/native_text_segment_buffer.js +2 -3
  56. package/dist/_esm5.processed/core/segment_buffers/implementations/types.d.ts +2 -2
  57. package/dist/_esm5.processed/core/segment_buffers/index.d.ts +2 -2
  58. package/dist/_esm5.processed/core/segment_buffers/index.js +2 -1
  59. package/dist/_esm5.processed/core/segment_buffers/inventory/index.d.ts +1 -0
  60. package/dist/_esm5.processed/core/segment_buffers/inventory/index.js +1 -0
  61. package/dist/_esm5.processed/core/segment_buffers/inventory/utils.d.ts +33 -0
  62. package/dist/_esm5.processed/core/segment_buffers/inventory/utils.js +49 -0
  63. package/dist/_esm5.processed/core/segment_buffers/segment_buffers_store.d.ts +0 -1
  64. package/dist/_esm5.processed/core/segment_buffers/segment_buffers_store.js +2 -16
  65. package/dist/_esm5.processed/core/stream/adaptation/adaptation_stream.d.ts +0 -15
  66. package/dist/_esm5.processed/core/stream/adaptation/adaptation_stream.js +183 -93
  67. package/dist/_esm5.processed/core/stream/adaptation/get_representations_switch_strategy.d.ts +39 -0
  68. package/dist/_esm5.processed/core/stream/adaptation/get_representations_switch_strategy.js +133 -0
  69. package/dist/_esm5.processed/core/stream/adaptation/types.d.ts +27 -13
  70. package/dist/_esm5.processed/core/stream/index.d.ts +2 -3
  71. package/dist/_esm5.processed/core/stream/orchestrator/stream_orchestrator.d.ts +2 -0
  72. package/dist/_esm5.processed/core/stream/orchestrator/stream_orchestrator.js +5 -7
  73. package/dist/_esm5.processed/core/stream/period/period_stream.js +13 -12
  74. package/dist/_esm5.processed/core/stream/period/types.d.ts +5 -14
  75. package/dist/_esm5.processed/core/stream/period/utils/get_adaptation_switch_strategy.d.ts +2 -4
  76. package/dist/_esm5.processed/core/stream/period/utils/get_adaptation_switch_strategy.js +10 -46
  77. package/dist/_esm5.processed/core/stream/representation/representation_stream.js +29 -23
  78. package/dist/_esm5.processed/core/stream/representation/types.d.ts +11 -1
  79. package/dist/_esm5.processed/default_config.d.ts +35 -98
  80. package/dist/_esm5.processed/default_config.js +36 -113
  81. package/dist/_esm5.processed/errors/custom_loader_error.d.ts +1 -3
  82. package/dist/_esm5.processed/errors/custom_loader_error.js +1 -3
  83. package/dist/_esm5.processed/errors/media_error.js +2 -2
  84. package/dist/_esm5.processed/errors/network_error.d.ts +0 -1
  85. package/dist/_esm5.processed/errors/network_error.js +0 -1
  86. package/dist/_esm5.processed/errors/request_error.d.ts +2 -3
  87. package/dist/_esm5.processed/errors/request_error.js +2 -5
  88. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +3 -3
  89. package/dist/_esm5.processed/features/features_object.js +0 -2
  90. package/dist/_esm5.processed/features/list/directfile.js +2 -5
  91. package/dist/_esm5.processed/features/list/index.d.ts +0 -2
  92. package/dist/_esm5.processed/features/list/index.js +0 -2
  93. package/dist/_esm5.processed/features/types.d.ts +3 -27
  94. package/dist/_esm5.processed/manifest/adaptation.d.ts +9 -11
  95. package/dist/_esm5.processed/manifest/adaptation.js +41 -30
  96. package/dist/_esm5.processed/manifest/index.d.ts +3 -4
  97. package/dist/_esm5.processed/manifest/manifest.d.ts +5 -54
  98. package/dist/_esm5.processed/manifest/manifest.js +5 -110
  99. package/dist/_esm5.processed/manifest/period.d.ts +4 -5
  100. package/dist/_esm5.processed/manifest/representation.d.ts +10 -5
  101. package/dist/_esm5.processed/manifest/representation.js +15 -5
  102. package/dist/_esm5.processed/manifest/representation_index/index.d.ts +2 -2
  103. package/dist/_esm5.processed/manifest/representation_index/static.d.ts +2 -0
  104. package/dist/_esm5.processed/manifest/representation_index/static.js +6 -0
  105. package/dist/_esm5.processed/manifest/representation_index/types.d.ts +42 -21
  106. package/dist/_esm5.processed/manifest/types.d.ts +0 -2
  107. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/base.d.ts +17 -31
  108. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/base.js +26 -19
  109. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/list.d.ts +2 -0
  110. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/list.js +7 -1
  111. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/template.d.ts +2 -6
  112. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/template.js +11 -8
  113. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts +2 -0
  114. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +6 -0
  115. package/dist/_esm5.processed/parsers/manifest/dash/common/infer_adaptation_type.d.ts +2 -2
  116. package/dist/_esm5.processed/parsers/manifest/dash/common/infer_adaptation_type.js +1 -6
  117. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_adaptation_sets.js +3 -5
  118. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_mpd.d.ts +0 -2
  119. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_mpd.js +1 -1
  120. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_periods.js +2 -2
  121. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representation_index.d.ts +0 -2
  122. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representation_index.js +2 -2
  123. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/AdaptationSet.js +10 -6
  124. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/Representation.js +4 -2
  125. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/utils.d.ts +10 -1
  126. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/utils.js +18 -2
  127. package/dist/_esm5.processed/parsers/manifest/dash/node_parser_types.d.ts +4 -4
  128. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/AdaptationSet.js +3 -6
  129. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/Representation.js +1 -2
  130. package/dist/_esm5.processed/parsers/manifest/local/representation_index.d.ts +2 -0
  131. package/dist/_esm5.processed/parsers/manifest/local/representation_index.js +6 -0
  132. package/dist/_esm5.processed/parsers/manifest/metaplaylist/metaplaylist_parser.js +6 -6
  133. package/dist/_esm5.processed/parsers/manifest/metaplaylist/representation_index.d.ts +12 -3
  134. package/dist/_esm5.processed/parsers/manifest/metaplaylist/representation_index.js +11 -2
  135. package/dist/_esm5.processed/parsers/manifest/smooth/create_parser.d.ts +0 -1
  136. package/dist/_esm5.processed/parsers/manifest/smooth/create_parser.js +11 -17
  137. package/dist/_esm5.processed/parsers/manifest/smooth/representation_index.d.ts +21 -83
  138. package/dist/_esm5.processed/parsers/manifest/smooth/representation_index.js +53 -125
  139. package/dist/_esm5.processed/parsers/manifest/smooth/shared_smooth_segment_timeline.d.ts +119 -0
  140. package/dist/_esm5.processed/parsers/manifest/smooth/shared_smooth_segment_timeline.js +159 -0
  141. package/dist/_esm5.processed/parsers/manifest/smooth/utils/add_segment_infos.d.ts +3 -6
  142. package/dist/_esm5.processed/parsers/manifest/smooth/utils/add_segment_infos.js +4 -4
  143. package/dist/_esm5.processed/parsers/manifest/types.d.ts +3 -3
  144. package/dist/_esm5.processed/parsers/texttracks/ttml/html/apply_extent.js +1 -8
  145. package/dist/_esm5.processed/parsers/texttracks/ttml/html/apply_origin.js +1 -9
  146. package/dist/_esm5.processed/public_types.d.ts +396 -308
  147. package/dist/_esm5.processed/tools/TextTrackRenderer/text_track_renderer.d.ts +5 -4
  148. package/dist/_esm5.processed/tools/TextTrackRenderer/text_track_renderer.js +5 -4
  149. package/dist/_esm5.processed/transports/dash/add_segment_integrity_checks_to_loader.js +4 -4
  150. package/dist/_esm5.processed/transports/dash/manifest_parser.js +2 -3
  151. package/dist/_esm5.processed/transports/dash/pipelines.js +1 -4
  152. package/dist/_esm5.processed/transports/dash/segment_loader.d.ts +2 -2
  153. package/dist/_esm5.processed/transports/dash/segment_loader.js +26 -20
  154. package/dist/_esm5.processed/transports/dash/segment_parser.js +19 -24
  155. package/dist/_esm5.processed/transports/dash/text_loader.js +5 -5
  156. package/dist/_esm5.processed/transports/dash/text_parser.js +28 -33
  157. package/dist/_esm5.processed/transports/local/pipelines.js +1 -10
  158. package/dist/_esm5.processed/transports/local/segment_loader.js +2 -2
  159. package/dist/_esm5.processed/transports/local/segment_parser.d.ts +1 -1
  160. package/dist/_esm5.processed/transports/local/segment_parser.js +10 -10
  161. package/dist/_esm5.processed/transports/local/text_parser.d.ts +2 -2
  162. package/dist/_esm5.processed/transports/local/text_parser.js +23 -23
  163. package/dist/_esm5.processed/transports/metaplaylist/pipelines.js +34 -52
  164. package/dist/_esm5.processed/{utils/list_to_map.d.ts → transports/smooth/is_mp4_embedded_track.d.ts} +5 -5
  165. package/dist/_esm5.processed/{features/list/image_buffer.d.ts → transports/smooth/is_mp4_embedded_track.js} +7 -6
  166. package/dist/_esm5.processed/transports/smooth/pipelines.js +33 -190
  167. package/dist/_esm5.processed/transports/smooth/segment_loader.d.ts +1 -1
  168. package/dist/_esm5.processed/transports/smooth/segment_loader.js +28 -22
  169. package/dist/_esm5.processed/transports/smooth/utils.d.ts +1 -26
  170. package/dist/_esm5.processed/transports/smooth/utils.js +1 -55
  171. package/dist/_esm5.processed/transports/types.d.ts +94 -89
  172. package/dist/_esm5.processed/transports/utils/call_custom_manifest_loader.js +3 -3
  173. package/dist/_esm5.processed/transports/utils/infer_segment_container.d.ts +3 -3
  174. package/dist/_esm5.processed/transports/utils/infer_segment_container.js +5 -7
  175. package/dist/_esm5.processed/transports/utils/parse_text_track.d.ts +8 -12
  176. package/dist/_esm5.processed/transports/utils/parse_text_track.js +19 -21
  177. package/dist/_esm5.processed/utils/array_includes.d.ts +2 -1
  178. package/dist/_esm5.processed/utils/array_includes.js +30 -28
  179. package/dist/_esm5.processed/utils/request/xhr.js +5 -5
  180. package/dist/commonjs/compat/is_codec_supported.js +22 -1
  181. package/dist/commonjs/config.d.ts +1 -0
  182. package/dist/commonjs/core/api/debug/buffer_graph.js +2 -6
  183. package/dist/commonjs/core/api/debug/modules/general_info.js +17 -10
  184. package/dist/commonjs/core/api/option_utils.d.ts +2 -0
  185. package/dist/commonjs/core/api/option_utils.js +2 -3
  186. package/dist/commonjs/core/api/public_api.d.ts +9 -0
  187. package/dist/commonjs/core/api/public_api.js +34 -9
  188. package/dist/commonjs/core/fetchers/manifest/manifest_fetcher.d.ts +6 -0
  189. package/dist/commonjs/core/fetchers/manifest/manifest_fetcher.js +11 -3
  190. package/dist/commonjs/core/fetchers/segment/segment_fetcher.d.ts +8 -1
  191. package/dist/commonjs/core/fetchers/segment/segment_fetcher.js +8 -4
  192. package/dist/commonjs/core/fetchers/segment/segment_fetcher_creator.d.ts +1 -0
  193. package/dist/commonjs/core/fetchers/utils/schedule_request.js +1 -1
  194. package/dist/commonjs/core/init/directfile_content_initializer.js +24 -7
  195. package/dist/commonjs/core/init/media_source_content_initializer.d.ts +6 -0
  196. package/dist/commonjs/core/init/media_source_content_initializer.js +4 -6
  197. package/dist/commonjs/core/init/utils/content_time_boundaries_observer.d.ts +13 -12
  198. package/dist/commonjs/core/init/utils/content_time_boundaries_observer.js +16 -17
  199. package/dist/commonjs/core/init/utils/get_initial_time.d.ts +17 -3
  200. package/dist/commonjs/core/init/utils/get_initial_time.js +9 -7
  201. package/dist/commonjs/core/stream/representation/utils/get_buffer_status.js +3 -3
  202. package/dist/commonjs/core/stream/representation/utils/get_needed_segments.js +1 -1
  203. package/dist/commonjs/default_config.d.ts +5 -0
  204. package/dist/commonjs/default_config.js +5 -0
  205. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +3 -1
  206. package/dist/commonjs/experimental/tools/createMetaplaylist/get_duration_from_manifest.js +2 -0
  207. package/dist/commonjs/manifest/representation_index/static.d.ts +1 -1
  208. package/dist/commonjs/manifest/representation_index/static.js +2 -2
  209. package/dist/commonjs/manifest/representation_index/types.d.ts +4 -4
  210. package/dist/commonjs/parsers/manifest/dash/common/indexes/base.d.ts +6 -1
  211. package/dist/commonjs/parsers/manifest/dash/common/indexes/base.js +4 -3
  212. package/dist/commonjs/parsers/manifest/dash/common/indexes/get_segments_from_timeline.d.ts +5 -2
  213. package/dist/commonjs/parsers/manifest/dash/common/indexes/get_segments_from_timeline.js +15 -4
  214. package/dist/commonjs/parsers/manifest/dash/common/indexes/index.d.ts +5 -5
  215. package/dist/commonjs/parsers/manifest/dash/common/indexes/list.d.ts +1 -1
  216. package/dist/commonjs/parsers/manifest/dash/common/indexes/list.js +2 -2
  217. package/dist/commonjs/parsers/manifest/dash/common/indexes/template.d.ts +12 -5
  218. package/dist/commonjs/parsers/manifest/dash/common/indexes/template.js +42 -29
  219. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/index.d.ts +2 -1
  220. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts +99 -6
  221. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +250 -51
  222. package/dist/commonjs/parsers/manifest/dash/common/manifest_bounds_calculator.d.ts +40 -17
  223. package/dist/commonjs/parsers/manifest/dash/common/manifest_bounds_calculator.js +38 -18
  224. package/dist/commonjs/parsers/manifest/dash/common/parse_adaptation_sets.js +13 -10
  225. package/dist/commonjs/parsers/manifest/dash/common/parse_mpd.js +27 -14
  226. package/dist/commonjs/parsers/manifest/dash/common/parse_periods.d.ts +1 -1
  227. package/dist/commonjs/parsers/manifest/dash/common/parse_periods.js +17 -18
  228. package/dist/commonjs/parsers/manifest/dash/common/parse_representation_index.d.ts +19 -6
  229. package/dist/commonjs/parsers/manifest/dash/common/parse_representation_index.js +21 -8
  230. package/dist/commonjs/parsers/manifest/dash/common/parse_representations.js +7 -3
  231. package/dist/commonjs/parsers/manifest/local/representation_index.d.ts +1 -1
  232. package/dist/commonjs/parsers/manifest/local/representation_index.js +3 -3
  233. package/dist/commonjs/parsers/manifest/metaplaylist/representation_index.d.ts +1 -1
  234. package/dist/commonjs/parsers/manifest/metaplaylist/representation_index.js +2 -2
  235. package/dist/commonjs/parsers/manifest/smooth/representation_index.d.ts +5 -5
  236. package/dist/commonjs/parsers/manifest/smooth/representation_index.js +25 -9
  237. package/dist/commonjs/parsers/manifest/utils/index_helpers.js +1 -1
  238. package/dist/commonjs/public_types.d.ts +78 -34
  239. package/dist/commonjs/transports/dash/init_segment_loader.js +10 -5
  240. package/dist/commonjs/transports/dash/manifest_parser.js +5 -2
  241. package/dist/commonjs/transports/dash/segment_loader.js +2 -1
  242. package/dist/commonjs/transports/dash/text_loader.js +2 -0
  243. package/dist/commonjs/transports/metaplaylist/manifest_loader.js +2 -1
  244. package/dist/commonjs/transports/metaplaylist/pipelines.js +4 -1
  245. package/dist/commonjs/transports/smooth/pipelines.js +4 -2
  246. package/dist/commonjs/transports/smooth/segment_loader.js +2 -1
  247. package/dist/commonjs/transports/types.d.ts +12 -0
  248. package/dist/commonjs/transports/utils/generate_manifest_loader.js +6 -3
  249. package/dist/commonjs/utils/request/fetch.d.ts +6 -0
  250. package/dist/commonjs/utils/request/fetch.js +29 -8
  251. package/dist/commonjs/utils/request/xhr.d.ts +11 -5
  252. package/dist/commonjs/utils/request/xhr.js +29 -8
  253. package/dist/es2017/compat/is_codec_supported.js +22 -1
  254. package/dist/es2017/config.d.ts +1 -0
  255. package/dist/es2017/core/api/debug/buffer_graph.js +2 -6
  256. package/dist/es2017/core/api/debug/modules/general_info.js +17 -10
  257. package/dist/es2017/core/api/option_utils.d.ts +2 -0
  258. package/dist/es2017/core/api/option_utils.js +2 -3
  259. package/dist/es2017/core/api/public_api.d.ts +9 -0
  260. package/dist/es2017/core/api/public_api.js +33 -8
  261. package/dist/es2017/core/fetchers/manifest/manifest_fetcher.d.ts +6 -0
  262. package/dist/es2017/core/fetchers/manifest/manifest_fetcher.js +11 -3
  263. package/dist/es2017/core/fetchers/segment/segment_fetcher.d.ts +8 -1
  264. package/dist/es2017/core/fetchers/segment/segment_fetcher.js +8 -4
  265. package/dist/es2017/core/fetchers/segment/segment_fetcher_creator.d.ts +1 -0
  266. package/dist/es2017/core/fetchers/utils/schedule_request.js +1 -1
  267. package/dist/es2017/core/init/directfile_content_initializer.js +24 -7
  268. package/dist/es2017/core/init/media_source_content_initializer.d.ts +6 -0
  269. package/dist/es2017/core/init/media_source_content_initializer.js +4 -6
  270. package/dist/es2017/core/init/utils/content_time_boundaries_observer.d.ts +13 -12
  271. package/dist/es2017/core/init/utils/content_time_boundaries_observer.js +16 -15
  272. package/dist/es2017/core/init/utils/get_initial_time.d.ts +17 -3
  273. package/dist/es2017/core/init/utils/get_initial_time.js +9 -7
  274. package/dist/es2017/core/stream/representation/utils/get_buffer_status.js +3 -3
  275. package/dist/es2017/core/stream/representation/utils/get_needed_segments.js +1 -1
  276. package/dist/es2017/default_config.d.ts +5 -0
  277. package/dist/es2017/default_config.js +5 -0
  278. package/dist/es2017/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +3 -1
  279. package/dist/es2017/experimental/tools/createMetaplaylist/get_duration_from_manifest.js +2 -0
  280. package/dist/es2017/manifest/representation_index/static.d.ts +1 -1
  281. package/dist/es2017/manifest/representation_index/static.js +2 -2
  282. package/dist/es2017/manifest/representation_index/types.d.ts +4 -4
  283. package/dist/es2017/parsers/manifest/dash/common/indexes/base.d.ts +6 -1
  284. package/dist/es2017/parsers/manifest/dash/common/indexes/base.js +4 -3
  285. package/dist/es2017/parsers/manifest/dash/common/indexes/get_segments_from_timeline.d.ts +5 -2
  286. package/dist/es2017/parsers/manifest/dash/common/indexes/get_segments_from_timeline.js +15 -4
  287. package/dist/es2017/parsers/manifest/dash/common/indexes/index.d.ts +5 -5
  288. package/dist/es2017/parsers/manifest/dash/common/indexes/list.d.ts +1 -1
  289. package/dist/es2017/parsers/manifest/dash/common/indexes/list.js +2 -2
  290. package/dist/es2017/parsers/manifest/dash/common/indexes/template.d.ts +12 -5
  291. package/dist/es2017/parsers/manifest/dash/common/indexes/template.js +40 -27
  292. package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/index.d.ts +2 -1
  293. package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts +99 -6
  294. package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +246 -51
  295. package/dist/es2017/parsers/manifest/dash/common/manifest_bounds_calculator.d.ts +40 -17
  296. package/dist/es2017/parsers/manifest/dash/common/manifest_bounds_calculator.js +38 -18
  297. package/dist/es2017/parsers/manifest/dash/common/parse_adaptation_sets.js +11 -8
  298. package/dist/es2017/parsers/manifest/dash/common/parse_mpd.js +27 -13
  299. package/dist/es2017/parsers/manifest/dash/common/parse_periods.d.ts +1 -1
  300. package/dist/es2017/parsers/manifest/dash/common/parse_periods.js +13 -16
  301. package/dist/es2017/parsers/manifest/dash/common/parse_representation_index.d.ts +19 -6
  302. package/dist/es2017/parsers/manifest/dash/common/parse_representation_index.js +10 -8
  303. package/dist/es2017/parsers/manifest/dash/common/parse_representations.js +7 -3
  304. package/dist/es2017/parsers/manifest/local/representation_index.d.ts +1 -1
  305. package/dist/es2017/parsers/manifest/local/representation_index.js +3 -3
  306. package/dist/es2017/parsers/manifest/metaplaylist/representation_index.d.ts +1 -1
  307. package/dist/es2017/parsers/manifest/metaplaylist/representation_index.js +2 -2
  308. package/dist/es2017/parsers/manifest/smooth/representation_index.d.ts +5 -5
  309. package/dist/es2017/parsers/manifest/smooth/representation_index.js +25 -9
  310. package/dist/es2017/parsers/manifest/utils/index_helpers.js +1 -1
  311. package/dist/es2017/public_types.d.ts +78 -34
  312. package/dist/es2017/transports/dash/init_segment_loader.js +5 -0
  313. package/dist/es2017/transports/dash/manifest_parser.js +3 -0
  314. package/dist/es2017/transports/dash/segment_loader.js +1 -0
  315. package/dist/es2017/transports/dash/text_loader.js +2 -0
  316. package/dist/es2017/transports/metaplaylist/manifest_loader.js +1 -0
  317. package/dist/es2017/transports/metaplaylist/pipelines.js +4 -1
  318. package/dist/es2017/transports/smooth/pipelines.js +2 -0
  319. package/dist/es2017/transports/smooth/segment_loader.js +1 -0
  320. package/dist/es2017/transports/types.d.ts +12 -0
  321. package/dist/es2017/transports/utils/generate_manifest_loader.js +3 -0
  322. package/dist/es2017/utils/request/fetch.d.ts +6 -0
  323. package/dist/es2017/utils/request/fetch.js +29 -8
  324. package/dist/es2017/utils/request/xhr.d.ts +11 -5
  325. package/dist/es2017/utils/request/xhr.js +30 -9
  326. package/dist/rx-player.js +723 -376
  327. package/dist/rx-player.min.js +1 -1
  328. package/package.json +3 -4
  329. package/scripts/update-version +2 -0
  330. package/sonar-project.properties +1 -1
  331. package/src/compat/is_codec_supported.ts +23 -1
  332. package/src/core/api/debug/buffer_graph.ts +2 -5
  333. package/src/core/api/debug/modules/general_info.ts +15 -10
  334. package/src/core/api/option_utils.ts +3 -3
  335. package/src/core/api/public_api.ts +35 -7
  336. package/src/core/fetchers/manifest/manifest_fetcher.ts +21 -3
  337. package/src/core/fetchers/segment/segment_fetcher.ts +19 -5
  338. package/src/core/fetchers/segment/segment_fetcher_creator.ts +1 -0
  339. package/src/core/fetchers/utils/schedule_request.ts +1 -1
  340. package/src/core/init/directfile_content_initializer.ts +23 -7
  341. package/src/core/init/media_source_content_initializer.ts +13 -7
  342. package/src/core/init/utils/content_time_boundaries_observer.ts +23 -22
  343. package/src/core/init/utils/get_initial_time.ts +25 -12
  344. package/src/core/stream/representation/utils/get_buffer_status.ts +3 -3
  345. package/src/core/stream/representation/utils/get_needed_segments.ts +2 -2
  346. package/src/default_config.ts +5 -0
  347. package/src/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.ts +3 -1
  348. package/src/experimental/tools/createMetaplaylist/get_duration_from_manifest.ts +2 -0
  349. package/src/manifest/representation_index/static.ts +2 -2
  350. package/src/manifest/representation_index/types.ts +4 -4
  351. package/src/parsers/manifest/dash/common/__tests__/manifest_bounds_calculator.test.ts +182 -36
  352. package/src/parsers/manifest/dash/common/indexes/base.ts +12 -4
  353. package/src/parsers/manifest/dash/common/indexes/get_segments_from_timeline.ts +19 -5
  354. package/src/parsers/manifest/dash/common/indexes/index.ts +16 -4
  355. package/src/parsers/manifest/dash/common/indexes/list.ts +2 -2
  356. package/src/parsers/manifest/dash/common/indexes/template.ts +52 -31
  357. package/src/parsers/manifest/dash/common/indexes/timeline/index.ts +4 -1
  358. package/src/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.ts +366 -60
  359. package/src/parsers/manifest/dash/common/manifest_bounds_calculator.ts +63 -25
  360. package/src/parsers/manifest/dash/common/parse_adaptation_sets.ts +10 -4
  361. package/src/parsers/manifest/dash/common/parse_mpd.ts +28 -15
  362. package/src/parsers/manifest/dash/common/parse_periods.ts +12 -17
  363. package/src/parsers/manifest/dash/common/parse_representation_index.ts +50 -26
  364. package/src/parsers/manifest/dash/common/parse_representations.ts +9 -3
  365. package/src/parsers/manifest/local/representation_index.ts +3 -3
  366. package/src/parsers/manifest/metaplaylist/representation_index.ts +2 -2
  367. package/src/parsers/manifest/smooth/representation_index.ts +23 -9
  368. package/src/parsers/manifest/utils/__tests__/get_first_time_from_adaptations.test.ts +1 -1
  369. package/src/parsers/manifest/utils/__tests__/get_last_time_from_adaptation.test.ts +1 -1
  370. package/src/parsers/manifest/utils/index_helpers.ts +1 -1
  371. package/src/public_types.ts +79 -34
  372. package/src/transports/dash/init_segment_loader.ts +5 -0
  373. package/src/transports/dash/manifest_parser.ts +6 -0
  374. package/src/transports/dash/segment_loader.ts +1 -0
  375. package/src/transports/dash/text_loader.ts +2 -0
  376. package/src/transports/metaplaylist/manifest_loader.ts +1 -0
  377. package/src/transports/metaplaylist/pipelines.ts +4 -1
  378. package/src/transports/smooth/pipelines.ts +2 -0
  379. package/src/transports/smooth/segment_loader.ts +1 -0
  380. package/src/transports/types.ts +12 -0
  381. package/src/transports/utils/generate_manifest_loader.ts +3 -0
  382. package/src/utils/request/fetch.ts +35 -8
  383. package/src/utils/request/xhr.ts +45 -14
  384. package/dist/_esm5.processed/compat/fullscreen.d.ts +0 -32
  385. package/dist/_esm5.processed/compat/fullscreen.js +0 -78
  386. package/dist/_esm5.processed/compat/is_offline.d.ts +0 -39
  387. package/dist/_esm5.processed/compat/is_offline.js +0 -43
  388. package/dist/_esm5.processed/core/api/tracks_management/track_choice_manager.d.ts +0 -258
  389. package/dist/_esm5.processed/core/api/tracks_management/track_choice_manager.js +0 -989
  390. package/dist/_esm5.processed/core/segment_buffers/implementations/image/image_segment_buffer.d.ts +0 -75
  391. package/dist/_esm5.processed/core/segment_buffers/implementations/image/image_segment_buffer.js +0 -133
  392. package/dist/_esm5.processed/features/list/bif_parser.d.ts +0 -23
  393. package/dist/_esm5.processed/features/list/bif_parser.js +0 -27
  394. package/dist/_esm5.processed/features/list/image_buffer.js +0 -25
  395. package/dist/_esm5.processed/transports/dash/image_pipelines.d.ts +0 -38
  396. package/dist/_esm5.processed/transports/dash/image_pipelines.js +0 -129
  397. package/dist/_esm5.processed/utils/list_to_map.js +0 -28
  398. package/dist/_esm5.processed/utils/simple_set.d.ts +0 -51
  399. package/dist/_esm5.processed/utils/simple_set.js +0 -57
  400. package/dist/_esm5.processed/utils/uniq.d.ts +0 -36
  401. package/dist/_esm5.processed/utils/uniq.js +0 -43
  402. package/dist/commonjs/parsers/manifest/utils/is_segment_still_available.d.ts +0 -29
  403. package/dist/commonjs/parsers/manifest/utils/is_segment_still_available.js +0 -54
  404. package/dist/es2017/parsers/manifest/utils/is_segment_still_available.d.ts +0 -29
  405. package/dist/es2017/parsers/manifest/utils/is_segment_still_available.js +0 -51
  406. package/src/parsers/manifest/utils/is_segment_still_available.ts +0 -58
  407. package/src/typings/object-assign.d.ts +0 -48
package/dist/rx-player.js CHANGED
@@ -535,6 +535,11 @@ var DEFAULT_CONFIG = {
535
535
  * @type {Number}
536
536
  */
537
537
  DEFAULT_REQUEST_TIMEOUT: 30 * 1000,
538
+ /**
539
+ * Default connection time after which a request will timeout, in ms.
540
+ * @type {Number}
541
+ */
542
+ DEFAULT_CONNECTION_TIMEOUT: 15 * 1000,
538
543
  /**
539
544
  * Can be either:
540
545
  * - "native": Subtitles are all displayed in a <track> element
@@ -5215,8 +5220,7 @@ function parseLoadVideoOptions(options) {
5215
5220
  src_log.warn("API: You have set a textTrackElement without being in " + "an \"html\" textTrackMode. It will be ignored.");
5216
5221
  }
5217
5222
  if (!is_null_or_undefined_isNullOrUndefined(options.startAt)) {
5218
- // TODO Better way to express that in TypeScript?
5219
- if (options.startAt.wallClockTime instanceof Date) {
5223
+ if ("wallClockTime" in options.startAt && options.startAt.wallClockTime instanceof Date) {
5220
5224
  var wallClockTime = options.startAt.wallClockTime.getTime() / 1000;
5221
5225
  startAt = object_assign({}, options.startAt, {
5222
5226
  wallClockTime: wallClockTime
@@ -7299,7 +7303,7 @@ var Player = /*#__PURE__*/function (_EventEmitter) {
7299
7303
  // Workaround to support Firefox autoplay on FF 42.
7300
7304
  // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1194624
7301
7305
  videoElement.preload = "auto";
7302
- _this.version = /* PLAYER_VERSION */"4.0.0-dev.2023111400";
7306
+ _this.version = /* PLAYER_VERSION */"4.0.0-dev.2023120600";
7303
7307
  _this.log = src_log;
7304
7308
  _this.state = "STOPPED";
7305
7309
  _this.videoElement = videoElement;
@@ -7470,7 +7474,7 @@ var Player = /*#__PURE__*/function (_EventEmitter) {
7470
7474
  */;
7471
7475
  _proto._priv_initializeContentPlayback = function _priv_initializeContentPlayback(options) {
7472
7476
  var _this2 = this;
7473
- var _a, _b, _c, _d;
7477
+ var _a, _b, _c, _d, _e, _f;
7474
7478
  var autoPlay = options.autoPlay,
7475
7479
  defaultAudioTrackSwitchingMode = options.defaultAudioTrackSwitchingMode,
7476
7480
  enableFastSwitching = options.enableFastSwitching,
@@ -7528,6 +7532,7 @@ var Player = /*#__PURE__*/function (_EventEmitter) {
7528
7532
  lowLatencyMode: lowLatencyMode,
7529
7533
  maxRetry: (_a = requestConfig.manifest) === null || _a === void 0 ? void 0 : _a.maxRetry,
7530
7534
  requestTimeout: (_b = requestConfig.manifest) === null || _b === void 0 ? void 0 : _b.timeout,
7535
+ connectionTimeout: (_c = requestConfig.manifest) === null || _c === void 0 ? void 0 : _c.connectionTimeout,
7531
7536
  minimumManifestUpdateInterval: minimumManifestUpdateInterval,
7532
7537
  initialManifest: initialManifest
7533
7538
  };
@@ -7579,8 +7584,9 @@ var Player = /*#__PURE__*/function (_EventEmitter) {
7579
7584
  }, this._priv_bufferOptions);
7580
7585
  var segmentRequestOptions = {
7581
7586
  lowLatencyMode: lowLatencyMode,
7582
- maxRetry: (_c = requestConfig.segment) === null || _c === void 0 ? void 0 : _c.maxRetry,
7583
- requestTimeout: (_d = requestConfig.segment) === null || _d === void 0 ? void 0 : _d.timeout
7587
+ maxRetry: (_d = requestConfig.segment) === null || _d === void 0 ? void 0 : _d.maxRetry,
7588
+ requestTimeout: (_e = requestConfig.segment) === null || _e === void 0 ? void 0 : _e.timeout,
7589
+ connectionTimeout: (_f = requestConfig.segment) === null || _f === void 0 ? void 0 : _f.connectionTimeout
7584
7590
  };
7585
7591
  initializer = new src_features.mediaSourceInit({
7586
7592
  adaptiveOptions: adaptiveOptions,
@@ -8807,16 +8813,39 @@ var Player = /*#__PURE__*/function (_EventEmitter) {
8807
8813
  return null;
8808
8814
  }
8809
8815
  /**
8810
- * Get maximum seek-able position.
8816
+ * Returns the current position for live contents.
8817
+ *
8818
+ * Returns `null` if no content is loaded or if the current loaded content is
8819
+ * not considered as a live content.
8820
+ * Returns `undefined` if that live position is currently unknown.
8811
8821
  * @returns {number}
8812
8822
  */;
8813
- _proto.getMaximumPosition = function getMaximumPosition() {
8823
+ _proto.getLivePosition = function getLivePosition() {
8814
8824
  if (this._priv_contentInfos === null) {
8815
8825
  return null;
8816
8826
  }
8817
8827
  var _this$_priv_contentIn17 = this._priv_contentInfos,
8818
8828
  isDirectFile = _this$_priv_contentIn17.isDirectFile,
8819
8829
  manifest = _this$_priv_contentIn17.manifest;
8830
+ if (isDirectFile) {
8831
+ return undefined;
8832
+ }
8833
+ if ((manifest === null || manifest === void 0 ? void 0 : manifest.isLive) !== true) {
8834
+ return null;
8835
+ }
8836
+ return manifest.getLivePosition();
8837
+ }
8838
+ /**
8839
+ * Get maximum seek-able position.
8840
+ * @returns {number}
8841
+ */;
8842
+ _proto.getMaximumPosition = function getMaximumPosition() {
8843
+ if (this._priv_contentInfos === null) {
8844
+ return null;
8845
+ }
8846
+ var _this$_priv_contentIn18 = this._priv_contentInfos,
8847
+ isDirectFile = _this$_priv_contentIn18.isDirectFile,
8848
+ manifest = _this$_priv_contentIn18.manifest;
8820
8849
  if (isDirectFile) {
8821
8850
  if (this.videoElement === null) {
8822
8851
  throw new Error("Disposed player");
@@ -8850,7 +8879,11 @@ var Player = /*#__PURE__*/function (_EventEmitter) {
8850
8879
  return null;
8851
8880
  }
8852
8881
  var segmentBufferStatus = this._priv_contentInfos.segmentBuffersStore.getStatus(bufferType);
8853
- return segmentBufferStatus.type === "initialized" ? segmentBufferStatus.value.getInventory() : null;
8882
+ if (segmentBufferStatus.type === "initialized") {
8883
+ segmentBufferStatus.value.synchronizeInventory();
8884
+ return segmentBufferStatus.value.getInventory();
8885
+ }
8886
+ return null;
8854
8887
  }
8855
8888
  /**
8856
8889
  * /!\ For tools use only! Do not touch!
@@ -8873,9 +8906,9 @@ var Player = /*#__PURE__*/function (_EventEmitter) {
8873
8906
  if (this._priv_contentInfos === null) {
8874
8907
  return null;
8875
8908
  }
8876
- var _this$_priv_contentIn18 = this._priv_contentInfos,
8877
- currentPeriod = _this$_priv_contentIn18.currentPeriod,
8878
- activeAdaptations = _this$_priv_contentIn18.activeAdaptations;
8909
+ var _this$_priv_contentIn19 = this._priv_contentInfos,
8910
+ currentPeriod = _this$_priv_contentIn19.currentPeriod,
8911
+ activeAdaptations = _this$_priv_contentIn19.activeAdaptations;
8879
8912
  if (currentPeriod === null || activeAdaptations === null || is_null_or_undefined_isNullOrUndefined(activeAdaptations[currentPeriod.id])) {
8880
8913
  return null;
8881
8914
  }
@@ -8887,9 +8920,9 @@ var Player = /*#__PURE__*/function (_EventEmitter) {
8887
8920
  if (this._priv_contentInfos === null) {
8888
8921
  return null;
8889
8922
  }
8890
- var _this$_priv_contentIn19 = this._priv_contentInfos,
8891
- currentPeriod = _this$_priv_contentIn19.currentPeriod,
8892
- activeRepresentations = _this$_priv_contentIn19.activeRepresentations;
8923
+ var _this$_priv_contentIn20 = this._priv_contentInfos,
8924
+ currentPeriod = _this$_priv_contentIn20.currentPeriod,
8925
+ activeRepresentations = _this$_priv_contentIn20.activeRepresentations;
8893
8926
  if (currentPeriod === null || activeRepresentations === null || is_null_or_undefined_isNullOrUndefined(activeRepresentations[currentPeriod.id])) {
8894
8927
  return null;
8895
8928
  }
@@ -9506,7 +9539,7 @@ var Player = /*#__PURE__*/function (_EventEmitter) {
9506
9539
  }]);
9507
9540
  return Player;
9508
9541
  }(EventEmitter);
9509
- Player.version = /* PLAYER_VERSION */"4.0.0-dev.2023111400";
9542
+ Player.version = /* PLAYER_VERSION */"4.0.0-dev.2023120600";
9510
9543
  /* harmony default export */ var public_api = (Player);
9511
9544
  ;// CONCATENATED MODULE: ./src/core/api/index.ts
9512
9545
  /**
@@ -11868,6 +11901,16 @@ var READY_STATES = {
11868
11901
  * limitations under the License.
11869
11902
  */
11870
11903
 
11904
+ /**
11905
+ * Setting this value limit the number of entries in the support map
11906
+ * preventing important memory usage, value is arbitrary
11907
+ */
11908
+ var MAX_SUPPORT_MAP_ENTRIES = 200;
11909
+ /**
11910
+ * caching the codec support reduce the amount of call to `isTypeSupported`
11911
+ * and help for performance especially on low-end devices.
11912
+ */
11913
+ var supportMap = new Map();
11871
11914
  /**
11872
11915
  * Returns true if the given codec is supported by the browser's MediaSource
11873
11916
  * implementation.
@@ -11884,7 +11927,17 @@ function isCodecSupported(mimeType) {
11884
11927
  /* eslint-disable @typescript-eslint/unbound-method */
11885
11928
  if (typeof MediaSource_.isTypeSupported === "function") {
11886
11929
  /* eslint-enable @typescript-eslint/unbound-method */
11887
- return MediaSource_.isTypeSupported(mimeType);
11930
+ var cachedSupport = supportMap.get(mimeType);
11931
+ if (cachedSupport !== undefined) {
11932
+ return cachedSupport;
11933
+ } else {
11934
+ var isSupported = MediaSource_.isTypeSupported(mimeType);
11935
+ if (supportMap.size >= MAX_SUPPORT_MAP_ENTRIES) {
11936
+ supportMap.clear();
11937
+ }
11938
+ supportMap.set(mimeType, isSupported);
11939
+ return isSupported;
11940
+ }
11888
11941
  }
11889
11942
  return true;
11890
11943
  }
@@ -13938,7 +13991,6 @@ function manifest_fetcher_arrayLikeToArray(arr, len) { if (len == null || len >
13938
13991
 
13939
13992
 
13940
13993
 
13941
-
13942
13994
  /**
13943
13995
  * Class allowing to facilitate the task of loading and parsing a Manifest, as
13944
13996
  * well as automatically refreshing it.
@@ -14063,13 +14115,18 @@ var ManifestFetcher = /*#__PURE__*/function (_EventEmitter) {
14063
14115
  case 0:
14064
14116
  callLoaderWithRetries = function _callLoaderWithRetrie(manifestUrl) {
14065
14117
  var loadManifest = pipelines.loadManifest;
14066
- var requestTimeout = is_null_or_undefined_isNullOrUndefined(settings.requestTimeout) ? config.getCurrent().DEFAULT_REQUEST_TIMEOUT : settings.requestTimeout;
14118
+ var requestTimeout = settings.requestTimeout === undefined ? config.getCurrent().DEFAULT_REQUEST_TIMEOUT : settings.requestTimeout;
14119
+ var connectionTimeout = settings.connectionTimeout === undefined ? config.getCurrent().DEFAULT_CONNECTION_TIMEOUT : settings.connectionTimeout;
14067
14120
  if (requestTimeout < 0) {
14068
14121
  requestTimeout = undefined;
14069
14122
  }
14123
+ if (connectionTimeout < 0) {
14124
+ connectionTimeout = undefined;
14125
+ }
14070
14126
  var callLoader = function callLoader() {
14071
14127
  return loadManifest(manifestUrl, {
14072
- timeout: requestTimeout
14128
+ timeout: requestTimeout,
14129
+ connectionTimeout: connectionTimeout
14073
14130
  }, cancelSignal);
14074
14131
  };
14075
14132
  return scheduleRequestPromise(callLoader, backoffSettings, cancelSignal);
@@ -14925,7 +14982,8 @@ var generateRequestID = idGenerator();
14925
14982
  */
14926
14983
  function segment_fetcher_createSegmentFetcher(bufferType, pipeline, cdnPrioritizer, lifecycleCallbacks, options) {
14927
14984
  var requestOptions = {
14928
- timeout: options.requestTimeout < 0 ? undefined : options.requestTimeout
14985
+ timeout: options.requestTimeout < 0 ? undefined : options.requestTimeout,
14986
+ connectionTimeout: options.connectionTimeout === undefined ? undefined : options.connectionTimeout < 0 ? undefined : options.connectionTimeout
14929
14987
  };
14930
14988
  /**
14931
14989
  * Cache audio and video initialization segments.
@@ -15168,17 +15226,20 @@ function segment_fetcher_createSegmentFetcher(bufferType, pipeline, cdnPrioritiz
15168
15226
  function getSegmentFetcherOptions(_ref) {
15169
15227
  var maxRetry = _ref.maxRetry,
15170
15228
  lowLatencyMode = _ref.lowLatencyMode,
15171
- requestTimeout = _ref.requestTimeout;
15229
+ requestTimeout = _ref.requestTimeout,
15230
+ connectionTimeout = _ref.connectionTimeout;
15172
15231
  var _config$getCurrent = config.getCurrent(),
15173
15232
  DEFAULT_MAX_REQUESTS_RETRY_ON_ERROR = _config$getCurrent.DEFAULT_MAX_REQUESTS_RETRY_ON_ERROR,
15174
15233
  DEFAULT_REQUEST_TIMEOUT = _config$getCurrent.DEFAULT_REQUEST_TIMEOUT,
15234
+ DEFAULT_CONNECTION_TIMEOUT = _config$getCurrent.DEFAULT_CONNECTION_TIMEOUT,
15175
15235
  INITIAL_BACKOFF_DELAY_BASE = _config$getCurrent.INITIAL_BACKOFF_DELAY_BASE,
15176
15236
  MAX_BACKOFF_DELAY_BASE = _config$getCurrent.MAX_BACKOFF_DELAY_BASE;
15177
15237
  return {
15178
15238
  maxRetry: maxRetry !== null && maxRetry !== void 0 ? maxRetry : DEFAULT_MAX_REQUESTS_RETRY_ON_ERROR,
15179
15239
  baseDelay: lowLatencyMode ? INITIAL_BACKOFF_DELAY_BASE.LOW_LATENCY : INITIAL_BACKOFF_DELAY_BASE.REGULAR,
15180
15240
  maxDelay: lowLatencyMode ? MAX_BACKOFF_DELAY_BASE.LOW_LATENCY : MAX_BACKOFF_DELAY_BASE.REGULAR,
15181
- requestTimeout: is_null_or_undefined_isNullOrUndefined(requestTimeout) ? DEFAULT_REQUEST_TIMEOUT : requestTimeout
15241
+ requestTimeout: requestTimeout === undefined ? DEFAULT_REQUEST_TIMEOUT : requestTimeout,
15242
+ connectionTimeout: connectionTimeout === undefined ? DEFAULT_CONNECTION_TIMEOUT : connectionTimeout
15182
15243
  };
15183
15244
  }
15184
15245
  ;// CONCATENATED MODULE: ./src/core/fetchers/segment/task_prioritizer.ts
@@ -18883,7 +18944,7 @@ function doesEndSeemGarbageCollected(currentSeg, nextSeg, minimumEndTime) {
18883
18944
  return false;
18884
18945
  }
18885
18946
  if (minimumEndTime > currentSeg.bufferedEnd && currentSeg.end - currentSeg.bufferedEnd > MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT) {
18886
- src_log.info("Stream: The end of the wanted segment has been garbage collected", currentSeg.start, currentSeg.bufferedStart);
18947
+ src_log.info("Stream: The end of the wanted segment has been garbage collected", currentSeg.end, currentSeg.bufferedEnd);
18887
18948
  return true;
18888
18949
  }
18889
18950
  return false;
@@ -19107,7 +19168,7 @@ function getBufferStatus(content, initialWantedTime, playbackObserver, fastSwitc
19107
19168
  * `true` if the current `RepresentationStream` has loaded all the
19108
19169
  * needed segments for this Representation until the end of the Period.
19109
19170
  */
19110
- var hasFinishedLoading = representation.index.isInitialized() && representation.index.isFinished() && neededRange.hasReachedPeriodEnd && prioritizedNeededSegments.length === 0 && segmentsOnHold.length === 0;
19171
+ var hasFinishedLoading = representation.index.isInitialized() && !representation.index.isStillAwaitingFutureSegments() && neededRange.hasReachedPeriodEnd && prioritizedNeededSegments.length === 0 && segmentsOnHold.length === 0;
19111
19172
  /**
19112
19173
  * Start time in seconds of the next available not-yet pushed segment.
19113
19174
  * `null` if no segment is wanted for the current wanted range.
@@ -19156,14 +19217,14 @@ function getRangeOfNeededSegments(content, initialWantedTime, bufferGoal) {
19156
19217
  // In that case, we want to actually request at least the last segment to
19157
19218
  // avoid ending the last Period - and by extension the content - with a
19158
19219
  // segment which isn't the last one.
19159
- if (!is_null_or_undefined_isNullOrUndefined(lastIndexPosition) && segment_buffers.isNative(content.adaptation.type) && initialWantedTime >= lastIndexPosition && representationIndex.isInitialized() && representationIndex.isFinished() && isPeriodTheCurrentAndLastOne(manifest, period, initialWantedTime)) {
19220
+ if (!is_null_or_undefined_isNullOrUndefined(lastIndexPosition) && segment_buffers.isNative(content.adaptation.type) && initialWantedTime >= lastIndexPosition && representationIndex.isInitialized() && !representationIndex.isStillAwaitingFutureSegments() && isPeriodTheCurrentAndLastOne(manifest, period, initialWantedTime)) {
19160
19221
  wantedStartPosition = lastIndexPosition - 1;
19161
19222
  } else {
19162
19223
  wantedStartPosition = initialWantedTime - 0.1;
19163
19224
  }
19164
19225
  var wantedEndPosition = wantedStartPosition + bufferGoal;
19165
19226
  var hasReachedPeriodEnd;
19166
- if (!representation.index.isInitialized() || !representation.index.isFinished() || period.end === undefined) {
19227
+ if (!representation.index.isInitialized() || representation.index.isStillAwaitingFutureSegments() || period.end === undefined) {
19167
19228
  hasReachedPeriodEnd = false;
19168
19229
  } else if (lastIndexPosition === undefined) {
19169
19230
  // We do not know the end of this index.
@@ -22270,8 +22331,8 @@ function content_time_boundaries_observer_arrayLikeToArray(arr, len) { if (len =
22270
22331
  /**
22271
22332
  * Observes what's being played and take care of media events relating to time
22272
22333
  * boundaries:
22273
- * - Emits a `durationUpdate` when the duration of the current content is
22274
- * known and every time it changes.
22334
+ * - Emits a `endingPositionChange` when the known maximum playable position
22335
+ * of the current content is known and every time it changes.
22275
22336
  * - Emits `endOfStream` API once segments have been pushed until the end and
22276
22337
  * `resumeStream` if downloads starts back.
22277
22338
  * - Emits a `periodChange` event when the currently-playing Period seemed to
@@ -22317,7 +22378,7 @@ var ContentTimeBoundariesObserver = /*#__PURE__*/function (_EventEmitter) {
22317
22378
  clearSignal: cancelSignal
22318
22379
  });
22319
22380
  manifest.addEventListener("manifestUpdate", function () {
22320
- _this.trigger("durationUpdate", _this._getManifestDuration());
22381
+ _this.trigger("endingPositionChange", _this._getManifestEndTime());
22321
22382
  if (cancelSignal.isCancelled()) {
22322
22383
  return;
22323
22384
  }
@@ -22326,12 +22387,13 @@ var ContentTimeBoundariesObserver = /*#__PURE__*/function (_EventEmitter) {
22326
22387
  return _this;
22327
22388
  }
22328
22389
  /**
22329
- * Returns an estimate of the current duration of the content.
22390
+ * Returns an estimate of the current last position which may be played in
22391
+ * the content at the moment.
22330
22392
  * @returns {Object}
22331
22393
  */
22332
22394
  var _proto = ContentTimeBoundariesObserver.prototype;
22333
- _proto.getCurrentDuration = function getCurrentDuration() {
22334
- return this._getManifestDuration();
22395
+ _proto.getCurrentEndingTime = function getCurrentEndingTime() {
22396
+ return this._getManifestEndTime();
22335
22397
  }
22336
22398
  /**
22337
22399
  * Method to call any time an Adaptation has been selected.
@@ -22357,14 +22419,14 @@ var ContentTimeBoundariesObserver = /*#__PURE__*/function (_EventEmitter) {
22357
22419
  this._maximumPositionCalculator.updateLastVideoAdaptation(adaptation);
22358
22420
  }
22359
22421
  var endingPosition = this._maximumPositionCalculator.getEndingPosition();
22360
- var newDuration = endingPosition !== undefined ? {
22422
+ var newEndingPosition = endingPosition !== undefined ? {
22361
22423
  isEnd: true,
22362
- duration: endingPosition
22424
+ endingPosition: endingPosition
22363
22425
  } : {
22364
22426
  isEnd: false,
22365
- duration: this._maximumPositionCalculator.getMaximumAvailablePosition()
22427
+ endingPosition: this._maximumPositionCalculator.getMaximumAvailablePosition()
22366
22428
  };
22367
- this.trigger("durationUpdate", newDuration);
22429
+ this.trigger("endingPositionChange", newEndingPosition);
22368
22430
  }
22369
22431
  }
22370
22432
  }
@@ -22504,14 +22566,14 @@ var ContentTimeBoundariesObserver = /*#__PURE__*/function (_EventEmitter) {
22504
22566
  if (_ret) return _ret.v;
22505
22567
  }
22506
22568
  };
22507
- _proto._getManifestDuration = function _getManifestDuration() {
22569
+ _proto._getManifestEndTime = function _getManifestEndTime() {
22508
22570
  var endingPosition = this._maximumPositionCalculator.getEndingPosition();
22509
22571
  return endingPosition !== undefined ? {
22510
22572
  isEnd: true,
22511
- duration: endingPosition
22573
+ endingPosition: endingPosition
22512
22574
  } : {
22513
22575
  isEnd: false,
22514
- duration: this._maximumPositionCalculator.getMaximumAvailablePosition()
22576
+ endingPosition: this._maximumPositionCalculator.getMaximumAvailablePosition()
22515
22577
  };
22516
22578
  };
22517
22579
  _proto._lazilyCreateActiveStreamInfo = function _lazilyCreateActiveStreamInfo(bufferType) {
@@ -22588,9 +22650,8 @@ var MaximumPositionCalculator = /*#__PURE__*/function () {
22588
22650
  * @returns {number}
22589
22651
  */;
22590
22652
  _proto2.getMaximumAvailablePosition = function getMaximumAvailablePosition() {
22591
- var _a;
22592
22653
  if (this._manifest.isDynamic) {
22593
- return (_a = this._manifest.getLivePosition()) !== null && _a !== void 0 ? _a : this._manifest.getMaximumSafePosition();
22654
+ return this._manifest.getMaximumSafePosition();
22594
22655
  }
22595
22656
  if (this._lastVideoAdaptation === undefined || this._lastAudioAdaptation === undefined) {
22596
22657
  return this._manifest.getMaximumSafePosition();
@@ -23106,15 +23167,10 @@ function maintainEndOfStream(mediaSource, cancelSignal) {
23106
23167
  * @returns {Number}
23107
23168
  */
23108
23169
  function getInitialTime(manifest, lowLatencyMode, startAt) {
23170
+ var _a;
23109
23171
  if (!is_null_or_undefined_isNullOrUndefined(startAt)) {
23110
23172
  var min = manifest.getMinimumSafePosition();
23111
- var max;
23112
- if (manifest.isLive) {
23113
- max = manifest.getLivePosition();
23114
- }
23115
- if (max === undefined) {
23116
- max = manifest.getMaximumSafePosition();
23117
- }
23173
+ var max = manifest.getMaximumSafePosition();
23118
23174
  if (!is_null_or_undefined_isNullOrUndefined(startAt.position)) {
23119
23175
  src_log.debug("Init: using startAt.minimumPosition");
23120
23176
  return Math.max(Math.min(startAt.position, max), min);
@@ -23131,6 +23187,11 @@ function getInitialTime(manifest, lowLatencyMode, startAt) {
23131
23187
  src_log.debug("Init: using startAt.fromLastPosition");
23132
23188
  var fromLastPosition = startAt.fromLastPosition;
23133
23189
  return fromLastPosition >= 0 ? max : Math.max(min, max + fromLastPosition);
23190
+ } else if (!is_null_or_undefined_isNullOrUndefined(startAt.fromLivePosition)) {
23191
+ src_log.debug("Init: using startAt.fromLivePosition");
23192
+ var livePosition = (_a = manifest.getLivePosition()) !== null && _a !== void 0 ? _a : max;
23193
+ var fromLivePosition = startAt.fromLivePosition;
23194
+ return fromLivePosition >= 0 ? livePosition : Math.max(min, livePosition + fromLivePosition);
23134
23195
  } else if (!is_null_or_undefined_isNullOrUndefined(startAt.percentage)) {
23135
23196
  src_log.debug("Init: using startAt.percentage");
23136
23197
  var percentage = startAt.percentage;
@@ -25308,7 +25369,7 @@ var MediaSourceContentInitializer = /*#__PURE__*/function (_ContentInitializer)
25308
25369
  if (
25309
25370
  // Data is buffered around the current position
25310
25371
  obs.currentRange !== null ||
25311
- // Or, for whatever reason, playback is already advancing
25372
+ // Or, for whatever reason, we have no buffer but we're already advancing
25312
25373
  obs.position > seekedTime + 0.1) {
25313
25374
  stopListening();
25314
25375
  playbackObserver.setCurrentTime(obs.position + 0.001);
@@ -25491,8 +25552,8 @@ var MediaSourceContentInitializer = /*#__PURE__*/function (_ContentInitializer)
25491
25552
  period: period
25492
25553
  });
25493
25554
  });
25494
- contentTimeBoundariesObserver.addEventListener("durationUpdate", function (newDuration) {
25495
- mediaSourceDurationUpdater.updateDuration(newDuration.duration, newDuration.isEnd);
25555
+ contentTimeBoundariesObserver.addEventListener("endingPositionChange", function (x) {
25556
+ return mediaSourceDurationUpdater.updateDuration(x.endingPosition, x.isEnd);
25496
25557
  });
25497
25558
  contentTimeBoundariesObserver.addEventListener("endOfStream", function () {
25498
25559
  if (endOfStreamCanceller === null) {
@@ -25509,8 +25570,8 @@ var MediaSourceContentInitializer = /*#__PURE__*/function (_ContentInitializer)
25509
25570
  endOfStreamCanceller = null;
25510
25571
  }
25511
25572
  });
25512
- var currentDuration = contentTimeBoundariesObserver.getCurrentDuration();
25513
- mediaSourceDurationUpdater.updateDuration(currentDuration.duration, currentDuration.isEnd);
25573
+ var endInfo = contentTimeBoundariesObserver.getCurrentEndingTime();
25574
+ mediaSourceDurationUpdater.updateDuration(endInfo.endingPosition, endInfo.isEnd);
25514
25575
  return contentTimeBoundariesObserver;
25515
25576
  }
25516
25577
  /**
@@ -27117,7 +27178,7 @@ function getTimescaledRange(start, duration, timescale) {
27117
27178
  * timescaled time.
27118
27179
  * Returns -1 if the given time is lower than the start of the first available
27119
27180
  * segment.
27120
- * @param {Object} index
27181
+ * @param {Object} timeline
27121
27182
  * @param {Number} timeTScaled
27122
27183
  * @returns {Number}
27123
27184
  */
@@ -27162,55 +27223,6 @@ function index_helpers_checkDiscontinuity(index, timeSec, maxPosition) {
27162
27223
  var segmentEnd = getIndexSegmentEnd(timelineItem, nextTimelineItem, maxPosition);
27163
27224
  return scaledTime >= segmentEnd && scaledTime < nextStart ? fromIndexTime(nextStart, index) : null;
27164
27225
  }
27165
- ;// CONCATENATED MODULE: ./src/parsers/manifest/utils/is_segment_still_available.ts
27166
- /**
27167
- * Copyright 2015 CANAL+ Group
27168
- *
27169
- * Licensed under the Apache License, Version 2.0 (the "License");
27170
- * you may not use this file except in compliance with the License.
27171
- * You may obtain a copy of the License at
27172
- *
27173
- * http://www.apache.org/licenses/LICENSE-2.0
27174
- *
27175
- * Unless required by applicable law or agreed to in writing, software
27176
- * distributed under the License is distributed on an "AS IS" BASIS,
27177
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27178
- * See the License for the specific language governing permissions and
27179
- * limitations under the License.
27180
- */
27181
- /**
27182
- * Returns true if a Segment returned by the corresponding index is still
27183
- * considered available.
27184
- * Returns false if it is not available anymore.
27185
- * Returns undefined if we cannot know whether it is still available or not.
27186
- * /!\ We do not check the mediaURLs of the segment.
27187
- * @param {Object} segment
27188
- * @param {Array.<Object>} timescale
27189
- * @param {number} timeline
27190
- * @returns {Boolean|undefined}
27191
- */
27192
- function is_segment_still_available_isSegmentStillAvailable(segment, timeline, timescale, indexTimeOffset) {
27193
- for (var i = 0; i < timeline.length; i++) {
27194
- var tSegment = timeline[i];
27195
- var tSegmentTime = (tSegment.start - indexTimeOffset) / timescale;
27196
- if (tSegmentTime > segment.time) {
27197
- return false;
27198
- } else if (tSegmentTime === segment.time) {
27199
- if (tSegment.range === undefined) {
27200
- return segment.range === undefined;
27201
- }
27202
- return segment.range != null && tSegment.range[0] === segment.range[0] && tSegment.range[1] === segment.range[1];
27203
- } else {
27204
- // tSegment.start < segment.time
27205
- if (tSegment.repeatCount >= 0 && tSegment.duration !== undefined) {
27206
- var timeDiff = tSegmentTime - tSegment.start;
27207
- var repeat = timeDiff / tSegment.duration - 1;
27208
- return repeat % 1 === 0 && repeat <= tSegment.repeatCount;
27209
- }
27210
- }
27211
- }
27212
- return false;
27213
- }
27214
27226
  ;// CONCATENATED MODULE: ./src/parsers/manifest/smooth/utils/tokens.ts
27215
27227
  /**
27216
27228
  * Copyright 2015 CANAL+ Group
@@ -27266,7 +27278,6 @@ function replaceSegmentSmoothTokens(url, time) {
27266
27278
 
27267
27279
 
27268
27280
 
27269
-
27270
27281
  /**
27271
27282
  * @param {Number} start
27272
27283
  * @param {Number} up
@@ -27536,7 +27547,7 @@ var SmoothRepresentationIndex = /*#__PURE__*/function () {
27536
27547
  _proto.awaitSegmentBetween = function awaitSegmentBetween(start, end) {
27537
27548
  var _a;
27538
27549
  assert_assert(start <= end);
27539
- if (this.isFinished()) {
27550
+ if (this.isStillAwaitingFutureSegments()) {
27540
27551
  return false;
27541
27552
  }
27542
27553
  var lastAvailablePosition = this.getLastAvailablePosition();
@@ -27574,7 +27585,23 @@ var SmoothRepresentationIndex = /*#__PURE__*/function () {
27574
27585
  var _this$_sharedSmoothTi5 = this._sharedSmoothTimeline,
27575
27586
  timeline = _this$_sharedSmoothTi5.timeline,
27576
27587
  timescale = _this$_sharedSmoothTi5.timescale;
27577
- return is_segment_still_available_isSegmentStillAvailable(segment, timeline, timescale, 0);
27588
+ for (var i = 0; i < timeline.length; i++) {
27589
+ var tSegment = timeline[i];
27590
+ var tSegmentTime = tSegment.start / timescale;
27591
+ if (tSegmentTime > segment.time) {
27592
+ return false; // We went over it without finding it
27593
+ } else if (tSegmentTime === segment.time) {
27594
+ return true;
27595
+ } else {
27596
+ // tSegment.start < segment.time
27597
+ if (tSegment.repeatCount >= 0 && tSegment.duration !== undefined) {
27598
+ var timeDiff = tSegmentTime - tSegment.start;
27599
+ var repeat = timeDiff / tSegment.duration - 1;
27600
+ return repeat % 1 === 0 && repeat <= tSegment.repeatCount;
27601
+ }
27602
+ }
27603
+ }
27604
+ return false;
27578
27605
  }
27579
27606
  /**
27580
27607
  * @param {Error} error
@@ -27607,9 +27634,9 @@ var SmoothRepresentationIndex = /*#__PURE__*/function () {
27607
27634
  this._sharedSmoothTimeline.update(newIndex._sharedSmoothTimeline);
27608
27635
  }
27609
27636
  /**
27610
- * Returns `true` if the last segments in this index have already been
27637
+ * Returns `false` if the last segments in this index have already been
27611
27638
  * generated.
27612
- * Returns `false` if the index is still waiting on future segments to be
27639
+ * Returns `true` if the index is still waiting on future segments to be
27613
27640
  * generated.
27614
27641
  *
27615
27642
  * For Smooth, it should only depend on whether the content is a live content
@@ -27617,8 +27644,8 @@ var SmoothRepresentationIndex = /*#__PURE__*/function () {
27617
27644
  * TODO What about Smooth live content that finishes at some point?
27618
27645
  * @returns {boolean}
27619
27646
  */;
27620
- _proto.isFinished = function isFinished() {
27621
- return !this._isLive;
27647
+ _proto.isStillAwaitingFutureSegments = function isStillAwaitingFutureSegments() {
27648
+ return this._isLive;
27622
27649
  }
27623
27650
  /**
27624
27651
  * @returns {Boolean}
@@ -27633,8 +27660,8 @@ var SmoothRepresentationIndex = /*#__PURE__*/function () {
27633
27660
  * Add segments to a `SharedSmoothSegmentTimeline` that were predicted to come
27634
27661
  * after `currentSegment`.
27635
27662
  * @param {Array.<Object>} nextSegments - The segment information parsed.
27636
- * @param {Object} segment - Information on the segment which contained that
27637
- * new segment information.
27663
+ * @param {Object} currentSegment - Information on the segment which contained
27664
+ * that new segment information.
27638
27665
  */;
27639
27666
  _proto.addPredictedSegments = function addPredictedSegments(nextSegments, currentSegment) {
27640
27667
  this._sharedSmoothTimeline.addPredictedSegments(nextSegments, currentSegment);
@@ -28684,7 +28711,8 @@ function request(options) {
28684
28711
  url: options.url,
28685
28712
  headers: options.headers,
28686
28713
  responseType: is_null_or_undefined_isNullOrUndefined(options.responseType) ? DEFAULT_RESPONSE_TYPE : options.responseType,
28687
- timeout: options.timeout
28714
+ timeout: options.timeout,
28715
+ connectionTimeout: options.connectionTimeout
28688
28716
  };
28689
28717
  return new Promise(function (resolve, reject) {
28690
28718
  var onProgress = options.onProgress,
@@ -28692,7 +28720,8 @@ function request(options) {
28692
28720
  var url = requestOptions.url,
28693
28721
  headers = requestOptions.headers,
28694
28722
  responseType = requestOptions.responseType,
28695
- timeout = requestOptions.timeout;
28723
+ timeout = requestOptions.timeout,
28724
+ connectionTimeout = requestOptions.connectionTimeout;
28696
28725
  var xhr = new XMLHttpRequest();
28697
28726
  xhr.open("GET", url, true);
28698
28727
  var timeoutId;
@@ -28706,9 +28735,19 @@ function request(options) {
28706
28735
  // is more precise, it might also be more efficient.
28707
28736
  timeoutId = setTimeout(function () {
28708
28737
  clearCancellingProcess();
28709
- reject(new RequestError(url, xhr.status, "TIMEOUT"));
28738
+ reject(new RequestError(url, xhr.status, NetworkErrorTypes.TIMEOUT));
28710
28739
  }, timeout + 3000);
28711
28740
  }
28741
+ var connectionTimeoutId;
28742
+ if (connectionTimeout !== undefined) {
28743
+ connectionTimeoutId = setTimeout(function () {
28744
+ clearCancellingProcess();
28745
+ if (xhr.readyState !== XMLHttpRequest.DONE) {
28746
+ xhr.abort();
28747
+ }
28748
+ reject(new RequestError(url, xhr.status, NetworkErrorTypes.TIMEOUT));
28749
+ }, connectionTimeout);
28750
+ }
28712
28751
  xhr.responseType = responseType;
28713
28752
  if (xhr.responseType === "document") {
28714
28753
  xhr.overrideMimeType("text/xml");
@@ -28727,7 +28766,7 @@ function request(options) {
28727
28766
  if (cancelSignal !== undefined) {
28728
28767
  deregisterCancellationListener = cancelSignal.register(function abortRequest(err) {
28729
28768
  clearCancellingProcess();
28730
- if (!is_null_or_undefined_isNullOrUndefined(xhr) && xhr.readyState !== 4) {
28769
+ if (xhr.readyState !== XMLHttpRequest.DONE) {
28731
28770
  xhr.abort();
28732
28771
  }
28733
28772
  reject(err);
@@ -28738,12 +28777,19 @@ function request(options) {
28738
28777
  }
28739
28778
  xhr.onerror = function onXHRError() {
28740
28779
  clearCancellingProcess();
28741
- reject(new RequestError(url, xhr.status, "ERROR_EVENT"));
28780
+ reject(new RequestError(url, xhr.status, NetworkErrorTypes.ERROR_EVENT));
28742
28781
  };
28743
28782
  xhr.ontimeout = function onXHRTimeout() {
28744
28783
  clearCancellingProcess();
28745
- reject(new RequestError(url, xhr.status, "TIMEOUT"));
28784
+ reject(new RequestError(url, xhr.status, NetworkErrorTypes.TIMEOUT));
28746
28785
  };
28786
+ if (connectionTimeout !== undefined) {
28787
+ xhr.onreadystatechange = function clearConnectionTimeout() {
28788
+ if (xhr.readyState >= XMLHttpRequest.HEADERS_RECEIVED) {
28789
+ clearTimeout(connectionTimeoutId);
28790
+ }
28791
+ };
28792
+ }
28747
28793
  if (onProgress !== undefined) {
28748
28794
  xhr.onprogress = function onXHRProgress(event) {
28749
28795
  var currentTime = getMonotonicTimeStamp();
@@ -28758,7 +28804,7 @@ function request(options) {
28758
28804
  };
28759
28805
  }
28760
28806
  xhr.onload = function onXHRLoad(event) {
28761
- if (xhr.readyState === 4) {
28807
+ if (xhr.readyState === XMLHttpRequest.DONE) {
28762
28808
  clearCancellingProcess();
28763
28809
  if (xhr.status >= 200 && xhr.status < 300) {
28764
28810
  var receivedTime = getMonotonicTimeStamp();
@@ -28776,7 +28822,7 @@ function request(options) {
28776
28822
  responseData = xhr.response;
28777
28823
  }
28778
28824
  if (is_null_or_undefined_isNullOrUndefined(responseData)) {
28779
- reject(new RequestError(url, xhr.status, "PARSE_ERROR"));
28825
+ reject(new RequestError(url, xhr.status, NetworkErrorTypes.PARSE_ERROR));
28780
28826
  return;
28781
28827
  }
28782
28828
  resolve({
@@ -28790,7 +28836,7 @@ function request(options) {
28790
28836
  responseData: responseData
28791
28837
  });
28792
28838
  } else {
28793
- reject(new RequestError(url, xhr.status, "ERROR_HTTP_CODE"));
28839
+ reject(new RequestError(url, xhr.status, NetworkErrorTypes.ERROR_HTTP_CODE));
28794
28840
  }
28795
28841
  }
28796
28842
  };
@@ -28802,6 +28848,9 @@ function request(options) {
28802
28848
  if (timeoutId !== undefined) {
28803
28849
  clearTimeout(timeoutId);
28804
28850
  }
28851
+ if (connectionTimeoutId !== undefined) {
28852
+ clearTimeout(connectionTimeoutId);
28853
+ }
28805
28854
  if (deregisterCancellationListener !== null) {
28806
28855
  deregisterCancellationListener();
28807
28856
  }
@@ -29078,6 +29127,7 @@ function generateRegularManifestLoader(preferredType) {
29078
29127
  url: url,
29079
29128
  responseType: "arraybuffer",
29080
29129
  timeout: loaderOptions.timeout,
29130
+ connectionTimeout: loaderOptions.connectionTimeout,
29081
29131
  cancelSignal: cancelSignal
29082
29132
  });
29083
29133
  case "text":
@@ -29085,6 +29135,7 @@ function generateRegularManifestLoader(preferredType) {
29085
29135
  url: url,
29086
29136
  responseType: "text",
29087
29137
  timeout: loaderOptions.timeout,
29138
+ connectionTimeout: loaderOptions.connectionTimeout,
29088
29139
  cancelSignal: cancelSignal
29089
29140
  });
29090
29141
  case "document":
@@ -29092,6 +29143,7 @@ function generateRegularManifestLoader(preferredType) {
29092
29143
  url: url,
29093
29144
  responseType: "document",
29094
29145
  timeout: loaderOptions.timeout,
29146
+ connectionTimeout: loaderOptions.connectionTimeout,
29095
29147
  cancelSignal: cancelSignal
29096
29148
  });
29097
29149
  default:
@@ -30567,6 +30619,7 @@ function regularSegmentLoader(url, context, callbacks, loaderOptions, cancelSign
30567
30619
  responseType: "arraybuffer",
30568
30620
  headers: headers,
30569
30621
  timeout: loaderOptions.timeout,
30622
+ connectionTimeout: loaderOptions.connectionTimeout,
30570
30623
  cancelSignal: cancelSignal,
30571
30624
  onProgress: callbacks.onProgress
30572
30625
  }).then(function (data) {
@@ -30942,6 +30995,7 @@ function constructSegmentUrl(wantedCdn, segment) {
30942
30995
  url: url,
30943
30996
  responseType: "text",
30944
30997
  timeout: loaderOptions.timeout,
30998
+ connectionTimeout: loaderOptions.connectionTimeout,
30945
30999
  cancelSignal: cancelSignal,
30946
31000
  onProgress: callbacks.onProgress
30947
31001
  }).then(function (data) {
@@ -30955,6 +31009,7 @@ function constructSegmentUrl(wantedCdn, segment) {
30955
31009
  url: url,
30956
31010
  responseType: "arraybuffer",
30957
31011
  timeout: loaderOptions.timeout,
31012
+ connectionTimeout: loaderOptions.connectionTimeout,
30958
31013
  cancelSignal: cancelSignal,
30959
31014
  onProgress: callbacks.onProgress
30960
31015
  }).then(function (data) {
@@ -31494,6 +31549,135 @@ function getMinimumAndMaximumPositions(periods) {
31494
31549
  maximumUnsafePosition: maxPositions.unsafe
31495
31550
  };
31496
31551
  }
31552
+ ;// CONCATENATED MODULE: ./src/parsers/manifest/dash/common/manifest_bounds_calculator.ts
31553
+ /**
31554
+ * Copyright 2015 CANAL+ Group
31555
+ *
31556
+ * Licensed under the Apache License, Version 2.0 (the "License");
31557
+ * you may not use this file except in compliance with the License.
31558
+ * You may obtain a copy of the License at
31559
+ *
31560
+ * http://www.apache.org/licenses/LICENSE-2.0
31561
+ *
31562
+ * Unless required by applicable law or agreed to in writing, software
31563
+ * distributed under the License is distributed on an "AS IS" BASIS,
31564
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31565
+ * See the License for the specific language governing permissions and
31566
+ * limitations under the License.
31567
+ */
31568
+
31569
+ /**
31570
+ * This class allows to easily calculate the first and last available positions
31571
+ * in a content at any time.
31572
+ *
31573
+ * By centralizing the manifest bounds calculation in this class and by giving
31574
+ * an instance of it to each parsed elements which might depend on it, we
31575
+ * ensure that we can provide it once it is known to every one of those
31576
+ * elements without needing to parse a second time the MPD.
31577
+ * @class ManifestBoundsCalculator
31578
+ */
31579
+ var ManifestBoundsCalculator = /*#__PURE__*/function () {
31580
+ /**
31581
+ * @param {Object} args
31582
+ */
31583
+ function ManifestBoundsCalculator(args) {
31584
+ this._isDynamic = args.isDynamic;
31585
+ this._timeShiftBufferDepth = !args.isDynamic || args.timeShiftBufferDepth === undefined ? null : args.timeShiftBufferDepth;
31586
+ this._serverTimestampOffset = args.serverTimestampOffset;
31587
+ this._availabilityStartTime = args.availabilityStartTime;
31588
+ }
31589
+ /**
31590
+ * Set the last position and the position time (the value of the RxPlayer's
31591
+ * monotonically-raising timestamp at the time that position was true
31592
+ * converted into seconds).
31593
+ *
31594
+ * @example
31595
+ * Example if you trust `Date.now()` to give you a reliable offset:
31596
+ * ```js
31597
+ * const lastPosition = Date.now();
31598
+ * const positionTime = getMonotonicTimeStamp() / 1000;
31599
+ * manifestBoundsCalculator.setLastPosition(lastPosition, positionTime);
31600
+ * ```
31601
+ *
31602
+ * @param {number} lastPosition
31603
+ * @param {number|undefined} positionTime
31604
+ */
31605
+ var _proto = ManifestBoundsCalculator.prototype;
31606
+ _proto.setLastPosition = function setLastPosition(lastPosition, positionTime) {
31607
+ this._lastPosition = lastPosition;
31608
+ this._positionTime = positionTime;
31609
+ }
31610
+ /**
31611
+ * Returns `true` if the last position and the position time
31612
+ * (for dynamic content only) have been comunicated.
31613
+ * `false` otherwise.
31614
+ * @returns {boolean}
31615
+ */;
31616
+ _proto.lastPositionIsKnown = function lastPositionIsKnown() {
31617
+ if (this._isDynamic) {
31618
+ return this._positionTime != null && this._lastPosition != null;
31619
+ }
31620
+ return this._lastPosition != null;
31621
+ }
31622
+ /**
31623
+ * Estimate a minimum bound for the content from the last set segment time
31624
+ * and buffer depth.
31625
+ * Consider that it is only an estimation, not the real value.
31626
+ * @return {number|undefined}
31627
+ */;
31628
+ _proto.getEstimatedMinimumSegmentTime = function getEstimatedMinimumSegmentTime() {
31629
+ var _a;
31630
+ if (!this._isDynamic || this._timeShiftBufferDepth === null) {
31631
+ return 0;
31632
+ }
31633
+ var maximumBound = (_a = this.getEstimatedLiveEdge()) !== null && _a !== void 0 ? _a : this.getEstimatedMaximumPosition(0);
31634
+ if (maximumBound === undefined) {
31635
+ return undefined;
31636
+ }
31637
+ var minimumBound = maximumBound - this._timeShiftBufferDepth;
31638
+ return minimumBound;
31639
+ }
31640
+ /**
31641
+ * Estimate the segment time in seconds that corresponds to what could be
31642
+ * considered the live edge (or `undefined` for non-live contents).
31643
+ *
31644
+ * Note that for some contents which just anounce segments in advance, this
31645
+ * value might be very different than the maximum position that is
31646
+ * requestable.
31647
+ * @return {number|undefined}
31648
+ */;
31649
+ _proto.getEstimatedLiveEdge = function getEstimatedLiveEdge() {
31650
+ if (!this._isDynamic || this._serverTimestampOffset === undefined) {
31651
+ return undefined;
31652
+ }
31653
+ return (getMonotonicTimeStamp() + this._serverTimestampOffset) / 1000 - this._availabilityStartTime;
31654
+ }
31655
+ /**
31656
+ * Produce a rough estimate of the ending time of the last requestable segment
31657
+ * in that content.
31658
+ *
31659
+ * This value is only an estimate and may be far from reality.
31660
+ *
31661
+ * The `availabilityTimeOffset` in argument is the corresponding
31662
+ * `availabilityTimeOffset` that applies to the current wanted segment, or `0`
31663
+ * if none exist. It will be applied on live content to deduce the maximum
31664
+ * segment time available.
31665
+ */;
31666
+ _proto.getEstimatedMaximumPosition = function getEstimatedMaximumPosition(availabilityTimeOffset) {
31667
+ if (!this._isDynamic) {
31668
+ return this._lastPosition;
31669
+ }
31670
+ var liveEdge = this.getEstimatedLiveEdge();
31671
+ if (liveEdge !== undefined && availabilityTimeOffset !== Infinity) {
31672
+ return liveEdge + availabilityTimeOffset;
31673
+ } else if (this._positionTime !== undefined && this._lastPosition !== undefined) {
31674
+ return Math.max(this._lastPosition - this._positionTime + getMonotonicTimeStamp() / 1000, 0);
31675
+ }
31676
+ return this._lastPosition;
31677
+ };
31678
+ return ManifestBoundsCalculator;
31679
+ }();
31680
+
31497
31681
  ;// CONCATENATED MODULE: ./src/parsers/manifest/dash/common/parse_availability_start_time.ts
31498
31682
  /**
31499
31683
  * Copyright 2015 CANAL+ Group
@@ -31700,115 +31884,6 @@ function getPeriodsTimeInformation(periodsIR, manifestInfos) {
31700
31884
  });
31701
31885
  return periodsTimeInformation;
31702
31886
  }
31703
- ;// CONCATENATED MODULE: ./src/parsers/manifest/dash/common/manifest_bounds_calculator.ts
31704
- /**
31705
- * Copyright 2015 CANAL+ Group
31706
- *
31707
- * Licensed under the Apache License, Version 2.0 (the "License");
31708
- * you may not use this file except in compliance with the License.
31709
- * You may obtain a copy of the License at
31710
- *
31711
- * http://www.apache.org/licenses/LICENSE-2.0
31712
- *
31713
- * Unless required by applicable law or agreed to in writing, software
31714
- * distributed under the License is distributed on an "AS IS" BASIS,
31715
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31716
- * See the License for the specific language governing permissions and
31717
- * limitations under the License.
31718
- */
31719
-
31720
- /**
31721
- * This class allows to easily calculate the first and last available positions
31722
- * in a content at any time.
31723
- *
31724
- * That task can be an hard for dynamic DASH contents: it depends on a
31725
- * `timeShiftBufferDepth` defined in the MPD and on the maximum possible
31726
- * position.
31727
- *
31728
- * The latter can come from either a clock synchronization mechanism or the
31729
- * indexing schemes (e.g. SegmentTemplate, SegmentTimeline etc.) of the last
31730
- * Periods.
31731
- * As such, it might only be known once a large chunk of the MPD has already
31732
- * been parsed.
31733
- *
31734
- * By centralizing the manifest bounds calculation in this class and by giving
31735
- * an instance of it to each parsed elements which might depend on it, we
31736
- * ensure that we can provide it once it is known to every one of those
31737
- * elements without needing to parse a second time the MPD.
31738
- * @class ManifestBoundsCalculator
31739
- */
31740
- var ManifestBoundsCalculator = /*#__PURE__*/function () {
31741
- /**
31742
- * @param {Object} args
31743
- */
31744
- function ManifestBoundsCalculator(args) {
31745
- this._isDynamic = args.isDynamic;
31746
- this._timeShiftBufferDepth = !args.isDynamic || args.timeShiftBufferDepth === undefined ? null : args.timeShiftBufferDepth;
31747
- }
31748
- /**
31749
- * Set the last position and the position time (the value of the RxPlayer's
31750
- * monotonically-raising timestamp at the time that position was true
31751
- * converted into seconds).
31752
- *
31753
- * @example
31754
- * Example if you trust `Date.now()` to give you a reliable offset:
31755
- * ```js
31756
- * const lastPosition = Date.now();
31757
- * const positionTime = getMonotonicTimeStamp() / 1000;
31758
- * manifestBoundsCalculator.setLastPosition(lastPosition, positionTime);
31759
- * ```
31760
- *
31761
- * @param {number} lastPosition
31762
- * @param {number|undefined} positionTime
31763
- */
31764
- var _proto = ManifestBoundsCalculator.prototype;
31765
- _proto.setLastPosition = function setLastPosition(lastPosition, positionTime) {
31766
- this._lastPosition = lastPosition;
31767
- this._positionTime = positionTime;
31768
- }
31769
- /**
31770
- * Returns `true` if the last position and the position time
31771
- * (for dynamic content only) have been comunicated.
31772
- * `false` otherwise.
31773
- * @returns {boolean}
31774
- */;
31775
- _proto.lastPositionIsKnown = function lastPositionIsKnown() {
31776
- if (this._isDynamic) {
31777
- return this._positionTime != null && this._lastPosition != null;
31778
- }
31779
- return this._lastPosition != null;
31780
- }
31781
- /**
31782
- * Estimate a minimum bound for the content from the last set segment time
31783
- * and buffer depth.
31784
- * Consider that it is only an estimation, not the real value.
31785
- * @return {number|undefined}
31786
- */;
31787
- _proto.estimateMinimumBound = function estimateMinimumBound() {
31788
- if (!this._isDynamic || this._timeShiftBufferDepth === null) {
31789
- return 0;
31790
- }
31791
- var maximumBound = this.estimateMaximumBound();
31792
- if (maximumBound === undefined) {
31793
- return undefined;
31794
- }
31795
- var minimumBound = maximumBound - this._timeShiftBufferDepth;
31796
- return minimumBound;
31797
- }
31798
- /**
31799
- * Estimate a maximum bound for the content from the last set segment time.
31800
- * Consider that it is only an estimation, not the real value.
31801
- * @return {number|undefined}
31802
- */;
31803
- _proto.estimateMaximumBound = function estimateMaximumBound() {
31804
- if (this._isDynamic && this._positionTime != null && this._lastPosition != null) {
31805
- return Math.max(this._lastPosition - this._positionTime + getMonotonicTimeStamp() / 1000, 0);
31806
- }
31807
- return this._lastPosition;
31808
- };
31809
- return ManifestBoundsCalculator;
31810
- }();
31811
-
31812
31887
  ;// CONCATENATED MODULE: ./src/parsers/manifest/dash/common/attach_trickmode_track.ts
31813
31888
  function attach_trickmode_track_createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = attach_trickmode_track_unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
31814
31889
  function attach_trickmode_track_unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return attach_trickmode_track_arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return attach_trickmode_track_arrayLikeToArray(o, minLen); }
@@ -32240,13 +32315,17 @@ function getWantedRepeatIndex(segmentStartTime, segmentDuration, wantedTime) {
32240
32315
  * @param {Object} index - index object, constructed by parsing the manifest.
32241
32316
  * @param {number} from - starting timestamp wanted, in seconds
32242
32317
  * @param {number} durationWanted - duration wanted, in seconds
32318
+ * @param {Object} manifestBoundsCalculator
32319
+ * @param {number|undefined} scaledPeriodEnd
32243
32320
  * @param {function} isEMSGWhitelisted
32244
- * @param {number|undefined} maximumTime
32245
32321
  * @returns {Array.<Object>}
32246
32322
  */
32247
- function getSegmentsFromTimeline(index, from, durationWanted, isEMSGWhitelisted, maximumTime) {
32323
+ function getSegmentsFromTimeline(index, from, durationWanted, manifestBoundsCalculator, scaledPeriodEnd, isEMSGWhitelisted) {
32324
+ var _a;
32325
+ var maximumTime = manifestBoundsCalculator.getEstimatedMaximumPosition((_a = index.availabilityTimeOffset) !== null && _a !== void 0 ? _a : 0);
32326
+ var wantedMaximum = Math.min(from + durationWanted, maximumTime !== null && maximumTime !== void 0 ? maximumTime : Infinity);
32248
32327
  var scaledUp = toIndexTime(from, index);
32249
- var scaledTo = toIndexTime(from + durationWanted, index);
32328
+ var scaledTo = toIndexTime(wantedMaximum, index);
32250
32329
  var timeline = index.timeline,
32251
32330
  timescale = index.timescale,
32252
32331
  segmentUrlTemplate = index.segmentUrlTemplate,
@@ -32260,7 +32339,13 @@ function getSegmentsFromTimeline(index, from, durationWanted, isEMSGWhitelisted,
32260
32339
  var duration = timelineItem.duration,
32261
32340
  start = timelineItem.start,
32262
32341
  range = timelineItem.range;
32263
- var repeat = calculateRepeat(timelineItem, timeline[i + 1], maximumTime);
32342
+ var maxRepeatTime = void 0;
32343
+ if (maximumTime === undefined) {
32344
+ maxRepeatTime = scaledPeriodEnd;
32345
+ } else {
32346
+ maxRepeatTime = Math.min(maximumTime * timescale, scaledPeriodEnd !== null && scaledPeriodEnd !== void 0 ? scaledPeriodEnd : Infinity);
32347
+ }
32348
+ var repeat = calculateRepeat(timelineItem, timeline[i + 1], maxRepeatTime);
32264
32349
  var complete = index.availabilityTimeComplete !== false || i !== timelineLength - 1 && repeat !== 0;
32265
32350
  var segmentNumberInCurrentRange = getWantedRepeatIndex(start, duration, scaledUp);
32266
32351
  var segmentTime = start + segmentNumberInCurrentRange * duration;
@@ -32393,6 +32478,7 @@ var BaseRepresentationIndex = /*#__PURE__*/function () {
32393
32478
  timeline: (_c = index.timeline) !== null && _c !== void 0 ? _c : [],
32394
32479
  timescale: timescale
32395
32480
  };
32481
+ this._manifestBoundsCalculator = context.manifestBoundsCalculator;
32396
32482
  this._scaledPeriodStart = toIndexTime(periodStart, this._index);
32397
32483
  this._scaledPeriodEnd = periodEnd == null ? undefined : toIndexTime(periodEnd, this._index);
32398
32484
  this._isInitialized = this._index.timeline.length > 0;
@@ -32421,7 +32507,7 @@ var BaseRepresentationIndex = /*#__PURE__*/function () {
32421
32507
  * @returns {Array.<Object>}
32422
32508
  */;
32423
32509
  _proto.getSegments = function getSegments(from, dur) {
32424
- return getSegmentsFromTimeline(this._index, from, dur, this._isEMSGWhitelisted, this._scaledPeriodEnd);
32510
+ return getSegmentsFromTimeline(this._index, from, dur, this._manifestBoundsCalculator, this._scaledPeriodEnd, this._isEMSGWhitelisted);
32425
32511
  }
32426
32512
  /**
32427
32513
  * Returns false as no Segment-Base based index should need to be refreshed.
@@ -32505,8 +32591,8 @@ var BaseRepresentationIndex = /*#__PURE__*/function () {
32505
32591
  * should become available in the future.
32506
32592
  * @returns {Boolean}
32507
32593
  */;
32508
- _proto.isFinished = function isFinished() {
32509
- return true;
32594
+ _proto.isStillAwaitingFutureSegments = function isStillAwaitingFutureSegments() {
32595
+ return false;
32510
32596
  }
32511
32597
  /**
32512
32598
  * No segment in a `BaseRepresentationIndex` are known initially.
@@ -32762,8 +32848,8 @@ var ListRepresentationIndex = /*#__PURE__*/function () {
32762
32848
  /**
32763
32849
  * @returns {Boolean}
32764
32850
  */;
32765
- _proto.isFinished = function isFinished() {
32766
- return true;
32851
+ _proto.isStillAwaitingFutureSegments = function isStillAwaitingFutureSegments() {
32852
+ return false;
32767
32853
  }
32768
32854
  /**
32769
32855
  * @returns {Boolean}
@@ -33209,9 +33295,13 @@ function constructTimelineFromPreviousTimeline(newElements, prevTimeline) {
33209
33295
 
33210
33296
 
33211
33297
 
33212
-
33213
33298
  // eslint-disable-next-line max-len
33214
33299
 
33300
+ /**
33301
+ * `IRepresentationIndex` implementation for a DASH `SegmentTimeline` segment
33302
+ * indexing scheme.
33303
+ * @class TimelineRepresentationIndex
33304
+ */
33215
33305
  var TimelineRepresentationIndex = /*#__PURE__*/function () {
33216
33306
  /**
33217
33307
  * @param {Object} index
@@ -33223,6 +33313,7 @@ var TimelineRepresentationIndex = /*#__PURE__*/function () {
33223
33313
  throw new Error("The given index is not compatible with a " + "TimelineRepresentationIndex.");
33224
33314
  }
33225
33315
  var availabilityTimeComplete = context.availabilityTimeComplete,
33316
+ availabilityTimeOffset = context.availabilityTimeOffset,
33226
33317
  manifestBoundsCalculator = context.manifestBoundsCalculator,
33227
33318
  isDynamic = context.isDynamic,
33228
33319
  isLastPeriod = context.isLastPeriod,
@@ -33249,8 +33340,25 @@ var TimelineRepresentationIndex = /*#__PURE__*/function () {
33249
33340
  this._parseTimeline = (_b = index.timelineParser) !== null && _b !== void 0 ? _b : null;
33250
33341
  var initializationUrl = ((_c = index.initialization) === null || _c === void 0 ? void 0 : _c.media) === undefined ? null : constructRepresentationUrl(index.initialization.media, representationId, representationBitrate);
33251
33342
  var segmentUrlTemplate = index.media === undefined ? null : constructRepresentationUrl(index.media, representationId, representationBitrate);
33343
+ var actualAvailabilityTimeOffset;
33344
+ // Technically, it seems (although it is not clear) that an MPD may contain
33345
+ // future segments and it's the job of a player to not request segments later
33346
+ // than the time at which they should be available.
33347
+ // In practice, we don't do that for various reasons: precision issues,
33348
+ // various DASH spec interpretations by packagers and players...
33349
+ //
33350
+ // So as a compromise, if nothing in the MPD indicates that future segments
33351
+ // may be announced (see code below), we will act as if ALL segments in this
33352
+ // TimelineRepresentationIndex are requestable
33353
+ if (availabilityTimeOffset === undefined && availabilityTimeComplete === undefined) {
33354
+ actualAvailabilityTimeOffset = Infinity; // Meaning: we can request
33355
+ // everything in the index
33356
+ } else {
33357
+ actualAvailabilityTimeOffset = availabilityTimeOffset !== null && availabilityTimeOffset !== void 0 ? availabilityTimeOffset : 0;
33358
+ }
33252
33359
  this._index = {
33253
- availabilityTimeComplete: availabilityTimeComplete,
33360
+ availabilityTimeComplete: availabilityTimeComplete !== null && availabilityTimeComplete !== void 0 ? availabilityTimeComplete : true,
33361
+ availabilityTimeOffset: actualAvailabilityTimeOffset,
33254
33362
  indexRange: index.indexRange,
33255
33363
  indexTimeOffset: indexTimeOffset,
33256
33364
  initialization: index.initialization == null ? undefined : {
@@ -33300,7 +33408,7 @@ var TimelineRepresentationIndex = /*#__PURE__*/function () {
33300
33408
  timeline: timeline,
33301
33409
  timescale: timescale,
33302
33410
  indexTimeOffset: indexTimeOffset
33303
- }, from, duration, this._isEMSGWhitelisted, this._scaledPeriodEnd);
33411
+ }, from, duration, this._manifestBoundsCalculator, this._scaledPeriodEnd, this._isEMSGWhitelisted);
33304
33412
  }
33305
33413
  /**
33306
33414
  * Returns true if the index should be refreshed.
@@ -33332,12 +33440,19 @@ var TimelineRepresentationIndex = /*#__PURE__*/function () {
33332
33440
  * @returns {Number|null}
33333
33441
  */;
33334
33442
  _proto.getLastAvailablePosition = function getLastAvailablePosition() {
33443
+ var _a;
33335
33444
  this._refreshTimeline();
33336
33445
  if (this._index.timeline === null) {
33337
33446
  this._index.timeline = this._getTimeline();
33338
33447
  }
33339
- var lastTime = TimelineRepresentationIndex.getIndexEnd(this._index.timeline, this._scaledPeriodEnd);
33340
- return lastTime === null ? null : fromIndexTime(lastTime, this._index);
33448
+ var lastReqSegInfo = getLastRequestableSegmentInfo(
33449
+ // Needed typecast for TypeScript
33450
+ this._index, this._manifestBoundsCalculator, this._scaledPeriodEnd);
33451
+ if (lastReqSegInfo === null) {
33452
+ return null;
33453
+ }
33454
+ var lastScaledPosition = Math.min(lastReqSegInfo.end, (_a = this._scaledPeriodEnd) !== null && _a !== void 0 ? _a : Infinity);
33455
+ return fromIndexTime(lastScaledPosition, this._index);
33341
33456
  }
33342
33457
  /**
33343
33458
  * Returns the absolute end in seconds this RepresentationIndex can reach once
@@ -33345,11 +33460,20 @@ var TimelineRepresentationIndex = /*#__PURE__*/function () {
33345
33460
  * @returns {number|null|undefined}
33346
33461
  */;
33347
33462
  _proto.getEnd = function getEnd() {
33348
- if (!this._isDynamic || !this._isLastPeriod) {
33349
- // @see isFinished
33350
- return this.getLastAvailablePosition();
33463
+ var _a;
33464
+ if (this._isDynamic && !this._isLastPeriod) {
33465
+ return undefined;
33351
33466
  }
33352
- return undefined;
33467
+ this._refreshTimeline();
33468
+ if (this._index.timeline === null) {
33469
+ this._index.timeline = this._getTimeline();
33470
+ }
33471
+ if (this._index.timeline.length <= 0) {
33472
+ return null;
33473
+ }
33474
+ var lastSegment = this._index.timeline[this._index.timeline.length - 1];
33475
+ var lastTime = Math.min(getIndexSegmentEnd(lastSegment, null, this._scaledPeriodEnd), (_a = this._scaledPeriodEnd) !== null && _a !== void 0 ? _a : Infinity);
33476
+ return fromIndexTime(lastTime, this._index);
33353
33477
  }
33354
33478
  /**
33355
33479
  * Returns:
@@ -33363,34 +33487,56 @@ var TimelineRepresentationIndex = /*#__PURE__*/function () {
33363
33487
  * @returns {boolean|undefined}
33364
33488
  */;
33365
33489
  _proto.awaitSegmentBetween = function awaitSegmentBetween(start, end) {
33366
- var _a;
33490
+ var _a, _b;
33367
33491
  assert_assert(start <= end);
33368
- if (!this._isDynamic || !this._isLastPeriod) {
33369
- return false;
33492
+ if (!this._isDynamic) {
33493
+ return false; // No segment will be newly available in the future
33370
33494
  }
33495
+
33371
33496
  this._refreshTimeline();
33372
33497
  if (this._index.timeline === null) {
33373
33498
  this._index.timeline = this._getTimeline();
33374
33499
  }
33375
33500
  var _this$_index2 = this._index,
33376
- timeline = _this$_index2.timeline,
33377
- timescale = _this$_index2.timescale;
33501
+ timescale = _this$_index2.timescale,
33502
+ timeline = _this$_index2.timeline;
33378
33503
  var segmentTimeRounding = getSegmentTimeRoundingError(timescale);
33379
- var scaledEnd = toIndexTime(end, this._index);
33380
- if (timeline.length > 0) {
33381
- var lastTimelineElement = timeline[timeline.length - 1];
33382
- var lastSegmentEnd = getIndexSegmentEnd(lastTimelineElement, null, this._scaledPeriodEnd);
33383
- var roundedEnd = lastSegmentEnd + segmentTimeRounding;
33384
- if (roundedEnd >= Math.min(scaledEnd, (_a = this._scaledPeriodEnd) !== null && _a !== void 0 ? _a : Infinity)) {
33385
- return false; // already loaded
33504
+ var scaledWantedEnd = toIndexTime(end, this._index);
33505
+ var lastReqSegInfo = getLastRequestableSegmentInfo(
33506
+ // Needed typecast for TypeScript
33507
+ this._index, this._manifestBoundsCalculator, this._scaledPeriodEnd);
33508
+ if (lastReqSegInfo !== null) {
33509
+ var lastReqSegmentEnd = Math.min(lastReqSegInfo.end, (_a = this._scaledPeriodEnd) !== null && _a !== void 0 ? _a : Infinity);
33510
+ var roundedReqSegmentEnd = lastReqSegmentEnd + segmentTimeRounding;
33511
+ if (roundedReqSegmentEnd >= Math.min(scaledWantedEnd, (_b = this._scaledPeriodEnd) !== null && _b !== void 0 ? _b : Infinity)) {
33512
+ return false; // everything up to that point is already requestable
33513
+ }
33514
+ }
33515
+
33516
+ var scaledWantedStart = toIndexTime(start, this._index);
33517
+ if (timeline.length > 0 && lastReqSegInfo !== null && !lastReqSegInfo.isLastOfTimeline) {
33518
+ // There are some future segments already anounced in the MPD
33519
+ var lastSegment = timeline[timeline.length - 1];
33520
+ var lastSegmentEnd = getIndexSegmentEnd(lastSegment, null, this._scaledPeriodEnd);
33521
+ var roundedLastSegEnd = lastSegmentEnd + segmentTimeRounding;
33522
+ if (scaledWantedStart < roundedLastSegEnd + segmentTimeRounding) {
33523
+ return true; // The MPD's timeline already contains one such element,
33524
+ // It is just not requestable yet
33386
33525
  }
33387
33526
  }
33388
33527
 
33528
+ if (!this._isLastPeriod) {
33529
+ // Let's consider - perhaps wrongly, that Periods which aren't the last
33530
+ // one have all of their segments announced.
33531
+ return false;
33532
+ }
33389
33533
  if (this._scaledPeriodEnd === undefined) {
33390
- return scaledEnd + segmentTimeRounding > this._scaledPeriodStart ? undefined : false;
33534
+ return scaledWantedEnd + segmentTimeRounding > this._scaledPeriodStart ? undefined :
33535
+ // There may be future segments at this point
33536
+ false; // Before the current Period
33391
33537
  }
33392
- var scaledStart = toIndexTime(start, this._index);
33393
- return scaledStart - segmentTimeRounding < this._scaledPeriodEnd && scaledEnd + segmentTimeRounding > this._scaledPeriodStart;
33538
+ // `true` if within the boundaries of this Period. `false` otherwise.
33539
+ return scaledWantedStart - segmentTimeRounding < this._scaledPeriodEnd && scaledWantedEnd + segmentTimeRounding > this._scaledPeriodStart;
33394
33540
  }
33395
33541
  /**
33396
33542
  * Returns true if a Segment returned by this index is still considered
@@ -33408,11 +33554,9 @@ var TimelineRepresentationIndex = /*#__PURE__*/function () {
33408
33554
  if (this._index.timeline === null) {
33409
33555
  this._index.timeline = this._getTimeline();
33410
33556
  }
33411
- var _this$_index3 = this._index,
33412
- timeline = _this$_index3.timeline,
33413
- timescale = _this$_index3.timescale,
33414
- indexTimeOffset = _this$_index3.indexTimeOffset;
33415
- return is_segment_still_available_isSegmentStillAvailable(segment, timeline, timescale, indexTimeOffset);
33557
+ return _isSegmentStillAvailable(segment,
33558
+ // Needed typecast for TypeScript
33559
+ this._index, this._manifestBoundsCalculator, this._scaledPeriodEnd);
33416
33560
  }
33417
33561
  /**
33418
33562
  * Checks if the time given is in a discontinuity. That is:
@@ -33476,6 +33620,8 @@ var TimelineRepresentationIndex = /*#__PURE__*/function () {
33476
33620
  if (hasReplaced) {
33477
33621
  this._index.startNumber = newIndex._index.startNumber;
33478
33622
  }
33623
+ this._index.availabilityTimeOffset = newIndex._index.availabilityTimeOffset;
33624
+ this._index.availabilityTimeComplete = newIndex._index.availabilityTimeComplete;
33479
33625
  this._index.endNumber = newIndex._index.endNumber;
33480
33626
  this._isDynamic = newIndex._isDynamic;
33481
33627
  this._scaledPeriodStart = newIndex._scaledPeriodStart;
@@ -33484,32 +33630,66 @@ var TimelineRepresentationIndex = /*#__PURE__*/function () {
33484
33630
  this._isLastPeriod = newIndex._isLastPeriod;
33485
33631
  }
33486
33632
  /**
33487
- * Returns `true` if this RepresentationIndex currently contains its last
33633
+ * Returns `false` if this RepresentationIndex currently contains its last
33488
33634
  * segment.
33489
- * Returns `false` if it's still pending.
33635
+ * Returns `true` if it's still pending.
33490
33636
  * @returns {Boolean}
33491
33637
  */;
33492
- _proto.isFinished = function isFinished() {
33493
- if (!this._isDynamic || !this._isLastPeriod) {
33494
- // Either the content is not dynamic, in which case no new segment will
33495
- // be generated, either it is but this index is not linked to the current
33496
- // last Period in the MPD, in which case it is inferred that it has been
33497
- // completely generated. Note that this second condition might break very
33498
- // very rare use cases where old Periods are still being generated, yet it
33499
- // should fix more cases than it breaks.
33500
- return true;
33638
+ _proto.isStillAwaitingFutureSegments = function isStillAwaitingFutureSegments() {
33639
+ var _a;
33640
+ if (!this._isDynamic) {
33641
+ return false;
33501
33642
  }
33643
+ this._refreshTimeline();
33502
33644
  if (this._index.timeline === null) {
33503
33645
  this._index.timeline = this._getTimeline();
33504
33646
  }
33505
33647
  var timeline = this._index.timeline;
33506
- if (this._scaledPeriodEnd === undefined || timeline.length === 0) {
33507
- return false;
33648
+ if (timeline.length === 0) {
33649
+ // No segment announced in this Period
33650
+ if (this._scaledPeriodEnd !== undefined) {
33651
+ var liveEdge = this._manifestBoundsCalculator.getEstimatedLiveEdge();
33652
+ if (liveEdge !== undefined && toIndexTime(liveEdge, this._index) > this._scaledPeriodEnd) {
33653
+ // This Period is over, we're not awaiting anything
33654
+ return false;
33655
+ }
33656
+ }
33657
+ // Let's just consider that we're awaiting only for when this is the last Period.
33658
+ return this._isLastPeriod;
33508
33659
  }
33509
- var lastTimelineElement = timeline[timeline.length - 1];
33510
- var lastTime = getIndexSegmentEnd(lastTimelineElement, null, this._scaledPeriodEnd);
33511
33660
  var segmentTimeRounding = getSegmentTimeRoundingError(this._index.timescale);
33512
- return lastTime + segmentTimeRounding >= this._scaledPeriodEnd;
33661
+ var lastReqSegInfo = getLastRequestableSegmentInfo(
33662
+ // Needed typecast for TypeScript
33663
+ this._index, this._manifestBoundsCalculator, this._scaledPeriodEnd);
33664
+ if (lastReqSegInfo !== null && !lastReqSegInfo.isLastOfTimeline) {
33665
+ // There might be non-yet requestable segments in the manifest
33666
+ var lastReqSegmentEnd = Math.min(lastReqSegInfo.end, (_a = this._scaledPeriodEnd) !== null && _a !== void 0 ? _a : Infinity);
33667
+ if (this._scaledPeriodEnd !== undefined && lastReqSegmentEnd + segmentTimeRounding >= this._scaledPeriodEnd) {
33668
+ // The last requestable segment ends after the end of the Period anyway
33669
+ return false;
33670
+ }
33671
+ return true; // There are not-yet requestable segments
33672
+ }
33673
+
33674
+ if (!this._isLastPeriod) {
33675
+ // This index is not linked to the current last Period in the MPD, in
33676
+ // which case it is inferred that all segments have been announced.
33677
+ //
33678
+ // Note that this condition might break very very rare use cases where old
33679
+ // Periods are still being generated, yet it should fix more cases than it
33680
+ // breaks.
33681
+ return false;
33682
+ }
33683
+ if (this._scaledPeriodEnd === undefined) {
33684
+ // This is the last Period of a dynamic content whose end is unknown.
33685
+ // Just return true.
33686
+ return true;
33687
+ }
33688
+ var lastSegment = timeline[timeline.length - 1];
33689
+ var lastSegmentEnd = getIndexSegmentEnd(lastSegment, null, this._scaledPeriodEnd);
33690
+ // We're awaiting future segments only if the current end is before the end
33691
+ // of the Period
33692
+ return lastSegmentEnd + segmentTimeRounding < this._scaledPeriodEnd;
33513
33693
  }
33514
33694
  /**
33515
33695
  * @returns {Boolean}
@@ -33543,7 +33723,7 @@ var TimelineRepresentationIndex = /*#__PURE__*/function () {
33543
33723
  if (!this._isDynamic) {
33544
33724
  return;
33545
33725
  }
33546
- var firstPosition = this._manifestBoundsCalculator.estimateMinimumBound();
33726
+ var firstPosition = this._manifestBoundsCalculator.getEstimatedMinimumSegmentTime();
33547
33727
  if (firstPosition == null) {
33548
33728
  return; // we don't know yet
33549
33729
  }
@@ -33555,12 +33735,6 @@ var TimelineRepresentationIndex = /*#__PURE__*/function () {
33555
33735
  } else if (this._index.endNumber !== undefined) {
33556
33736
  this._index.startNumber = nbEltsRemoved + 1;
33557
33737
  }
33558
- };
33559
- TimelineRepresentationIndex.getIndexEnd = function getIndexEnd(timeline, scaledPeriodEnd) {
33560
- if (timeline.length <= 0) {
33561
- return null;
33562
- }
33563
- return Math.min(getIndexSegmentEnd(timeline[timeline.length - 1], null, scaledPeriodEnd), scaledPeriodEnd !== null && scaledPeriodEnd !== void 0 ? scaledPeriodEnd : Infinity);
33564
33738
  }
33565
33739
  /**
33566
33740
  * Allows to generate the "timeline" for this RepresentationIndex.
@@ -33649,6 +33823,113 @@ function updateTimelineFromEndNumber(timeline, startNumber, endNumber) {
33649
33823
  }
33650
33824
  return timeline;
33651
33825
  }
33826
+ /**
33827
+ * Returns true if a Segment returned by the corresponding index is still
33828
+ * considered available.
33829
+ * Returns false if it is not available anymore.
33830
+ * Returns undefined if we cannot know whether it is still available or not.
33831
+ * /!\ We do not check the mediaURLs of the segment.
33832
+ * @param {Object} segment
33833
+ * @param {Object} index
33834
+ * @param {Object} manifestBoundsCalculator
33835
+ * @param {number|undefined} scaledPeriodEnd
33836
+ * @returns {Boolean|undefined}
33837
+ */
33838
+ function _isSegmentStillAvailable(segment, index, manifestBoundsCalculator, scaledPeriodEnd) {
33839
+ var lastReqSegInfo = getLastRequestableSegmentInfo(index, manifestBoundsCalculator, scaledPeriodEnd);
33840
+ if (lastReqSegInfo === null) {
33841
+ return false;
33842
+ }
33843
+ for (var i = 0; i < index.timeline.length; i++) {
33844
+ if (lastReqSegInfo.timelineIdx < i) {
33845
+ return false;
33846
+ }
33847
+ var tSegment = index.timeline[i];
33848
+ var tSegmentTime = (tSegment.start - index.indexTimeOffset) / index.timescale;
33849
+ if (tSegmentTime > segment.time) {
33850
+ return false; // We went over it without finding it
33851
+ } else if (tSegmentTime === segment.time) {
33852
+ if (tSegment.range === undefined) {
33853
+ return segment.range === undefined;
33854
+ }
33855
+ return segment.range != null && tSegment.range[0] === segment.range[0] && tSegment.range[1] === segment.range[1];
33856
+ } else {
33857
+ // tSegment.start < segment.time
33858
+ if (tSegment.repeatCount >= 0 && tSegment.duration !== undefined) {
33859
+ var timeDiff = tSegmentTime - tSegment.start;
33860
+ var repeat = timeDiff / tSegment.duration - 1;
33861
+ return repeat % 1 === 0 && repeat <= lastReqSegInfo.newRepeatCount;
33862
+ }
33863
+ }
33864
+ }
33865
+ return false;
33866
+ }
33867
+ /**
33868
+ * Returns from the given RepresentationIndex information on the last segment
33869
+ * that may be requested currently.
33870
+ *
33871
+ * Returns `null` if there's no such segment.
33872
+ * @param {Object} index
33873
+ * @param {Object} manifestBoundsCalculator
33874
+ * @param {number|undefined} scaledPeriodEnd
33875
+ * @returns {number|null}
33876
+ */
33877
+
33878
+ function getLastRequestableSegmentInfo(index, manifestBoundsCalculator, scaledPeriodEnd) {
33879
+ if (index.timeline.length <= 0) {
33880
+ return null;
33881
+ }
33882
+ if (index.availabilityTimeOffset === Infinity) {
33883
+ // availabilityTimeOffset to Infinity == Everything is requestable in the timeline.
33884
+ var lastIndex = index.timeline.length - 1;
33885
+ var lastElem = index.timeline[lastIndex];
33886
+ return {
33887
+ isLastOfTimeline: true,
33888
+ timelineIdx: lastIndex,
33889
+ newRepeatCount: lastElem.repeatCount,
33890
+ end: getIndexSegmentEnd(lastElem, null, scaledPeriodEnd)
33891
+ };
33892
+ }
33893
+ var adjustedMaxSeconds = manifestBoundsCalculator.getEstimatedMaximumPosition(index.availabilityTimeOffset);
33894
+ if (adjustedMaxSeconds === undefined) {
33895
+ var _lastIndex = index.timeline.length - 1;
33896
+ var _lastElem = index.timeline[_lastIndex];
33897
+ return {
33898
+ isLastOfTimeline: true,
33899
+ timelineIdx: _lastIndex,
33900
+ newRepeatCount: _lastElem.repeatCount,
33901
+ end: getIndexSegmentEnd(_lastElem, null, scaledPeriodEnd)
33902
+ };
33903
+ }
33904
+ for (var i = index.timeline.length - 1; i >= index.timeline.length; i--) {
33905
+ var element = index.timeline[i];
33906
+ var endOfFirstOccurence = element.start + element.duration;
33907
+ if (fromIndexTime(endOfFirstOccurence, index) <= adjustedMaxSeconds) {
33908
+ var endTime = getIndexSegmentEnd(element, index.timeline[i + 1], scaledPeriodEnd);
33909
+ if (fromIndexTime(endTime, index) <= adjustedMaxSeconds) {
33910
+ return {
33911
+ isLastOfTimeline: i === index.timeline.length - 1,
33912
+ timelineIdx: i,
33913
+ newRepeatCount: element.repeatCount,
33914
+ end: endOfFirstOccurence
33915
+ };
33916
+ } else {
33917
+ // We have to find the right repeatCount
33918
+ var maxIndexTime = toIndexTime(adjustedMaxSeconds, index);
33919
+ var diffToSegStart = maxIndexTime - element.start;
33920
+ var nbOfSegs = Math.floor(diffToSegStart / element.duration);
33921
+ assert_assert(nbOfSegs >= 1);
33922
+ return {
33923
+ isLastOfTimeline: false,
33924
+ timelineIdx: i,
33925
+ newRepeatCount: nbOfSegs - 1,
33926
+ end: element.start + nbOfSegs * element.duration
33927
+ };
33928
+ }
33929
+ }
33930
+ }
33931
+ return null;
33932
+ }
33652
33933
  ;// CONCATENATED MODULE: ./src/parsers/manifest/dash/common/indexes/timeline/index.ts
33653
33934
  /**
33654
33935
  * Copyright 2015 CANAL+ Group
@@ -33878,13 +34159,22 @@ var TemplateRepresentationIndex = /*#__PURE__*/function () {
33878
34159
  var timescale = this._index.timescale;
33879
34160
  var segmentTimeRounding = getSegmentTimeRoundingError(timescale);
33880
34161
  var scaledPeriodStart = this._periodStart * timescale;
34162
+ var scaledRelativeStart = start * timescale - scaledPeriodStart;
33881
34163
  var scaledRelativeEnd = end * timescale - scaledPeriodStart;
34164
+ var lastSegmentStart = this._getLastSegmentStart();
34165
+ if (is_null_or_undefined_isNullOrUndefined(lastSegmentStart)) {
34166
+ var _relativeScaledIndexEnd = this._estimateRelativeScaledEnd();
34167
+ if (_relativeScaledIndexEnd === undefined) {
34168
+ return scaledRelativeEnd + segmentTimeRounding >= 0;
34169
+ }
34170
+ return scaledRelativeEnd + segmentTimeRounding >= 0 && scaledRelativeStart < _relativeScaledIndexEnd - segmentTimeRounding;
34171
+ }
34172
+ var lastSegmentEnd = lastSegmentStart + this._index.duration;
33882
34173
  var relativeScaledIndexEnd = this._estimateRelativeScaledEnd();
33883
34174
  if (relativeScaledIndexEnd === undefined) {
33884
- return scaledRelativeEnd + segmentTimeRounding >= 0;
34175
+ return scaledRelativeEnd > lastSegmentEnd - segmentTimeRounding;
33885
34176
  }
33886
- var scaledRelativeStart = start * timescale - scaledPeriodStart;
33887
- return scaledRelativeStart - segmentTimeRounding < relativeScaledIndexEnd;
34177
+ return scaledRelativeEnd > lastSegmentEnd - segmentTimeRounding && scaledRelativeStart < relativeScaledIndexEnd - segmentTimeRounding;
33888
34178
  }
33889
34179
  /**
33890
34180
  * Returns true if, based on the arguments, the index should be refreshed.
@@ -33927,30 +34217,30 @@ var TemplateRepresentationIndex = /*#__PURE__*/function () {
33927
34217
  return false;
33928
34218
  }
33929
34219
  /**
33930
- * Returns `true` if the last segments in this index have already been
34220
+ * Returns `false` if the last segments in this index have already been
33931
34221
  * generated so that we can freely go to the next period.
33932
- * Returns `false` if the index is still waiting on future segments to be
34222
+ * Returns `true` if the index is still waiting on future segments to be
33933
34223
  * generated.
33934
34224
  * @returns {Boolean}
33935
34225
  */;
33936
- _proto.isFinished = function isFinished() {
34226
+ _proto.isStillAwaitingFutureSegments = function isStillAwaitingFutureSegments() {
33937
34227
  if (!this._isDynamic) {
33938
- return true;
34228
+ return false;
33939
34229
  }
33940
34230
  var scaledRelativeIndexEnd = this._estimateRelativeScaledEnd();
33941
34231
  if (scaledRelativeIndexEnd === undefined) {
33942
- return false;
34232
+ return true;
33943
34233
  }
33944
34234
  var timescale = this._index.timescale;
33945
34235
  var lastSegmentStart = this._getLastSegmentStart();
33946
34236
  // As last segment start is null if live time is before
33947
34237
  // current period, consider the index not to be finished.
33948
34238
  if (is_null_or_undefined_isNullOrUndefined(lastSegmentStart)) {
33949
- return false;
34239
+ return true;
33950
34240
  }
33951
34241
  var lastSegmentEnd = lastSegmentStart + this._index.duration;
33952
34242
  var segmentTimeRounding = getSegmentTimeRoundingError(timescale);
33953
- return lastSegmentEnd + segmentTimeRounding >= scaledRelativeIndexEnd;
34243
+ return lastSegmentEnd + segmentTimeRounding < scaledRelativeIndexEnd;
33954
34244
  }
33955
34245
  /**
33956
34246
  * @returns {Boolean}
@@ -33988,6 +34278,7 @@ var TemplateRepresentationIndex = /*#__PURE__*/function () {
33988
34278
  * @returns {number | null | undefined}
33989
34279
  */;
33990
34280
  _proto._getFirstSegmentStart = function _getFirstSegmentStart() {
34281
+ var _a;
33991
34282
  if (!this._isDynamic) {
33992
34283
  return 0; // it is the start of the Period
33993
34284
  }
@@ -33996,8 +34287,8 @@ var TemplateRepresentationIndex = /*#__PURE__*/function () {
33996
34287
  // /!\ The scaled max position augments continuously and might not
33997
34288
  // reflect exactly the real server-side value. As segments are
33998
34289
  // generated discretely.
33999
- var maximumBound = this._manifestBoundsCalculator.estimateMaximumBound();
34000
- if (maximumBound !== undefined && maximumBound < this._periodStart) {
34290
+ var maximumSegmentTime = this._manifestBoundsCalculator.getEstimatedMaximumPosition((_a = this._availabilityTimeOffset) !== null && _a !== void 0 ? _a : 0);
34291
+ if (maximumSegmentTime !== undefined && maximumSegmentTime < this._periodStart) {
34001
34292
  // Maximum position is before this period.
34002
34293
  // No segment is yet available here
34003
34294
  return null;
@@ -34006,7 +34297,7 @@ var TemplateRepresentationIndex = /*#__PURE__*/function () {
34006
34297
  var _this$_index = this._index,
34007
34298
  duration = _this$_index.duration,
34008
34299
  timescale = _this$_index.timescale;
34009
- var firstPosition = this._manifestBoundsCalculator.estimateMinimumBound();
34300
+ var firstPosition = this._manifestBoundsCalculator.getEstimatedMinimumSegmentTime();
34010
34301
  if (firstPosition === undefined) {
34011
34302
  return undefined;
34012
34303
  }
@@ -34021,7 +34312,7 @@ var TemplateRepresentationIndex = /*#__PURE__*/function () {
34021
34312
  * @returns {number|null|undefined}
34022
34313
  */;
34023
34314
  _proto._getLastSegmentStart = function _getLastSegmentStart() {
34024
- var _a;
34315
+ var _a, _b;
34025
34316
  var _this$_index2 = this._index,
34026
34317
  duration = _this$_index2.duration,
34027
34318
  timescale = _this$_index2.timescale,
@@ -34029,34 +34320,34 @@ var TemplateRepresentationIndex = /*#__PURE__*/function () {
34029
34320
  _this$_index2$startNu = _this$_index2.startNumber,
34030
34321
  startNumber = _this$_index2$startNu === void 0 ? 1 : _this$_index2$startNu;
34031
34322
  if (this._isDynamic) {
34032
- var lastPos = this._manifestBoundsCalculator.estimateMaximumBound();
34033
- if (lastPos === undefined) {
34034
- return undefined;
34035
- }
34036
- if (this._scaledRelativePeriodEnd !== undefined && this._scaledRelativePeriodEnd < (lastPos - this._periodStart) * this._index.timescale) {
34323
+ var liveEdge = this._manifestBoundsCalculator.getEstimatedLiveEdge();
34324
+ if (liveEdge !== undefined && this._scaledRelativePeriodEnd !== undefined && this._scaledRelativePeriodEnd < liveEdge - this._periodStart * this._index.timescale) {
34037
34325
  var numberOfSegments = Math.ceil(this._scaledRelativePeriodEnd / duration);
34038
34326
  if (endNumber !== undefined && endNumber - startNumber + 1 < numberOfSegments) {
34039
34327
  numberOfSegments = endNumber - startNumber + 1;
34040
34328
  }
34041
34329
  return (numberOfSegments - 1) * duration;
34042
34330
  }
34331
+ var lastPosition = this._manifestBoundsCalculator.getEstimatedMaximumPosition((_a = this._availabilityTimeOffset) !== null && _a !== void 0 ? _a : 0);
34332
+ if (lastPosition === undefined) {
34333
+ return undefined;
34334
+ }
34043
34335
  // /!\ The scaled last position augments continuously and might not
34044
34336
  // reflect exactly the real server-side value. As segments are
34045
34337
  // generated discretely.
34046
- var scaledLastPosition = (lastPos - this._periodStart) * timescale;
34338
+ var scaledLastPosition = (lastPosition - this._periodStart) * timescale;
34047
34339
  // Maximum position is before this period.
34048
34340
  // No segment is yet available here
34049
34341
  if (scaledLastPosition < 0) {
34050
34342
  return null;
34051
34343
  }
34052
- var availabilityTimeOffset = (this._availabilityTimeOffset !== undefined ? this._availabilityTimeOffset : 0) * timescale;
34053
- var numberOfSegmentsAvailable = Math.floor((scaledLastPosition + availabilityTimeOffset) / duration);
34344
+ var numberOfSegmentsAvailable = Math.floor(scaledLastPosition / duration);
34054
34345
  if (endNumber !== undefined && endNumber - startNumber + 1 < numberOfSegmentsAvailable) {
34055
34346
  numberOfSegmentsAvailable = endNumber - startNumber + 1;
34056
34347
  }
34057
34348
  return numberOfSegmentsAvailable <= 0 ? null : (numberOfSegmentsAvailable - 1) * duration;
34058
34349
  } else {
34059
- var maximumTime = (_a = this._scaledRelativePeriodEnd) !== null && _a !== void 0 ? _a : 0;
34350
+ var maximumTime = (_b = this._scaledRelativePeriodEnd) !== null && _b !== void 0 ? _b : 0;
34060
34351
  var _numberOfSegments = Math.ceil(maximumTime / duration);
34061
34352
  if (endNumber !== undefined && endNumber - startNumber + 1 < _numberOfSegments) {
34062
34353
  _numberOfSegments = endNumber - startNumber + 1;
@@ -34128,7 +34419,6 @@ function parseRepresentationIndex(representation, context) {
34128
34419
  periodEnd = context.end,
34129
34420
  periodStart = context.start,
34130
34421
  receivedTime = context.receivedTime,
34131
- timeShiftBufferDepth = context.timeShiftBufferDepth,
34132
34422
  unsafelyBaseOnPreviousRepresentation = context.unsafelyBaseOnPreviousRepresentation,
34133
34423
  inbandEventStreams = context.inbandEventStreams,
34134
34424
  isLastPeriod = context.isLastPeriod;
@@ -34142,7 +34432,7 @@ function parseRepresentationIndex(representation, context) {
34142
34432
  });
34143
34433
  };
34144
34434
  var reprIndexCtxt = {
34145
- availabilityTimeComplete: true,
34435
+ availabilityTimeComplete: undefined,
34146
34436
  availabilityTimeOffset: availabilityTimeOffset,
34147
34437
  unsafelyBaseOnPreviousRepresentation: unsafelyBaseOnPreviousRepresentation,
34148
34438
  isEMSGWhitelisted: isEMSGWhitelisted,
@@ -34153,8 +34443,7 @@ function parseRepresentationIndex(representation, context) {
34153
34443
  periodStart: periodStart,
34154
34444
  receivedTime: receivedTime,
34155
34445
  representationBitrate: representation.attributes.bitrate,
34156
- representationId: representation.attributes.id,
34157
- timeShiftBufferDepth: timeShiftBufferDepth
34446
+ representationId: representation.attributes.id
34158
34447
  };
34159
34448
  var representationIndex;
34160
34449
  if (representation.children.segmentBase !== undefined) {
@@ -34170,8 +34459,9 @@ function parseRepresentationIndex(representation, context) {
34170
34459
  segmentTemplates.push(childSegmentTemplate);
34171
34460
  }
34172
34461
  var segmentTemplate = object_assign.apply(void 0, [{}].concat(segmentTemplates));
34173
- reprIndexCtxt.availabilityTimeComplete = (_a = segmentTemplate.availabilityTimeComplete) !== null && _a !== void 0 ? _a : context.availabilityTimeComplete;
34174
- reprIndexCtxt.availabilityTimeOffset = ((_b = segmentTemplate.availabilityTimeOffset) !== null && _b !== void 0 ? _b : 0) + context.availabilityTimeOffset;
34462
+ if (segmentTemplate.availabilityTimeOffset !== undefined || context.availabilityTimeOffset !== undefined) {
34463
+ reprIndexCtxt.availabilityTimeOffset = ((_a = segmentTemplate.availabilityTimeOffset) !== null && _a !== void 0 ? _a : 0) + ((_b = context.availabilityTimeOffset) !== null && _b !== void 0 ? _b : 0);
34464
+ }
34175
34465
  representationIndex = timeline.isTimelineIndexArgument(segmentTemplate) ? new timeline(segmentTemplate, reprIndexCtxt) : new TemplateRepresentationIndex(segmentTemplate, reprIndexCtxt);
34176
34466
  } else {
34177
34467
  var adaptationChildren = context.adaptation.children;
@@ -34337,7 +34627,7 @@ function getHDRInformation(_ref) {
34337
34627
  * @returns {Array.<Object>}
34338
34628
  */
34339
34629
  function parseRepresentations(representationsIR, adaptation, context) {
34340
- var _a, _b, _c, _d;
34630
+ var _a, _b, _c, _d, _e;
34341
34631
  var parsedRepresentations = [];
34342
34632
  var _loop = function _loop() {
34343
34633
  var representation = _step.value;
@@ -34353,7 +34643,10 @@ function parseRepresentations(representationsIR, adaptation, context) {
34353
34643
  var unsafelyBaseOnPreviousRepresentation = (_b = (_a = context.unsafelyBaseOnPreviousAdaptation) === null || _a === void 0 ? void 0 : _a.getRepresentation(representationID)) !== null && _b !== void 0 ? _b : null;
34354
34644
  var inbandEventStreams = combineInbandEventStreams(representation, adaptation);
34355
34645
  var availabilityTimeComplete = (_c = representation.attributes.availabilityTimeComplete) !== null && _c !== void 0 ? _c : context.availabilityTimeComplete;
34356
- var availabilityTimeOffset = ((_d = representation.attributes.availabilityTimeOffset) !== null && _d !== void 0 ? _d : 0) + context.availabilityTimeOffset;
34646
+ var availabilityTimeOffset;
34647
+ if (representation.attributes.availabilityTimeOffset !== undefined || context.availabilityTimeOffset !== undefined) {
34648
+ availabilityTimeOffset = ((_d = representation.attributes.availabilityTimeOffset) !== null && _d !== void 0 ? _d : 0) + ((_e = context.availabilityTimeOffset) !== null && _e !== void 0 ? _e : 0);
34649
+ }
34357
34650
  var reprIndexCtxt = object_assign({}, context, {
34358
34651
  availabilityTimeOffset: availabilityTimeOffset,
34359
34652
  availabilityTimeComplete: availabilityTimeComplete,
@@ -34671,7 +34964,7 @@ function getAdaptationSetSwitchingIDs(adaptation) {
34671
34964
  * @returns {Array.<Object>}
34672
34965
  */
34673
34966
  function parseAdaptationSets(adaptationsIR, context) {
34674
- var _a, _b, _c, _d, _e, _f;
34967
+ var _a, _b, _c, _d, _e, _f, _g;
34675
34968
  var parsedAdaptations = {
34676
34969
  video: [],
34677
34970
  audio: [],
@@ -34693,14 +34986,17 @@ function parseAdaptationSets(adaptationsIR, context) {
34693
34986
  });
34694
34987
  var representationsIR = adaptation.children.representations;
34695
34988
  var availabilityTimeComplete = (_a = adaptation.attributes.availabilityTimeComplete) !== null && _a !== void 0 ? _a : context.availabilityTimeComplete;
34696
- var availabilityTimeOffset = ((_b = adaptation.attributes.availabilityTimeOffset) !== null && _b !== void 0 ? _b : 0) + context.availabilityTimeOffset;
34989
+ var availabilityTimeOffset = void 0;
34990
+ if (adaptation.attributes.availabilityTimeOffset !== undefined || context.availabilityTimeOffset !== undefined) {
34991
+ availabilityTimeOffset = ((_b = adaptation.attributes.availabilityTimeOffset) !== null && _b !== void 0 ? _b : 0) + ((_c = context.availabilityTimeOffset) !== null && _c !== void 0 ? _c : 0);
34992
+ }
34697
34993
  var adaptationMimeType = adaptation.attributes.mimeType;
34698
34994
  var adaptationCodecs = adaptation.attributes.codecs;
34699
34995
  var type = inferAdaptationType(representationsIR, isNonEmptyString(adaptationMimeType) ? adaptationMimeType : null, isNonEmptyString(adaptationCodecs) ? adaptationCodecs : null, adaptationChildren.roles != null ? adaptationChildren.roles : null);
34700
34996
  if (type === undefined) {
34701
34997
  continue;
34702
34998
  }
34703
- var priority = (_c = adaptation.attributes.selectionPriority) !== null && _c !== void 0 ? _c : 1;
34999
+ var priority = (_d = adaptation.attributes.selectionPriority) !== null && _d !== void 0 ? _d : 1;
34704
35000
  var originalID = adaptation.attributes.id;
34705
35001
  var adaptationSetSwitchingIDs = getAdaptationSetSwitchingIDs(adaptation);
34706
35002
  var parentSegmentTemplates = [];
@@ -34722,13 +35018,12 @@ function parseAdaptationSets(adaptationsIR, context) {
34722
35018
  parentSegmentTemplates: parentSegmentTemplates,
34723
35019
  receivedTime: context.receivedTime,
34724
35020
  start: context.start,
34725
- timeShiftBufferDepth: context.timeShiftBufferDepth,
34726
35021
  unsafelyBaseOnPreviousAdaptation: null
34727
35022
  };
34728
35023
  var trickModeProperty = Array.isArray(essentialProperties) ? arrayFind(essentialProperties, function (scheme) {
34729
35024
  return scheme.schemeIdUri === "http://dashif.org/guidelines/trickmode";
34730
35025
  }) : undefined;
34731
- var trickModeAttachedAdaptationIds = (_d = trickModeProperty === null || trickModeProperty === void 0 ? void 0 : trickModeProperty.value) === null || _d === void 0 ? void 0 : _d.split(" ");
35026
+ var trickModeAttachedAdaptationIds = (_e = trickModeProperty === null || trickModeProperty === void 0 ? void 0 : trickModeProperty.value) === null || _e === void 0 ? void 0 : _e.split(" ");
34732
35027
  var isTrickModeTrack = trickModeAttachedAdaptationIds !== undefined;
34733
35028
  var accessibilities = adaptationChildren.accessibilities;
34734
35029
  var isDub = void 0;
@@ -34775,7 +35070,7 @@ function parseAdaptationSets(adaptationsIR, context) {
34775
35070
  }
34776
35071
  var newID = adaptationID;
34777
35072
  parsedAdaptationsIDs.push(adaptationID);
34778
- reprCtxt.unsafelyBaseOnPreviousAdaptation = (_f = (_e = context.unsafelyBaseOnPreviousPeriod) === null || _e === void 0 ? void 0 : _e.getAdaptation(adaptationID)) !== null && _f !== void 0 ? _f : null;
35073
+ reprCtxt.unsafelyBaseOnPreviousAdaptation = (_g = (_f = context.unsafelyBaseOnPreviousPeriod) === null || _f === void 0 ? void 0 : _f.getAdaptation(adaptationID)) !== null && _g !== void 0 ? _g : null;
34779
35074
  var representations = parseRepresentations(representationsIR, adaptation, reprCtxt);
34780
35075
  var parsedAdaptationSet = {
34781
35076
  id: adaptationID,
@@ -34909,8 +35204,8 @@ function parse_periods_arrayLikeToArray(arr, len) { if (len == null || len > arr
34909
35204
 
34910
35205
 
34911
35206
 
34912
- // eslint-disable-next-line max-len
34913
35207
 
35208
+ // eslint-disable-next-line max-len
34914
35209
 
34915
35210
 
34916
35211
 
@@ -34923,19 +35218,15 @@ var generatePeriodID = idGenerator();
34923
35218
  * @returns {Array.<Object>}
34924
35219
  */
34925
35220
  function parsePeriods(periodsIR, context) {
34926
- var _a, _b, _c, _d, _e, _f;
35221
+ var _a, _b, _c, _d;
34927
35222
  var parsedPeriods = [];
34928
35223
  var periodsTimeInformation = getPeriodsTimeInformation(periodsIR, context);
34929
35224
  if (periodsTimeInformation.length !== periodsIR.length) {
34930
35225
  throw new Error("MPD parsing error: the time information are incoherent.");
34931
35226
  }
34932
35227
  var isDynamic = context.isDynamic,
34933
- timeShiftBufferDepth = context.timeShiftBufferDepth;
34934
- var manifestBoundsCalculator = new ManifestBoundsCalculator({
34935
- isDynamic: isDynamic,
34936
- timeShiftBufferDepth: timeShiftBufferDepth
34937
- });
34938
- if (!isDynamic && context.duration != null) {
35228
+ manifestBoundsCalculator = context.manifestBoundsCalculator;
35229
+ if (!isDynamic && !is_null_or_undefined_isNullOrUndefined(context.duration)) {
34939
35230
  manifestBoundsCalculator.setLastPosition(context.duration);
34940
35231
  }
34941
35232
  // We parse it in reverse because we might need to deduce the buffer depth from
@@ -34950,7 +35241,7 @@ function parsePeriods(periodsIR, context) {
34950
35241
  periodDuration = _periodsTimeInformati.periodDuration,
34951
35242
  periodEnd = _periodsTimeInformati.periodEnd;
34952
35243
  var periodID;
34953
- if (periodIR.attributes.id == null) {
35244
+ if (is_null_or_undefined_isNullOrUndefined(periodIR.attributes.id)) {
34954
35245
  src_log.warn("DASH: No usable id found in the Period. Generating one.");
34955
35246
  periodID = "gen-dash-period-" + generatePeriodID();
34956
35247
  } else {
@@ -34964,8 +35255,8 @@ function parsePeriods(periodsIR, context) {
34964
35255
  }
34965
35256
  var receivedTime = xlinkInfos !== undefined ? xlinkInfos.receivedTime : context.receivedTime;
34966
35257
  var unsafelyBaseOnPreviousPeriod = (_b = (_a = context.unsafelyBaseOnPreviousManifest) === null || _a === void 0 ? void 0 : _a.getPeriod(periodID)) !== null && _b !== void 0 ? _b : null;
34967
- var availabilityTimeComplete = (_c = periodIR.attributes.availabilityTimeComplete) !== null && _c !== void 0 ? _c : true;
34968
- var availabilityTimeOffset = (_d = periodIR.attributes.availabilityTimeOffset) !== null && _d !== void 0 ? _d : 0;
35258
+ var availabilityTimeComplete = periodIR.attributes.availabilityTimeComplete;
35259
+ var availabilityTimeOffset = periodIR.attributes.availabilityTimeOffset;
34969
35260
  var manifestProfiles = context.manifestProfiles;
34970
35261
  var segmentTemplate = periodIR.children.segmentTemplate;
34971
35262
  var adapCtxt = {
@@ -34980,11 +35271,10 @@ function parsePeriods(periodsIR, context) {
34980
35271
  receivedTime: receivedTime,
34981
35272
  segmentTemplate: segmentTemplate,
34982
35273
  start: periodStart,
34983
- timeShiftBufferDepth: timeShiftBufferDepth,
34984
35274
  unsafelyBaseOnPreviousPeriod: unsafelyBaseOnPreviousPeriod
34985
35275
  };
34986
35276
  var adaptations = parseAdaptationSets(periodIR.children.adaptations, adapCtxt);
34987
- var namespaces = ((_e = context.xmlNamespaces) !== null && _e !== void 0 ? _e : []).concat((_f = periodIR.attributes.namespaces) !== null && _f !== void 0 ? _f : []);
35277
+ var namespaces = ((_c = context.xmlNamespaces) !== null && _c !== void 0 ? _c : []).concat((_d = periodIR.attributes.namespaces) !== null && _d !== void 0 ? _d : []);
34988
35278
  var streamEvents = generateStreamEvents(periodIR.children.eventStreams, periodStart, namespaces);
34989
35279
  var parsedPeriod = {
34990
35280
  id: periodID,
@@ -35059,7 +35349,7 @@ function parsePeriods(periodsIR, context) {
35059
35349
  * @returns {Array.<number|undefined>}
35060
35350
  */
35061
35351
  function guessLastPositionFromClock(context, minimumTime) {
35062
- if (context.clockOffset != null) {
35352
+ if (!is_null_or_undefined_isNullOrUndefined(context.clockOffset)) {
35063
35353
  var lastPosition = context.clockOffset / 1000 - context.availabilityStartTime;
35064
35354
  var positionTime = getMonotonicTimeStamp() / 1000;
35065
35355
  var timeInSec = positionTime + lastPosition;
@@ -35091,7 +35381,7 @@ function getMaximumLastPosition(adaptationsPerType) {
35091
35381
  var maxEncounteredPosition = null;
35092
35382
  var allIndexAreEmpty = true;
35093
35383
  var adaptationsVal = object_values(adaptationsPerType).filter(function (ada) {
35094
- return ada != null;
35384
+ return !is_null_or_undefined_isNullOrUndefined(ada);
35095
35385
  });
35096
35386
  var allAdaptations = flatMap(adaptationsVal, function (adaptationsForType) {
35097
35387
  return adaptationsForType;
@@ -35105,12 +35395,12 @@ function getMaximumLastPosition(adaptationsPerType) {
35105
35395
  if (position !== null) {
35106
35396
  allIndexAreEmpty = false;
35107
35397
  if (typeof position === "number") {
35108
- maxEncounteredPosition = maxEncounteredPosition == null ? position : Math.max(maxEncounteredPosition, position);
35398
+ maxEncounteredPosition = is_null_or_undefined_isNullOrUndefined(maxEncounteredPosition) ? position : Math.max(maxEncounteredPosition, position);
35109
35399
  }
35110
35400
  }
35111
35401
  }
35112
35402
  }
35113
- if (maxEncounteredPosition != null) {
35403
+ if (!is_null_or_undefined_isNullOrUndefined(maxEncounteredPosition)) {
35114
35404
  return maxEncounteredPosition;
35115
35405
  } else if (allIndexAreEmpty) {
35116
35406
  return null;
@@ -35208,6 +35498,7 @@ function parse_mpd_arrayLikeToArray(arr, len) { if (len == null || len > arr.len
35208
35498
 
35209
35499
 
35210
35500
 
35501
+
35211
35502
  /**
35212
35503
  * Checks if xlinks needs to be loaded before actually parsing the manifest.
35213
35504
  * @param {Object} mpdIR
@@ -35330,12 +35621,20 @@ function parseCompleteIntermediateRepresentation(mpdIR, args, warnings, xlinkInf
35330
35621
  var timeShiftBufferDepth = rootAttributes.timeShiftBufferDepth;
35331
35622
  var clockOffset = args.externalClockOffset,
35332
35623
  unsafelyBaseOnPreviousManifest = args.unsafelyBaseOnPreviousManifest;
35624
+ var externalClockOffset = args.externalClockOffset;
35625
+ var manifestBoundsCalculator = new ManifestBoundsCalculator({
35626
+ availabilityStartTime: availabilityStartTime,
35627
+ isDynamic: isDynamic,
35628
+ timeShiftBufferDepth: timeShiftBufferDepth,
35629
+ serverTimestampOffset: externalClockOffset
35630
+ });
35333
35631
  var manifestInfos = {
35334
35632
  availabilityStartTime: availabilityStartTime,
35335
35633
  baseURLs: mpdBaseUrls,
35336
35634
  clockOffset: clockOffset,
35337
35635
  duration: rootAttributes.duration,
35338
35636
  isDynamic: isDynamic,
35637
+ manifestBoundsCalculator: manifestBoundsCalculator,
35339
35638
  manifestProfiles: mpdIR.attributes.profiles,
35340
35639
  receivedTime: args.manifestReceivedTime,
35341
35640
  timeShiftBufferDepth: timeShiftBufferDepth,
@@ -35377,29 +35676,32 @@ function parseCompleteIntermediateRepresentation(mpdIR, args, warnings, xlinkInf
35377
35676
  time: now
35378
35677
  };
35379
35678
  } else {
35380
- minimumTime = minimumSafePosition;
35381
- timeshiftDepth = timeShiftBufferDepth !== null && timeShiftBufferDepth !== void 0 ? timeShiftBufferDepth : null;
35679
+ // Determine the maximum seekable position
35382
35680
  var _finalMaximumSafePosition;
35383
- var livePosition;
35384
- if (maximumUnsafePosition !== undefined) {
35385
- livePosition = maximumUnsafePosition;
35386
- }
35387
35681
  if (maximumSafePosition !== undefined) {
35388
35682
  _finalMaximumSafePosition = maximumSafePosition;
35389
35683
  } else {
35390
- var ast = availabilityStartTime !== null && availabilityStartTime !== void 0 ? availabilityStartTime : 0;
35391
- var externalClockOffset = args.externalClockOffset;
35392
35684
  if (externalClockOffset === undefined) {
35393
35685
  src_log.warn("DASH Parser: use system clock to define maximum position");
35394
- _finalMaximumSafePosition = Date.now() / 1000 - ast;
35686
+ _finalMaximumSafePosition = Date.now() / 1000 - availabilityStartTime;
35395
35687
  } else {
35396
35688
  var serverTime = getMonotonicTimeStamp() + externalClockOffset;
35397
- _finalMaximumSafePosition = serverTime / 1000 - ast;
35689
+ _finalMaximumSafePosition = serverTime / 1000 - availabilityStartTime;
35398
35690
  }
35399
35691
  }
35692
+ // Determine live edge (what position corresponds to live content, can be
35693
+ // inferior or superior to the maximum anounced position in some specific
35694
+ // scenarios). However, the `timeShiftBufferDepth` should be based on it.
35695
+ var livePosition = manifestBoundsCalculator.getEstimatedLiveEdge();
35400
35696
  if (livePosition === undefined) {
35401
- livePosition = _finalMaximumSafePosition;
35697
+ if (maximumUnsafePosition !== undefined) {
35698
+ livePosition = maximumUnsafePosition;
35699
+ } else {
35700
+ livePosition = _finalMaximumSafePosition;
35701
+ }
35702
+ // manifestBoundsCalculator.forceLiveEdge(livePosition);
35402
35703
  }
35704
+
35403
35705
  maximumTimeData = {
35404
35706
  isLinear: true,
35405
35707
  maximumSafePosition: _finalMaximumSafePosition,
@@ -35408,8 +35710,10 @@ function parseCompleteIntermediateRepresentation(mpdIR, args, warnings, xlinkInf
35408
35710
  };
35409
35711
  // if the minimum calculated time is even below the buffer depth, perhaps we
35410
35712
  // can go even lower in terms of depth
35411
- if (timeshiftDepth !== null && minimumTime !== undefined && _finalMaximumSafePosition - minimumTime > timeshiftDepth) {
35412
- timeshiftDepth = _finalMaximumSafePosition - minimumTime;
35713
+ minimumTime = minimumSafePosition;
35714
+ timeshiftDepth = timeShiftBufferDepth !== null && timeShiftBufferDepth !== void 0 ? timeShiftBufferDepth : null;
35715
+ if (timeshiftDepth !== null && minimumTime !== undefined && livePosition - minimumTime > timeshiftDepth) {
35716
+ timeshiftDepth = livePosition - minimumTime;
35413
35717
  }
35414
35718
  }
35415
35719
  // `isLastPeriodKnown` should be `true` in two cases for DASH contents:
@@ -37562,15 +37866,18 @@ function generateManifestParser(options) {
37562
37866
  var externalResources = value.urls.map(function (resourceUrl) {
37563
37867
  return scheduleRequest(function () {
37564
37868
  var defaultTimeout = config.getCurrent().DEFAULT_REQUEST_TIMEOUT;
37869
+ var defaultConnectionTimeout = config.getCurrent().DEFAULT_CONNECTION_TIMEOUT;
37565
37870
  return value.format === "string" ? utils_request({
37566
37871
  url: resourceUrl,
37567
37872
  responseType: "text",
37568
37873
  timeout: defaultTimeout,
37874
+ connectionTimeout: defaultConnectionTimeout,
37569
37875
  cancelSignal: cancelSignal
37570
37876
  }) : utils_request({
37571
37877
  url: resourceUrl,
37572
37878
  responseType: "arraybuffer",
37573
37879
  timeout: defaultTimeout,
37880
+ connectionTimeout: defaultConnectionTimeout,
37574
37881
  cancelSignal: cancelSignal
37575
37882
  });
37576
37883
  }).then(function (res) {
@@ -37764,7 +38071,8 @@ function fetchRequest(options) {
37764
38071
  }
37765
38072
  src_log.debug("Fetch: Called with URL", options.url);
37766
38073
  var cancellation = null;
37767
- var timeouted = false;
38074
+ var isTimedOut = false;
38075
+ var isConnectionTimedOut = false;
37768
38076
  var sendingTime = getMonotonicTimeStamp();
37769
38077
  var abortController = !is_null_or_undefined_isNullOrUndefined(_AbortController) ? new _AbortController() : null;
37770
38078
  /**
@@ -37778,13 +38086,26 @@ function fetchRequest(options) {
37778
38086
  }
37779
38087
  abortController.abort();
37780
38088
  }
37781
- var timeout;
38089
+ var timeoutId;
37782
38090
  if (options.timeout !== undefined) {
37783
- timeout = setTimeout(function () {
37784
- timeouted = true;
38091
+ timeoutId = setTimeout(function () {
38092
+ isTimedOut = true;
38093
+ if (connectionTimeoutId !== undefined) {
38094
+ clearTimeout(connectionTimeoutId);
38095
+ }
37785
38096
  abortFetch();
37786
38097
  }, options.timeout);
37787
38098
  }
38099
+ var connectionTimeoutId;
38100
+ if (options.connectionTimeout !== undefined) {
38101
+ connectionTimeoutId = setTimeout(function () {
38102
+ isConnectionTimedOut = true;
38103
+ if (timeoutId !== undefined) {
38104
+ clearTimeout(timeoutId);
38105
+ }
38106
+ abortFetch();
38107
+ }, options.connectionTimeout);
38108
+ }
37788
38109
  var deregisterCancelLstnr = options.cancelSignal.register(function abortRequest(err) {
37789
38110
  cancellation = err;
37790
38111
  abortFetch();
@@ -37797,8 +38118,8 @@ function fetchRequest(options) {
37797
38118
  }
37798
38119
  fetchOpts.signal = !is_null_or_undefined_isNullOrUndefined(abortController) ? abortController.signal : null;
37799
38120
  return fetch(options.url, fetchOpts).then(function (response) {
37800
- if (!is_null_or_undefined_isNullOrUndefined(timeout)) {
37801
- clearTimeout(timeout);
38121
+ if (connectionTimeoutId !== undefined) {
38122
+ clearTimeout(connectionTimeoutId);
37802
38123
  }
37803
38124
  if (response.status >= 300) {
37804
38125
  src_log.warn("Fetch: Request HTTP Error", response.status, response.url);
@@ -37845,9 +38166,12 @@ function fetchRequest(options) {
37845
38166
  return _context.abrupt("return", readBufferAndSendEvents());
37846
38167
  case 11:
37847
38168
  if (!data.done) {
37848
- _context.next = 16;
38169
+ _context.next = 17;
37849
38170
  break;
37850
38171
  }
38172
+ if (timeoutId !== undefined) {
38173
+ clearTimeout(timeoutId);
38174
+ }
37851
38175
  deregisterCancelLstnr();
37852
38176
  receivedTime = getMonotonicTimeStamp();
37853
38177
  requestDuration = receivedTime - sendingTime;
@@ -37859,9 +38183,9 @@ function fetchRequest(options) {
37859
38183
  status: response.status,
37860
38184
  url: response.url
37861
38185
  });
37862
- case 16:
37863
- return _context.abrupt("return", readBufferAndSendEvents());
37864
38186
  case 17:
38187
+ return _context.abrupt("return", readBufferAndSendEvents());
38188
+ case 18:
37865
38189
  case "end":
37866
38190
  return _context.stop();
37867
38191
  }
@@ -37874,8 +38198,11 @@ function fetchRequest(options) {
37874
38198
  throw cancellation;
37875
38199
  }
37876
38200
  deregisterCancelLstnr();
37877
- if (timeouted) {
37878
- src_log.warn("Fetch: Request timeouted.");
38201
+ if (isTimedOut) {
38202
+ src_log.warn("Fetch: Request timed out.");
38203
+ throw new RequestError(options.url, 0, NetworkErrorTypes.TIMEOUT);
38204
+ } else if (isConnectionTimedOut) {
38205
+ src_log.warn("Fetch: Request connection timed out.");
37879
38206
  throw new RequestError(options.url, 0, NetworkErrorTypes.TIMEOUT);
37880
38207
  } else if (err instanceof RequestError) {
37881
38208
  throw err;
@@ -38068,6 +38395,7 @@ function initSegmentLoader(url, segment, options, cancelSignal, callbacks) {
38068
38395
  url: url,
38069
38396
  responseType: "arraybuffer",
38070
38397
  timeout: options.timeout,
38398
+ connectionTimeout: options.connectionTimeout,
38071
38399
  cancelSignal: cancelSignal,
38072
38400
  onProgress: callbacks.onProgress
38073
38401
  }).then(function (data) {
@@ -38085,6 +38413,7 @@ function initSegmentLoader(url, segment, options, cancelSignal, callbacks) {
38085
38413
  },
38086
38414
  responseType: "arraybuffer",
38087
38415
  timeout: options.timeout,
38416
+ connectionTimeout: options.connectionTimeout,
38088
38417
  cancelSignal: cancelSignal,
38089
38418
  onProgress: callbacks.onProgress
38090
38419
  }).then(function (data) {
@@ -38103,6 +38432,7 @@ function initSegmentLoader(url, segment, options, cancelSignal, callbacks) {
38103
38432
  },
38104
38433
  responseType: "arraybuffer",
38105
38434
  timeout: options.timeout,
38435
+ connectionTimeout: options.connectionTimeout,
38106
38436
  cancelSignal: cancelSignal,
38107
38437
  onProgress: callbacks.onProgress
38108
38438
  }).then(function (data) {
@@ -38119,6 +38449,7 @@ function initSegmentLoader(url, segment, options, cancelSignal, callbacks) {
38119
38449
  },
38120
38450
  responseType: "arraybuffer",
38121
38451
  timeout: options.timeout,
38452
+ connectionTimeout: options.connectionTimeout,
38122
38453
  cancelSignal: cancelSignal,
38123
38454
  onProgress: callbacks.onProgress
38124
38455
  });
@@ -38129,6 +38460,7 @@ function initSegmentLoader(url, segment, options, cancelSignal, callbacks) {
38129
38460
  },
38130
38461
  responseType: "arraybuffer",
38131
38462
  timeout: options.timeout,
38463
+ connectionTimeout: options.connectionTimeout,
38132
38464
  cancelSignal: cancelSignal,
38133
38465
  onProgress: callbacks.onProgress
38134
38466
  });
@@ -38342,6 +38674,7 @@ function segment_loader_regularSegmentLoader(url, context, lowLatencyMode, optio
38342
38674
  Range: byteRange(segment.range)
38343
38675
  } : undefined,
38344
38676
  timeout: options.timeout,
38677
+ connectionTimeout: options.connectionTimeout,
38345
38678
  cancelSignal: cancelSignal,
38346
38679
  onProgress: callbacks.onProgress
38347
38680
  }).then(function (data) {
@@ -39232,6 +39565,7 @@ function generateTextTrackLoader(_ref) {
39232
39565
  Range: byteRange(range)
39233
39566
  } : null,
39234
39567
  timeout: options.timeout,
39568
+ connectionTimeout: options.connectionTimeout,
39235
39569
  onProgress: callbacks.onProgress,
39236
39570
  cancelSignal: cancelSignal
39237
39571
  }).then(function (data) {
@@ -39248,6 +39582,7 @@ function generateTextTrackLoader(_ref) {
39248
39582
  Range: byteRange(range)
39249
39583
  } : null,
39250
39584
  timeout: options.timeout,
39585
+ connectionTimeout: options.connectionTimeout,
39251
39586
  onProgress: callbacks.onProgress,
39252
39587
  cancelSignal: cancelSignal
39253
39588
  }).then(function (data) {
@@ -40445,6 +40780,7 @@ function disableVideoTracks(videoTracks) {
40445
40780
 
40446
40781
 
40447
40782
 
40783
+
40448
40784
  /**
40449
40785
  * `ContentIntializer` which will load contents by putting their URL in the
40450
40786
  * `src` attribute of the given HTMLMediaElement.
@@ -40630,10 +40966,10 @@ var DirectFileContentInitializer = /*#__PURE__*/function (_ContentInitializer) {
40630
40966
  */
40631
40967
 
40632
40968
  function getDirectFileInitialTime(mediaElement, startAt) {
40633
- if (startAt == null) {
40969
+ if (is_null_or_undefined_isNullOrUndefined(startAt)) {
40634
40970
  return 0;
40635
40971
  }
40636
- if (startAt.position != null) {
40972
+ if (!is_null_or_undefined_isNullOrUndefined(startAt.position)) {
40637
40973
  return startAt.position;
40638
40974
  } else if (startAt.wallClockTime != null) {
40639
40975
  return startAt.wallClockTime;
@@ -40641,13 +40977,24 @@ function getDirectFileInitialTime(mediaElement, startAt) {
40641
40977
  return startAt.fromFirstPosition;
40642
40978
  }
40643
40979
  var duration = mediaElement.duration;
40644
- if (duration == null || !isFinite(duration)) {
40645
- src_log.warn("startAt.fromLastPosition set but no known duration, " + "beginning at 0.");
40646
- return 0;
40647
- }
40648
40980
  if (typeof startAt.fromLastPosition === "number") {
40981
+ if (is_null_or_undefined_isNullOrUndefined(duration) || !isFinite(duration)) {
40982
+ src_log.warn("startAt.fromLastPosition set but no known duration, " + "beginning at 0.");
40983
+ return 0;
40984
+ }
40649
40985
  return Math.max(0, duration + startAt.fromLastPosition);
40986
+ } else if (typeof startAt.fromLivePosition === "number") {
40987
+ var livePosition = mediaElement.seekable.length > 0 ? mediaElement.seekable.end(0) : duration;
40988
+ if (is_null_or_undefined_isNullOrUndefined(livePosition)) {
40989
+ src_log.warn("startAt.fromLivePosition set but no known live position, " + "beginning at 0.");
40990
+ return 0;
40991
+ }
40992
+ return Math.max(0, livePosition + startAt.fromLivePosition);
40650
40993
  } else if (startAt.percentage != null) {
40994
+ if (is_null_or_undefined_isNullOrUndefined(duration) || !isFinite(duration)) {
40995
+ src_log.warn("startAt.percentage set but no known duration, " + "beginning at 0.");
40996
+ return 0;
40997
+ }
40651
40998
  var percentage = startAt.percentage;
40652
40999
  if (percentage >= 100) {
40653
41000
  return duration;