rx-player 4.0.0-dev.2023110700 → 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 (479) hide show
  1. package/CHANGELOG.md +18 -226
  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 +14 -35
  21. package/dist/_esm5.processed/core/api/option_utils.js +47 -230
  22. package/dist/_esm5.processed/core/api/public_api.d.ts +92 -266
  23. package/dist/_esm5.processed/core/api/public_api.js +451 -807
  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/html/text_track_cues_store.js +54 -6
  55. package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/utils.d.ts +2 -1
  56. package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/utils.js +19 -2
  57. package/dist/_esm5.processed/core/segment_buffers/implementations/text/native/native_text_segment_buffer.d.ts +1 -2
  58. package/dist/_esm5.processed/core/segment_buffers/implementations/text/native/native_text_segment_buffer.js +2 -3
  59. package/dist/_esm5.processed/core/segment_buffers/implementations/types.d.ts +2 -2
  60. package/dist/_esm5.processed/core/segment_buffers/index.d.ts +2 -2
  61. package/dist/_esm5.processed/core/segment_buffers/index.js +2 -1
  62. package/dist/_esm5.processed/core/segment_buffers/inventory/index.d.ts +1 -0
  63. package/dist/_esm5.processed/core/segment_buffers/inventory/index.js +1 -0
  64. package/dist/_esm5.processed/core/segment_buffers/inventory/utils.d.ts +33 -0
  65. package/dist/_esm5.processed/core/segment_buffers/inventory/utils.js +49 -0
  66. package/dist/_esm5.processed/core/segment_buffers/segment_buffers_store.d.ts +0 -1
  67. package/dist/_esm5.processed/core/segment_buffers/segment_buffers_store.js +2 -16
  68. package/dist/_esm5.processed/core/stream/adaptation/adaptation_stream.d.ts +0 -15
  69. package/dist/_esm5.processed/core/stream/adaptation/adaptation_stream.js +183 -93
  70. package/dist/_esm5.processed/core/stream/adaptation/get_representations_switch_strategy.d.ts +39 -0
  71. package/dist/_esm5.processed/core/stream/adaptation/get_representations_switch_strategy.js +133 -0
  72. package/dist/_esm5.processed/core/stream/adaptation/types.d.ts +27 -13
  73. package/dist/_esm5.processed/core/stream/index.d.ts +2 -3
  74. package/dist/_esm5.processed/core/stream/orchestrator/stream_orchestrator.d.ts +2 -0
  75. package/dist/_esm5.processed/core/stream/orchestrator/stream_orchestrator.js +5 -7
  76. package/dist/_esm5.processed/core/stream/period/period_stream.js +13 -12
  77. package/dist/_esm5.processed/core/stream/period/types.d.ts +5 -14
  78. package/dist/_esm5.processed/core/stream/period/utils/get_adaptation_switch_strategy.d.ts +2 -4
  79. package/dist/_esm5.processed/core/stream/period/utils/get_adaptation_switch_strategy.js +10 -46
  80. package/dist/_esm5.processed/core/stream/representation/representation_stream.js +29 -23
  81. package/dist/_esm5.processed/core/stream/representation/types.d.ts +11 -1
  82. package/dist/_esm5.processed/default_config.d.ts +35 -98
  83. package/dist/_esm5.processed/default_config.js +36 -113
  84. package/dist/_esm5.processed/errors/custom_loader_error.d.ts +1 -3
  85. package/dist/_esm5.processed/errors/custom_loader_error.js +1 -3
  86. package/dist/_esm5.processed/errors/media_error.js +2 -2
  87. package/dist/_esm5.processed/errors/network_error.d.ts +0 -1
  88. package/dist/_esm5.processed/errors/network_error.js +0 -1
  89. package/dist/_esm5.processed/errors/request_error.d.ts +2 -3
  90. package/dist/_esm5.processed/errors/request_error.js +2 -5
  91. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +3 -3
  92. package/dist/_esm5.processed/features/features_object.js +0 -2
  93. package/dist/_esm5.processed/features/list/directfile.js +2 -5
  94. package/dist/_esm5.processed/features/list/index.d.ts +0 -2
  95. package/dist/_esm5.processed/features/list/index.js +0 -2
  96. package/dist/_esm5.processed/features/types.d.ts +3 -27
  97. package/dist/_esm5.processed/manifest/adaptation.d.ts +9 -11
  98. package/dist/_esm5.processed/manifest/adaptation.js +41 -30
  99. package/dist/_esm5.processed/manifest/index.d.ts +3 -4
  100. package/dist/_esm5.processed/manifest/manifest.d.ts +5 -54
  101. package/dist/_esm5.processed/manifest/manifest.js +5 -110
  102. package/dist/_esm5.processed/manifest/period.d.ts +4 -5
  103. package/dist/_esm5.processed/manifest/representation.d.ts +10 -5
  104. package/dist/_esm5.processed/manifest/representation.js +33 -10
  105. package/dist/_esm5.processed/manifest/representation_index/index.d.ts +2 -2
  106. package/dist/_esm5.processed/manifest/representation_index/static.d.ts +2 -0
  107. package/dist/_esm5.processed/manifest/representation_index/static.js +6 -0
  108. package/dist/_esm5.processed/manifest/representation_index/types.d.ts +42 -21
  109. package/dist/_esm5.processed/manifest/types.d.ts +0 -2
  110. package/dist/_esm5.processed/parsers/manifest/dash/common/convert_supplemental_codecs.d.ts +17 -0
  111. package/dist/_esm5.processed/parsers/manifest/dash/common/convert_supplemental_codecs.js +26 -0
  112. package/dist/_esm5.processed/parsers/manifest/dash/common/flatten_overlapping_periods.js +5 -0
  113. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/base.d.ts +17 -31
  114. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/base.js +26 -19
  115. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/list.d.ts +2 -0
  116. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/list.js +7 -1
  117. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/template.d.ts +2 -6
  118. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/template.js +11 -8
  119. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts +2 -0
  120. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +6 -0
  121. package/dist/_esm5.processed/parsers/manifest/dash/common/infer_adaptation_type.d.ts +2 -2
  122. package/dist/_esm5.processed/parsers/manifest/dash/common/infer_adaptation_type.js +1 -6
  123. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_adaptation_sets.js +3 -5
  124. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_mpd.d.ts +0 -2
  125. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_mpd.js +1 -1
  126. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_periods.js +2 -2
  127. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representation_index.d.ts +0 -2
  128. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representation_index.js +2 -2
  129. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representations.js +29 -17
  130. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/AdaptationSet.js +13 -6
  131. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/Representation.js +7 -2
  132. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/utils.d.ts +10 -1
  133. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/utils.js +18 -2
  134. package/dist/_esm5.processed/parsers/manifest/dash/node_parser_types.d.ts +6 -4
  135. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/AdaptationSet.js +7 -6
  136. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/Representation.js +5 -2
  137. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/types.d.ts +2 -1
  138. package/dist/_esm5.processed/parsers/manifest/local/representation_index.d.ts +2 -0
  139. package/dist/_esm5.processed/parsers/manifest/local/representation_index.js +6 -0
  140. package/dist/_esm5.processed/parsers/manifest/metaplaylist/metaplaylist_parser.js +6 -6
  141. package/dist/_esm5.processed/parsers/manifest/metaplaylist/representation_index.d.ts +12 -3
  142. package/dist/_esm5.processed/parsers/manifest/metaplaylist/representation_index.js +11 -2
  143. package/dist/_esm5.processed/parsers/manifest/smooth/create_parser.d.ts +0 -1
  144. package/dist/_esm5.processed/parsers/manifest/smooth/create_parser.js +11 -17
  145. package/dist/_esm5.processed/parsers/manifest/smooth/representation_index.d.ts +21 -83
  146. package/dist/_esm5.processed/parsers/manifest/smooth/representation_index.js +53 -125
  147. package/dist/_esm5.processed/parsers/manifest/smooth/shared_smooth_segment_timeline.d.ts +119 -0
  148. package/dist/_esm5.processed/parsers/manifest/smooth/shared_smooth_segment_timeline.js +159 -0
  149. package/dist/_esm5.processed/parsers/manifest/smooth/utils/add_segment_infos.d.ts +3 -6
  150. package/dist/_esm5.processed/parsers/manifest/smooth/utils/add_segment_infos.js +4 -4
  151. package/dist/_esm5.processed/parsers/manifest/types.d.ts +4 -3
  152. package/dist/_esm5.processed/parsers/texttracks/ttml/html/apply_extent.js +1 -8
  153. package/dist/_esm5.processed/parsers/texttracks/ttml/html/apply_origin.js +1 -9
  154. package/dist/_esm5.processed/public_types.d.ts +396 -308
  155. package/dist/_esm5.processed/tools/TextTrackRenderer/text_track_renderer.d.ts +5 -4
  156. package/dist/_esm5.processed/tools/TextTrackRenderer/text_track_renderer.js +5 -4
  157. package/dist/_esm5.processed/transports/dash/add_segment_integrity_checks_to_loader.js +4 -4
  158. package/dist/_esm5.processed/transports/dash/manifest_parser.js +2 -3
  159. package/dist/_esm5.processed/transports/dash/pipelines.js +1 -4
  160. package/dist/_esm5.processed/transports/dash/segment_loader.d.ts +2 -2
  161. package/dist/_esm5.processed/transports/dash/segment_loader.js +26 -20
  162. package/dist/_esm5.processed/transports/dash/segment_parser.js +19 -24
  163. package/dist/_esm5.processed/transports/dash/text_loader.js +5 -5
  164. package/dist/_esm5.processed/transports/dash/text_parser.js +28 -33
  165. package/dist/_esm5.processed/transports/local/pipelines.js +1 -10
  166. package/dist/_esm5.processed/transports/local/segment_loader.js +2 -2
  167. package/dist/_esm5.processed/transports/local/segment_parser.d.ts +1 -1
  168. package/dist/_esm5.processed/transports/local/segment_parser.js +10 -10
  169. package/dist/_esm5.processed/transports/local/text_parser.d.ts +2 -2
  170. package/dist/_esm5.processed/transports/local/text_parser.js +23 -23
  171. package/dist/_esm5.processed/transports/metaplaylist/pipelines.js +34 -52
  172. package/dist/_esm5.processed/{utils/list_to_map.d.ts → transports/smooth/is_mp4_embedded_track.d.ts} +5 -5
  173. package/dist/_esm5.processed/{features/list/image_buffer.d.ts → transports/smooth/is_mp4_embedded_track.js} +7 -6
  174. package/dist/_esm5.processed/transports/smooth/pipelines.js +33 -190
  175. package/dist/_esm5.processed/transports/smooth/segment_loader.d.ts +1 -1
  176. package/dist/_esm5.processed/transports/smooth/segment_loader.js +28 -22
  177. package/dist/_esm5.processed/transports/smooth/utils.d.ts +1 -26
  178. package/dist/_esm5.processed/transports/smooth/utils.js +1 -55
  179. package/dist/_esm5.processed/transports/types.d.ts +94 -89
  180. package/dist/_esm5.processed/transports/utils/call_custom_manifest_loader.js +3 -3
  181. package/dist/_esm5.processed/transports/utils/infer_segment_container.d.ts +3 -3
  182. package/dist/_esm5.processed/transports/utils/infer_segment_container.js +5 -7
  183. package/dist/_esm5.processed/transports/utils/parse_text_track.d.ts +8 -12
  184. package/dist/_esm5.processed/transports/utils/parse_text_track.js +19 -21
  185. package/dist/_esm5.processed/utils/array_includes.d.ts +2 -1
  186. package/dist/_esm5.processed/utils/array_includes.js +30 -28
  187. package/dist/_esm5.processed/utils/request/xhr.js +5 -5
  188. package/dist/commonjs/compat/is_codec_supported.js +22 -1
  189. package/dist/commonjs/compat/patch_webkit_source_buffer.js +2 -2
  190. package/dist/commonjs/config.d.ts +1 -0
  191. package/dist/commonjs/core/api/debug/buffer_graph.js +2 -6
  192. package/dist/commonjs/core/api/debug/modules/general_info.js +17 -10
  193. package/dist/commonjs/core/api/option_utils.d.ts +4 -0
  194. package/dist/commonjs/core/api/option_utils.js +8 -3
  195. package/dist/commonjs/core/api/public_api.d.ts +11 -1
  196. package/dist/commonjs/core/api/public_api.js +46 -11
  197. package/dist/commonjs/core/fetchers/manifest/manifest_fetcher.d.ts +6 -0
  198. package/dist/commonjs/core/fetchers/manifest/manifest_fetcher.js +11 -3
  199. package/dist/commonjs/core/fetchers/segment/segment_fetcher.d.ts +8 -1
  200. package/dist/commonjs/core/fetchers/segment/segment_fetcher.js +8 -4
  201. package/dist/commonjs/core/fetchers/segment/segment_fetcher_creator.d.ts +1 -0
  202. package/dist/commonjs/core/fetchers/utils/schedule_request.js +1 -1
  203. package/dist/commonjs/core/init/directfile_content_initializer.js +24 -7
  204. package/dist/commonjs/core/init/media_source_content_initializer.d.ts +6 -0
  205. package/dist/commonjs/core/init/media_source_content_initializer.js +4 -6
  206. package/dist/commonjs/core/init/utils/content_time_boundaries_observer.d.ts +13 -12
  207. package/dist/commonjs/core/init/utils/content_time_boundaries_observer.js +16 -17
  208. package/dist/commonjs/core/init/utils/get_initial_time.d.ts +17 -3
  209. package/dist/commonjs/core/init/utils/get_initial_time.js +9 -7
  210. package/dist/commonjs/core/segment_buffers/implementations/text/html/text_track_cues_store.js +54 -6
  211. package/dist/commonjs/core/segment_buffers/implementations/text/html/utils.d.ts +2 -1
  212. package/dist/commonjs/core/segment_buffers/implementations/text/html/utils.js +19 -2
  213. package/dist/commonjs/core/stream/adaptation/adaptation_stream.js +2 -2
  214. package/dist/commonjs/core/stream/orchestrator/stream_orchestrator.js +3 -3
  215. package/dist/commonjs/core/stream/period/period_stream.js +2 -2
  216. package/dist/commonjs/core/stream/representation/utils/get_buffer_status.js +3 -3
  217. package/dist/commonjs/core/stream/representation/utils/get_needed_segments.js +1 -1
  218. package/dist/commonjs/default_config.d.ts +5 -0
  219. package/dist/commonjs/default_config.js +5 -0
  220. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +3 -1
  221. package/dist/commonjs/experimental/tools/createMetaplaylist/get_duration_from_manifest.js +2 -0
  222. package/dist/commonjs/manifest/representation.js +18 -5
  223. package/dist/commonjs/manifest/representation_index/static.d.ts +1 -1
  224. package/dist/commonjs/manifest/representation_index/static.js +2 -2
  225. package/dist/commonjs/manifest/representation_index/types.d.ts +4 -4
  226. package/dist/commonjs/parsers/manifest/dash/common/convert_supplemental_codecs.d.ts +17 -0
  227. package/dist/commonjs/parsers/manifest/dash/common/convert_supplemental_codecs.js +30 -0
  228. package/dist/commonjs/parsers/manifest/dash/common/flatten_overlapping_periods.js +5 -0
  229. package/dist/commonjs/parsers/manifest/dash/common/indexes/base.d.ts +6 -1
  230. package/dist/commonjs/parsers/manifest/dash/common/indexes/base.js +4 -3
  231. package/dist/commonjs/parsers/manifest/dash/common/indexes/get_segments_from_timeline.d.ts +5 -2
  232. package/dist/commonjs/parsers/manifest/dash/common/indexes/get_segments_from_timeline.js +15 -4
  233. package/dist/commonjs/parsers/manifest/dash/common/indexes/index.d.ts +5 -5
  234. package/dist/commonjs/parsers/manifest/dash/common/indexes/list.d.ts +1 -1
  235. package/dist/commonjs/parsers/manifest/dash/common/indexes/list.js +2 -2
  236. package/dist/commonjs/parsers/manifest/dash/common/indexes/template.d.ts +12 -5
  237. package/dist/commonjs/parsers/manifest/dash/common/indexes/template.js +42 -29
  238. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/index.d.ts +2 -1
  239. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts +99 -6
  240. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +250 -51
  241. package/dist/commonjs/parsers/manifest/dash/common/manifest_bounds_calculator.d.ts +40 -17
  242. package/dist/commonjs/parsers/manifest/dash/common/manifest_bounds_calculator.js +38 -18
  243. package/dist/commonjs/parsers/manifest/dash/common/parse_adaptation_sets.js +13 -10
  244. package/dist/commonjs/parsers/manifest/dash/common/parse_mpd.js +27 -14
  245. package/dist/commonjs/parsers/manifest/dash/common/parse_periods.d.ts +1 -1
  246. package/dist/commonjs/parsers/manifest/dash/common/parse_periods.js +17 -18
  247. package/dist/commonjs/parsers/manifest/dash/common/parse_representation_index.d.ts +19 -6
  248. package/dist/commonjs/parsers/manifest/dash/common/parse_representation_index.js +21 -8
  249. package/dist/commonjs/parsers/manifest/dash/common/parse_representations.js +36 -20
  250. package/dist/commonjs/parsers/manifest/dash/js-parser/node_parsers/AdaptationSet.js +3 -0
  251. package/dist/commonjs/parsers/manifest/dash/js-parser/node_parsers/Representation.js +3 -0
  252. package/dist/commonjs/parsers/manifest/dash/node_parser_types.d.ts +2 -0
  253. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/AdaptationSet.js +4 -0
  254. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/Representation.js +4 -0
  255. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/types.d.ts +2 -1
  256. package/dist/commonjs/parsers/manifest/local/representation_index.d.ts +1 -1
  257. package/dist/commonjs/parsers/manifest/local/representation_index.js +3 -3
  258. package/dist/commonjs/parsers/manifest/metaplaylist/representation_index.d.ts +1 -1
  259. package/dist/commonjs/parsers/manifest/metaplaylist/representation_index.js +2 -2
  260. package/dist/commonjs/parsers/manifest/smooth/representation_index.d.ts +5 -5
  261. package/dist/commonjs/parsers/manifest/smooth/representation_index.js +25 -9
  262. package/dist/commonjs/parsers/manifest/types.d.ts +1 -0
  263. package/dist/commonjs/parsers/manifest/utils/index_helpers.js +1 -1
  264. package/dist/commonjs/public_types.d.ts +78 -34
  265. package/dist/commonjs/transports/dash/init_segment_loader.js +10 -5
  266. package/dist/commonjs/transports/dash/manifest_parser.js +5 -2
  267. package/dist/commonjs/transports/dash/segment_loader.js +2 -1
  268. package/dist/commonjs/transports/dash/text_loader.js +2 -0
  269. package/dist/commonjs/transports/metaplaylist/manifest_loader.js +2 -1
  270. package/dist/commonjs/transports/metaplaylist/pipelines.js +4 -1
  271. package/dist/commonjs/transports/smooth/pipelines.js +4 -2
  272. package/dist/commonjs/transports/smooth/segment_loader.js +2 -1
  273. package/dist/commonjs/transports/types.d.ts +12 -0
  274. package/dist/commonjs/transports/utils/generate_manifest_loader.js +6 -3
  275. package/dist/commonjs/utils/queue_microtask.d.ts +2 -0
  276. package/dist/commonjs/utils/queue_microtask.js +7 -0
  277. package/dist/commonjs/utils/request/fetch.d.ts +6 -0
  278. package/dist/commonjs/utils/request/fetch.js +29 -8
  279. package/dist/commonjs/utils/request/xhr.d.ts +11 -5
  280. package/dist/commonjs/utils/request/xhr.js +29 -8
  281. package/dist/es2017/compat/is_codec_supported.js +22 -1
  282. package/dist/es2017/compat/patch_webkit_source_buffer.js +2 -2
  283. package/dist/es2017/config.d.ts +1 -0
  284. package/dist/es2017/core/api/debug/buffer_graph.js +2 -6
  285. package/dist/es2017/core/api/debug/modules/general_info.js +17 -10
  286. package/dist/es2017/core/api/option_utils.d.ts +4 -0
  287. package/dist/es2017/core/api/option_utils.js +8 -3
  288. package/dist/es2017/core/api/public_api.d.ts +11 -1
  289. package/dist/es2017/core/api/public_api.js +44 -9
  290. package/dist/es2017/core/fetchers/manifest/manifest_fetcher.d.ts +6 -0
  291. package/dist/es2017/core/fetchers/manifest/manifest_fetcher.js +11 -3
  292. package/dist/es2017/core/fetchers/segment/segment_fetcher.d.ts +8 -1
  293. package/dist/es2017/core/fetchers/segment/segment_fetcher.js +8 -4
  294. package/dist/es2017/core/fetchers/segment/segment_fetcher_creator.d.ts +1 -0
  295. package/dist/es2017/core/fetchers/utils/schedule_request.js +1 -1
  296. package/dist/es2017/core/init/directfile_content_initializer.js +24 -7
  297. package/dist/es2017/core/init/media_source_content_initializer.d.ts +6 -0
  298. package/dist/es2017/core/init/media_source_content_initializer.js +4 -6
  299. package/dist/es2017/core/init/utils/content_time_boundaries_observer.d.ts +13 -12
  300. package/dist/es2017/core/init/utils/content_time_boundaries_observer.js +16 -15
  301. package/dist/es2017/core/init/utils/get_initial_time.d.ts +17 -3
  302. package/dist/es2017/core/init/utils/get_initial_time.js +9 -7
  303. package/dist/es2017/core/segment_buffers/implementations/text/html/text_track_cues_store.js +54 -6
  304. package/dist/es2017/core/segment_buffers/implementations/text/html/utils.d.ts +2 -1
  305. package/dist/es2017/core/segment_buffers/implementations/text/html/utils.js +18 -2
  306. package/dist/es2017/core/stream/adaptation/adaptation_stream.js +2 -2
  307. package/dist/es2017/core/stream/orchestrator/stream_orchestrator.js +3 -3
  308. package/dist/es2017/core/stream/period/period_stream.js +2 -2
  309. package/dist/es2017/core/stream/representation/utils/get_buffer_status.js +3 -3
  310. package/dist/es2017/core/stream/representation/utils/get_needed_segments.js +1 -1
  311. package/dist/es2017/default_config.d.ts +5 -0
  312. package/dist/es2017/default_config.js +5 -0
  313. package/dist/es2017/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +3 -1
  314. package/dist/es2017/experimental/tools/createMetaplaylist/get_duration_from_manifest.js +2 -0
  315. package/dist/es2017/manifest/representation.js +18 -5
  316. package/dist/es2017/manifest/representation_index/static.d.ts +1 -1
  317. package/dist/es2017/manifest/representation_index/static.js +2 -2
  318. package/dist/es2017/manifest/representation_index/types.d.ts +4 -4
  319. package/dist/es2017/parsers/manifest/dash/common/convert_supplemental_codecs.d.ts +17 -0
  320. package/dist/es2017/parsers/manifest/dash/common/convert_supplemental_codecs.js +26 -0
  321. package/dist/es2017/parsers/manifest/dash/common/flatten_overlapping_periods.js +5 -0
  322. package/dist/es2017/parsers/manifest/dash/common/indexes/base.d.ts +6 -1
  323. package/dist/es2017/parsers/manifest/dash/common/indexes/base.js +4 -3
  324. package/dist/es2017/parsers/manifest/dash/common/indexes/get_segments_from_timeline.d.ts +5 -2
  325. package/dist/es2017/parsers/manifest/dash/common/indexes/get_segments_from_timeline.js +15 -4
  326. package/dist/es2017/parsers/manifest/dash/common/indexes/index.d.ts +5 -5
  327. package/dist/es2017/parsers/manifest/dash/common/indexes/list.d.ts +1 -1
  328. package/dist/es2017/parsers/manifest/dash/common/indexes/list.js +2 -2
  329. package/dist/es2017/parsers/manifest/dash/common/indexes/template.d.ts +12 -5
  330. package/dist/es2017/parsers/manifest/dash/common/indexes/template.js +40 -27
  331. package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/index.d.ts +2 -1
  332. package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts +99 -6
  333. package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +246 -51
  334. package/dist/es2017/parsers/manifest/dash/common/manifest_bounds_calculator.d.ts +40 -17
  335. package/dist/es2017/parsers/manifest/dash/common/manifest_bounds_calculator.js +38 -18
  336. package/dist/es2017/parsers/manifest/dash/common/parse_adaptation_sets.js +11 -8
  337. package/dist/es2017/parsers/manifest/dash/common/parse_mpd.js +27 -13
  338. package/dist/es2017/parsers/manifest/dash/common/parse_periods.d.ts +1 -1
  339. package/dist/es2017/parsers/manifest/dash/common/parse_periods.js +13 -16
  340. package/dist/es2017/parsers/manifest/dash/common/parse_representation_index.d.ts +19 -6
  341. package/dist/es2017/parsers/manifest/dash/common/parse_representation_index.js +10 -8
  342. package/dist/es2017/parsers/manifest/dash/common/parse_representations.js +36 -20
  343. package/dist/es2017/parsers/manifest/dash/js-parser/node_parsers/AdaptationSet.js +3 -0
  344. package/dist/es2017/parsers/manifest/dash/js-parser/node_parsers/Representation.js +3 -0
  345. package/dist/es2017/parsers/manifest/dash/node_parser_types.d.ts +2 -0
  346. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/AdaptationSet.js +4 -0
  347. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/Representation.js +4 -0
  348. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/types.d.ts +2 -1
  349. package/dist/es2017/parsers/manifest/local/representation_index.d.ts +1 -1
  350. package/dist/es2017/parsers/manifest/local/representation_index.js +3 -3
  351. package/dist/es2017/parsers/manifest/metaplaylist/representation_index.d.ts +1 -1
  352. package/dist/es2017/parsers/manifest/metaplaylist/representation_index.js +2 -2
  353. package/dist/es2017/parsers/manifest/smooth/representation_index.d.ts +5 -5
  354. package/dist/es2017/parsers/manifest/smooth/representation_index.js +25 -9
  355. package/dist/es2017/parsers/manifest/types.d.ts +1 -0
  356. package/dist/es2017/parsers/manifest/utils/index_helpers.js +1 -1
  357. package/dist/es2017/public_types.d.ts +78 -34
  358. package/dist/es2017/transports/dash/init_segment_loader.js +5 -0
  359. package/dist/es2017/transports/dash/manifest_parser.js +3 -0
  360. package/dist/es2017/transports/dash/segment_loader.js +1 -0
  361. package/dist/es2017/transports/dash/text_loader.js +2 -0
  362. package/dist/es2017/transports/metaplaylist/manifest_loader.js +1 -0
  363. package/dist/es2017/transports/metaplaylist/pipelines.js +4 -1
  364. package/dist/es2017/transports/smooth/pipelines.js +2 -0
  365. package/dist/es2017/transports/smooth/segment_loader.js +1 -0
  366. package/dist/es2017/transports/types.d.ts +12 -0
  367. package/dist/es2017/transports/utils/generate_manifest_loader.js +3 -0
  368. package/dist/es2017/utils/queue_microtask.d.ts +2 -0
  369. package/dist/es2017/utils/queue_microtask.js +5 -0
  370. package/dist/es2017/utils/request/fetch.d.ts +6 -0
  371. package/dist/es2017/utils/request/fetch.js +29 -8
  372. package/dist/es2017/utils/request/xhr.d.ts +11 -5
  373. package/dist/es2017/utils/request/xhr.js +30 -9
  374. package/dist/mpd-parser.wasm +0 -0
  375. package/dist/rx-player.js +900 -492
  376. package/dist/rx-player.min.js +1 -1
  377. package/package.json +3 -7
  378. package/scripts/update-version +2 -0
  379. package/sonar-project.properties +1 -1
  380. package/src/compat/is_codec_supported.ts +23 -1
  381. package/src/compat/patch_webkit_source_buffer.ts +2 -2
  382. package/src/core/api/debug/buffer_graph.ts +2 -5
  383. package/src/core/api/debug/modules/general_info.ts +15 -10
  384. package/src/core/api/option_utils.ts +11 -3
  385. package/src/core/api/public_api.ts +48 -8
  386. package/src/core/fetchers/manifest/manifest_fetcher.ts +21 -3
  387. package/src/core/fetchers/segment/segment_fetcher.ts +19 -5
  388. package/src/core/fetchers/segment/segment_fetcher_creator.ts +1 -0
  389. package/src/core/fetchers/utils/schedule_request.ts +1 -1
  390. package/src/core/init/directfile_content_initializer.ts +23 -7
  391. package/src/core/init/media_source_content_initializer.ts +13 -7
  392. package/src/core/init/utils/content_time_boundaries_observer.ts +23 -22
  393. package/src/core/init/utils/get_initial_time.ts +25 -12
  394. package/src/core/segment_buffers/implementations/text/html/__tests__/utils.test.ts +15 -0
  395. package/src/core/segment_buffers/implementations/text/html/text_track_cues_store.ts +57 -6
  396. package/src/core/segment_buffers/implementations/text/html/utils.ts +19 -2
  397. package/src/core/stream/adaptation/adaptation_stream.ts +2 -2
  398. package/src/core/stream/orchestrator/stream_orchestrator.ts +3 -3
  399. package/src/core/stream/period/period_stream.ts +2 -2
  400. package/src/core/stream/representation/utils/get_buffer_status.ts +3 -3
  401. package/src/core/stream/representation/utils/get_needed_segments.ts +2 -2
  402. package/src/default_config.ts +5 -0
  403. package/src/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.ts +3 -1
  404. package/src/experimental/tools/createMetaplaylist/get_duration_from_manifest.ts +2 -0
  405. package/src/manifest/representation.ts +19 -6
  406. package/src/manifest/representation_index/static.ts +2 -2
  407. package/src/manifest/representation_index/types.ts +4 -4
  408. package/src/parsers/manifest/dash/common/__tests__/convert_supplemental_codecs.test.ts +37 -0
  409. package/src/parsers/manifest/dash/common/__tests__/flatten_overlapping_period.test.ts +20 -0
  410. package/src/parsers/manifest/dash/common/__tests__/manifest_bounds_calculator.test.ts +182 -36
  411. package/src/parsers/manifest/dash/common/convert_supplemental_codecs.ts +32 -0
  412. package/src/parsers/manifest/dash/common/flatten_overlapping_periods.ts +5 -0
  413. package/src/parsers/manifest/dash/common/indexes/base.ts +12 -4
  414. package/src/parsers/manifest/dash/common/indexes/get_segments_from_timeline.ts +19 -5
  415. package/src/parsers/manifest/dash/common/indexes/index.ts +16 -4
  416. package/src/parsers/manifest/dash/common/indexes/list.ts +2 -2
  417. package/src/parsers/manifest/dash/common/indexes/template.ts +52 -31
  418. package/src/parsers/manifest/dash/common/indexes/timeline/index.ts +4 -1
  419. package/src/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.ts +366 -60
  420. package/src/parsers/manifest/dash/common/manifest_bounds_calculator.ts +63 -25
  421. package/src/parsers/manifest/dash/common/parse_adaptation_sets.ts +10 -4
  422. package/src/parsers/manifest/dash/common/parse_mpd.ts +28 -15
  423. package/src/parsers/manifest/dash/common/parse_periods.ts +12 -17
  424. package/src/parsers/manifest/dash/common/parse_representation_index.ts +50 -26
  425. package/src/parsers/manifest/dash/common/parse_representations.ts +39 -20
  426. package/src/parsers/manifest/dash/js-parser/node_parsers/AdaptationSet.ts +4 -0
  427. package/src/parsers/manifest/dash/js-parser/node_parsers/Representation.ts +4 -0
  428. package/src/parsers/manifest/dash/node_parser_types.ts +2 -0
  429. package/src/parsers/manifest/dash/wasm-parser/rs/events.rs +2 -0
  430. package/src/parsers/manifest/dash/wasm-parser/rs/processor/attributes.rs +2 -0
  431. package/src/parsers/manifest/dash/wasm-parser/ts/generators/AdaptationSet.ts +4 -0
  432. package/src/parsers/manifest/dash/wasm-parser/ts/generators/Representation.ts +4 -0
  433. package/src/parsers/manifest/dash/wasm-parser/ts/types.ts +2 -0
  434. package/src/parsers/manifest/local/representation_index.ts +3 -3
  435. package/src/parsers/manifest/metaplaylist/representation_index.ts +2 -2
  436. package/src/parsers/manifest/smooth/representation_index.ts +23 -9
  437. package/src/parsers/manifest/types.ts +2 -0
  438. package/src/parsers/manifest/utils/__tests__/get_first_time_from_adaptations.test.ts +1 -1
  439. package/src/parsers/manifest/utils/__tests__/get_last_time_from_adaptation.test.ts +1 -1
  440. package/src/parsers/manifest/utils/index_helpers.ts +1 -1
  441. package/src/public_types.ts +79 -34
  442. package/src/transports/dash/init_segment_loader.ts +5 -0
  443. package/src/transports/dash/manifest_parser.ts +6 -0
  444. package/src/transports/dash/segment_loader.ts +1 -0
  445. package/src/transports/dash/text_loader.ts +2 -0
  446. package/src/transports/metaplaylist/manifest_loader.ts +1 -0
  447. package/src/transports/metaplaylist/pipelines.ts +4 -1
  448. package/src/transports/smooth/pipelines.ts +2 -0
  449. package/src/transports/smooth/segment_loader.ts +1 -0
  450. package/src/transports/types.ts +12 -0
  451. package/src/transports/utils/generate_manifest_loader.ts +3 -0
  452. package/src/utils/queue_microtask.ts +7 -0
  453. package/src/utils/request/fetch.ts +35 -8
  454. package/src/utils/request/xhr.ts +45 -14
  455. package/dist/_esm5.processed/compat/fullscreen.d.ts +0 -32
  456. package/dist/_esm5.processed/compat/fullscreen.js +0 -78
  457. package/dist/_esm5.processed/compat/is_offline.d.ts +0 -39
  458. package/dist/_esm5.processed/compat/is_offline.js +0 -43
  459. package/dist/_esm5.processed/core/api/tracks_management/track_choice_manager.d.ts +0 -258
  460. package/dist/_esm5.processed/core/api/tracks_management/track_choice_manager.js +0 -989
  461. package/dist/_esm5.processed/core/segment_buffers/implementations/image/image_segment_buffer.d.ts +0 -75
  462. package/dist/_esm5.processed/core/segment_buffers/implementations/image/image_segment_buffer.js +0 -133
  463. package/dist/_esm5.processed/features/list/bif_parser.d.ts +0 -23
  464. package/dist/_esm5.processed/features/list/bif_parser.js +0 -27
  465. package/dist/_esm5.processed/features/list/image_buffer.js +0 -25
  466. package/dist/_esm5.processed/transports/dash/image_pipelines.d.ts +0 -38
  467. package/dist/_esm5.processed/transports/dash/image_pipelines.js +0 -129
  468. package/dist/_esm5.processed/utils/list_to_map.js +0 -28
  469. package/dist/_esm5.processed/utils/simple_set.d.ts +0 -51
  470. package/dist/_esm5.processed/utils/simple_set.js +0 -57
  471. package/dist/_esm5.processed/utils/uniq.d.ts +0 -36
  472. package/dist/_esm5.processed/utils/uniq.js +0 -43
  473. package/dist/commonjs/parsers/manifest/utils/is_segment_still_available.d.ts +0 -29
  474. package/dist/commonjs/parsers/manifest/utils/is_segment_still_available.js +0 -54
  475. package/dist/es2017/parsers/manifest/utils/is_segment_still_available.d.ts +0 -29
  476. package/dist/es2017/parsers/manifest/utils/is_segment_still_available.js +0 -51
  477. package/src/parsers/manifest/utils/is_segment_still_available.ts +0 -58
  478. package/src/typings/next-tick.d.ts +0 -23
  479. package/src/typings/object-assign.d.ts +0 -48
package/dist/rx-player.js CHANGED
@@ -11,88 +11,6 @@
11
11
  return /******/ (function() { // webpackBootstrap
12
12
  /******/ var __webpack_modules__ = ({
13
13
 
14
- /***/ 473:
15
- /***/ (function(module) {
16
-
17
- "use strict";
18
-
19
-
20
- var ensureCallable = function (fn) {
21
- if (typeof fn !== 'function') throw new TypeError(fn + " is not a function");
22
- return fn;
23
- };
24
-
25
- var byObserver = function (Observer) {
26
- var node = document.createTextNode(''), queue, currentQueue, i = 0;
27
- new Observer(function () {
28
- var callback;
29
- if (!queue) {
30
- if (!currentQueue) return;
31
- queue = currentQueue;
32
- } else if (currentQueue) {
33
- queue = currentQueue.concat(queue);
34
- }
35
- currentQueue = queue;
36
- queue = null;
37
- if (typeof currentQueue === 'function') {
38
- callback = currentQueue;
39
- currentQueue = null;
40
- callback();
41
- return;
42
- }
43
- node.data = (i = ++i % 2); // Invoke other batch, to handle leftover callbacks in case of crash
44
- while (currentQueue) {
45
- callback = currentQueue.shift();
46
- if (!currentQueue.length) currentQueue = null;
47
- callback();
48
- }
49
- }).observe(node, { characterData: true });
50
- return function (fn) {
51
- ensureCallable(fn);
52
- if (queue) {
53
- if (typeof queue === 'function') queue = [queue, fn];
54
- else queue.push(fn);
55
- return;
56
- }
57
- queue = fn;
58
- node.data = (i = ++i % 2);
59
- };
60
- };
61
-
62
- module.exports = (function () {
63
- // Node.js
64
- if ((typeof process === 'object') && process && (typeof process.nextTick === 'function')) {
65
- return process.nextTick;
66
- }
67
-
68
- // queueMicrotask
69
- if (typeof queueMicrotask === "function") {
70
- return function (cb) { queueMicrotask(ensureCallable(cb)); };
71
- }
72
-
73
- // MutationObserver
74
- if ((typeof document === 'object') && document) {
75
- if (typeof MutationObserver === 'function') return byObserver(MutationObserver);
76
- if (typeof WebKitMutationObserver === 'function') return byObserver(WebKitMutationObserver);
77
- }
78
-
79
- // W3C Draft
80
- // http://dvcs.w3.org/hg/webperf/raw-file/tip/specs/setImmediate/Overview.html
81
- if (typeof setImmediate === 'function') {
82
- return function (cb) { setImmediate(ensureCallable(cb)); };
83
- }
84
-
85
- // Wide available standard
86
- if ((typeof setTimeout === 'function') || (typeof setTimeout === 'object')) {
87
- return function (cb) { setTimeout(ensureCallable(cb), 0); };
88
- }
89
-
90
- return null;
91
- }());
92
-
93
-
94
- /***/ }),
95
-
96
14
  /***/ 61:
97
15
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
98
16
 
@@ -617,6 +535,11 @@ var DEFAULT_CONFIG = {
617
535
  * @type {Number}
618
536
  */
619
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,
620
543
  /**
621
544
  * Can be either:
622
545
  * - "native": Subtitles are all displayed in a <track> element
@@ -5206,6 +5129,12 @@ function checkReloadOptions(options) {
5206
5129
  if (typeof ((_c = options === null || options === void 0 ? void 0 : options.reloadAt) === null || _c === void 0 ? void 0 : _c.relative) !== "number" && ((_d = options === null || options === void 0 ? void 0 : options.reloadAt) === null || _d === void 0 ? void 0 : _d.relative) !== undefined) {
5207
5130
  throw new Error("API: reload - Invalid 'reloadAt.relative' option format.");
5208
5131
  }
5132
+ if (!Array.isArray(options === null || options === void 0 ? void 0 : options.keySystems) && (options === null || options === void 0 ? void 0 : options.keySystems) !== undefined) {
5133
+ throw new Error("API: reload - Invalid 'keySystems' option format.");
5134
+ }
5135
+ if ((options === null || options === void 0 ? void 0 : options.autoPlay) !== undefined && typeof options.autoPlay !== "boolean") {
5136
+ throw new Error("API: reload - Invalid 'autoPlay' option format.");
5137
+ }
5209
5138
  }
5210
5139
  /**
5211
5140
  * Parse options given to loadVideo and set default options as found
@@ -5291,8 +5220,7 @@ function parseLoadVideoOptions(options) {
5291
5220
  src_log.warn("API: You have set a textTrackElement without being in " + "an \"html\" textTrackMode. It will be ignored.");
5292
5221
  }
5293
5222
  if (!is_null_or_undefined_isNullOrUndefined(options.startAt)) {
5294
- // TODO Better way to express that in TypeScript?
5295
- if (options.startAt.wallClockTime instanceof Date) {
5223
+ if ("wallClockTime" in options.startAt && options.startAt.wallClockTime instanceof Date) {
5296
5224
  var wallClockTime = options.startAt.wallClockTime.getTime() / 1000;
5297
5225
  startAt = object_assign({}, options.startAt, {
5298
5226
  wallClockTime: wallClockTime
@@ -7375,7 +7303,7 @@ var Player = /*#__PURE__*/function (_EventEmitter) {
7375
7303
  // Workaround to support Firefox autoplay on FF 42.
7376
7304
  // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1194624
7377
7305
  videoElement.preload = "auto";
7378
- _this.version = /* PLAYER_VERSION */"4.0.0-dev.2023110700";
7306
+ _this.version = /* PLAYER_VERSION */"4.0.0-dev.2023120600";
7379
7307
  _this.log = src_log;
7380
7308
  _this.state = "STOPPED";
7381
7309
  _this.videoElement = videoElement;
@@ -7474,7 +7402,7 @@ var Player = /*#__PURE__*/function (_EventEmitter) {
7474
7402
  * @param {Object} reloadOpts
7475
7403
  */;
7476
7404
  _proto.reload = function reload(reloadOpts) {
7477
- var _a, _b;
7405
+ var _a, _b, _c;
7478
7406
  var _this$_priv_reloading = this._priv_reloadingMetadata,
7479
7407
  options = _this$_priv_reloading.options,
7480
7408
  manifest = _this$_priv_reloading.manifest,
@@ -7508,6 +7436,12 @@ var Player = /*#__PURE__*/function (_EventEmitter) {
7508
7436
  } else if (reloadInPause !== undefined) {
7509
7437
  autoPlay = !reloadInPause;
7510
7438
  }
7439
+ var keySystems;
7440
+ if ((reloadOpts === null || reloadOpts === void 0 ? void 0 : reloadOpts.keySystems) !== undefined) {
7441
+ keySystems = reloadOpts.keySystems;
7442
+ } else if (((_c = this._priv_reloadingMetadata.options) === null || _c === void 0 ? void 0 : _c.keySystems) !== undefined) {
7443
+ keySystems = this._priv_reloadingMetadata.options.keySystems;
7444
+ }
7511
7445
  var newOptions = Object.assign(Object.assign({}, options), {
7512
7446
  initialManifest: manifest
7513
7447
  });
@@ -7517,6 +7451,9 @@ var Player = /*#__PURE__*/function (_EventEmitter) {
7517
7451
  if (autoPlay !== undefined) {
7518
7452
  newOptions.autoPlay = autoPlay;
7519
7453
  }
7454
+ if (keySystems !== undefined) {
7455
+ newOptions.keySystems = keySystems;
7456
+ }
7520
7457
  this._priv_initializeContentPlayback(newOptions);
7521
7458
  };
7522
7459
  _proto.createDebugElement = function createDebugElement(element) {
@@ -7537,7 +7474,7 @@ var Player = /*#__PURE__*/function (_EventEmitter) {
7537
7474
  */;
7538
7475
  _proto._priv_initializeContentPlayback = function _priv_initializeContentPlayback(options) {
7539
7476
  var _this2 = this;
7540
- var _a, _b, _c, _d;
7477
+ var _a, _b, _c, _d, _e, _f;
7541
7478
  var autoPlay = options.autoPlay,
7542
7479
  defaultAudioTrackSwitchingMode = options.defaultAudioTrackSwitchingMode,
7543
7480
  enableFastSwitching = options.enableFastSwitching,
@@ -7595,6 +7532,7 @@ var Player = /*#__PURE__*/function (_EventEmitter) {
7595
7532
  lowLatencyMode: lowLatencyMode,
7596
7533
  maxRetry: (_a = requestConfig.manifest) === null || _a === void 0 ? void 0 : _a.maxRetry,
7597
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,
7598
7536
  minimumManifestUpdateInterval: minimumManifestUpdateInterval,
7599
7537
  initialManifest: initialManifest
7600
7538
  };
@@ -7646,8 +7584,9 @@ var Player = /*#__PURE__*/function (_EventEmitter) {
7646
7584
  }, this._priv_bufferOptions);
7647
7585
  var segmentRequestOptions = {
7648
7586
  lowLatencyMode: lowLatencyMode,
7649
- maxRetry: (_c = requestConfig.segment) === null || _c === void 0 ? void 0 : _c.maxRetry,
7650
- 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
7651
7590
  };
7652
7591
  initializer = new src_features.mediaSourceInit({
7653
7592
  adaptiveOptions: adaptiveOptions,
@@ -8874,16 +8813,39 @@ var Player = /*#__PURE__*/function (_EventEmitter) {
8874
8813
  return null;
8875
8814
  }
8876
8815
  /**
8877
- * 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.
8878
8821
  * @returns {number}
8879
8822
  */;
8880
- _proto.getMaximumPosition = function getMaximumPosition() {
8823
+ _proto.getLivePosition = function getLivePosition() {
8881
8824
  if (this._priv_contentInfos === null) {
8882
8825
  return null;
8883
8826
  }
8884
8827
  var _this$_priv_contentIn17 = this._priv_contentInfos,
8885
8828
  isDirectFile = _this$_priv_contentIn17.isDirectFile,
8886
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;
8887
8849
  if (isDirectFile) {
8888
8850
  if (this.videoElement === null) {
8889
8851
  throw new Error("Disposed player");
@@ -8917,7 +8879,11 @@ var Player = /*#__PURE__*/function (_EventEmitter) {
8917
8879
  return null;
8918
8880
  }
8919
8881
  var segmentBufferStatus = this._priv_contentInfos.segmentBuffersStore.getStatus(bufferType);
8920
- 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;
8921
8887
  }
8922
8888
  /**
8923
8889
  * /!\ For tools use only! Do not touch!
@@ -8940,9 +8906,9 @@ var Player = /*#__PURE__*/function (_EventEmitter) {
8940
8906
  if (this._priv_contentInfos === null) {
8941
8907
  return null;
8942
8908
  }
8943
- var _this$_priv_contentIn18 = this._priv_contentInfos,
8944
- currentPeriod = _this$_priv_contentIn18.currentPeriod,
8945
- 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;
8946
8912
  if (currentPeriod === null || activeAdaptations === null || is_null_or_undefined_isNullOrUndefined(activeAdaptations[currentPeriod.id])) {
8947
8913
  return null;
8948
8914
  }
@@ -8954,9 +8920,9 @@ var Player = /*#__PURE__*/function (_EventEmitter) {
8954
8920
  if (this._priv_contentInfos === null) {
8955
8921
  return null;
8956
8922
  }
8957
- var _this$_priv_contentIn19 = this._priv_contentInfos,
8958
- currentPeriod = _this$_priv_contentIn19.currentPeriod,
8959
- 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;
8960
8926
  if (currentPeriod === null || activeRepresentations === null || is_null_or_undefined_isNullOrUndefined(activeRepresentations[currentPeriod.id])) {
8961
8927
  return null;
8962
8928
  }
@@ -9573,7 +9539,7 @@ var Player = /*#__PURE__*/function (_EventEmitter) {
9573
9539
  }]);
9574
9540
  return Player;
9575
9541
  }(EventEmitter);
9576
- Player.version = /* PLAYER_VERSION */"4.0.0-dev.2023110700";
9542
+ Player.version = /* PLAYER_VERSION */"4.0.0-dev.2023120600";
9577
9543
  /* harmony default export */ var public_api = (Player);
9578
9544
  ;// CONCATENATED MODULE: ./src/core/api/index.ts
9579
9545
  /**
@@ -11935,6 +11901,16 @@ var READY_STATES = {
11935
11901
  * limitations under the License.
11936
11902
  */
11937
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();
11938
11914
  /**
11939
11915
  * Returns true if the given codec is supported by the browser's MediaSource
11940
11916
  * implementation.
@@ -11951,7 +11927,17 @@ function isCodecSupported(mimeType) {
11951
11927
  /* eslint-disable @typescript-eslint/unbound-method */
11952
11928
  if (typeof MediaSource_.isTypeSupported === "function") {
11953
11929
  /* eslint-enable @typescript-eslint/unbound-method */
11954
- 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
+ }
11955
11941
  }
11956
11942
  return true;
11957
11943
  }
@@ -12024,6 +12010,7 @@ var Representation = /*#__PURE__*/function () {
12024
12010
  * @param {Object} args
12025
12011
  */
12026
12012
  function Representation(args, opts) {
12013
+ var _a;
12027
12014
  this.id = args.id;
12028
12015
  this.uniqueId = generateRepresentationUniqueId();
12029
12016
  this.bitrate = args.bitrate;
@@ -12052,12 +12039,24 @@ var Representation = /*#__PURE__*/function () {
12052
12039
  this.cdnMetadata = args.cdnMetadata;
12053
12040
  this.index = args.index;
12054
12041
  if (opts.type === "audio" || opts.type === "video") {
12055
- var mimeTypeStr = this.getMimeTypeString();
12056
- var isSupported = isCodecSupported(mimeTypeStr);
12057
- if (!isSupported) {
12058
- src_log.info("Unsupported Representation", mimeTypeStr, this.id, this.bitrate);
12042
+ this.isSupported = false;
12043
+ // Supplemental codecs are defined as backwards-compatible codecs enhancing
12044
+ // the experience of a base layer codec
12045
+ if (args.supplementalCodecs !== undefined) {
12046
+ var supplementalCodecMimeTypeStr = ((_a = this.mimeType) !== null && _a !== void 0 ? _a : "") + ";codecs=\"" + args.supplementalCodecs + "\"";
12047
+ if (isCodecSupported(supplementalCodecMimeTypeStr)) {
12048
+ this.codec = args.supplementalCodecs;
12049
+ this.isSupported = true;
12050
+ }
12051
+ }
12052
+ if (!this.isSupported) {
12053
+ var mimeTypeStr = this.getMimeTypeString();
12054
+ var isSupported = isCodecSupported(mimeTypeStr);
12055
+ if (!isSupported) {
12056
+ src_log.info("Unsupported Representation", mimeTypeStr, this.id, this.bitrate);
12057
+ }
12058
+ this.isSupported = isSupported;
12059
12059
  }
12060
- this.isSupported = isSupported;
12061
12060
  } else {
12062
12061
  this.isSupported = true; // TODO for other types
12063
12062
  }
@@ -13992,7 +13991,6 @@ function manifest_fetcher_arrayLikeToArray(arr, len) { if (len == null || len >
13992
13991
 
13993
13992
 
13994
13993
 
13995
-
13996
13994
  /**
13997
13995
  * Class allowing to facilitate the task of loading and parsing a Manifest, as
13998
13996
  * well as automatically refreshing it.
@@ -14117,13 +14115,18 @@ var ManifestFetcher = /*#__PURE__*/function (_EventEmitter) {
14117
14115
  case 0:
14118
14116
  callLoaderWithRetries = function _callLoaderWithRetrie(manifestUrl) {
14119
14117
  var loadManifest = pipelines.loadManifest;
14120
- 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;
14121
14120
  if (requestTimeout < 0) {
14122
14121
  requestTimeout = undefined;
14123
14122
  }
14123
+ if (connectionTimeout < 0) {
14124
+ connectionTimeout = undefined;
14125
+ }
14124
14126
  var callLoader = function callLoader() {
14125
14127
  return loadManifest(manifestUrl, {
14126
- timeout: requestTimeout
14128
+ timeout: requestTimeout,
14129
+ connectionTimeout: connectionTimeout
14127
14130
  }, cancelSignal);
14128
14131
  };
14129
14132
  return scheduleRequestPromise(callLoader, backoffSettings, cancelSignal);
@@ -14979,7 +14982,8 @@ var generateRequestID = idGenerator();
14979
14982
  */
14980
14983
  function segment_fetcher_createSegmentFetcher(bufferType, pipeline, cdnPrioritizer, lifecycleCallbacks, options) {
14981
14984
  var requestOptions = {
14982
- 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
14983
14987
  };
14984
14988
  /**
14985
14989
  * Cache audio and video initialization segments.
@@ -15222,17 +15226,20 @@ function segment_fetcher_createSegmentFetcher(bufferType, pipeline, cdnPrioritiz
15222
15226
  function getSegmentFetcherOptions(_ref) {
15223
15227
  var maxRetry = _ref.maxRetry,
15224
15228
  lowLatencyMode = _ref.lowLatencyMode,
15225
- requestTimeout = _ref.requestTimeout;
15229
+ requestTimeout = _ref.requestTimeout,
15230
+ connectionTimeout = _ref.connectionTimeout;
15226
15231
  var _config$getCurrent = config.getCurrent(),
15227
15232
  DEFAULT_MAX_REQUESTS_RETRY_ON_ERROR = _config$getCurrent.DEFAULT_MAX_REQUESTS_RETRY_ON_ERROR,
15228
15233
  DEFAULT_REQUEST_TIMEOUT = _config$getCurrent.DEFAULT_REQUEST_TIMEOUT,
15234
+ DEFAULT_CONNECTION_TIMEOUT = _config$getCurrent.DEFAULT_CONNECTION_TIMEOUT,
15229
15235
  INITIAL_BACKOFF_DELAY_BASE = _config$getCurrent.INITIAL_BACKOFF_DELAY_BASE,
15230
15236
  MAX_BACKOFF_DELAY_BASE = _config$getCurrent.MAX_BACKOFF_DELAY_BASE;
15231
15237
  return {
15232
15238
  maxRetry: maxRetry !== null && maxRetry !== void 0 ? maxRetry : DEFAULT_MAX_REQUESTS_RETRY_ON_ERROR,
15233
15239
  baseDelay: lowLatencyMode ? INITIAL_BACKOFF_DELAY_BASE.LOW_LATENCY : INITIAL_BACKOFF_DELAY_BASE.REGULAR,
15234
15240
  maxDelay: lowLatencyMode ? MAX_BACKOFF_DELAY_BASE.LOW_LATENCY : MAX_BACKOFF_DELAY_BASE.REGULAR,
15235
- 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
15236
15243
  };
15237
15244
  }
15238
15245
  ;// CONCATENATED MODULE: ./src/core/fetchers/segment/task_prioritizer.ts
@@ -17514,9 +17521,12 @@ function shouldHaveNativeBuffer(bufferType) {
17514
17521
 
17515
17522
  /* harmony default export */ var segment_buffers = (SegmentBuffersStore);
17516
17523
 
17517
- // EXTERNAL MODULE: ./node_modules/next-tick/index.js
17518
- var next_tick = __webpack_require__(473);
17519
- var next_tick_default = /*#__PURE__*/__webpack_require__.n(next_tick);
17524
+ ;// CONCATENATED MODULE: ./src/utils/queue_microtask.ts
17525
+ /* harmony default export */ var queue_microtask = (typeof queueMicrotask === "function" ? queueMicrotask : function queueMicrotaskPonyfill(cb) {
17526
+ Promise.resolve().then(cb, function () {
17527
+ return cb();
17528
+ });
17529
+ });
17520
17530
  ;// CONCATENATED MODULE: ./src/utils/sorted_list.ts
17521
17531
  /**
17522
17532
  * Copyright 2015 CANAL+ Group
@@ -18934,7 +18944,7 @@ function doesEndSeemGarbageCollected(currentSeg, nextSeg, minimumEndTime) {
18934
18944
  return false;
18935
18945
  }
18936
18946
  if (minimumEndTime > currentSeg.bufferedEnd && currentSeg.end - currentSeg.bufferedEnd > MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT) {
18937
- 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);
18938
18948
  return true;
18939
18949
  }
18940
18950
  return false;
@@ -19158,7 +19168,7 @@ function getBufferStatus(content, initialWantedTime, playbackObserver, fastSwitc
19158
19168
  * `true` if the current `RepresentationStream` has loaded all the
19159
19169
  * needed segments for this Representation until the end of the Period.
19160
19170
  */
19161
- 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;
19162
19172
  /**
19163
19173
  * Start time in seconds of the next available not-yet pushed segment.
19164
19174
  * `null` if no segment is wanted for the current wanted range.
@@ -19207,14 +19217,14 @@ function getRangeOfNeededSegments(content, initialWantedTime, bufferGoal) {
19207
19217
  // In that case, we want to actually request at least the last segment to
19208
19218
  // avoid ending the last Period - and by extension the content - with a
19209
19219
  // segment which isn't the last one.
19210
- 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)) {
19211
19221
  wantedStartPosition = lastIndexPosition - 1;
19212
19222
  } else {
19213
19223
  wantedStartPosition = initialWantedTime - 0.1;
19214
19224
  }
19215
19225
  var wantedEndPosition = wantedStartPosition + bufferGoal;
19216
19226
  var hasReachedPeriodEnd;
19217
- if (!representation.index.isInitialized() || !representation.index.isFinished() || period.end === undefined) {
19227
+ if (!representation.index.isInitialized() || representation.index.isStillAwaitingFutureSegments() || period.end === undefined) {
19218
19228
  hasReachedPeriodEnd = false;
19219
19229
  } else if (lastIndexPosition === undefined) {
19220
19230
  // We do not know the end of this index.
@@ -20514,7 +20524,7 @@ function AdaptationStream(_ref, callbacks, parentCancelSignal) {
20514
20524
  case 4:
20515
20525
  return _context.abrupt("break", 21);
20516
20526
  case 5:
20517
- return _context.abrupt("return", next_tick_default()(function () {
20527
+ return _context.abrupt("return", queue_microtask(function () {
20518
20528
  playbackObserver.listen(function () {
20519
20529
  if (fnCancelSignal.isCancelled()) {
20520
20530
  return;
@@ -21447,7 +21457,7 @@ function PeriodStream(_ref, callbacks, parentCancelSignal) {
21447
21457
  // is actually received.
21448
21458
  // It can happen when `askForMediaSourceReload` is called as a side-effect of
21449
21459
  // the same event that triggers the playback observation to be emitted.
21450
- next_tick_default()(function () {
21460
+ queue_microtask(function () {
21451
21461
  playbackObserver.listen(function () {
21452
21462
  if (cancelSignal.isCancelled()) {
21453
21463
  return;
@@ -21979,7 +21989,7 @@ function StreamOrchestrator(content, playbackObserver, representationEstimator,
21979
21989
  // Schedule micro task before checking the last playback observation
21980
21990
  // to reduce the risk of race conditions where the next observation
21981
21991
  // was going to be emitted synchronously.
21982
- next_tick_default()(function () {
21992
+ queue_microtask(function () {
21983
21993
  var _a;
21984
21994
  if (orchestratorCancelSignal.isCancelled()) {
21985
21995
  return;
@@ -22166,7 +22176,7 @@ function StreamOrchestrator(content, playbackObserver, representationEstimator,
22166
22176
  // conditions where the inner logic would be called synchronously before
22167
22177
  // the next observation (which may reflect very different playback
22168
22178
  // conditions) is actually received.
22169
- return next_tick_default()(function () {
22179
+ return queue_microtask(function () {
22170
22180
  if (innerCancelSignal.isCancelled()) {
22171
22181
  return;
22172
22182
  }
@@ -22321,8 +22331,8 @@ function content_time_boundaries_observer_arrayLikeToArray(arr, len) { if (len =
22321
22331
  /**
22322
22332
  * Observes what's being played and take care of media events relating to time
22323
22333
  * boundaries:
22324
- * - Emits a `durationUpdate` when the duration of the current content is
22325
- * 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.
22326
22336
  * - Emits `endOfStream` API once segments have been pushed until the end and
22327
22337
  * `resumeStream` if downloads starts back.
22328
22338
  * - Emits a `periodChange` event when the currently-playing Period seemed to
@@ -22368,7 +22378,7 @@ var ContentTimeBoundariesObserver = /*#__PURE__*/function (_EventEmitter) {
22368
22378
  clearSignal: cancelSignal
22369
22379
  });
22370
22380
  manifest.addEventListener("manifestUpdate", function () {
22371
- _this.trigger("durationUpdate", _this._getManifestDuration());
22381
+ _this.trigger("endingPositionChange", _this._getManifestEndTime());
22372
22382
  if (cancelSignal.isCancelled()) {
22373
22383
  return;
22374
22384
  }
@@ -22377,12 +22387,13 @@ var ContentTimeBoundariesObserver = /*#__PURE__*/function (_EventEmitter) {
22377
22387
  return _this;
22378
22388
  }
22379
22389
  /**
22380
- * 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.
22381
22392
  * @returns {Object}
22382
22393
  */
22383
22394
  var _proto = ContentTimeBoundariesObserver.prototype;
22384
- _proto.getCurrentDuration = function getCurrentDuration() {
22385
- return this._getManifestDuration();
22395
+ _proto.getCurrentEndingTime = function getCurrentEndingTime() {
22396
+ return this._getManifestEndTime();
22386
22397
  }
22387
22398
  /**
22388
22399
  * Method to call any time an Adaptation has been selected.
@@ -22408,14 +22419,14 @@ var ContentTimeBoundariesObserver = /*#__PURE__*/function (_EventEmitter) {
22408
22419
  this._maximumPositionCalculator.updateLastVideoAdaptation(adaptation);
22409
22420
  }
22410
22421
  var endingPosition = this._maximumPositionCalculator.getEndingPosition();
22411
- var newDuration = endingPosition !== undefined ? {
22422
+ var newEndingPosition = endingPosition !== undefined ? {
22412
22423
  isEnd: true,
22413
- duration: endingPosition
22424
+ endingPosition: endingPosition
22414
22425
  } : {
22415
22426
  isEnd: false,
22416
- duration: this._maximumPositionCalculator.getMaximumAvailablePosition()
22427
+ endingPosition: this._maximumPositionCalculator.getMaximumAvailablePosition()
22417
22428
  };
22418
- this.trigger("durationUpdate", newDuration);
22429
+ this.trigger("endingPositionChange", newEndingPosition);
22419
22430
  }
22420
22431
  }
22421
22432
  }
@@ -22555,14 +22566,14 @@ var ContentTimeBoundariesObserver = /*#__PURE__*/function (_EventEmitter) {
22555
22566
  if (_ret) return _ret.v;
22556
22567
  }
22557
22568
  };
22558
- _proto._getManifestDuration = function _getManifestDuration() {
22569
+ _proto._getManifestEndTime = function _getManifestEndTime() {
22559
22570
  var endingPosition = this._maximumPositionCalculator.getEndingPosition();
22560
22571
  return endingPosition !== undefined ? {
22561
22572
  isEnd: true,
22562
- duration: endingPosition
22573
+ endingPosition: endingPosition
22563
22574
  } : {
22564
22575
  isEnd: false,
22565
- duration: this._maximumPositionCalculator.getMaximumAvailablePosition()
22576
+ endingPosition: this._maximumPositionCalculator.getMaximumAvailablePosition()
22566
22577
  };
22567
22578
  };
22568
22579
  _proto._lazilyCreateActiveStreamInfo = function _lazilyCreateActiveStreamInfo(bufferType) {
@@ -22639,9 +22650,8 @@ var MaximumPositionCalculator = /*#__PURE__*/function () {
22639
22650
  * @returns {number}
22640
22651
  */;
22641
22652
  _proto2.getMaximumAvailablePosition = function getMaximumAvailablePosition() {
22642
- var _a;
22643
22653
  if (this._manifest.isDynamic) {
22644
- return (_a = this._manifest.getLivePosition()) !== null && _a !== void 0 ? _a : this._manifest.getMaximumSafePosition();
22654
+ return this._manifest.getMaximumSafePosition();
22645
22655
  }
22646
22656
  if (this._lastVideoAdaptation === undefined || this._lastAudioAdaptation === undefined) {
22647
22657
  return this._manifest.getMaximumSafePosition();
@@ -23157,15 +23167,10 @@ function maintainEndOfStream(mediaSource, cancelSignal) {
23157
23167
  * @returns {Number}
23158
23168
  */
23159
23169
  function getInitialTime(manifest, lowLatencyMode, startAt) {
23170
+ var _a;
23160
23171
  if (!is_null_or_undefined_isNullOrUndefined(startAt)) {
23161
23172
  var min = manifest.getMinimumSafePosition();
23162
- var max;
23163
- if (manifest.isLive) {
23164
- max = manifest.getLivePosition();
23165
- }
23166
- if (max === undefined) {
23167
- max = manifest.getMaximumSafePosition();
23168
- }
23173
+ var max = manifest.getMaximumSafePosition();
23169
23174
  if (!is_null_or_undefined_isNullOrUndefined(startAt.position)) {
23170
23175
  src_log.debug("Init: using startAt.minimumPosition");
23171
23176
  return Math.max(Math.min(startAt.position, max), min);
@@ -23182,6 +23187,11 @@ function getInitialTime(manifest, lowLatencyMode, startAt) {
23182
23187
  src_log.debug("Init: using startAt.fromLastPosition");
23183
23188
  var fromLastPosition = startAt.fromLastPosition;
23184
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);
23185
23195
  } else if (!is_null_or_undefined_isNullOrUndefined(startAt.percentage)) {
23186
23196
  src_log.debug("Init: using startAt.percentage");
23187
23197
  var percentage = startAt.percentage;
@@ -25359,7 +25369,7 @@ var MediaSourceContentInitializer = /*#__PURE__*/function (_ContentInitializer)
25359
25369
  if (
25360
25370
  // Data is buffered around the current position
25361
25371
  obs.currentRange !== null ||
25362
- // Or, for whatever reason, playback is already advancing
25372
+ // Or, for whatever reason, we have no buffer but we're already advancing
25363
25373
  obs.position > seekedTime + 0.1) {
25364
25374
  stopListening();
25365
25375
  playbackObserver.setCurrentTime(obs.position + 0.001);
@@ -25542,8 +25552,8 @@ var MediaSourceContentInitializer = /*#__PURE__*/function (_ContentInitializer)
25542
25552
  period: period
25543
25553
  });
25544
25554
  });
25545
- contentTimeBoundariesObserver.addEventListener("durationUpdate", function (newDuration) {
25546
- mediaSourceDurationUpdater.updateDuration(newDuration.duration, newDuration.isEnd);
25555
+ contentTimeBoundariesObserver.addEventListener("endingPositionChange", function (x) {
25556
+ return mediaSourceDurationUpdater.updateDuration(x.endingPosition, x.isEnd);
25547
25557
  });
25548
25558
  contentTimeBoundariesObserver.addEventListener("endOfStream", function () {
25549
25559
  if (endOfStreamCanceller === null) {
@@ -25560,8 +25570,8 @@ var MediaSourceContentInitializer = /*#__PURE__*/function (_ContentInitializer)
25560
25570
  endOfStreamCanceller = null;
25561
25571
  }
25562
25572
  });
25563
- var currentDuration = contentTimeBoundariesObserver.getCurrentDuration();
25564
- mediaSourceDurationUpdater.updateDuration(currentDuration.duration, currentDuration.isEnd);
25573
+ var endInfo = contentTimeBoundariesObserver.getCurrentEndingTime();
25574
+ mediaSourceDurationUpdater.updateDuration(endInfo.endingPosition, endInfo.isEnd);
25565
25575
  return contentTimeBoundariesObserver;
25566
25576
  }
25567
25577
  /**
@@ -27168,7 +27178,7 @@ function getTimescaledRange(start, duration, timescale) {
27168
27178
  * timescaled time.
27169
27179
  * Returns -1 if the given time is lower than the start of the first available
27170
27180
  * segment.
27171
- * @param {Object} index
27181
+ * @param {Object} timeline
27172
27182
  * @param {Number} timeTScaled
27173
27183
  * @returns {Number}
27174
27184
  */
@@ -27213,55 +27223,6 @@ function index_helpers_checkDiscontinuity(index, timeSec, maxPosition) {
27213
27223
  var segmentEnd = getIndexSegmentEnd(timelineItem, nextTimelineItem, maxPosition);
27214
27224
  return scaledTime >= segmentEnd && scaledTime < nextStart ? fromIndexTime(nextStart, index) : null;
27215
27225
  }
27216
- ;// CONCATENATED MODULE: ./src/parsers/manifest/utils/is_segment_still_available.ts
27217
- /**
27218
- * Copyright 2015 CANAL+ Group
27219
- *
27220
- * Licensed under the Apache License, Version 2.0 (the "License");
27221
- * you may not use this file except in compliance with the License.
27222
- * You may obtain a copy of the License at
27223
- *
27224
- * http://www.apache.org/licenses/LICENSE-2.0
27225
- *
27226
- * Unless required by applicable law or agreed to in writing, software
27227
- * distributed under the License is distributed on an "AS IS" BASIS,
27228
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27229
- * See the License for the specific language governing permissions and
27230
- * limitations under the License.
27231
- */
27232
- /**
27233
- * Returns true if a Segment returned by the corresponding index is still
27234
- * considered available.
27235
- * Returns false if it is not available anymore.
27236
- * Returns undefined if we cannot know whether it is still available or not.
27237
- * /!\ We do not check the mediaURLs of the segment.
27238
- * @param {Object} segment
27239
- * @param {Array.<Object>} timescale
27240
- * @param {number} timeline
27241
- * @returns {Boolean|undefined}
27242
- */
27243
- function is_segment_still_available_isSegmentStillAvailable(segment, timeline, timescale, indexTimeOffset) {
27244
- for (var i = 0; i < timeline.length; i++) {
27245
- var tSegment = timeline[i];
27246
- var tSegmentTime = (tSegment.start - indexTimeOffset) / timescale;
27247
- if (tSegmentTime > segment.time) {
27248
- return false;
27249
- } else if (tSegmentTime === segment.time) {
27250
- if (tSegment.range === undefined) {
27251
- return segment.range === undefined;
27252
- }
27253
- return segment.range != null && tSegment.range[0] === segment.range[0] && tSegment.range[1] === segment.range[1];
27254
- } else {
27255
- // tSegment.start < segment.time
27256
- if (tSegment.repeatCount >= 0 && tSegment.duration !== undefined) {
27257
- var timeDiff = tSegmentTime - tSegment.start;
27258
- var repeat = timeDiff / tSegment.duration - 1;
27259
- return repeat % 1 === 0 && repeat <= tSegment.repeatCount;
27260
- }
27261
- }
27262
- }
27263
- return false;
27264
- }
27265
27226
  ;// CONCATENATED MODULE: ./src/parsers/manifest/smooth/utils/tokens.ts
27266
27227
  /**
27267
27228
  * Copyright 2015 CANAL+ Group
@@ -27317,7 +27278,6 @@ function replaceSegmentSmoothTokens(url, time) {
27317
27278
 
27318
27279
 
27319
27280
 
27320
-
27321
27281
  /**
27322
27282
  * @param {Number} start
27323
27283
  * @param {Number} up
@@ -27587,7 +27547,7 @@ var SmoothRepresentationIndex = /*#__PURE__*/function () {
27587
27547
  _proto.awaitSegmentBetween = function awaitSegmentBetween(start, end) {
27588
27548
  var _a;
27589
27549
  assert_assert(start <= end);
27590
- if (this.isFinished()) {
27550
+ if (this.isStillAwaitingFutureSegments()) {
27591
27551
  return false;
27592
27552
  }
27593
27553
  var lastAvailablePosition = this.getLastAvailablePosition();
@@ -27625,7 +27585,23 @@ var SmoothRepresentationIndex = /*#__PURE__*/function () {
27625
27585
  var _this$_sharedSmoothTi5 = this._sharedSmoothTimeline,
27626
27586
  timeline = _this$_sharedSmoothTi5.timeline,
27627
27587
  timescale = _this$_sharedSmoothTi5.timescale;
27628
- 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;
27629
27605
  }
27630
27606
  /**
27631
27607
  * @param {Error} error
@@ -27658,9 +27634,9 @@ var SmoothRepresentationIndex = /*#__PURE__*/function () {
27658
27634
  this._sharedSmoothTimeline.update(newIndex._sharedSmoothTimeline);
27659
27635
  }
27660
27636
  /**
27661
- * 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
27662
27638
  * generated.
27663
- * 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
27664
27640
  * generated.
27665
27641
  *
27666
27642
  * For Smooth, it should only depend on whether the content is a live content
@@ -27668,8 +27644,8 @@ var SmoothRepresentationIndex = /*#__PURE__*/function () {
27668
27644
  * TODO What about Smooth live content that finishes at some point?
27669
27645
  * @returns {boolean}
27670
27646
  */;
27671
- _proto.isFinished = function isFinished() {
27672
- return !this._isLive;
27647
+ _proto.isStillAwaitingFutureSegments = function isStillAwaitingFutureSegments() {
27648
+ return this._isLive;
27673
27649
  }
27674
27650
  /**
27675
27651
  * @returns {Boolean}
@@ -27684,8 +27660,8 @@ var SmoothRepresentationIndex = /*#__PURE__*/function () {
27684
27660
  * Add segments to a `SharedSmoothSegmentTimeline` that were predicted to come
27685
27661
  * after `currentSegment`.
27686
27662
  * @param {Array.<Object>} nextSegments - The segment information parsed.
27687
- * @param {Object} segment - Information on the segment which contained that
27688
- * new segment information.
27663
+ * @param {Object} currentSegment - Information on the segment which contained
27664
+ * that new segment information.
27689
27665
  */;
27690
27666
  _proto.addPredictedSegments = function addPredictedSegments(nextSegments, currentSegment) {
27691
27667
  this._sharedSmoothTimeline.addPredictedSegments(nextSegments, currentSegment);
@@ -28735,7 +28711,8 @@ function request(options) {
28735
28711
  url: options.url,
28736
28712
  headers: options.headers,
28737
28713
  responseType: is_null_or_undefined_isNullOrUndefined(options.responseType) ? DEFAULT_RESPONSE_TYPE : options.responseType,
28738
- timeout: options.timeout
28714
+ timeout: options.timeout,
28715
+ connectionTimeout: options.connectionTimeout
28739
28716
  };
28740
28717
  return new Promise(function (resolve, reject) {
28741
28718
  var onProgress = options.onProgress,
@@ -28743,7 +28720,8 @@ function request(options) {
28743
28720
  var url = requestOptions.url,
28744
28721
  headers = requestOptions.headers,
28745
28722
  responseType = requestOptions.responseType,
28746
- timeout = requestOptions.timeout;
28723
+ timeout = requestOptions.timeout,
28724
+ connectionTimeout = requestOptions.connectionTimeout;
28747
28725
  var xhr = new XMLHttpRequest();
28748
28726
  xhr.open("GET", url, true);
28749
28727
  var timeoutId;
@@ -28757,9 +28735,19 @@ function request(options) {
28757
28735
  // is more precise, it might also be more efficient.
28758
28736
  timeoutId = setTimeout(function () {
28759
28737
  clearCancellingProcess();
28760
- reject(new RequestError(url, xhr.status, "TIMEOUT"));
28738
+ reject(new RequestError(url, xhr.status, NetworkErrorTypes.TIMEOUT));
28761
28739
  }, timeout + 3000);
28762
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
+ }
28763
28751
  xhr.responseType = responseType;
28764
28752
  if (xhr.responseType === "document") {
28765
28753
  xhr.overrideMimeType("text/xml");
@@ -28778,7 +28766,7 @@ function request(options) {
28778
28766
  if (cancelSignal !== undefined) {
28779
28767
  deregisterCancellationListener = cancelSignal.register(function abortRequest(err) {
28780
28768
  clearCancellingProcess();
28781
- if (!is_null_or_undefined_isNullOrUndefined(xhr) && xhr.readyState !== 4) {
28769
+ if (xhr.readyState !== XMLHttpRequest.DONE) {
28782
28770
  xhr.abort();
28783
28771
  }
28784
28772
  reject(err);
@@ -28789,12 +28777,19 @@ function request(options) {
28789
28777
  }
28790
28778
  xhr.onerror = function onXHRError() {
28791
28779
  clearCancellingProcess();
28792
- reject(new RequestError(url, xhr.status, "ERROR_EVENT"));
28780
+ reject(new RequestError(url, xhr.status, NetworkErrorTypes.ERROR_EVENT));
28793
28781
  };
28794
28782
  xhr.ontimeout = function onXHRTimeout() {
28795
28783
  clearCancellingProcess();
28796
- reject(new RequestError(url, xhr.status, "TIMEOUT"));
28784
+ reject(new RequestError(url, xhr.status, NetworkErrorTypes.TIMEOUT));
28797
28785
  };
28786
+ if (connectionTimeout !== undefined) {
28787
+ xhr.onreadystatechange = function clearConnectionTimeout() {
28788
+ if (xhr.readyState >= XMLHttpRequest.HEADERS_RECEIVED) {
28789
+ clearTimeout(connectionTimeoutId);
28790
+ }
28791
+ };
28792
+ }
28798
28793
  if (onProgress !== undefined) {
28799
28794
  xhr.onprogress = function onXHRProgress(event) {
28800
28795
  var currentTime = getMonotonicTimeStamp();
@@ -28809,7 +28804,7 @@ function request(options) {
28809
28804
  };
28810
28805
  }
28811
28806
  xhr.onload = function onXHRLoad(event) {
28812
- if (xhr.readyState === 4) {
28807
+ if (xhr.readyState === XMLHttpRequest.DONE) {
28813
28808
  clearCancellingProcess();
28814
28809
  if (xhr.status >= 200 && xhr.status < 300) {
28815
28810
  var receivedTime = getMonotonicTimeStamp();
@@ -28827,7 +28822,7 @@ function request(options) {
28827
28822
  responseData = xhr.response;
28828
28823
  }
28829
28824
  if (is_null_or_undefined_isNullOrUndefined(responseData)) {
28830
- reject(new RequestError(url, xhr.status, "PARSE_ERROR"));
28825
+ reject(new RequestError(url, xhr.status, NetworkErrorTypes.PARSE_ERROR));
28831
28826
  return;
28832
28827
  }
28833
28828
  resolve({
@@ -28841,7 +28836,7 @@ function request(options) {
28841
28836
  responseData: responseData
28842
28837
  });
28843
28838
  } else {
28844
- reject(new RequestError(url, xhr.status, "ERROR_HTTP_CODE"));
28839
+ reject(new RequestError(url, xhr.status, NetworkErrorTypes.ERROR_HTTP_CODE));
28845
28840
  }
28846
28841
  }
28847
28842
  };
@@ -28853,6 +28848,9 @@ function request(options) {
28853
28848
  if (timeoutId !== undefined) {
28854
28849
  clearTimeout(timeoutId);
28855
28850
  }
28851
+ if (connectionTimeoutId !== undefined) {
28852
+ clearTimeout(connectionTimeoutId);
28853
+ }
28856
28854
  if (deregisterCancellationListener !== null) {
28857
28855
  deregisterCancellationListener();
28858
28856
  }
@@ -29129,6 +29127,7 @@ function generateRegularManifestLoader(preferredType) {
29129
29127
  url: url,
29130
29128
  responseType: "arraybuffer",
29131
29129
  timeout: loaderOptions.timeout,
29130
+ connectionTimeout: loaderOptions.connectionTimeout,
29132
29131
  cancelSignal: cancelSignal
29133
29132
  });
29134
29133
  case "text":
@@ -29136,6 +29135,7 @@ function generateRegularManifestLoader(preferredType) {
29136
29135
  url: url,
29137
29136
  responseType: "text",
29138
29137
  timeout: loaderOptions.timeout,
29138
+ connectionTimeout: loaderOptions.connectionTimeout,
29139
29139
  cancelSignal: cancelSignal
29140
29140
  });
29141
29141
  case "document":
@@ -29143,6 +29143,7 @@ function generateRegularManifestLoader(preferredType) {
29143
29143
  url: url,
29144
29144
  responseType: "document",
29145
29145
  timeout: loaderOptions.timeout,
29146
+ connectionTimeout: loaderOptions.connectionTimeout,
29146
29147
  cancelSignal: cancelSignal
29147
29148
  });
29148
29149
  default:
@@ -30618,6 +30619,7 @@ function regularSegmentLoader(url, context, callbacks, loaderOptions, cancelSign
30618
30619
  responseType: "arraybuffer",
30619
30620
  headers: headers,
30620
30621
  timeout: loaderOptions.timeout,
30622
+ connectionTimeout: loaderOptions.connectionTimeout,
30621
30623
  cancelSignal: cancelSignal,
30622
30624
  onProgress: callbacks.onProgress
30623
30625
  }).then(function (data) {
@@ -30993,6 +30995,7 @@ function constructSegmentUrl(wantedCdn, segment) {
30993
30995
  url: url,
30994
30996
  responseType: "text",
30995
30997
  timeout: loaderOptions.timeout,
30998
+ connectionTimeout: loaderOptions.connectionTimeout,
30996
30999
  cancelSignal: cancelSignal,
30997
31000
  onProgress: callbacks.onProgress
30998
31001
  }).then(function (data) {
@@ -31006,6 +31009,7 @@ function constructSegmentUrl(wantedCdn, segment) {
31006
31009
  url: url,
31007
31010
  responseType: "arraybuffer",
31008
31011
  timeout: loaderOptions.timeout,
31012
+ connectionTimeout: loaderOptions.connectionTimeout,
31009
31013
  cancelSignal: cancelSignal,
31010
31014
  onProgress: callbacks.onProgress
31011
31015
  }).then(function (data) {
@@ -31545,6 +31549,135 @@ function getMinimumAndMaximumPositions(periods) {
31545
31549
  maximumUnsafePosition: maxPositions.unsafe
31546
31550
  };
31547
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
+
31548
31681
  ;// CONCATENATED MODULE: ./src/parsers/manifest/dash/common/parse_availability_start_time.ts
31549
31682
  /**
31550
31683
  * Copyright 2015 CANAL+ Group
@@ -31679,6 +31812,11 @@ function flattenOverlappingPeriods(parsedPeriods) {
31679
31812
  // `lastFlattenedPeriod` has now a negative or `0` duration.
31680
31813
  // Remove it, consider the next Period in its place, and re-start the loop.
31681
31814
  flattenedPeriods.pop();
31815
+ if (flattenedPeriods.length === 0) {
31816
+ // There's no remaining Period to compare to `parsedPeriod`
31817
+ break;
31818
+ }
31819
+ // Take the previous Period as reference and compare it now to `parsedPeriod`
31682
31820
  lastFlattenedPeriod = flattenedPeriods[flattenedPeriods.length - 1];
31683
31821
  }
31684
31822
  }
@@ -31746,115 +31884,6 @@ function getPeriodsTimeInformation(periodsIR, manifestInfos) {
31746
31884
  });
31747
31885
  return periodsTimeInformation;
31748
31886
  }
31749
- ;// CONCATENATED MODULE: ./src/parsers/manifest/dash/common/manifest_bounds_calculator.ts
31750
- /**
31751
- * Copyright 2015 CANAL+ Group
31752
- *
31753
- * Licensed under the Apache License, Version 2.0 (the "License");
31754
- * you may not use this file except in compliance with the License.
31755
- * You may obtain a copy of the License at
31756
- *
31757
- * http://www.apache.org/licenses/LICENSE-2.0
31758
- *
31759
- * Unless required by applicable law or agreed to in writing, software
31760
- * distributed under the License is distributed on an "AS IS" BASIS,
31761
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31762
- * See the License for the specific language governing permissions and
31763
- * limitations under the License.
31764
- */
31765
-
31766
- /**
31767
- * This class allows to easily calculate the first and last available positions
31768
- * in a content at any time.
31769
- *
31770
- * That task can be an hard for dynamic DASH contents: it depends on a
31771
- * `timeShiftBufferDepth` defined in the MPD and on the maximum possible
31772
- * position.
31773
- *
31774
- * The latter can come from either a clock synchronization mechanism or the
31775
- * indexing schemes (e.g. SegmentTemplate, SegmentTimeline etc.) of the last
31776
- * Periods.
31777
- * As such, it might only be known once a large chunk of the MPD has already
31778
- * been parsed.
31779
- *
31780
- * By centralizing the manifest bounds calculation in this class and by giving
31781
- * an instance of it to each parsed elements which might depend on it, we
31782
- * ensure that we can provide it once it is known to every one of those
31783
- * elements without needing to parse a second time the MPD.
31784
- * @class ManifestBoundsCalculator
31785
- */
31786
- var ManifestBoundsCalculator = /*#__PURE__*/function () {
31787
- /**
31788
- * @param {Object} args
31789
- */
31790
- function ManifestBoundsCalculator(args) {
31791
- this._isDynamic = args.isDynamic;
31792
- this._timeShiftBufferDepth = !args.isDynamic || args.timeShiftBufferDepth === undefined ? null : args.timeShiftBufferDepth;
31793
- }
31794
- /**
31795
- * Set the last position and the position time (the value of the RxPlayer's
31796
- * monotonically-raising timestamp at the time that position was true
31797
- * converted into seconds).
31798
- *
31799
- * @example
31800
- * Example if you trust `Date.now()` to give you a reliable offset:
31801
- * ```js
31802
- * const lastPosition = Date.now();
31803
- * const positionTime = getMonotonicTimeStamp() / 1000;
31804
- * manifestBoundsCalculator.setLastPosition(lastPosition, positionTime);
31805
- * ```
31806
- *
31807
- * @param {number} lastPosition
31808
- * @param {number|undefined} positionTime
31809
- */
31810
- var _proto = ManifestBoundsCalculator.prototype;
31811
- _proto.setLastPosition = function setLastPosition(lastPosition, positionTime) {
31812
- this._lastPosition = lastPosition;
31813
- this._positionTime = positionTime;
31814
- }
31815
- /**
31816
- * Returns `true` if the last position and the position time
31817
- * (for dynamic content only) have been comunicated.
31818
- * `false` otherwise.
31819
- * @returns {boolean}
31820
- */;
31821
- _proto.lastPositionIsKnown = function lastPositionIsKnown() {
31822
- if (this._isDynamic) {
31823
- return this._positionTime != null && this._lastPosition != null;
31824
- }
31825
- return this._lastPosition != null;
31826
- }
31827
- /**
31828
- * Estimate a minimum bound for the content from the last set segment time
31829
- * and buffer depth.
31830
- * Consider that it is only an estimation, not the real value.
31831
- * @return {number|undefined}
31832
- */;
31833
- _proto.estimateMinimumBound = function estimateMinimumBound() {
31834
- if (!this._isDynamic || this._timeShiftBufferDepth === null) {
31835
- return 0;
31836
- }
31837
- var maximumBound = this.estimateMaximumBound();
31838
- if (maximumBound === undefined) {
31839
- return undefined;
31840
- }
31841
- var minimumBound = maximumBound - this._timeShiftBufferDepth;
31842
- return minimumBound;
31843
- }
31844
- /**
31845
- * Estimate a maximum bound for the content from the last set segment time.
31846
- * Consider that it is only an estimation, not the real value.
31847
- * @return {number|undefined}
31848
- */;
31849
- _proto.estimateMaximumBound = function estimateMaximumBound() {
31850
- if (this._isDynamic && this._positionTime != null && this._lastPosition != null) {
31851
- return Math.max(this._lastPosition - this._positionTime + getMonotonicTimeStamp() / 1000, 0);
31852
- }
31853
- return this._lastPosition;
31854
- };
31855
- return ManifestBoundsCalculator;
31856
- }();
31857
-
31858
31887
  ;// CONCATENATED MODULE: ./src/parsers/manifest/dash/common/attach_trickmode_track.ts
31859
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."); }
31860
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); }
@@ -32019,6 +32048,31 @@ function inferAdaptationType(representations, adaptationMimeType, adaptationCode
32019
32048
  }
32020
32049
  return undefined;
32021
32050
  }
32051
+ ;// CONCATENATED MODULE: ./src/parsers/manifest/dash/common/convert_supplemental_codecs.ts
32052
+
32053
+ var supplementalCodecSeparator = /[, ]+/g;
32054
+ /**
32055
+ * Converts SCTE 214 supplemental codec string into RFC4281 codec string
32056
+ *
32057
+ * The returned value is a codec string respecting RFC6381
32058
+ *
32059
+ * SCTE 214 defines supplemental codecs as a whitespace-separated multiple list of
32060
+ * codec strings
32061
+ *
32062
+ * RFC6381 defines codecs as a comma-separated list of codec strings.
32063
+ *
32064
+ * This two syntax differs and this parser is used to convert SCTE214
32065
+ * to be compliant with what MSE APIs expect
32066
+ *
32067
+ * @param {string} val - The codec string to parse
32068
+ * @returns { Array.<string | undefined | null>}
32069
+ */
32070
+ function convertSupplementalCodecsToRFC6381(val) {
32071
+ if (isNonEmptyString(val)) {
32072
+ return val.trim().replace(supplementalCodecSeparator, ", ");
32073
+ }
32074
+ return "";
32075
+ }
32022
32076
  ;// CONCATENATED MODULE: ./src/parsers/manifest/dash/common/get_hdr_information.ts
32023
32077
  /**
32024
32078
  * Copyright 2015 CANAL+ Group
@@ -32261,13 +32315,17 @@ function getWantedRepeatIndex(segmentStartTime, segmentDuration, wantedTime) {
32261
32315
  * @param {Object} index - index object, constructed by parsing the manifest.
32262
32316
  * @param {number} from - starting timestamp wanted, in seconds
32263
32317
  * @param {number} durationWanted - duration wanted, in seconds
32318
+ * @param {Object} manifestBoundsCalculator
32319
+ * @param {number|undefined} scaledPeriodEnd
32264
32320
  * @param {function} isEMSGWhitelisted
32265
- * @param {number|undefined} maximumTime
32266
32321
  * @returns {Array.<Object>}
32267
32322
  */
32268
- 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);
32269
32327
  var scaledUp = toIndexTime(from, index);
32270
- var scaledTo = toIndexTime(from + durationWanted, index);
32328
+ var scaledTo = toIndexTime(wantedMaximum, index);
32271
32329
  var timeline = index.timeline,
32272
32330
  timescale = index.timescale,
32273
32331
  segmentUrlTemplate = index.segmentUrlTemplate,
@@ -32281,7 +32339,13 @@ function getSegmentsFromTimeline(index, from, durationWanted, isEMSGWhitelisted,
32281
32339
  var duration = timelineItem.duration,
32282
32340
  start = timelineItem.start,
32283
32341
  range = timelineItem.range;
32284
- 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);
32285
32349
  var complete = index.availabilityTimeComplete !== false || i !== timelineLength - 1 && repeat !== 0;
32286
32350
  var segmentNumberInCurrentRange = getWantedRepeatIndex(start, duration, scaledUp);
32287
32351
  var segmentTime = start + segmentNumberInCurrentRange * duration;
@@ -32414,6 +32478,7 @@ var BaseRepresentationIndex = /*#__PURE__*/function () {
32414
32478
  timeline: (_c = index.timeline) !== null && _c !== void 0 ? _c : [],
32415
32479
  timescale: timescale
32416
32480
  };
32481
+ this._manifestBoundsCalculator = context.manifestBoundsCalculator;
32417
32482
  this._scaledPeriodStart = toIndexTime(periodStart, this._index);
32418
32483
  this._scaledPeriodEnd = periodEnd == null ? undefined : toIndexTime(periodEnd, this._index);
32419
32484
  this._isInitialized = this._index.timeline.length > 0;
@@ -32442,7 +32507,7 @@ var BaseRepresentationIndex = /*#__PURE__*/function () {
32442
32507
  * @returns {Array.<Object>}
32443
32508
  */;
32444
32509
  _proto.getSegments = function getSegments(from, dur) {
32445
- return getSegmentsFromTimeline(this._index, from, dur, this._isEMSGWhitelisted, this._scaledPeriodEnd);
32510
+ return getSegmentsFromTimeline(this._index, from, dur, this._manifestBoundsCalculator, this._scaledPeriodEnd, this._isEMSGWhitelisted);
32446
32511
  }
32447
32512
  /**
32448
32513
  * Returns false as no Segment-Base based index should need to be refreshed.
@@ -32526,8 +32591,8 @@ var BaseRepresentationIndex = /*#__PURE__*/function () {
32526
32591
  * should become available in the future.
32527
32592
  * @returns {Boolean}
32528
32593
  */;
32529
- _proto.isFinished = function isFinished() {
32530
- return true;
32594
+ _proto.isStillAwaitingFutureSegments = function isStillAwaitingFutureSegments() {
32595
+ return false;
32531
32596
  }
32532
32597
  /**
32533
32598
  * No segment in a `BaseRepresentationIndex` are known initially.
@@ -32783,8 +32848,8 @@ var ListRepresentationIndex = /*#__PURE__*/function () {
32783
32848
  /**
32784
32849
  * @returns {Boolean}
32785
32850
  */;
32786
- _proto.isFinished = function isFinished() {
32787
- return true;
32851
+ _proto.isStillAwaitingFutureSegments = function isStillAwaitingFutureSegments() {
32852
+ return false;
32788
32853
  }
32789
32854
  /**
32790
32855
  * @returns {Boolean}
@@ -33230,9 +33295,13 @@ function constructTimelineFromPreviousTimeline(newElements, prevTimeline) {
33230
33295
 
33231
33296
 
33232
33297
 
33233
-
33234
33298
  // eslint-disable-next-line max-len
33235
33299
 
33300
+ /**
33301
+ * `IRepresentationIndex` implementation for a DASH `SegmentTimeline` segment
33302
+ * indexing scheme.
33303
+ * @class TimelineRepresentationIndex
33304
+ */
33236
33305
  var TimelineRepresentationIndex = /*#__PURE__*/function () {
33237
33306
  /**
33238
33307
  * @param {Object} index
@@ -33244,6 +33313,7 @@ var TimelineRepresentationIndex = /*#__PURE__*/function () {
33244
33313
  throw new Error("The given index is not compatible with a " + "TimelineRepresentationIndex.");
33245
33314
  }
33246
33315
  var availabilityTimeComplete = context.availabilityTimeComplete,
33316
+ availabilityTimeOffset = context.availabilityTimeOffset,
33247
33317
  manifestBoundsCalculator = context.manifestBoundsCalculator,
33248
33318
  isDynamic = context.isDynamic,
33249
33319
  isLastPeriod = context.isLastPeriod,
@@ -33270,8 +33340,25 @@ var TimelineRepresentationIndex = /*#__PURE__*/function () {
33270
33340
  this._parseTimeline = (_b = index.timelineParser) !== null && _b !== void 0 ? _b : null;
33271
33341
  var initializationUrl = ((_c = index.initialization) === null || _c === void 0 ? void 0 : _c.media) === undefined ? null : constructRepresentationUrl(index.initialization.media, representationId, representationBitrate);
33272
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
+ }
33273
33359
  this._index = {
33274
- availabilityTimeComplete: availabilityTimeComplete,
33360
+ availabilityTimeComplete: availabilityTimeComplete !== null && availabilityTimeComplete !== void 0 ? availabilityTimeComplete : true,
33361
+ availabilityTimeOffset: actualAvailabilityTimeOffset,
33275
33362
  indexRange: index.indexRange,
33276
33363
  indexTimeOffset: indexTimeOffset,
33277
33364
  initialization: index.initialization == null ? undefined : {
@@ -33321,7 +33408,7 @@ var TimelineRepresentationIndex = /*#__PURE__*/function () {
33321
33408
  timeline: timeline,
33322
33409
  timescale: timescale,
33323
33410
  indexTimeOffset: indexTimeOffset
33324
- }, from, duration, this._isEMSGWhitelisted, this._scaledPeriodEnd);
33411
+ }, from, duration, this._manifestBoundsCalculator, this._scaledPeriodEnd, this._isEMSGWhitelisted);
33325
33412
  }
33326
33413
  /**
33327
33414
  * Returns true if the index should be refreshed.
@@ -33353,12 +33440,19 @@ var TimelineRepresentationIndex = /*#__PURE__*/function () {
33353
33440
  * @returns {Number|null}
33354
33441
  */;
33355
33442
  _proto.getLastAvailablePosition = function getLastAvailablePosition() {
33443
+ var _a;
33356
33444
  this._refreshTimeline();
33357
33445
  if (this._index.timeline === null) {
33358
33446
  this._index.timeline = this._getTimeline();
33359
33447
  }
33360
- var lastTime = TimelineRepresentationIndex.getIndexEnd(this._index.timeline, this._scaledPeriodEnd);
33361
- 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);
33362
33456
  }
33363
33457
  /**
33364
33458
  * Returns the absolute end in seconds this RepresentationIndex can reach once
@@ -33366,11 +33460,20 @@ var TimelineRepresentationIndex = /*#__PURE__*/function () {
33366
33460
  * @returns {number|null|undefined}
33367
33461
  */;
33368
33462
  _proto.getEnd = function getEnd() {
33369
- if (!this._isDynamic || !this._isLastPeriod) {
33370
- // @see isFinished
33371
- return this.getLastAvailablePosition();
33463
+ var _a;
33464
+ if (this._isDynamic && !this._isLastPeriod) {
33465
+ return undefined;
33372
33466
  }
33373
- 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);
33374
33477
  }
33375
33478
  /**
33376
33479
  * Returns:
@@ -33384,34 +33487,56 @@ var TimelineRepresentationIndex = /*#__PURE__*/function () {
33384
33487
  * @returns {boolean|undefined}
33385
33488
  */;
33386
33489
  _proto.awaitSegmentBetween = function awaitSegmentBetween(start, end) {
33387
- var _a;
33490
+ var _a, _b;
33388
33491
  assert_assert(start <= end);
33389
- if (!this._isDynamic || !this._isLastPeriod) {
33390
- return false;
33492
+ if (!this._isDynamic) {
33493
+ return false; // No segment will be newly available in the future
33391
33494
  }
33495
+
33392
33496
  this._refreshTimeline();
33393
33497
  if (this._index.timeline === null) {
33394
33498
  this._index.timeline = this._getTimeline();
33395
33499
  }
33396
33500
  var _this$_index2 = this._index,
33397
- timeline = _this$_index2.timeline,
33398
- timescale = _this$_index2.timescale;
33501
+ timescale = _this$_index2.timescale,
33502
+ timeline = _this$_index2.timeline;
33399
33503
  var segmentTimeRounding = getSegmentTimeRoundingError(timescale);
33400
- var scaledEnd = toIndexTime(end, this._index);
33401
- if (timeline.length > 0) {
33402
- var lastTimelineElement = timeline[timeline.length - 1];
33403
- var lastSegmentEnd = getIndexSegmentEnd(lastTimelineElement, null, this._scaledPeriodEnd);
33404
- var roundedEnd = lastSegmentEnd + segmentTimeRounding;
33405
- if (roundedEnd >= Math.min(scaledEnd, (_a = this._scaledPeriodEnd) !== null && _a !== void 0 ? _a : Infinity)) {
33406
- 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
33407
33513
  }
33408
33514
  }
33409
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
33525
+ }
33526
+ }
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
+ }
33410
33533
  if (this._scaledPeriodEnd === undefined) {
33411
- 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
33412
33537
  }
33413
- var scaledStart = toIndexTime(start, this._index);
33414
- 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;
33415
33540
  }
33416
33541
  /**
33417
33542
  * Returns true if a Segment returned by this index is still considered
@@ -33429,11 +33554,9 @@ var TimelineRepresentationIndex = /*#__PURE__*/function () {
33429
33554
  if (this._index.timeline === null) {
33430
33555
  this._index.timeline = this._getTimeline();
33431
33556
  }
33432
- var _this$_index3 = this._index,
33433
- timeline = _this$_index3.timeline,
33434
- timescale = _this$_index3.timescale,
33435
- indexTimeOffset = _this$_index3.indexTimeOffset;
33436
- 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);
33437
33560
  }
33438
33561
  /**
33439
33562
  * Checks if the time given is in a discontinuity. That is:
@@ -33497,6 +33620,8 @@ var TimelineRepresentationIndex = /*#__PURE__*/function () {
33497
33620
  if (hasReplaced) {
33498
33621
  this._index.startNumber = newIndex._index.startNumber;
33499
33622
  }
33623
+ this._index.availabilityTimeOffset = newIndex._index.availabilityTimeOffset;
33624
+ this._index.availabilityTimeComplete = newIndex._index.availabilityTimeComplete;
33500
33625
  this._index.endNumber = newIndex._index.endNumber;
33501
33626
  this._isDynamic = newIndex._isDynamic;
33502
33627
  this._scaledPeriodStart = newIndex._scaledPeriodStart;
@@ -33505,32 +33630,66 @@ var TimelineRepresentationIndex = /*#__PURE__*/function () {
33505
33630
  this._isLastPeriod = newIndex._isLastPeriod;
33506
33631
  }
33507
33632
  /**
33508
- * Returns `true` if this RepresentationIndex currently contains its last
33633
+ * Returns `false` if this RepresentationIndex currently contains its last
33509
33634
  * segment.
33510
- * Returns `false` if it's still pending.
33635
+ * Returns `true` if it's still pending.
33511
33636
  * @returns {Boolean}
33512
33637
  */;
33513
- _proto.isFinished = function isFinished() {
33514
- if (!this._isDynamic || !this._isLastPeriod) {
33515
- // Either the content is not dynamic, in which case no new segment will
33516
- // be generated, either it is but this index is not linked to the current
33517
- // last Period in the MPD, in which case it is inferred that it has been
33518
- // completely generated. Note that this second condition might break very
33519
- // very rare use cases where old Periods are still being generated, yet it
33520
- // should fix more cases than it breaks.
33521
- return true;
33638
+ _proto.isStillAwaitingFutureSegments = function isStillAwaitingFutureSegments() {
33639
+ var _a;
33640
+ if (!this._isDynamic) {
33641
+ return false;
33522
33642
  }
33643
+ this._refreshTimeline();
33523
33644
  if (this._index.timeline === null) {
33524
33645
  this._index.timeline = this._getTimeline();
33525
33646
  }
33526
33647
  var timeline = this._index.timeline;
33527
- if (this._scaledPeriodEnd === undefined || timeline.length === 0) {
33528
- 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;
33529
33659
  }
33530
- var lastTimelineElement = timeline[timeline.length - 1];
33531
- var lastTime = getIndexSegmentEnd(lastTimelineElement, null, this._scaledPeriodEnd);
33532
33660
  var segmentTimeRounding = getSegmentTimeRoundingError(this._index.timescale);
33533
- 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;
33534
33693
  }
33535
33694
  /**
33536
33695
  * @returns {Boolean}
@@ -33564,7 +33723,7 @@ var TimelineRepresentationIndex = /*#__PURE__*/function () {
33564
33723
  if (!this._isDynamic) {
33565
33724
  return;
33566
33725
  }
33567
- var firstPosition = this._manifestBoundsCalculator.estimateMinimumBound();
33726
+ var firstPosition = this._manifestBoundsCalculator.getEstimatedMinimumSegmentTime();
33568
33727
  if (firstPosition == null) {
33569
33728
  return; // we don't know yet
33570
33729
  }
@@ -33576,12 +33735,6 @@ var TimelineRepresentationIndex = /*#__PURE__*/function () {
33576
33735
  } else if (this._index.endNumber !== undefined) {
33577
33736
  this._index.startNumber = nbEltsRemoved + 1;
33578
33737
  }
33579
- };
33580
- TimelineRepresentationIndex.getIndexEnd = function getIndexEnd(timeline, scaledPeriodEnd) {
33581
- if (timeline.length <= 0) {
33582
- return null;
33583
- }
33584
- return Math.min(getIndexSegmentEnd(timeline[timeline.length - 1], null, scaledPeriodEnd), scaledPeriodEnd !== null && scaledPeriodEnd !== void 0 ? scaledPeriodEnd : Infinity);
33585
33738
  }
33586
33739
  /**
33587
33740
  * Allows to generate the "timeline" for this RepresentationIndex.
@@ -33670,6 +33823,113 @@ function updateTimelineFromEndNumber(timeline, startNumber, endNumber) {
33670
33823
  }
33671
33824
  return timeline;
33672
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
+ }
33673
33933
  ;// CONCATENATED MODULE: ./src/parsers/manifest/dash/common/indexes/timeline/index.ts
33674
33934
  /**
33675
33935
  * Copyright 2015 CANAL+ Group
@@ -33899,13 +34159,22 @@ var TemplateRepresentationIndex = /*#__PURE__*/function () {
33899
34159
  var timescale = this._index.timescale;
33900
34160
  var segmentTimeRounding = getSegmentTimeRoundingError(timescale);
33901
34161
  var scaledPeriodStart = this._periodStart * timescale;
34162
+ var scaledRelativeStart = start * timescale - scaledPeriodStart;
33902
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;
33903
34173
  var relativeScaledIndexEnd = this._estimateRelativeScaledEnd();
33904
34174
  if (relativeScaledIndexEnd === undefined) {
33905
- return scaledRelativeEnd + segmentTimeRounding >= 0;
34175
+ return scaledRelativeEnd > lastSegmentEnd - segmentTimeRounding;
33906
34176
  }
33907
- var scaledRelativeStart = start * timescale - scaledPeriodStart;
33908
- return scaledRelativeStart - segmentTimeRounding < relativeScaledIndexEnd;
34177
+ return scaledRelativeEnd > lastSegmentEnd - segmentTimeRounding && scaledRelativeStart < relativeScaledIndexEnd - segmentTimeRounding;
33909
34178
  }
33910
34179
  /**
33911
34180
  * Returns true if, based on the arguments, the index should be refreshed.
@@ -33948,30 +34217,30 @@ var TemplateRepresentationIndex = /*#__PURE__*/function () {
33948
34217
  return false;
33949
34218
  }
33950
34219
  /**
33951
- * 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
33952
34221
  * generated so that we can freely go to the next period.
33953
- * 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
33954
34223
  * generated.
33955
34224
  * @returns {Boolean}
33956
34225
  */;
33957
- _proto.isFinished = function isFinished() {
34226
+ _proto.isStillAwaitingFutureSegments = function isStillAwaitingFutureSegments() {
33958
34227
  if (!this._isDynamic) {
33959
- return true;
34228
+ return false;
33960
34229
  }
33961
34230
  var scaledRelativeIndexEnd = this._estimateRelativeScaledEnd();
33962
34231
  if (scaledRelativeIndexEnd === undefined) {
33963
- return false;
34232
+ return true;
33964
34233
  }
33965
34234
  var timescale = this._index.timescale;
33966
34235
  var lastSegmentStart = this._getLastSegmentStart();
33967
34236
  // As last segment start is null if live time is before
33968
34237
  // current period, consider the index not to be finished.
33969
34238
  if (is_null_or_undefined_isNullOrUndefined(lastSegmentStart)) {
33970
- return false;
34239
+ return true;
33971
34240
  }
33972
34241
  var lastSegmentEnd = lastSegmentStart + this._index.duration;
33973
34242
  var segmentTimeRounding = getSegmentTimeRoundingError(timescale);
33974
- return lastSegmentEnd + segmentTimeRounding >= scaledRelativeIndexEnd;
34243
+ return lastSegmentEnd + segmentTimeRounding < scaledRelativeIndexEnd;
33975
34244
  }
33976
34245
  /**
33977
34246
  * @returns {Boolean}
@@ -34009,6 +34278,7 @@ var TemplateRepresentationIndex = /*#__PURE__*/function () {
34009
34278
  * @returns {number | null | undefined}
34010
34279
  */;
34011
34280
  _proto._getFirstSegmentStart = function _getFirstSegmentStart() {
34281
+ var _a;
34012
34282
  if (!this._isDynamic) {
34013
34283
  return 0; // it is the start of the Period
34014
34284
  }
@@ -34017,8 +34287,8 @@ var TemplateRepresentationIndex = /*#__PURE__*/function () {
34017
34287
  // /!\ The scaled max position augments continuously and might not
34018
34288
  // reflect exactly the real server-side value. As segments are
34019
34289
  // generated discretely.
34020
- var maximumBound = this._manifestBoundsCalculator.estimateMaximumBound();
34021
- 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) {
34022
34292
  // Maximum position is before this period.
34023
34293
  // No segment is yet available here
34024
34294
  return null;
@@ -34027,7 +34297,7 @@ var TemplateRepresentationIndex = /*#__PURE__*/function () {
34027
34297
  var _this$_index = this._index,
34028
34298
  duration = _this$_index.duration,
34029
34299
  timescale = _this$_index.timescale;
34030
- var firstPosition = this._manifestBoundsCalculator.estimateMinimumBound();
34300
+ var firstPosition = this._manifestBoundsCalculator.getEstimatedMinimumSegmentTime();
34031
34301
  if (firstPosition === undefined) {
34032
34302
  return undefined;
34033
34303
  }
@@ -34042,7 +34312,7 @@ var TemplateRepresentationIndex = /*#__PURE__*/function () {
34042
34312
  * @returns {number|null|undefined}
34043
34313
  */;
34044
34314
  _proto._getLastSegmentStart = function _getLastSegmentStart() {
34045
- var _a;
34315
+ var _a, _b;
34046
34316
  var _this$_index2 = this._index,
34047
34317
  duration = _this$_index2.duration,
34048
34318
  timescale = _this$_index2.timescale,
@@ -34050,34 +34320,34 @@ var TemplateRepresentationIndex = /*#__PURE__*/function () {
34050
34320
  _this$_index2$startNu = _this$_index2.startNumber,
34051
34321
  startNumber = _this$_index2$startNu === void 0 ? 1 : _this$_index2$startNu;
34052
34322
  if (this._isDynamic) {
34053
- var lastPos = this._manifestBoundsCalculator.estimateMaximumBound();
34054
- if (lastPos === undefined) {
34055
- return undefined;
34056
- }
34057
- 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) {
34058
34325
  var numberOfSegments = Math.ceil(this._scaledRelativePeriodEnd / duration);
34059
34326
  if (endNumber !== undefined && endNumber - startNumber + 1 < numberOfSegments) {
34060
34327
  numberOfSegments = endNumber - startNumber + 1;
34061
34328
  }
34062
34329
  return (numberOfSegments - 1) * duration;
34063
34330
  }
34331
+ var lastPosition = this._manifestBoundsCalculator.getEstimatedMaximumPosition((_a = this._availabilityTimeOffset) !== null && _a !== void 0 ? _a : 0);
34332
+ if (lastPosition === undefined) {
34333
+ return undefined;
34334
+ }
34064
34335
  // /!\ The scaled last position augments continuously and might not
34065
34336
  // reflect exactly the real server-side value. As segments are
34066
34337
  // generated discretely.
34067
- var scaledLastPosition = (lastPos - this._periodStart) * timescale;
34338
+ var scaledLastPosition = (lastPosition - this._periodStart) * timescale;
34068
34339
  // Maximum position is before this period.
34069
34340
  // No segment is yet available here
34070
34341
  if (scaledLastPosition < 0) {
34071
34342
  return null;
34072
34343
  }
34073
- var availabilityTimeOffset = (this._availabilityTimeOffset !== undefined ? this._availabilityTimeOffset : 0) * timescale;
34074
- var numberOfSegmentsAvailable = Math.floor((scaledLastPosition + availabilityTimeOffset) / duration);
34344
+ var numberOfSegmentsAvailable = Math.floor(scaledLastPosition / duration);
34075
34345
  if (endNumber !== undefined && endNumber - startNumber + 1 < numberOfSegmentsAvailable) {
34076
34346
  numberOfSegmentsAvailable = endNumber - startNumber + 1;
34077
34347
  }
34078
34348
  return numberOfSegmentsAvailable <= 0 ? null : (numberOfSegmentsAvailable - 1) * duration;
34079
34349
  } else {
34080
- var maximumTime = (_a = this._scaledRelativePeriodEnd) !== null && _a !== void 0 ? _a : 0;
34350
+ var maximumTime = (_b = this._scaledRelativePeriodEnd) !== null && _b !== void 0 ? _b : 0;
34081
34351
  var _numberOfSegments = Math.ceil(maximumTime / duration);
34082
34352
  if (endNumber !== undefined && endNumber - startNumber + 1 < _numberOfSegments) {
34083
34353
  _numberOfSegments = endNumber - startNumber + 1;
@@ -34149,7 +34419,6 @@ function parseRepresentationIndex(representation, context) {
34149
34419
  periodEnd = context.end,
34150
34420
  periodStart = context.start,
34151
34421
  receivedTime = context.receivedTime,
34152
- timeShiftBufferDepth = context.timeShiftBufferDepth,
34153
34422
  unsafelyBaseOnPreviousRepresentation = context.unsafelyBaseOnPreviousRepresentation,
34154
34423
  inbandEventStreams = context.inbandEventStreams,
34155
34424
  isLastPeriod = context.isLastPeriod;
@@ -34163,7 +34432,7 @@ function parseRepresentationIndex(representation, context) {
34163
34432
  });
34164
34433
  };
34165
34434
  var reprIndexCtxt = {
34166
- availabilityTimeComplete: true,
34435
+ availabilityTimeComplete: undefined,
34167
34436
  availabilityTimeOffset: availabilityTimeOffset,
34168
34437
  unsafelyBaseOnPreviousRepresentation: unsafelyBaseOnPreviousRepresentation,
34169
34438
  isEMSGWhitelisted: isEMSGWhitelisted,
@@ -34174,8 +34443,7 @@ function parseRepresentationIndex(representation, context) {
34174
34443
  periodStart: periodStart,
34175
34444
  receivedTime: receivedTime,
34176
34445
  representationBitrate: representation.attributes.bitrate,
34177
- representationId: representation.attributes.id,
34178
- timeShiftBufferDepth: timeShiftBufferDepth
34446
+ representationId: representation.attributes.id
34179
34447
  };
34180
34448
  var representationIndex;
34181
34449
  if (representation.children.segmentBase !== undefined) {
@@ -34191,8 +34459,9 @@ function parseRepresentationIndex(representation, context) {
34191
34459
  segmentTemplates.push(childSegmentTemplate);
34192
34460
  }
34193
34461
  var segmentTemplate = object_assign.apply(void 0, [{}].concat(segmentTemplates));
34194
- reprIndexCtxt.availabilityTimeComplete = (_a = segmentTemplate.availabilityTimeComplete) !== null && _a !== void 0 ? _a : context.availabilityTimeComplete;
34195
- 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
+ }
34196
34465
  representationIndex = timeline.isTimelineIndexArgument(segmentTemplate) ? new timeline(segmentTemplate, reprIndexCtxt) : new TemplateRepresentationIndex(segmentTemplate, reprIndexCtxt);
34197
34466
  } else {
34198
34467
  var adaptationChildren = context.adaptation.children;
@@ -34287,6 +34556,7 @@ function parse_representations_arrayLikeToArray(arr, len) { if (len == null || l
34287
34556
 
34288
34557
 
34289
34558
 
34559
+
34290
34560
  /**
34291
34561
  * Combine inband event streams from representation and
34292
34562
  * adaptation data.
@@ -34357,12 +34627,12 @@ function getHDRInformation(_ref) {
34357
34627
  * @returns {Array.<Object>}
34358
34628
  */
34359
34629
  function parseRepresentations(representationsIR, adaptation, context) {
34360
- var _a, _b, _c, _d;
34630
+ var _a, _b, _c, _d, _e;
34361
34631
  var parsedRepresentations = [];
34362
34632
  var _loop = function _loop() {
34363
34633
  var representation = _step.value;
34364
34634
  // Compute Representation ID
34365
- var representationID = representation.attributes.id != null ? representation.attributes.id : String(representation.attributes.bitrate) + (representation.attributes.height != null ? "-" + representation.attributes.height : "") + (representation.attributes.width != null ? "-" + representation.attributes.width : "") + (representation.attributes.mimeType != null ? "-" + representation.attributes.mimeType : "") + (representation.attributes.codecs != null ? "-" + representation.attributes.codecs : "");
34635
+ var representationID = representation.attributes.id !== undefined ? representation.attributes.id : String(representation.attributes.bitrate) + (representation.attributes.height !== undefined ? "-" + representation.attributes.height : "") + (representation.attributes.width !== undefined ? "-" + representation.attributes.width : "") + (representation.attributes.mimeType !== undefined ? "-" + representation.attributes.mimeType : "") + (representation.attributes.codecs !== undefined ? "-" + representation.attributes.codecs : "");
34366
34636
  // Avoid duplicate IDs
34367
34637
  while (parsedRepresentations.some(function (r) {
34368
34638
  return r.id === representationID;
@@ -34373,7 +34643,10 @@ function parseRepresentations(representationsIR, adaptation, context) {
34373
34643
  var unsafelyBaseOnPreviousRepresentation = (_b = (_a = context.unsafelyBaseOnPreviousAdaptation) === null || _a === void 0 ? void 0 : _a.getRepresentation(representationID)) !== null && _b !== void 0 ? _b : null;
34374
34644
  var inbandEventStreams = combineInbandEventStreams(representation, adaptation);
34375
34645
  var availabilityTimeComplete = (_c = representation.attributes.availabilityTimeComplete) !== null && _c !== void 0 ? _c : context.availabilityTimeComplete;
34376
- 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
+ }
34377
34650
  var reprIndexCtxt = object_assign({}, context, {
34378
34651
  availabilityTimeOffset: availabilityTimeOffset,
34379
34652
  availabilityTimeComplete: availabilityTimeComplete,
@@ -34384,7 +34657,7 @@ function parseRepresentations(representationsIR, adaptation, context) {
34384
34657
  var representationIndex = parseRepresentationIndex(representation, reprIndexCtxt);
34385
34658
  // Find bitrate
34386
34659
  var representationBitrate;
34387
- if (representation.attributes.bitrate == null) {
34660
+ if (representation.attributes.bitrate === undefined) {
34388
34661
  src_log.warn("DASH: No usable bitrate found in the Representation.");
34389
34662
  representationBitrate = 0;
34390
34663
  } else {
@@ -34419,33 +34692,42 @@ function parseRepresentations(representationsIR, adaptation, context) {
34419
34692
  }
34420
34693
  // Add optional attributes
34421
34694
  var codecs;
34422
- if (representation.attributes.codecs != null) {
34695
+ if (representation.attributes.codecs !== undefined) {
34423
34696
  codecs = representation.attributes.codecs;
34424
- } else if (adaptation.attributes.codecs != null) {
34697
+ } else if (adaptation.attributes.codecs !== undefined) {
34425
34698
  codecs = adaptation.attributes.codecs;
34426
34699
  }
34427
- if (codecs != null) {
34700
+ if (codecs !== undefined) {
34428
34701
  codecs = codecs === "mp4a.40.02" ? "mp4a.40.2" : codecs;
34429
34702
  parsedRepresentation.codecs = codecs;
34430
34703
  }
34431
- if (representation.attributes.frameRate != null) {
34704
+ var supplementalCodecs;
34705
+ if (representation.attributes.supplementalCodecs !== undefined) {
34706
+ supplementalCodecs = representation.attributes.supplementalCodecs;
34707
+ } else if (adaptation.attributes.supplementalCodecs !== undefined) {
34708
+ supplementalCodecs = adaptation.attributes.supplementalCodecs;
34709
+ }
34710
+ if (supplementalCodecs !== undefined) {
34711
+ parsedRepresentation.supplementalCodecs = convertSupplementalCodecsToRFC6381(supplementalCodecs);
34712
+ }
34713
+ if (representation.attributes.frameRate !== undefined) {
34432
34714
  parsedRepresentation.frameRate = representation.attributes.frameRate;
34433
- } else if (adaptation.attributes.frameRate != null) {
34715
+ } else if (adaptation.attributes.frameRate !== undefined) {
34434
34716
  parsedRepresentation.frameRate = adaptation.attributes.frameRate;
34435
34717
  }
34436
- if (representation.attributes.height != null) {
34718
+ if (representation.attributes.height !== undefined) {
34437
34719
  parsedRepresentation.height = representation.attributes.height;
34438
- } else if (adaptation.attributes.height != null) {
34720
+ } else if (adaptation.attributes.height !== undefined) {
34439
34721
  parsedRepresentation.height = adaptation.attributes.height;
34440
34722
  }
34441
- if (representation.attributes.mimeType != null) {
34723
+ if (representation.attributes.mimeType !== undefined) {
34442
34724
  parsedRepresentation.mimeType = representation.attributes.mimeType;
34443
- } else if (adaptation.attributes.mimeType != null) {
34725
+ } else if (adaptation.attributes.mimeType !== undefined) {
34444
34726
  parsedRepresentation.mimeType = adaptation.attributes.mimeType;
34445
34727
  }
34446
- if (representation.attributes.width != null) {
34728
+ if (representation.attributes.width !== undefined) {
34447
34729
  parsedRepresentation.width = representation.attributes.width;
34448
- } else if (adaptation.attributes.width != null) {
34730
+ } else if (adaptation.attributes.width !== undefined) {
34449
34731
  parsedRepresentation.width = adaptation.attributes.width;
34450
34732
  }
34451
34733
  var contentProtectionsIr = adaptation.children.contentProtections !== undefined ? adaptation.children.contentProtections : [];
@@ -34682,7 +34964,7 @@ function getAdaptationSetSwitchingIDs(adaptation) {
34682
34964
  * @returns {Array.<Object>}
34683
34965
  */
34684
34966
  function parseAdaptationSets(adaptationsIR, context) {
34685
- var _a, _b, _c, _d, _e, _f;
34967
+ var _a, _b, _c, _d, _e, _f, _g;
34686
34968
  var parsedAdaptations = {
34687
34969
  video: [],
34688
34970
  audio: [],
@@ -34704,14 +34986,17 @@ function parseAdaptationSets(adaptationsIR, context) {
34704
34986
  });
34705
34987
  var representationsIR = adaptation.children.representations;
34706
34988
  var availabilityTimeComplete = (_a = adaptation.attributes.availabilityTimeComplete) !== null && _a !== void 0 ? _a : context.availabilityTimeComplete;
34707
- 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
+ }
34708
34993
  var adaptationMimeType = adaptation.attributes.mimeType;
34709
34994
  var adaptationCodecs = adaptation.attributes.codecs;
34710
34995
  var type = inferAdaptationType(representationsIR, isNonEmptyString(adaptationMimeType) ? adaptationMimeType : null, isNonEmptyString(adaptationCodecs) ? adaptationCodecs : null, adaptationChildren.roles != null ? adaptationChildren.roles : null);
34711
34996
  if (type === undefined) {
34712
34997
  continue;
34713
34998
  }
34714
- 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;
34715
35000
  var originalID = adaptation.attributes.id;
34716
35001
  var adaptationSetSwitchingIDs = getAdaptationSetSwitchingIDs(adaptation);
34717
35002
  var parentSegmentTemplates = [];
@@ -34733,13 +35018,12 @@ function parseAdaptationSets(adaptationsIR, context) {
34733
35018
  parentSegmentTemplates: parentSegmentTemplates,
34734
35019
  receivedTime: context.receivedTime,
34735
35020
  start: context.start,
34736
- timeShiftBufferDepth: context.timeShiftBufferDepth,
34737
35021
  unsafelyBaseOnPreviousAdaptation: null
34738
35022
  };
34739
35023
  var trickModeProperty = Array.isArray(essentialProperties) ? arrayFind(essentialProperties, function (scheme) {
34740
35024
  return scheme.schemeIdUri === "http://dashif.org/guidelines/trickmode";
34741
35025
  }) : undefined;
34742
- 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(" ");
34743
35027
  var isTrickModeTrack = trickModeAttachedAdaptationIds !== undefined;
34744
35028
  var accessibilities = adaptationChildren.accessibilities;
34745
35029
  var isDub = void 0;
@@ -34786,7 +35070,7 @@ function parseAdaptationSets(adaptationsIR, context) {
34786
35070
  }
34787
35071
  var newID = adaptationID;
34788
35072
  parsedAdaptationsIDs.push(adaptationID);
34789
- 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;
34790
35074
  var representations = parseRepresentations(representationsIR, adaptation, reprCtxt);
34791
35075
  var parsedAdaptationSet = {
34792
35076
  id: adaptationID,
@@ -34920,8 +35204,8 @@ function parse_periods_arrayLikeToArray(arr, len) { if (len == null || len > arr
34920
35204
 
34921
35205
 
34922
35206
 
34923
- // eslint-disable-next-line max-len
34924
35207
 
35208
+ // eslint-disable-next-line max-len
34925
35209
 
34926
35210
 
34927
35211
 
@@ -34934,19 +35218,15 @@ var generatePeriodID = idGenerator();
34934
35218
  * @returns {Array.<Object>}
34935
35219
  */
34936
35220
  function parsePeriods(periodsIR, context) {
34937
- var _a, _b, _c, _d, _e, _f;
35221
+ var _a, _b, _c, _d;
34938
35222
  var parsedPeriods = [];
34939
35223
  var periodsTimeInformation = getPeriodsTimeInformation(periodsIR, context);
34940
35224
  if (periodsTimeInformation.length !== periodsIR.length) {
34941
35225
  throw new Error("MPD parsing error: the time information are incoherent.");
34942
35226
  }
34943
35227
  var isDynamic = context.isDynamic,
34944
- timeShiftBufferDepth = context.timeShiftBufferDepth;
34945
- var manifestBoundsCalculator = new ManifestBoundsCalculator({
34946
- isDynamic: isDynamic,
34947
- timeShiftBufferDepth: timeShiftBufferDepth
34948
- });
34949
- if (!isDynamic && context.duration != null) {
35228
+ manifestBoundsCalculator = context.manifestBoundsCalculator;
35229
+ if (!isDynamic && !is_null_or_undefined_isNullOrUndefined(context.duration)) {
34950
35230
  manifestBoundsCalculator.setLastPosition(context.duration);
34951
35231
  }
34952
35232
  // We parse it in reverse because we might need to deduce the buffer depth from
@@ -34961,7 +35241,7 @@ function parsePeriods(periodsIR, context) {
34961
35241
  periodDuration = _periodsTimeInformati.periodDuration,
34962
35242
  periodEnd = _periodsTimeInformati.periodEnd;
34963
35243
  var periodID;
34964
- if (periodIR.attributes.id == null) {
35244
+ if (is_null_or_undefined_isNullOrUndefined(periodIR.attributes.id)) {
34965
35245
  src_log.warn("DASH: No usable id found in the Period. Generating one.");
34966
35246
  periodID = "gen-dash-period-" + generatePeriodID();
34967
35247
  } else {
@@ -34975,8 +35255,8 @@ function parsePeriods(periodsIR, context) {
34975
35255
  }
34976
35256
  var receivedTime = xlinkInfos !== undefined ? xlinkInfos.receivedTime : context.receivedTime;
34977
35257
  var unsafelyBaseOnPreviousPeriod = (_b = (_a = context.unsafelyBaseOnPreviousManifest) === null || _a === void 0 ? void 0 : _a.getPeriod(periodID)) !== null && _b !== void 0 ? _b : null;
34978
- var availabilityTimeComplete = (_c = periodIR.attributes.availabilityTimeComplete) !== null && _c !== void 0 ? _c : true;
34979
- var availabilityTimeOffset = (_d = periodIR.attributes.availabilityTimeOffset) !== null && _d !== void 0 ? _d : 0;
35258
+ var availabilityTimeComplete = periodIR.attributes.availabilityTimeComplete;
35259
+ var availabilityTimeOffset = periodIR.attributes.availabilityTimeOffset;
34980
35260
  var manifestProfiles = context.manifestProfiles;
34981
35261
  var segmentTemplate = periodIR.children.segmentTemplate;
34982
35262
  var adapCtxt = {
@@ -34991,11 +35271,10 @@ function parsePeriods(periodsIR, context) {
34991
35271
  receivedTime: receivedTime,
34992
35272
  segmentTemplate: segmentTemplate,
34993
35273
  start: periodStart,
34994
- timeShiftBufferDepth: timeShiftBufferDepth,
34995
35274
  unsafelyBaseOnPreviousPeriod: unsafelyBaseOnPreviousPeriod
34996
35275
  };
34997
35276
  var adaptations = parseAdaptationSets(periodIR.children.adaptations, adapCtxt);
34998
- 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 : []);
34999
35278
  var streamEvents = generateStreamEvents(periodIR.children.eventStreams, periodStart, namespaces);
35000
35279
  var parsedPeriod = {
35001
35280
  id: periodID,
@@ -35070,7 +35349,7 @@ function parsePeriods(periodsIR, context) {
35070
35349
  * @returns {Array.<number|undefined>}
35071
35350
  */
35072
35351
  function guessLastPositionFromClock(context, minimumTime) {
35073
- if (context.clockOffset != null) {
35352
+ if (!is_null_or_undefined_isNullOrUndefined(context.clockOffset)) {
35074
35353
  var lastPosition = context.clockOffset / 1000 - context.availabilityStartTime;
35075
35354
  var positionTime = getMonotonicTimeStamp() / 1000;
35076
35355
  var timeInSec = positionTime + lastPosition;
@@ -35102,7 +35381,7 @@ function getMaximumLastPosition(adaptationsPerType) {
35102
35381
  var maxEncounteredPosition = null;
35103
35382
  var allIndexAreEmpty = true;
35104
35383
  var adaptationsVal = object_values(adaptationsPerType).filter(function (ada) {
35105
- return ada != null;
35384
+ return !is_null_or_undefined_isNullOrUndefined(ada);
35106
35385
  });
35107
35386
  var allAdaptations = flatMap(adaptationsVal, function (adaptationsForType) {
35108
35387
  return adaptationsForType;
@@ -35116,12 +35395,12 @@ function getMaximumLastPosition(adaptationsPerType) {
35116
35395
  if (position !== null) {
35117
35396
  allIndexAreEmpty = false;
35118
35397
  if (typeof position === "number") {
35119
- maxEncounteredPosition = maxEncounteredPosition == null ? position : Math.max(maxEncounteredPosition, position);
35398
+ maxEncounteredPosition = is_null_or_undefined_isNullOrUndefined(maxEncounteredPosition) ? position : Math.max(maxEncounteredPosition, position);
35120
35399
  }
35121
35400
  }
35122
35401
  }
35123
35402
  }
35124
- if (maxEncounteredPosition != null) {
35403
+ if (!is_null_or_undefined_isNullOrUndefined(maxEncounteredPosition)) {
35125
35404
  return maxEncounteredPosition;
35126
35405
  } else if (allIndexAreEmpty) {
35127
35406
  return null;
@@ -35219,6 +35498,7 @@ function parse_mpd_arrayLikeToArray(arr, len) { if (len == null || len > arr.len
35219
35498
 
35220
35499
 
35221
35500
 
35501
+
35222
35502
  /**
35223
35503
  * Checks if xlinks needs to be loaded before actually parsing the manifest.
35224
35504
  * @param {Object} mpdIR
@@ -35341,12 +35621,20 @@ function parseCompleteIntermediateRepresentation(mpdIR, args, warnings, xlinkInf
35341
35621
  var timeShiftBufferDepth = rootAttributes.timeShiftBufferDepth;
35342
35622
  var clockOffset = args.externalClockOffset,
35343
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
+ });
35344
35631
  var manifestInfos = {
35345
35632
  availabilityStartTime: availabilityStartTime,
35346
35633
  baseURLs: mpdBaseUrls,
35347
35634
  clockOffset: clockOffset,
35348
35635
  duration: rootAttributes.duration,
35349
35636
  isDynamic: isDynamic,
35637
+ manifestBoundsCalculator: manifestBoundsCalculator,
35350
35638
  manifestProfiles: mpdIR.attributes.profiles,
35351
35639
  receivedTime: args.manifestReceivedTime,
35352
35640
  timeShiftBufferDepth: timeShiftBufferDepth,
@@ -35388,29 +35676,32 @@ function parseCompleteIntermediateRepresentation(mpdIR, args, warnings, xlinkInf
35388
35676
  time: now
35389
35677
  };
35390
35678
  } else {
35391
- minimumTime = minimumSafePosition;
35392
- timeshiftDepth = timeShiftBufferDepth !== null && timeShiftBufferDepth !== void 0 ? timeShiftBufferDepth : null;
35679
+ // Determine the maximum seekable position
35393
35680
  var _finalMaximumSafePosition;
35394
- var livePosition;
35395
- if (maximumUnsafePosition !== undefined) {
35396
- livePosition = maximumUnsafePosition;
35397
- }
35398
35681
  if (maximumSafePosition !== undefined) {
35399
35682
  _finalMaximumSafePosition = maximumSafePosition;
35400
35683
  } else {
35401
- var ast = availabilityStartTime !== null && availabilityStartTime !== void 0 ? availabilityStartTime : 0;
35402
- var externalClockOffset = args.externalClockOffset;
35403
35684
  if (externalClockOffset === undefined) {
35404
35685
  src_log.warn("DASH Parser: use system clock to define maximum position");
35405
- _finalMaximumSafePosition = Date.now() / 1000 - ast;
35686
+ _finalMaximumSafePosition = Date.now() / 1000 - availabilityStartTime;
35406
35687
  } else {
35407
35688
  var serverTime = getMonotonicTimeStamp() + externalClockOffset;
35408
- _finalMaximumSafePosition = serverTime / 1000 - ast;
35689
+ _finalMaximumSafePosition = serverTime / 1000 - availabilityStartTime;
35409
35690
  }
35410
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();
35411
35696
  if (livePosition === undefined) {
35412
- livePosition = _finalMaximumSafePosition;
35697
+ if (maximumUnsafePosition !== undefined) {
35698
+ livePosition = maximumUnsafePosition;
35699
+ } else {
35700
+ livePosition = _finalMaximumSafePosition;
35701
+ }
35702
+ // manifestBoundsCalculator.forceLiveEdge(livePosition);
35413
35703
  }
35704
+
35414
35705
  maximumTimeData = {
35415
35706
  isLinear: true,
35416
35707
  maximumSafePosition: _finalMaximumSafePosition,
@@ -35419,8 +35710,10 @@ function parseCompleteIntermediateRepresentation(mpdIR, args, warnings, xlinkInf
35419
35710
  };
35420
35711
  // if the minimum calculated time is even below the buffer depth, perhaps we
35421
35712
  // can go even lower in terms of depth
35422
- if (timeshiftDepth !== null && minimumTime !== undefined && _finalMaximumSafePosition - minimumTime > timeshiftDepth) {
35423
- 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;
35424
35717
  }
35425
35718
  }
35426
35719
  // `isLastPeriodKnown` should be `true` in two cases for DASH contents:
@@ -36490,6 +36783,9 @@ function parseRepresentationAttributes(representationElement) {
36490
36783
  dashName: "qualityRanking"
36491
36784
  });
36492
36785
  break;
36786
+ case "scte214:supplementalCodecs":
36787
+ attributes.supplementalCodecs = attr.value;
36788
+ break;
36493
36789
  case "segmentProfiles":
36494
36790
  attributes.segmentProfiles = attr.value;
36495
36791
  break;
@@ -36816,6 +37112,9 @@ function parseAdaptationSetAttributes(root) {
36816
37112
  case "codecs":
36817
37113
  parsedAdaptation.codecs = attribute.value;
36818
37114
  break;
37115
+ case "scte214:supplementalCodecs":
37116
+ parsedAdaptation.supplementalCodecs = attribute.value;
37117
+ break;
36819
37118
  case "codingDependency":
36820
37119
  parseValue(attribute.value, {
36821
37120
  asKey: "codingDependency",
@@ -37567,15 +37866,18 @@ function generateManifestParser(options) {
37567
37866
  var externalResources = value.urls.map(function (resourceUrl) {
37568
37867
  return scheduleRequest(function () {
37569
37868
  var defaultTimeout = config.getCurrent().DEFAULT_REQUEST_TIMEOUT;
37869
+ var defaultConnectionTimeout = config.getCurrent().DEFAULT_CONNECTION_TIMEOUT;
37570
37870
  return value.format === "string" ? utils_request({
37571
37871
  url: resourceUrl,
37572
37872
  responseType: "text",
37573
37873
  timeout: defaultTimeout,
37874
+ connectionTimeout: defaultConnectionTimeout,
37574
37875
  cancelSignal: cancelSignal
37575
37876
  }) : utils_request({
37576
37877
  url: resourceUrl,
37577
37878
  responseType: "arraybuffer",
37578
37879
  timeout: defaultTimeout,
37880
+ connectionTimeout: defaultConnectionTimeout,
37579
37881
  cancelSignal: cancelSignal
37580
37882
  });
37581
37883
  }).then(function (res) {
@@ -37769,7 +38071,8 @@ function fetchRequest(options) {
37769
38071
  }
37770
38072
  src_log.debug("Fetch: Called with URL", options.url);
37771
38073
  var cancellation = null;
37772
- var timeouted = false;
38074
+ var isTimedOut = false;
38075
+ var isConnectionTimedOut = false;
37773
38076
  var sendingTime = getMonotonicTimeStamp();
37774
38077
  var abortController = !is_null_or_undefined_isNullOrUndefined(_AbortController) ? new _AbortController() : null;
37775
38078
  /**
@@ -37783,13 +38086,26 @@ function fetchRequest(options) {
37783
38086
  }
37784
38087
  abortController.abort();
37785
38088
  }
37786
- var timeout;
38089
+ var timeoutId;
37787
38090
  if (options.timeout !== undefined) {
37788
- timeout = setTimeout(function () {
37789
- timeouted = true;
38091
+ timeoutId = setTimeout(function () {
38092
+ isTimedOut = true;
38093
+ if (connectionTimeoutId !== undefined) {
38094
+ clearTimeout(connectionTimeoutId);
38095
+ }
37790
38096
  abortFetch();
37791
38097
  }, options.timeout);
37792
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
+ }
37793
38109
  var deregisterCancelLstnr = options.cancelSignal.register(function abortRequest(err) {
37794
38110
  cancellation = err;
37795
38111
  abortFetch();
@@ -37802,8 +38118,8 @@ function fetchRequest(options) {
37802
38118
  }
37803
38119
  fetchOpts.signal = !is_null_or_undefined_isNullOrUndefined(abortController) ? abortController.signal : null;
37804
38120
  return fetch(options.url, fetchOpts).then(function (response) {
37805
- if (!is_null_or_undefined_isNullOrUndefined(timeout)) {
37806
- clearTimeout(timeout);
38121
+ if (connectionTimeoutId !== undefined) {
38122
+ clearTimeout(connectionTimeoutId);
37807
38123
  }
37808
38124
  if (response.status >= 300) {
37809
38125
  src_log.warn("Fetch: Request HTTP Error", response.status, response.url);
@@ -37850,9 +38166,12 @@ function fetchRequest(options) {
37850
38166
  return _context.abrupt("return", readBufferAndSendEvents());
37851
38167
  case 11:
37852
38168
  if (!data.done) {
37853
- _context.next = 16;
38169
+ _context.next = 17;
37854
38170
  break;
37855
38171
  }
38172
+ if (timeoutId !== undefined) {
38173
+ clearTimeout(timeoutId);
38174
+ }
37856
38175
  deregisterCancelLstnr();
37857
38176
  receivedTime = getMonotonicTimeStamp();
37858
38177
  requestDuration = receivedTime - sendingTime;
@@ -37864,9 +38183,9 @@ function fetchRequest(options) {
37864
38183
  status: response.status,
37865
38184
  url: response.url
37866
38185
  });
37867
- case 16:
37868
- return _context.abrupt("return", readBufferAndSendEvents());
37869
38186
  case 17:
38187
+ return _context.abrupt("return", readBufferAndSendEvents());
38188
+ case 18:
37870
38189
  case "end":
37871
38190
  return _context.stop();
37872
38191
  }
@@ -37879,8 +38198,11 @@ function fetchRequest(options) {
37879
38198
  throw cancellation;
37880
38199
  }
37881
38200
  deregisterCancelLstnr();
37882
- if (timeouted) {
37883
- 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.");
37884
38206
  throw new RequestError(options.url, 0, NetworkErrorTypes.TIMEOUT);
37885
38207
  } else if (err instanceof RequestError) {
37886
38208
  throw err;
@@ -38073,6 +38395,7 @@ function initSegmentLoader(url, segment, options, cancelSignal, callbacks) {
38073
38395
  url: url,
38074
38396
  responseType: "arraybuffer",
38075
38397
  timeout: options.timeout,
38398
+ connectionTimeout: options.connectionTimeout,
38076
38399
  cancelSignal: cancelSignal,
38077
38400
  onProgress: callbacks.onProgress
38078
38401
  }).then(function (data) {
@@ -38090,6 +38413,7 @@ function initSegmentLoader(url, segment, options, cancelSignal, callbacks) {
38090
38413
  },
38091
38414
  responseType: "arraybuffer",
38092
38415
  timeout: options.timeout,
38416
+ connectionTimeout: options.connectionTimeout,
38093
38417
  cancelSignal: cancelSignal,
38094
38418
  onProgress: callbacks.onProgress
38095
38419
  }).then(function (data) {
@@ -38108,6 +38432,7 @@ function initSegmentLoader(url, segment, options, cancelSignal, callbacks) {
38108
38432
  },
38109
38433
  responseType: "arraybuffer",
38110
38434
  timeout: options.timeout,
38435
+ connectionTimeout: options.connectionTimeout,
38111
38436
  cancelSignal: cancelSignal,
38112
38437
  onProgress: callbacks.onProgress
38113
38438
  }).then(function (data) {
@@ -38124,6 +38449,7 @@ function initSegmentLoader(url, segment, options, cancelSignal, callbacks) {
38124
38449
  },
38125
38450
  responseType: "arraybuffer",
38126
38451
  timeout: options.timeout,
38452
+ connectionTimeout: options.connectionTimeout,
38127
38453
  cancelSignal: cancelSignal,
38128
38454
  onProgress: callbacks.onProgress
38129
38455
  });
@@ -38134,6 +38460,7 @@ function initSegmentLoader(url, segment, options, cancelSignal, callbacks) {
38134
38460
  },
38135
38461
  responseType: "arraybuffer",
38136
38462
  timeout: options.timeout,
38463
+ connectionTimeout: options.connectionTimeout,
38137
38464
  cancelSignal: cancelSignal,
38138
38465
  onProgress: callbacks.onProgress
38139
38466
  });
@@ -38347,6 +38674,7 @@ function segment_loader_regularSegmentLoader(url, context, lowLatencyMode, optio
38347
38674
  Range: byteRange(segment.range)
38348
38675
  } : undefined,
38349
38676
  timeout: options.timeout,
38677
+ connectionTimeout: options.connectionTimeout,
38350
38678
  cancelSignal: cancelSignal,
38351
38679
  onProgress: callbacks.onProgress
38352
38680
  }).then(function (data) {
@@ -39237,6 +39565,7 @@ function generateTextTrackLoader(_ref) {
39237
39565
  Range: byteRange(range)
39238
39566
  } : null,
39239
39567
  timeout: options.timeout,
39568
+ connectionTimeout: options.connectionTimeout,
39240
39569
  onProgress: callbacks.onProgress,
39241
39570
  cancelSignal: cancelSignal
39242
39571
  }).then(function (data) {
@@ -39253,6 +39582,7 @@ function generateTextTrackLoader(_ref) {
39253
39582
  Range: byteRange(range)
39254
39583
  } : null,
39255
39584
  timeout: options.timeout,
39585
+ connectionTimeout: options.connectionTimeout,
39256
39586
  onProgress: callbacks.onProgress,
39257
39587
  cancelSignal: cancelSignal
39258
39588
  }).then(function (data) {
@@ -40450,6 +40780,7 @@ function disableVideoTracks(videoTracks) {
40450
40780
 
40451
40781
 
40452
40782
 
40783
+
40453
40784
  /**
40454
40785
  * `ContentIntializer` which will load contents by putting their URL in the
40455
40786
  * `src` attribute of the given HTMLMediaElement.
@@ -40635,10 +40966,10 @@ var DirectFileContentInitializer = /*#__PURE__*/function (_ContentInitializer) {
40635
40966
  */
40636
40967
 
40637
40968
  function getDirectFileInitialTime(mediaElement, startAt) {
40638
- if (startAt == null) {
40969
+ if (is_null_or_undefined_isNullOrUndefined(startAt)) {
40639
40970
  return 0;
40640
40971
  }
40641
- if (startAt.position != null) {
40972
+ if (!is_null_or_undefined_isNullOrUndefined(startAt.position)) {
40642
40973
  return startAt.position;
40643
40974
  } else if (startAt.wallClockTime != null) {
40644
40975
  return startAt.wallClockTime;
@@ -40646,13 +40977,24 @@ function getDirectFileInitialTime(mediaElement, startAt) {
40646
40977
  return startAt.fromFirstPosition;
40647
40978
  }
40648
40979
  var duration = mediaElement.duration;
40649
- if (duration == null || !isFinite(duration)) {
40650
- src_log.warn("startAt.fromLastPosition set but no known duration, " + "beginning at 0.");
40651
- return 0;
40652
- }
40653
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
+ }
40654
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);
40655
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
+ }
40656
40998
  var percentage = startAt.percentage;
40657
40999
  if (percentage >= 100) {
40658
41000
  return duration;
@@ -49548,6 +49890,21 @@ function parseTextTrackToElements(type, data, timestampOffset, language) {
49548
49890
  * Setting a value too high might lead to two segments targeting different times
49549
49891
  * to be wrongly believed to target the same time. In worst case scenarios, this
49550
49892
  * could lead to wanted text tracks being removed.
49893
+ *
49894
+ * When comparing 2 segments s1 and s2, you may want to take into account the duration
49895
+ * of the segments:
49896
+ * - if s1 is [0, 2] and s2 is [0, 2.1] s1 and s2 can be considered as nearly equal as
49897
+ * there is a relative difference of: (2.1-2) / 2 = 5%;
49898
+ * Formula: (end_s1 - end_s2) / duration_s2 = relative_difference
49899
+ * - if s1 is [0, 0.04] and s2 is [0.04, 0.08] s1 and s2 may not considered as nearly
49900
+ * equal as there is a relative difference of: (0.04-0.08) / 0.04 = 100%
49901
+ *
49902
+ * To compare relatively to the duration of a segment you can provide and additional
49903
+ * parameter "delta" that remplace MAX_DELTA_BUFFER_TIME.
49904
+ * If parameter "delta" is higher than MAX_DELTA_BUFFER_TIME, MAX_DELTA_BUFFER_TIME
49905
+ * is used instead of delta. This ensure that segments are nearly equal when comparing
49906
+ * relatively AND absolutely.
49907
+ *
49551
49908
  * @type Number
49552
49909
  */
49553
49910
  var MAX_DELTA_BUFFER_TIME = 0.2;
@@ -49555,10 +49912,14 @@ var MAX_DELTA_BUFFER_TIME = 0.2;
49555
49912
  * @see MAX_DELTA_BUFFER_TIME
49556
49913
  * @param {Number} a
49557
49914
  * @param {Number} b
49915
+ * @param {Number} delta
49558
49916
  * @returns {Boolean}
49559
49917
  */
49560
- function areNearlyEqual(a, b) {
49561
- return Math.abs(a - b) <= MAX_DELTA_BUFFER_TIME;
49918
+ function areNearlyEqual(a, b, delta) {
49919
+ if (delta === void 0) {
49920
+ delta = MAX_DELTA_BUFFER_TIME;
49921
+ }
49922
+ return Math.abs(a - b) <= Math.min(delta, MAX_DELTA_BUFFER_TIME);
49562
49923
  }
49563
49924
  /**
49564
49925
  * Get all cues which have data before the given time.
@@ -49631,6 +49992,22 @@ function removeCuesInfosBetween(cuesInfos, start, end) {
49631
49992
  */
49632
49993
 
49633
49994
 
49995
+ /**
49996
+ * first or last IHTMLCue in a group can have a slighlty different start
49997
+ * or end time than the start or end time of the ICuesGroup due to parsing
49998
+ * approximation.
49999
+ * DELTA_CUES_GROUP defines the tolerance level when comparing the start/end
50000
+ * of a IHTMLCue to the start/end of a ICuesGroup.
50001
+ * Having this value too high may lead to have unwanted subtitle displayed
50002
+ * Having this value too low may lead to have subtitles not displayed
50003
+ */
50004
+ var DELTA_CUES_GROUP = 1e-3;
50005
+ /**
50006
+ * segment_duration / RELATIVE_DELTA_RATIO = relative_delta
50007
+ *
50008
+ * relative_delta is the tolerance to determine if two segements are the same
50009
+ */
50010
+ var RELATIVE_DELTA_RATIO = 5;
49634
50011
  /**
49635
50012
  * Manage the buffer of the HTMLTextSegmentBuffer.
49636
50013
  * Allows to add, remove and recuperate cues at given times.
@@ -49674,6 +50051,17 @@ var TextTrackCuesStore = /*#__PURE__*/function () {
49674
50051
  ret.push(cues[j].element);
49675
50052
  }
49676
50053
  }
50054
+ // first or last IHTMLCue in a group can have a slighlty different start
50055
+ // or end time than the start or end time of the ICuesGroup due to parsing
50056
+ // approximation.
50057
+ // Add a tolerance of 1ms to fix this issue
50058
+ if (ret.length === 0 && cues.length > 0) {
50059
+ for (var _j = 0; _j < cues.length; _j++) {
50060
+ if (areNearlyEqual(time, cues[_j].start, DELTA_CUES_GROUP) || areNearlyEqual(time, cues[_j].end, DELTA_CUES_GROUP)) {
50061
+ ret.push(cues[_j].element);
50062
+ }
50063
+ }
50064
+ }
49677
50065
  return ret;
49678
50066
  }
49679
50067
  }
@@ -49760,6 +50148,11 @@ var TextTrackCuesStore = /*#__PURE__*/function () {
49760
50148
  end: end,
49761
50149
  cues: cues
49762
50150
  };
50151
+ // it's preferable to have a delta depending on the duration of the segment
50152
+ // if the delta is one fifth of the length of the segment:
50153
+ // a segment of [0, 2] is the "same" segment as [0, 2.1]
50154
+ // but [0, 0.04] is not the "same" segement as [0,04, 0.08]
50155
+ var relativeDelta = Math.abs(start - end) / RELATIVE_DELTA_RATIO;
49763
50156
  /**
49764
50157
  * Called when we found the index of the next cue relative to the cue we
49765
50158
  * want to insert (that is a cue starting after its start or at the same
@@ -49772,7 +50165,7 @@ var TextTrackCuesStore = /*#__PURE__*/function () {
49772
50165
  var nextCue = cuesBuffer[indexOfNextCue];
49773
50166
  if (nextCue === undefined ||
49774
50167
  // no cue
49775
- areNearlyEqual(cuesInfosToInsert.end, nextCue.end))
50168
+ areNearlyEqual(cuesInfosToInsert.end, nextCue.end, relativeDelta))
49776
50169
  // samey end
49777
50170
  {
49778
50171
  // ours: |AAAAA|
@@ -49807,8 +50200,8 @@ var TextTrackCuesStore = /*#__PURE__*/function () {
49807
50200
  for (var cueIdx = 0; cueIdx < cuesBuffer.length; cueIdx++) {
49808
50201
  var cuesInfos = cuesBuffer[cueIdx];
49809
50202
  if (start < cuesInfos.end) {
49810
- if (areNearlyEqual(start, cuesInfos.start)) {
49811
- if (areNearlyEqual(end, cuesInfos.end)) {
50203
+ if (areNearlyEqual(start, cuesInfos.start, relativeDelta)) {
50204
+ if (areNearlyEqual(end, cuesInfos.end, relativeDelta)) {
49812
50205
  // exact same segment
49813
50206
  // ours: |AAAAA|
49814
50207
  // the current one: |BBBBB|
@@ -49853,7 +50246,7 @@ var TextTrackCuesStore = /*#__PURE__*/function () {
49853
50246
  // - add ours before the current one
49854
50247
  cuesBuffer.splice(cueIdx, 0, cuesInfosToInsert);
49855
50248
  return;
49856
- } else if (areNearlyEqual(end, cuesInfos.start)) {
50249
+ } else if (areNearlyEqual(end, cuesInfos.start, relativeDelta)) {
49857
50250
  // our cue goes just before the current one:
49858
50251
  // ours: |AAAAAAA|
49859
50252
  // the current one: |BBBB|
@@ -49864,7 +50257,7 @@ var TextTrackCuesStore = /*#__PURE__*/function () {
49864
50257
  cuesInfos.start = end;
49865
50258
  cuesBuffer.splice(cueIdx, 0, cuesInfosToInsert);
49866
50259
  return;
49867
- } else if (areNearlyEqual(end, cuesInfos.end)) {
50260
+ } else if (areNearlyEqual(end, cuesInfos.end, relativeDelta)) {
49868
50261
  // ours: |AAAAAAA|
49869
50262
  // the current one: |BBBB|
49870
50263
  // Result: |AAAAAAA|
@@ -49891,7 +50284,7 @@ var TextTrackCuesStore = /*#__PURE__*/function () {
49891
50284
  return;
49892
50285
  }
49893
50286
  // else -> start > cuesInfos.start
49894
- if (areNearlyEqual(cuesInfos.end, end)) {
50287
+ if (areNearlyEqual(cuesInfos.end, end, relativeDelta)) {
49895
50288
  // ours: |AAAAAA|
49896
50289
  // the current one: |BBBBBBBB|
49897
50290
  // Result: |BBAAAAAA|
@@ -49927,6 +50320,21 @@ var TextTrackCuesStore = /*#__PURE__*/function () {
49927
50320
  }
49928
50321
  }
49929
50322
  }
50323
+ if (cuesBuffer.length) {
50324
+ var lastCue = cuesBuffer[cuesBuffer.length - 1];
50325
+ if (areNearlyEqual(lastCue.end, start, relativeDelta)) {
50326
+ // Match the end of the previous cue to the start of the following one
50327
+ // if they are close enough. If there is a small gap between two segments
50328
+ // it can lead to having no subtitles for a short time, this is noticeable when
50329
+ // two successive segments displays the same text, making it diseappear
50330
+ // and reappear quickly, which gives the impression of blinking
50331
+ //
50332
+ // ours: |AAAAA|
50333
+ // the current one: |BBBBB|...
50334
+ // Result: |BBBBBBBAAAAA|
50335
+ lastCue.end = start;
50336
+ }
50337
+ }
49930
50338
  // no cues group has the end after our current start.
49931
50339
  // These cues should be the last one
49932
50340
  cuesBuffer.push(cuesInfosToInsert);