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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (407) hide show
  1. package/CHANGELOG.md +11 -227
  2. package/FILES.md +1 -1
  3. package/VERSION +1 -1
  4. package/dist/_esm5.processed/compat/add_text_track.d.ts +1 -3
  5. package/dist/_esm5.processed/compat/add_text_track.js +4 -7
  6. package/dist/_esm5.processed/compat/browser_compatibility_types.d.ts +0 -7
  7. package/dist/_esm5.processed/compat/event_listeners.d.ts +2 -15
  8. package/dist/_esm5.processed/compat/event_listeners.js +2 -37
  9. package/dist/_esm5.processed/compat/index.d.ts +1 -3
  10. package/dist/_esm5.processed/compat/index.js +1 -3
  11. package/dist/_esm5.processed/config.d.ts +9 -21
  12. package/dist/_esm5.processed/core/adaptive/adaptive_representation_selector.d.ts +0 -58
  13. package/dist/_esm5.processed/core/adaptive/adaptive_representation_selector.js +14 -54
  14. package/dist/_esm5.processed/core/adaptive/utils/select_optimal_representation.d.ts +2 -8
  15. package/dist/_esm5.processed/core/adaptive/utils/select_optimal_representation.js +2 -11
  16. package/dist/_esm5.processed/core/api/debug/buffer_graph.js +2 -6
  17. package/dist/_esm5.processed/core/api/debug/modules/general_info.js +13 -32
  18. package/dist/_esm5.processed/core/api/debug/modules/segment_buffer_content.js +3 -3
  19. package/dist/_esm5.processed/core/api/debug/modules/segment_buffer_size.js +1 -1
  20. package/dist/_esm5.processed/core/api/option_utils.d.ts +12 -35
  21. package/dist/_esm5.processed/core/api/option_utils.js +41 -230
  22. package/dist/_esm5.processed/core/api/public_api.d.ts +91 -266
  23. package/dist/_esm5.processed/core/api/public_api.js +439 -805
  24. package/dist/_esm5.processed/core/{segment_buffers/implementations/image → api/track_management}/index.d.ts +3 -2
  25. package/dist/_esm5.processed/core/{segment_buffers/implementations/image → api/track_management}/index.js +3 -2
  26. package/dist/_esm5.processed/core/api/{tracks_management/media_element_track_choice_manager.d.ts → track_management/media_element_tracks_store.d.ts} +15 -75
  27. package/dist/_esm5.processed/core/api/{tracks_management/media_element_track_choice_manager.js → track_management/media_element_tracks_store.js} +74 -193
  28. package/dist/_esm5.processed/core/api/track_management/track_dispatcher.d.ts +84 -0
  29. package/dist/_esm5.processed/core/api/track_management/track_dispatcher.js +158 -0
  30. package/dist/_esm5.processed/core/api/track_management/tracks_store.d.ts +406 -0
  31. package/dist/_esm5.processed/core/api/track_management/tracks_store.js +932 -0
  32. package/dist/_esm5.processed/core/api/utils.d.ts +1 -0
  33. package/dist/_esm5.processed/core/api/utils.js +28 -11
  34. package/dist/_esm5.processed/core/decrypt/content_decryptor.js +3 -3
  35. package/dist/_esm5.processed/core/decrypt/find_key_system.js +83 -71
  36. package/dist/_esm5.processed/core/decrypt/get_media_keys.js +6 -5
  37. package/dist/_esm5.processed/core/decrypt/session_events_listener.js +10 -72
  38. package/dist/_esm5.processed/core/decrypt/utils/persistent_sessions_store.d.ts +4 -4
  39. package/dist/_esm5.processed/core/decrypt/utils/persistent_sessions_store.js +6 -4
  40. package/dist/_esm5.processed/core/fetchers/manifest/manifest_fetcher.d.ts +1 -3
  41. package/dist/_esm5.processed/core/fetchers/manifest/manifest_fetcher.js +7 -26
  42. package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher.d.ts +3 -9
  43. package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher.js +16 -9
  44. package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher_creator.d.ts +1 -3
  45. package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher_creator.js +1 -1
  46. package/dist/_esm5.processed/core/fetchers/utils/schedule_request.d.ts +1 -6
  47. package/dist/_esm5.processed/core/fetchers/utils/schedule_request.js +4 -41
  48. package/dist/_esm5.processed/core/init/directfile_content_initializer.js +1 -1
  49. package/dist/_esm5.processed/core/init/media_source_content_initializer.d.ts +1 -8
  50. package/dist/_esm5.processed/core/init/media_source_content_initializer.js +5 -19
  51. package/dist/_esm5.processed/core/init/types.d.ts +5 -15
  52. package/dist/_esm5.processed/core/init/utils/rebuffering_controller.d.ts +2 -36
  53. package/dist/_esm5.processed/core/init/utils/rebuffering_controller.js +2 -82
  54. package/dist/_esm5.processed/core/segment_buffers/implementations/text/native/native_text_segment_buffer.d.ts +1 -2
  55. package/dist/_esm5.processed/core/segment_buffers/implementations/text/native/native_text_segment_buffer.js +2 -3
  56. package/dist/_esm5.processed/core/segment_buffers/implementations/types.d.ts +2 -2
  57. package/dist/_esm5.processed/core/segment_buffers/index.d.ts +2 -2
  58. package/dist/_esm5.processed/core/segment_buffers/index.js +2 -1
  59. package/dist/_esm5.processed/core/segment_buffers/inventory/index.d.ts +1 -0
  60. package/dist/_esm5.processed/core/segment_buffers/inventory/index.js +1 -0
  61. package/dist/_esm5.processed/core/segment_buffers/inventory/utils.d.ts +33 -0
  62. package/dist/_esm5.processed/core/segment_buffers/inventory/utils.js +49 -0
  63. package/dist/_esm5.processed/core/segment_buffers/segment_buffers_store.d.ts +0 -1
  64. package/dist/_esm5.processed/core/segment_buffers/segment_buffers_store.js +2 -16
  65. package/dist/_esm5.processed/core/stream/adaptation/adaptation_stream.d.ts +0 -15
  66. package/dist/_esm5.processed/core/stream/adaptation/adaptation_stream.js +183 -93
  67. package/dist/_esm5.processed/core/stream/adaptation/get_representations_switch_strategy.d.ts +39 -0
  68. package/dist/_esm5.processed/core/stream/adaptation/get_representations_switch_strategy.js +133 -0
  69. package/dist/_esm5.processed/core/stream/adaptation/types.d.ts +27 -13
  70. package/dist/_esm5.processed/core/stream/index.d.ts +2 -3
  71. package/dist/_esm5.processed/core/stream/orchestrator/stream_orchestrator.d.ts +2 -0
  72. package/dist/_esm5.processed/core/stream/orchestrator/stream_orchestrator.js +5 -7
  73. package/dist/_esm5.processed/core/stream/period/period_stream.js +13 -12
  74. package/dist/_esm5.processed/core/stream/period/types.d.ts +5 -14
  75. package/dist/_esm5.processed/core/stream/period/utils/get_adaptation_switch_strategy.d.ts +2 -4
  76. package/dist/_esm5.processed/core/stream/period/utils/get_adaptation_switch_strategy.js +10 -46
  77. package/dist/_esm5.processed/core/stream/representation/representation_stream.js +29 -23
  78. package/dist/_esm5.processed/core/stream/representation/types.d.ts +11 -1
  79. package/dist/_esm5.processed/default_config.d.ts +35 -98
  80. package/dist/_esm5.processed/default_config.js +36 -113
  81. package/dist/_esm5.processed/errors/custom_loader_error.d.ts +1 -3
  82. package/dist/_esm5.processed/errors/custom_loader_error.js +1 -3
  83. package/dist/_esm5.processed/errors/media_error.js +2 -2
  84. package/dist/_esm5.processed/errors/network_error.d.ts +0 -1
  85. package/dist/_esm5.processed/errors/network_error.js +0 -1
  86. package/dist/_esm5.processed/errors/request_error.d.ts +2 -3
  87. package/dist/_esm5.processed/errors/request_error.js +2 -5
  88. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +3 -3
  89. package/dist/_esm5.processed/features/features_object.js +0 -2
  90. package/dist/_esm5.processed/features/list/directfile.js +2 -5
  91. package/dist/_esm5.processed/features/list/index.d.ts +0 -2
  92. package/dist/_esm5.processed/features/list/index.js +0 -2
  93. package/dist/_esm5.processed/features/types.d.ts +3 -27
  94. package/dist/_esm5.processed/manifest/adaptation.d.ts +9 -11
  95. package/dist/_esm5.processed/manifest/adaptation.js +41 -30
  96. package/dist/_esm5.processed/manifest/index.d.ts +3 -4
  97. package/dist/_esm5.processed/manifest/manifest.d.ts +5 -54
  98. package/dist/_esm5.processed/manifest/manifest.js +5 -110
  99. package/dist/_esm5.processed/manifest/period.d.ts +4 -5
  100. package/dist/_esm5.processed/manifest/representation.d.ts +10 -5
  101. package/dist/_esm5.processed/manifest/representation.js +15 -5
  102. package/dist/_esm5.processed/manifest/representation_index/index.d.ts +2 -2
  103. package/dist/_esm5.processed/manifest/representation_index/static.d.ts +2 -0
  104. package/dist/_esm5.processed/manifest/representation_index/static.js +6 -0
  105. package/dist/_esm5.processed/manifest/representation_index/types.d.ts +42 -21
  106. package/dist/_esm5.processed/manifest/types.d.ts +0 -2
  107. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/base.d.ts +17 -31
  108. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/base.js +26 -19
  109. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/list.d.ts +2 -0
  110. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/list.js +7 -1
  111. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/template.d.ts +2 -6
  112. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/template.js +11 -8
  113. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts +2 -0
  114. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +6 -0
  115. package/dist/_esm5.processed/parsers/manifest/dash/common/infer_adaptation_type.d.ts +2 -2
  116. package/dist/_esm5.processed/parsers/manifest/dash/common/infer_adaptation_type.js +1 -6
  117. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_adaptation_sets.js +3 -5
  118. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_mpd.d.ts +0 -2
  119. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_mpd.js +1 -1
  120. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_periods.js +2 -2
  121. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representation_index.d.ts +0 -2
  122. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representation_index.js +2 -2
  123. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/AdaptationSet.js +10 -6
  124. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/Representation.js +4 -2
  125. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/utils.d.ts +10 -1
  126. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/utils.js +18 -2
  127. package/dist/_esm5.processed/parsers/manifest/dash/node_parser_types.d.ts +4 -4
  128. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/AdaptationSet.js +3 -6
  129. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/Representation.js +1 -2
  130. package/dist/_esm5.processed/parsers/manifest/local/representation_index.d.ts +2 -0
  131. package/dist/_esm5.processed/parsers/manifest/local/representation_index.js +6 -0
  132. package/dist/_esm5.processed/parsers/manifest/metaplaylist/metaplaylist_parser.js +6 -6
  133. package/dist/_esm5.processed/parsers/manifest/metaplaylist/representation_index.d.ts +12 -3
  134. package/dist/_esm5.processed/parsers/manifest/metaplaylist/representation_index.js +11 -2
  135. package/dist/_esm5.processed/parsers/manifest/smooth/create_parser.d.ts +0 -1
  136. package/dist/_esm5.processed/parsers/manifest/smooth/create_parser.js +11 -17
  137. package/dist/_esm5.processed/parsers/manifest/smooth/representation_index.d.ts +21 -83
  138. package/dist/_esm5.processed/parsers/manifest/smooth/representation_index.js +53 -125
  139. package/dist/_esm5.processed/parsers/manifest/smooth/shared_smooth_segment_timeline.d.ts +119 -0
  140. package/dist/_esm5.processed/parsers/manifest/smooth/shared_smooth_segment_timeline.js +159 -0
  141. package/dist/_esm5.processed/parsers/manifest/smooth/utils/add_segment_infos.d.ts +3 -6
  142. package/dist/_esm5.processed/parsers/manifest/smooth/utils/add_segment_infos.js +4 -4
  143. package/dist/_esm5.processed/parsers/manifest/types.d.ts +3 -3
  144. package/dist/_esm5.processed/parsers/texttracks/ttml/html/apply_extent.js +1 -8
  145. package/dist/_esm5.processed/parsers/texttracks/ttml/html/apply_origin.js +1 -9
  146. package/dist/_esm5.processed/public_types.d.ts +396 -308
  147. package/dist/_esm5.processed/tools/TextTrackRenderer/text_track_renderer.d.ts +5 -4
  148. package/dist/_esm5.processed/tools/TextTrackRenderer/text_track_renderer.js +5 -4
  149. package/dist/_esm5.processed/transports/dash/add_segment_integrity_checks_to_loader.js +4 -4
  150. package/dist/_esm5.processed/transports/dash/manifest_parser.js +2 -3
  151. package/dist/_esm5.processed/transports/dash/pipelines.js +1 -4
  152. package/dist/_esm5.processed/transports/dash/segment_loader.d.ts +2 -2
  153. package/dist/_esm5.processed/transports/dash/segment_loader.js +26 -20
  154. package/dist/_esm5.processed/transports/dash/segment_parser.js +19 -24
  155. package/dist/_esm5.processed/transports/dash/text_loader.js +5 -5
  156. package/dist/_esm5.processed/transports/dash/text_parser.js +28 -33
  157. package/dist/_esm5.processed/transports/local/pipelines.js +1 -10
  158. package/dist/_esm5.processed/transports/local/segment_loader.js +2 -2
  159. package/dist/_esm5.processed/transports/local/segment_parser.d.ts +1 -1
  160. package/dist/_esm5.processed/transports/local/segment_parser.js +10 -10
  161. package/dist/_esm5.processed/transports/local/text_parser.d.ts +2 -2
  162. package/dist/_esm5.processed/transports/local/text_parser.js +23 -23
  163. package/dist/_esm5.processed/transports/metaplaylist/pipelines.js +34 -52
  164. package/dist/_esm5.processed/{utils/list_to_map.d.ts → transports/smooth/is_mp4_embedded_track.d.ts} +5 -5
  165. package/dist/_esm5.processed/{features/list/image_buffer.d.ts → transports/smooth/is_mp4_embedded_track.js} +7 -6
  166. package/dist/_esm5.processed/transports/smooth/pipelines.js +33 -190
  167. package/dist/_esm5.processed/transports/smooth/segment_loader.d.ts +1 -1
  168. package/dist/_esm5.processed/transports/smooth/segment_loader.js +28 -22
  169. package/dist/_esm5.processed/transports/smooth/utils.d.ts +1 -26
  170. package/dist/_esm5.processed/transports/smooth/utils.js +1 -55
  171. package/dist/_esm5.processed/transports/types.d.ts +94 -89
  172. package/dist/_esm5.processed/transports/utils/call_custom_manifest_loader.js +3 -3
  173. package/dist/_esm5.processed/transports/utils/infer_segment_container.d.ts +3 -3
  174. package/dist/_esm5.processed/transports/utils/infer_segment_container.js +5 -7
  175. package/dist/_esm5.processed/transports/utils/parse_text_track.d.ts +8 -12
  176. package/dist/_esm5.processed/transports/utils/parse_text_track.js +19 -21
  177. package/dist/_esm5.processed/utils/array_includes.d.ts +2 -1
  178. package/dist/_esm5.processed/utils/array_includes.js +30 -28
  179. package/dist/_esm5.processed/utils/request/xhr.js +5 -5
  180. package/dist/commonjs/compat/is_codec_supported.js +22 -1
  181. package/dist/commonjs/config.d.ts +1 -0
  182. package/dist/commonjs/core/api/debug/buffer_graph.js +2 -6
  183. package/dist/commonjs/core/api/debug/modules/general_info.js +17 -10
  184. package/dist/commonjs/core/api/option_utils.d.ts +2 -0
  185. package/dist/commonjs/core/api/option_utils.js +2 -3
  186. package/dist/commonjs/core/api/public_api.d.ts +9 -0
  187. package/dist/commonjs/core/api/public_api.js +34 -9
  188. package/dist/commonjs/core/fetchers/manifest/manifest_fetcher.d.ts +6 -0
  189. package/dist/commonjs/core/fetchers/manifest/manifest_fetcher.js +11 -3
  190. package/dist/commonjs/core/fetchers/segment/segment_fetcher.d.ts +8 -1
  191. package/dist/commonjs/core/fetchers/segment/segment_fetcher.js +8 -4
  192. package/dist/commonjs/core/fetchers/segment/segment_fetcher_creator.d.ts +1 -0
  193. package/dist/commonjs/core/fetchers/utils/schedule_request.js +1 -1
  194. package/dist/commonjs/core/init/directfile_content_initializer.js +24 -7
  195. package/dist/commonjs/core/init/media_source_content_initializer.d.ts +6 -0
  196. package/dist/commonjs/core/init/media_source_content_initializer.js +4 -6
  197. package/dist/commonjs/core/init/utils/content_time_boundaries_observer.d.ts +13 -12
  198. package/dist/commonjs/core/init/utils/content_time_boundaries_observer.js +16 -17
  199. package/dist/commonjs/core/init/utils/get_initial_time.d.ts +17 -3
  200. package/dist/commonjs/core/init/utils/get_initial_time.js +9 -7
  201. package/dist/commonjs/core/stream/representation/utils/get_buffer_status.js +3 -3
  202. package/dist/commonjs/core/stream/representation/utils/get_needed_segments.js +1 -1
  203. package/dist/commonjs/default_config.d.ts +5 -0
  204. package/dist/commonjs/default_config.js +5 -0
  205. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +3 -1
  206. package/dist/commonjs/experimental/tools/createMetaplaylist/get_duration_from_manifest.js +2 -0
  207. package/dist/commonjs/manifest/representation_index/static.d.ts +1 -1
  208. package/dist/commonjs/manifest/representation_index/static.js +2 -2
  209. package/dist/commonjs/manifest/representation_index/types.d.ts +4 -4
  210. package/dist/commonjs/parsers/manifest/dash/common/indexes/base.d.ts +6 -1
  211. package/dist/commonjs/parsers/manifest/dash/common/indexes/base.js +4 -3
  212. package/dist/commonjs/parsers/manifest/dash/common/indexes/get_segments_from_timeline.d.ts +5 -2
  213. package/dist/commonjs/parsers/manifest/dash/common/indexes/get_segments_from_timeline.js +15 -4
  214. package/dist/commonjs/parsers/manifest/dash/common/indexes/index.d.ts +5 -5
  215. package/dist/commonjs/parsers/manifest/dash/common/indexes/list.d.ts +1 -1
  216. package/dist/commonjs/parsers/manifest/dash/common/indexes/list.js +2 -2
  217. package/dist/commonjs/parsers/manifest/dash/common/indexes/template.d.ts +12 -5
  218. package/dist/commonjs/parsers/manifest/dash/common/indexes/template.js +42 -29
  219. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/index.d.ts +2 -1
  220. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts +99 -6
  221. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +250 -51
  222. package/dist/commonjs/parsers/manifest/dash/common/manifest_bounds_calculator.d.ts +40 -17
  223. package/dist/commonjs/parsers/manifest/dash/common/manifest_bounds_calculator.js +38 -18
  224. package/dist/commonjs/parsers/manifest/dash/common/parse_adaptation_sets.js +13 -10
  225. package/dist/commonjs/parsers/manifest/dash/common/parse_mpd.js +27 -14
  226. package/dist/commonjs/parsers/manifest/dash/common/parse_periods.d.ts +1 -1
  227. package/dist/commonjs/parsers/manifest/dash/common/parse_periods.js +17 -18
  228. package/dist/commonjs/parsers/manifest/dash/common/parse_representation_index.d.ts +19 -6
  229. package/dist/commonjs/parsers/manifest/dash/common/parse_representation_index.js +21 -8
  230. package/dist/commonjs/parsers/manifest/dash/common/parse_representations.js +7 -3
  231. package/dist/commonjs/parsers/manifest/local/representation_index.d.ts +1 -1
  232. package/dist/commonjs/parsers/manifest/local/representation_index.js +3 -3
  233. package/dist/commonjs/parsers/manifest/metaplaylist/representation_index.d.ts +1 -1
  234. package/dist/commonjs/parsers/manifest/metaplaylist/representation_index.js +2 -2
  235. package/dist/commonjs/parsers/manifest/smooth/representation_index.d.ts +5 -5
  236. package/dist/commonjs/parsers/manifest/smooth/representation_index.js +25 -9
  237. package/dist/commonjs/parsers/manifest/utils/index_helpers.js +1 -1
  238. package/dist/commonjs/public_types.d.ts +78 -34
  239. package/dist/commonjs/transports/dash/init_segment_loader.js +10 -5
  240. package/dist/commonjs/transports/dash/manifest_parser.js +5 -2
  241. package/dist/commonjs/transports/dash/segment_loader.js +2 -1
  242. package/dist/commonjs/transports/dash/text_loader.js +2 -0
  243. package/dist/commonjs/transports/metaplaylist/manifest_loader.js +2 -1
  244. package/dist/commonjs/transports/metaplaylist/pipelines.js +4 -1
  245. package/dist/commonjs/transports/smooth/pipelines.js +4 -2
  246. package/dist/commonjs/transports/smooth/segment_loader.js +2 -1
  247. package/dist/commonjs/transports/types.d.ts +12 -0
  248. package/dist/commonjs/transports/utils/generate_manifest_loader.js +6 -3
  249. package/dist/commonjs/utils/request/fetch.d.ts +6 -0
  250. package/dist/commonjs/utils/request/fetch.js +29 -8
  251. package/dist/commonjs/utils/request/xhr.d.ts +11 -5
  252. package/dist/commonjs/utils/request/xhr.js +29 -8
  253. package/dist/es2017/compat/is_codec_supported.js +22 -1
  254. package/dist/es2017/config.d.ts +1 -0
  255. package/dist/es2017/core/api/debug/buffer_graph.js +2 -6
  256. package/dist/es2017/core/api/debug/modules/general_info.js +17 -10
  257. package/dist/es2017/core/api/option_utils.d.ts +2 -0
  258. package/dist/es2017/core/api/option_utils.js +2 -3
  259. package/dist/es2017/core/api/public_api.d.ts +9 -0
  260. package/dist/es2017/core/api/public_api.js +33 -8
  261. package/dist/es2017/core/fetchers/manifest/manifest_fetcher.d.ts +6 -0
  262. package/dist/es2017/core/fetchers/manifest/manifest_fetcher.js +11 -3
  263. package/dist/es2017/core/fetchers/segment/segment_fetcher.d.ts +8 -1
  264. package/dist/es2017/core/fetchers/segment/segment_fetcher.js +8 -4
  265. package/dist/es2017/core/fetchers/segment/segment_fetcher_creator.d.ts +1 -0
  266. package/dist/es2017/core/fetchers/utils/schedule_request.js +1 -1
  267. package/dist/es2017/core/init/directfile_content_initializer.js +24 -7
  268. package/dist/es2017/core/init/media_source_content_initializer.d.ts +6 -0
  269. package/dist/es2017/core/init/media_source_content_initializer.js +4 -6
  270. package/dist/es2017/core/init/utils/content_time_boundaries_observer.d.ts +13 -12
  271. package/dist/es2017/core/init/utils/content_time_boundaries_observer.js +16 -15
  272. package/dist/es2017/core/init/utils/get_initial_time.d.ts +17 -3
  273. package/dist/es2017/core/init/utils/get_initial_time.js +9 -7
  274. package/dist/es2017/core/stream/representation/utils/get_buffer_status.js +3 -3
  275. package/dist/es2017/core/stream/representation/utils/get_needed_segments.js +1 -1
  276. package/dist/es2017/default_config.d.ts +5 -0
  277. package/dist/es2017/default_config.js +5 -0
  278. package/dist/es2017/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +3 -1
  279. package/dist/es2017/experimental/tools/createMetaplaylist/get_duration_from_manifest.js +2 -0
  280. package/dist/es2017/manifest/representation_index/static.d.ts +1 -1
  281. package/dist/es2017/manifest/representation_index/static.js +2 -2
  282. package/dist/es2017/manifest/representation_index/types.d.ts +4 -4
  283. package/dist/es2017/parsers/manifest/dash/common/indexes/base.d.ts +6 -1
  284. package/dist/es2017/parsers/manifest/dash/common/indexes/base.js +4 -3
  285. package/dist/es2017/parsers/manifest/dash/common/indexes/get_segments_from_timeline.d.ts +5 -2
  286. package/dist/es2017/parsers/manifest/dash/common/indexes/get_segments_from_timeline.js +15 -4
  287. package/dist/es2017/parsers/manifest/dash/common/indexes/index.d.ts +5 -5
  288. package/dist/es2017/parsers/manifest/dash/common/indexes/list.d.ts +1 -1
  289. package/dist/es2017/parsers/manifest/dash/common/indexes/list.js +2 -2
  290. package/dist/es2017/parsers/manifest/dash/common/indexes/template.d.ts +12 -5
  291. package/dist/es2017/parsers/manifest/dash/common/indexes/template.js +40 -27
  292. package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/index.d.ts +2 -1
  293. package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts +99 -6
  294. package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +246 -51
  295. package/dist/es2017/parsers/manifest/dash/common/manifest_bounds_calculator.d.ts +40 -17
  296. package/dist/es2017/parsers/manifest/dash/common/manifest_bounds_calculator.js +38 -18
  297. package/dist/es2017/parsers/manifest/dash/common/parse_adaptation_sets.js +11 -8
  298. package/dist/es2017/parsers/manifest/dash/common/parse_mpd.js +27 -13
  299. package/dist/es2017/parsers/manifest/dash/common/parse_periods.d.ts +1 -1
  300. package/dist/es2017/parsers/manifest/dash/common/parse_periods.js +13 -16
  301. package/dist/es2017/parsers/manifest/dash/common/parse_representation_index.d.ts +19 -6
  302. package/dist/es2017/parsers/manifest/dash/common/parse_representation_index.js +10 -8
  303. package/dist/es2017/parsers/manifest/dash/common/parse_representations.js +7 -3
  304. package/dist/es2017/parsers/manifest/local/representation_index.d.ts +1 -1
  305. package/dist/es2017/parsers/manifest/local/representation_index.js +3 -3
  306. package/dist/es2017/parsers/manifest/metaplaylist/representation_index.d.ts +1 -1
  307. package/dist/es2017/parsers/manifest/metaplaylist/representation_index.js +2 -2
  308. package/dist/es2017/parsers/manifest/smooth/representation_index.d.ts +5 -5
  309. package/dist/es2017/parsers/manifest/smooth/representation_index.js +25 -9
  310. package/dist/es2017/parsers/manifest/utils/index_helpers.js +1 -1
  311. package/dist/es2017/public_types.d.ts +78 -34
  312. package/dist/es2017/transports/dash/init_segment_loader.js +5 -0
  313. package/dist/es2017/transports/dash/manifest_parser.js +3 -0
  314. package/dist/es2017/transports/dash/segment_loader.js +1 -0
  315. package/dist/es2017/transports/dash/text_loader.js +2 -0
  316. package/dist/es2017/transports/metaplaylist/manifest_loader.js +1 -0
  317. package/dist/es2017/transports/metaplaylist/pipelines.js +4 -1
  318. package/dist/es2017/transports/smooth/pipelines.js +2 -0
  319. package/dist/es2017/transports/smooth/segment_loader.js +1 -0
  320. package/dist/es2017/transports/types.d.ts +12 -0
  321. package/dist/es2017/transports/utils/generate_manifest_loader.js +3 -0
  322. package/dist/es2017/utils/request/fetch.d.ts +6 -0
  323. package/dist/es2017/utils/request/fetch.js +29 -8
  324. package/dist/es2017/utils/request/xhr.d.ts +11 -5
  325. package/dist/es2017/utils/request/xhr.js +30 -9
  326. package/dist/rx-player.js +723 -376
  327. package/dist/rx-player.min.js +1 -1
  328. package/package.json +3 -4
  329. package/scripts/update-version +2 -0
  330. package/sonar-project.properties +1 -1
  331. package/src/compat/is_codec_supported.ts +23 -1
  332. package/src/core/api/debug/buffer_graph.ts +2 -5
  333. package/src/core/api/debug/modules/general_info.ts +15 -10
  334. package/src/core/api/option_utils.ts +3 -3
  335. package/src/core/api/public_api.ts +35 -7
  336. package/src/core/fetchers/manifest/manifest_fetcher.ts +21 -3
  337. package/src/core/fetchers/segment/segment_fetcher.ts +19 -5
  338. package/src/core/fetchers/segment/segment_fetcher_creator.ts +1 -0
  339. package/src/core/fetchers/utils/schedule_request.ts +1 -1
  340. package/src/core/init/directfile_content_initializer.ts +23 -7
  341. package/src/core/init/media_source_content_initializer.ts +13 -7
  342. package/src/core/init/utils/content_time_boundaries_observer.ts +23 -22
  343. package/src/core/init/utils/get_initial_time.ts +25 -12
  344. package/src/core/stream/representation/utils/get_buffer_status.ts +3 -3
  345. package/src/core/stream/representation/utils/get_needed_segments.ts +2 -2
  346. package/src/default_config.ts +5 -0
  347. package/src/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.ts +3 -1
  348. package/src/experimental/tools/createMetaplaylist/get_duration_from_manifest.ts +2 -0
  349. package/src/manifest/representation_index/static.ts +2 -2
  350. package/src/manifest/representation_index/types.ts +4 -4
  351. package/src/parsers/manifest/dash/common/__tests__/manifest_bounds_calculator.test.ts +182 -36
  352. package/src/parsers/manifest/dash/common/indexes/base.ts +12 -4
  353. package/src/parsers/manifest/dash/common/indexes/get_segments_from_timeline.ts +19 -5
  354. package/src/parsers/manifest/dash/common/indexes/index.ts +16 -4
  355. package/src/parsers/manifest/dash/common/indexes/list.ts +2 -2
  356. package/src/parsers/manifest/dash/common/indexes/template.ts +52 -31
  357. package/src/parsers/manifest/dash/common/indexes/timeline/index.ts +4 -1
  358. package/src/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.ts +366 -60
  359. package/src/parsers/manifest/dash/common/manifest_bounds_calculator.ts +63 -25
  360. package/src/parsers/manifest/dash/common/parse_adaptation_sets.ts +10 -4
  361. package/src/parsers/manifest/dash/common/parse_mpd.ts +28 -15
  362. package/src/parsers/manifest/dash/common/parse_periods.ts +12 -17
  363. package/src/parsers/manifest/dash/common/parse_representation_index.ts +50 -26
  364. package/src/parsers/manifest/dash/common/parse_representations.ts +9 -3
  365. package/src/parsers/manifest/local/representation_index.ts +3 -3
  366. package/src/parsers/manifest/metaplaylist/representation_index.ts +2 -2
  367. package/src/parsers/manifest/smooth/representation_index.ts +23 -9
  368. package/src/parsers/manifest/utils/__tests__/get_first_time_from_adaptations.test.ts +1 -1
  369. package/src/parsers/manifest/utils/__tests__/get_last_time_from_adaptation.test.ts +1 -1
  370. package/src/parsers/manifest/utils/index_helpers.ts +1 -1
  371. package/src/public_types.ts +79 -34
  372. package/src/transports/dash/init_segment_loader.ts +5 -0
  373. package/src/transports/dash/manifest_parser.ts +6 -0
  374. package/src/transports/dash/segment_loader.ts +1 -0
  375. package/src/transports/dash/text_loader.ts +2 -0
  376. package/src/transports/metaplaylist/manifest_loader.ts +1 -0
  377. package/src/transports/metaplaylist/pipelines.ts +4 -1
  378. package/src/transports/smooth/pipelines.ts +2 -0
  379. package/src/transports/smooth/segment_loader.ts +1 -0
  380. package/src/transports/types.ts +12 -0
  381. package/src/transports/utils/generate_manifest_loader.ts +3 -0
  382. package/src/utils/request/fetch.ts +35 -8
  383. package/src/utils/request/xhr.ts +45 -14
  384. package/dist/_esm5.processed/compat/fullscreen.d.ts +0 -32
  385. package/dist/_esm5.processed/compat/fullscreen.js +0 -78
  386. package/dist/_esm5.processed/compat/is_offline.d.ts +0 -39
  387. package/dist/_esm5.processed/compat/is_offline.js +0 -43
  388. package/dist/_esm5.processed/core/api/tracks_management/track_choice_manager.d.ts +0 -258
  389. package/dist/_esm5.processed/core/api/tracks_management/track_choice_manager.js +0 -989
  390. package/dist/_esm5.processed/core/segment_buffers/implementations/image/image_segment_buffer.d.ts +0 -75
  391. package/dist/_esm5.processed/core/segment_buffers/implementations/image/image_segment_buffer.js +0 -133
  392. package/dist/_esm5.processed/features/list/bif_parser.d.ts +0 -23
  393. package/dist/_esm5.processed/features/list/bif_parser.js +0 -27
  394. package/dist/_esm5.processed/features/list/image_buffer.js +0 -25
  395. package/dist/_esm5.processed/transports/dash/image_pipelines.d.ts +0 -38
  396. package/dist/_esm5.processed/transports/dash/image_pipelines.js +0 -129
  397. package/dist/_esm5.processed/utils/list_to_map.js +0 -28
  398. package/dist/_esm5.processed/utils/simple_set.d.ts +0 -51
  399. package/dist/_esm5.processed/utils/simple_set.js +0 -57
  400. package/dist/_esm5.processed/utils/uniq.d.ts +0 -36
  401. package/dist/_esm5.processed/utils/uniq.js +0 -43
  402. package/dist/commonjs/parsers/manifest/utils/is_segment_still_available.d.ts +0 -29
  403. package/dist/commonjs/parsers/manifest/utils/is_segment_still_available.js +0 -54
  404. package/dist/es2017/parsers/manifest/utils/is_segment_still_available.d.ts +0 -29
  405. package/dist/es2017/parsers/manifest/utils/is_segment_still_available.js +0 -51
  406. package/src/parsers/manifest/utils/is_segment_still_available.ts +0 -58
  407. package/src/typings/object-assign.d.ts +0 -48
@@ -20,16 +20,6 @@ import getMonotonicTimeStamp from "../../../../utils/monotonic_timestamp";
20
20
  * This class allows to easily calculate the first and last available positions
21
21
  * in a content at any time.
22
22
  *
23
- * That task can be an hard for dynamic DASH contents: it depends on a
24
- * `timeShiftBufferDepth` defined in the MPD and on the maximum possible
25
- * position.
26
- *
27
- * The latter can come from either a clock synchronization mechanism or the
28
- * indexing schemes (e.g. SegmentTemplate, SegmentTimeline etc.) of the last
29
- * Periods.
30
- * As such, it might only be known once a large chunk of the MPD has already
31
- * been parsed.
32
- *
33
23
  * By centralizing the manifest bounds calculation in this class and by giving
34
24
  * an instance of it to each parsed elements which might depend on it, we
35
25
  * ensure that we can provide it once it is known to every one of those
@@ -37,8 +27,18 @@ import getMonotonicTimeStamp from "../../../../utils/monotonic_timestamp";
37
27
  * @class ManifestBoundsCalculator
38
28
  */
39
29
  export default class ManifestBoundsCalculator {
40
- /** Value of MPD@timeShiftBufferDepth. */
30
+ /**
31
+ * Value of MPD@timeShiftBufferDepth.
32
+ * `null` if not defined.
33
+ */
41
34
  private _timeShiftBufferDepth : number | null;
35
+ /**
36
+ * Value of MPD@availabilityStartTime as an unix timestamp in seconds.
37
+ * `0` if it wasn't defined.
38
+ */
39
+ private _availabilityStartTime : number;
40
+ /** `true` if MPD@type is equal to "dynamic". */
41
+ private _isDynamic : boolean;
42
42
  /**
43
43
  * Monotonically-raising timestamp (the one used by the RxPlayer) when
44
44
  * `lastPosition` was calculated.
@@ -46,20 +46,30 @@ export default class ManifestBoundsCalculator {
46
46
  private _positionTime : number | undefined;
47
47
  /** Last position calculated at a given moment (itself indicated by `_positionTime`. */
48
48
  private _lastPosition : number | undefined;
49
- /** `true` if MPD@type is equal to "dynamic". */
50
- private _isDynamic : boolean;
49
+ /**
50
+ * Offset to add to `performance.now` to obtain a good estimation of the
51
+ * server-side unix timestamp.
52
+ *
53
+ * `undefined` if unknown.
54
+ */
55
+ private _serverTimestampOffset : number | undefined;
51
56
 
52
57
  /**
53
58
  * @param {Object} args
54
59
  */
55
- constructor(args : { timeShiftBufferDepth : number | undefined;
56
- isDynamic : boolean; }
57
- ) {
60
+ constructor(args : {
61
+ availabilityStartTime : number;
62
+ timeShiftBufferDepth : number | undefined;
63
+ isDynamic : boolean;
64
+ serverTimestampOffset: number | undefined;
65
+ }) {
58
66
  this._isDynamic = args.isDynamic;
59
67
  this._timeShiftBufferDepth = !args.isDynamic ||
60
68
  args.timeShiftBufferDepth === undefined ?
61
69
  null :
62
70
  args.timeShiftBufferDepth;
71
+ this._serverTimestampOffset = args.serverTimestampOffset;
72
+ this._availabilityStartTime = args.availabilityStartTime;
63
73
  }
64
74
 
65
75
  /**
@@ -102,11 +112,12 @@ export default class ManifestBoundsCalculator {
102
112
  * Consider that it is only an estimation, not the real value.
103
113
  * @return {number|undefined}
104
114
  */
105
- estimateMinimumBound(): number | undefined {
115
+ getEstimatedMinimumSegmentTime(): number | undefined {
106
116
  if (!this._isDynamic || this._timeShiftBufferDepth === null) {
107
117
  return 0;
108
118
  }
109
- const maximumBound = this.estimateMaximumBound();
119
+ const maximumBound = this.getEstimatedLiveEdge() ??
120
+ this.getEstimatedMaximumPosition(0);
110
121
  if (maximumBound === undefined) {
111
122
  return undefined;
112
123
  }
@@ -115,15 +126,42 @@ export default class ManifestBoundsCalculator {
115
126
  }
116
127
 
117
128
  /**
118
- * Estimate a maximum bound for the content from the last set segment time.
119
- * Consider that it is only an estimation, not the real value.
129
+ * Estimate the segment time in seconds that corresponds to what could be
130
+ * considered the live edge (or `undefined` for non-live contents).
131
+ *
132
+ * Note that for some contents which just anounce segments in advance, this
133
+ * value might be very different than the maximum position that is
134
+ * requestable.
120
135
  * @return {number|undefined}
121
136
  */
122
- estimateMaximumBound() : number | undefined {
123
- if (this._isDynamic &&
124
- this._positionTime != null &&
125
- this._lastPosition != null)
126
- {
137
+ getEstimatedLiveEdge() : number | undefined {
138
+ if (!this._isDynamic || this._serverTimestampOffset === undefined) {
139
+ return undefined;
140
+ }
141
+ return (getMonotonicTimeStamp() + this._serverTimestampOffset) / 1000 -
142
+ this._availabilityStartTime;
143
+ }
144
+
145
+ /**
146
+ * Produce a rough estimate of the ending time of the last requestable segment
147
+ * in that content.
148
+ *
149
+ * This value is only an estimate and may be far from reality.
150
+ *
151
+ * The `availabilityTimeOffset` in argument is the corresponding
152
+ * `availabilityTimeOffset` that applies to the current wanted segment, or `0`
153
+ * if none exist. It will be applied on live content to deduce the maximum
154
+ * segment time available.
155
+ */
156
+ getEstimatedMaximumPosition(availabilityTimeOffset: number) : number | undefined {
157
+ if (!this._isDynamic) {
158
+ return this._lastPosition;
159
+ }
160
+
161
+ const liveEdge = this.getEstimatedLiveEdge();
162
+ if (liveEdge !== undefined && availabilityTimeOffset !== Infinity) {
163
+ return liveEdge + availabilityTimeOffset;
164
+ } else if (this._positionTime !== undefined && this._lastPosition !== undefined) {
127
165
  return Math.max((this._lastPosition - this._positionTime) +
128
166
  (getMonotonicTimeStamp() / 1000),
129
167
  0);
@@ -281,12 +281,19 @@ export default function parseAdaptationSets(
281
281
  roles.some((role) => role.schemeIdUri === "urn:mpeg:dash:role:2011");
282
282
 
283
283
  const representationsIR = adaptation.children.representations;
284
+
284
285
  const availabilityTimeComplete =
285
286
  adaptation.attributes.availabilityTimeComplete ??
286
287
  context.availabilityTimeComplete;
287
- const availabilityTimeOffset =
288
- (adaptation.attributes.availabilityTimeOffset ?? 0) +
289
- context.availabilityTimeOffset;
288
+
289
+ let availabilityTimeOffset;
290
+ if (
291
+ adaptation.attributes.availabilityTimeOffset !== undefined ||
292
+ context.availabilityTimeOffset !== undefined
293
+ ) {
294
+ availabilityTimeOffset = (adaptation.attributes.availabilityTimeOffset ?? 0) +
295
+ (context.availabilityTimeOffset ?? 0);
296
+ }
290
297
 
291
298
  const adaptationMimeType = adaptation.attributes.mimeType;
292
299
  const adaptationCodecs = adaptation.attributes.codecs;
@@ -327,7 +334,6 @@ export default function parseAdaptationSets(
327
334
  parentSegmentTemplates,
328
335
  receivedTime: context.receivedTime,
329
336
  start: context.start,
330
- timeShiftBufferDepth: context.timeShiftBufferDepth,
331
337
  unsafelyBaseOnPreviousAdaptation: null,
332
338
  };
333
339
 
@@ -30,6 +30,7 @@ import { IResponseData } from "../parsers_types";
30
30
  import getClockOffset from "./get_clock_offset";
31
31
  import getHTTPUTCTimingURL from "./get_http_utc-timing_url";
32
32
  import getMinimumAndMaximumPositions from "./get_minimum_and_maximum_positions";
33
+ import ManifestBoundsCalculator from "./manifest_bounds_calculator";
33
34
  import parseAvailabilityStartTime from "./parse_availability_start_time";
34
35
  import parsePeriods, {
35
36
  IXLinkInfos,
@@ -252,11 +253,19 @@ function parseCompleteIntermediateRepresentation(
252
253
  const { externalClockOffset: clockOffset,
253
254
  unsafelyBaseOnPreviousManifest } = args;
254
255
 
256
+ const { externalClockOffset } = args;
257
+ const manifestBoundsCalculator = new ManifestBoundsCalculator({
258
+ availabilityStartTime,
259
+ isDynamic,
260
+ timeShiftBufferDepth,
261
+ serverTimestampOffset: externalClockOffset,
262
+ });
255
263
  const manifestInfos = { availabilityStartTime,
256
264
  baseURLs: mpdBaseUrls,
257
265
  clockOffset,
258
266
  duration: rootAttributes.duration,
259
267
  isDynamic,
268
+ manifestBoundsCalculator,
260
269
  manifestProfiles: mpdIR.attributes.profiles,
261
270
  receivedTime: args.manifestReceivedTime,
262
271
  timeShiftBufferDepth,
@@ -313,31 +322,33 @@ function parseCompleteIntermediateRepresentation(
313
322
  livePosition: undefined,
314
323
  time: now };
315
324
  } else {
316
- minimumTime = minimumSafePosition;
317
- timeshiftDepth = timeShiftBufferDepth ?? null;
325
+ // Determine the maximum seekable position
318
326
  let finalMaximumSafePosition : number;
319
- let livePosition;
320
-
321
- if (maximumUnsafePosition !== undefined) {
322
- livePosition = maximumUnsafePosition;
323
- }
324
-
325
327
  if (maximumSafePosition !== undefined) {
326
328
  finalMaximumSafePosition = maximumSafePosition;
327
329
  } else {
328
- const ast = availabilityStartTime ?? 0;
329
- const { externalClockOffset } = args;
330
330
  if (externalClockOffset === undefined) {
331
331
  log.warn("DASH Parser: use system clock to define maximum position");
332
- finalMaximumSafePosition = (Date.now() / 1000) - ast;
332
+ finalMaximumSafePosition = (Date.now() / 1000) - availabilityStartTime;
333
333
  } else {
334
334
  const serverTime = getMonotonicTimeStamp() + externalClockOffset;
335
- finalMaximumSafePosition = (serverTime / 1000) - ast;
335
+ finalMaximumSafePosition = (serverTime / 1000) - availabilityStartTime;
336
336
  }
337
337
  }
338
+
339
+ // Determine live edge (what position corresponds to live content, can be
340
+ // inferior or superior to the maximum anounced position in some specific
341
+ // scenarios). However, the `timeShiftBufferDepth` should be based on it.
342
+ let livePosition = manifestBoundsCalculator.getEstimatedLiveEdge();
338
343
  if (livePosition === undefined) {
339
- livePosition = finalMaximumSafePosition;
344
+ if (maximumUnsafePosition !== undefined) {
345
+ livePosition = maximumUnsafePosition;
346
+ } else {
347
+ livePosition = finalMaximumSafePosition;
348
+ }
349
+ // manifestBoundsCalculator.forceLiveEdge(livePosition);
340
350
  }
351
+
341
352
  maximumTimeData = { isLinear: true,
342
353
  maximumSafePosition: finalMaximumSafePosition,
343
354
  livePosition,
@@ -345,10 +356,12 @@ function parseCompleteIntermediateRepresentation(
345
356
 
346
357
  // if the minimum calculated time is even below the buffer depth, perhaps we
347
358
  // can go even lower in terms of depth
359
+ minimumTime = minimumSafePosition;
360
+ timeshiftDepth = timeShiftBufferDepth ?? null;
348
361
  if (timeshiftDepth !== null && minimumTime !== undefined &&
349
- finalMaximumSafePosition - minimumTime > timeshiftDepth)
362
+ livePosition - minimumTime > timeshiftDepth)
350
363
  {
351
- timeshiftDepth = finalMaximumSafePosition - minimumTime;
364
+ timeshiftDepth = livePosition - minimumTime;
352
365
  }
353
366
  }
354
367
 
@@ -18,6 +18,7 @@ import log from "../../../../log";
18
18
  import Manifest from "../../../../manifest";
19
19
  import flatMap from "../../../../utils/flat_map";
20
20
  import idGenerator from "../../../../utils/id_generator";
21
+ import isNullOrUndefined from "../../../../utils/is_null_or_undefined";
21
22
  import getMonotonicTimeStamp from "../../../../utils/monotonic_timestamp";
22
23
  import objectValues from "../../../../utils/object_values";
23
24
  import { utf8ToStr } from "../../../../utils/string_parsing";
@@ -34,7 +35,6 @@ import {
34
35
  // eslint-disable-next-line max-len
35
36
  import flattenOverlappingPeriods from "./flatten_overlapping_periods";
36
37
  import getPeriodsTimeInformation from "./get_periods_time_infos";
37
- import ManifestBoundsCalculator from "./manifest_bounds_calculator";
38
38
  import parseAdaptationSets, {
39
39
  IAdaptationSetContext,
40
40
  } from "./parse_adaptation_sets";
@@ -68,12 +68,9 @@ export default function parsePeriods(
68
68
  throw new Error("MPD parsing error: the time information are incoherent.");
69
69
  }
70
70
 
71
- const { isDynamic,
72
- timeShiftBufferDepth } = context;
73
- const manifestBoundsCalculator = new ManifestBoundsCalculator({ isDynamic,
74
- timeShiftBufferDepth });
71
+ const { isDynamic, manifestBoundsCalculator } = context;
75
72
 
76
- if (!isDynamic && context.duration != null) {
73
+ if (!isDynamic && !isNullOrUndefined(context.duration)) {
77
74
  manifestBoundsCalculator.setLastPosition(context.duration);
78
75
  }
79
76
 
@@ -91,7 +88,7 @@ export default function parsePeriods(
91
88
  periodEnd } = periodsTimeInformation[i];
92
89
 
93
90
  let periodID : string;
94
- if (periodIR.attributes.id == null) {
91
+ if (isNullOrUndefined(periodIR.attributes.id)) {
95
92
  log.warn("DASH: No usable id found in the Period. Generating one.");
96
93
  periodID = "gen-dash-period-" + generatePeriodID();
97
94
  } else {
@@ -109,8 +106,8 @@ export default function parsePeriods(
109
106
  const unsafelyBaseOnPreviousPeriod = context
110
107
  .unsafelyBaseOnPreviousManifest?.getPeriod(periodID) ?? null;
111
108
 
112
- const availabilityTimeComplete = periodIR.attributes.availabilityTimeComplete ?? true;
113
- const availabilityTimeOffset = periodIR.attributes.availabilityTimeOffset ?? 0;
109
+ const availabilityTimeComplete = periodIR.attributes.availabilityTimeComplete;
110
+ const availabilityTimeOffset = periodIR.attributes.availabilityTimeOffset;
114
111
  const { manifestProfiles } = context;
115
112
  const { segmentTemplate } = periodIR.children;
116
113
  const adapCtxt : IAdaptationSetContext = { availabilityTimeComplete,
@@ -124,7 +121,6 @@ export default function parsePeriods(
124
121
  receivedTime,
125
122
  segmentTemplate,
126
123
  start: periodStart,
127
- timeShiftBufferDepth,
128
124
  unsafelyBaseOnPreviousPeriod };
129
125
  const adaptations = parseAdaptationSets(periodIR.children.adaptations, adapCtxt);
130
126
 
@@ -208,7 +204,7 @@ function guessLastPositionFromClock(
208
204
  context : IPeriodContext,
209
205
  minimumTime : number
210
206
  ) : [number, number] | undefined {
211
- if (context.clockOffset != null) {
207
+ if (!isNullOrUndefined(context.clockOffset)) {
212
208
  const lastPosition = context.clockOffset / 1000 -
213
209
  context.availabilityStartTime;
214
210
  const positionTime = getMonotonicTimeStamp() / 1000;
@@ -245,7 +241,7 @@ function getMaximumLastPosition(
245
241
  let maxEncounteredPosition : number | null = null;
246
242
  let allIndexAreEmpty = true;
247
243
  const adaptationsVal = objectValues(adaptationsPerType)
248
- .filter((ada) : ada is IParsedAdaptation[] => ada != null);
244
+ .filter((ada) : ada is IParsedAdaptation[] => !isNullOrUndefined(ada));
249
245
  const allAdaptations = flatMap(adaptationsVal,
250
246
  (adaptationsForType) => adaptationsForType);
251
247
  for (const adaptation of allAdaptations) {
@@ -256,15 +252,15 @@ function getMaximumLastPosition(
256
252
  allIndexAreEmpty = false;
257
253
  if (typeof position === "number") {
258
254
  maxEncounteredPosition =
259
- maxEncounteredPosition == null ? position :
260
- Math.max(maxEncounteredPosition,
261
- position);
255
+ isNullOrUndefined(maxEncounteredPosition) ? position :
256
+ Math.max(maxEncounteredPosition,
257
+ position);
262
258
  }
263
259
  }
264
260
  }
265
261
  }
266
262
 
267
- if (maxEncounteredPosition != null) {
263
+ if (!isNullOrUndefined(maxEncounteredPosition)) {
268
264
  return maxEncounteredPosition;
269
265
  } else if (allIndexAreEmpty) {
270
266
  return null;
@@ -369,6 +365,5 @@ type IInheritedAdaptationContext = Omit<IAdaptationSetContext,
369
365
  "availabilityTimeOffset" |
370
366
  "duration" |
371
367
  "isLastPeriod" |
372
- "manifestBoundsCalculator" |
373
368
  "start" |
374
369
  "unsafelyBaseOnPreviousPeriod">;
@@ -31,6 +31,10 @@ import {
31
31
  ListRepresentationIndex,
32
32
  TemplateRepresentationIndex,
33
33
  TimelineRepresentationIndex,
34
+ IBaseIndexContextArgument,
35
+ IListIndexContextArgument,
36
+ ITemplateIndexContextArgument,
37
+ ITimelineIndexContextArgument,
34
38
  } from "./indexes";
35
39
  import ManifestBoundsCalculator from "./manifest_bounds_calculator";
36
40
  import { IResolvedBaseUrl } from "./resolve_base_urls";
@@ -52,7 +56,6 @@ export default function parseRepresentationIndex(
52
56
  end: periodEnd,
53
57
  start: periodStart,
54
58
  receivedTime,
55
- timeShiftBufferDepth,
56
59
  unsafelyBaseOnPreviousRepresentation,
57
60
  inbandEventStreams,
58
61
  isLastPeriod } = context;
@@ -64,19 +67,24 @@ export default function parseRepresentationIndex(
64
67
  return inbandEventStreams
65
68
  .some(({ schemeIdUri }) => schemeIdUri === inbandEvent.schemeIdUri);
66
69
  };
67
- const reprIndexCtxt = { availabilityTimeComplete: true,
68
- availabilityTimeOffset,
69
- unsafelyBaseOnPreviousRepresentation,
70
- isEMSGWhitelisted,
71
- isLastPeriod,
72
- manifestBoundsCalculator,
73
- isDynamic,
74
- periodEnd,
75
- periodStart,
76
- receivedTime,
77
- representationBitrate: representation.attributes.bitrate,
78
- representationId: representation.attributes.id,
79
- timeShiftBufferDepth };
70
+ const reprIndexCtxt: ITimelineIndexContextArgument |
71
+ ITemplateIndexContextArgument |
72
+ IListIndexContextArgument |
73
+ IBaseIndexContextArgument =
74
+ {
75
+ availabilityTimeComplete: undefined,
76
+ availabilityTimeOffset,
77
+ unsafelyBaseOnPreviousRepresentation,
78
+ isEMSGWhitelisted,
79
+ isLastPeriod,
80
+ manifestBoundsCalculator,
81
+ isDynamic,
82
+ periodEnd,
83
+ periodStart,
84
+ receivedTime,
85
+ representationBitrate: representation.attributes.bitrate,
86
+ representationId: representation.attributes.id,
87
+ };
80
88
  let representationIndex : IRepresentationIndex;
81
89
  if (representation.children.segmentBase !== undefined) {
82
90
  const { segmentBase } = representation.children;
@@ -97,12 +105,15 @@ export default function parseRepresentationIndex(
97
105
  ...segmentTemplates as [
98
106
  ISegmentTemplateIntermediateRepresentation
99
107
  ] /* Ugly TS Hack */);
100
- reprIndexCtxt.availabilityTimeComplete =
101
- segmentTemplate.availabilityTimeComplete ??
102
- context.availabilityTimeComplete;
103
- reprIndexCtxt.availabilityTimeOffset =
104
- (segmentTemplate.availabilityTimeOffset ?? 0) +
105
- context.availabilityTimeOffset;
108
+ if (
109
+ segmentTemplate.availabilityTimeOffset !== undefined ||
110
+ context.availabilityTimeOffset !== undefined
111
+ ) {
112
+ reprIndexCtxt.availabilityTimeOffset =
113
+ (segmentTemplate.availabilityTimeOffset ?? 0) +
114
+ (context.availabilityTimeOffset ?? 0);
115
+ }
116
+
106
117
  representationIndex = TimelineRepresentationIndex
107
118
  .isTimelineIndexArgument(segmentTemplate) ?
108
119
  new TimelineRepresentationIndex(segmentTemplate, reprIndexCtxt) :
@@ -131,10 +142,25 @@ export default function parseRepresentationIndex(
131
142
  export interface IRepresentationIndexContext {
132
143
  /** Parsed AdaptationSet which contains the Representation. */
133
144
  adaptation : IAdaptationSetIntermediateRepresentation;
134
- /** If false, declared segments in the MPD might still be not completely generated. */
135
- availabilityTimeComplete : boolean;
136
- /** availability time offset of the concerned Adaptation. */
137
- availabilityTimeOffset : number;
145
+ /**
146
+ * If `false`, declared segments in the MPD might still be not completely generated.
147
+ * If `true`, they are completely generated.
148
+ *
149
+ * If `undefined`, the corresponding property was not set in the MPD and it is
150
+ * thus assumed that they are all generated.
151
+ * It might however be semantically different than `true` in the RxPlayer as it
152
+ * means that the packager didn't include that information in the MPD.
153
+ */
154
+ availabilityTimeComplete : boolean | undefined;
155
+ /**
156
+ * availability time offset of the concerned Adaptation.
157
+ *
158
+ * If `undefined`, the corresponding property was not set in the MPD and it is
159
+ * thus assumed to be equal to `0`.
160
+ * It might however be semantically different than `0` in the RxPlayer as it
161
+ * means that the packager didn't include that information in the MPD.
162
+ */
163
+ availabilityTimeOffset : number | undefined;
138
164
  /** Eventual URLs from which every relative URL will be based on. */
139
165
  baseURLs : IResolvedBaseUrl[];
140
166
  /** End time of the current Period, in seconds. */
@@ -163,8 +189,6 @@ export interface IRepresentationIndexContext {
163
189
  receivedTime? : number | undefined;
164
190
  /** Start time of the current period, in seconds. */
165
191
  start : number;
166
- /** Depth of the buffer for the whole content, in seconds. */
167
- timeShiftBufferDepth? : number | undefined;
168
192
  /**
169
193
  * The parser should take this Representation - which is the same as this one
170
194
  * parsed at an earlier time - as a base to speed-up the parsing process.
@@ -153,9 +153,15 @@ export default function parseRepresentations(
153
153
  const availabilityTimeComplete =
154
154
  representation.attributes.availabilityTimeComplete ??
155
155
  context.availabilityTimeComplete;
156
- const availabilityTimeOffset =
157
- (representation.attributes.availabilityTimeOffset ?? 0) +
158
- context.availabilityTimeOffset;
156
+
157
+ let availabilityTimeOffset: number | undefined;
158
+ if (
159
+ representation.attributes.availabilityTimeOffset !== undefined ||
160
+ context.availabilityTimeOffset !== undefined
161
+ ) {
162
+ availabilityTimeOffset = (representation.attributes.availabilityTimeOffset ?? 0) +
163
+ (context.availabilityTimeOffset ?? 0);
164
+ }
159
165
  const reprIndexCtxt = objectAssign({},
160
166
  context,
161
167
  { availabilityTimeOffset,
@@ -149,7 +149,7 @@ export default class LocalRepresentationIndex implements IRepresentationIndex {
149
149
  * @returns {boolean|undefined}
150
150
  */
151
151
  awaitSegmentBetween(start: number, end: number): boolean | undefined {
152
- if (this.isFinished()) {
152
+ if (this.isStillAwaitingFutureSegments()) {
153
153
  return false;
154
154
  }
155
155
  if (this._index.incomingRanges === undefined) {
@@ -173,8 +173,8 @@ export default class LocalRepresentationIndex implements IRepresentationIndex {
173
173
  return true;
174
174
  }
175
175
 
176
- isFinished() : boolean {
177
- return this._index.isFinished;
176
+ isStillAwaitingFutureSegments() : boolean {
177
+ return !this._index.isFinished;
178
178
  }
179
179
 
180
180
  /**
@@ -203,8 +203,8 @@ export default class MetaRepresentationIndex implements IRepresentationIndex {
203
203
  /**
204
204
  * @returns {Boolean}
205
205
  */
206
- public isFinished() : boolean {
207
- return this._wrappedIndex.isFinished();
206
+ public isStillAwaitingFutureSegments() : boolean {
207
+ return this._wrappedIndex.isStillAwaitingFutureSegments();
208
208
  }
209
209
 
210
210
  /**
@@ -27,7 +27,6 @@ import {
27
27
  checkDiscontinuity,
28
28
  getIndexSegmentEnd,
29
29
  } from "../utils/index_helpers";
30
- import isSegmentStillAvailable from "../utils/is_segment_still_available";
31
30
  import SharedSmoothSegmentTimeline, {
32
31
  IIndexSegment,
33
32
  } from "./shared_smooth_segment_timeline";
@@ -423,7 +422,7 @@ export default class SmoothRepresentationIndex implements IRepresentationIndex {
423
422
  */
424
423
  awaitSegmentBetween(start: number, end: number): boolean | undefined {
425
424
  assert(start <= end);
426
- if (this.isFinished()) {
425
+ if (this.isStillAwaitingFutureSegments()) {
427
426
  return false;
428
427
  }
429
428
  const lastAvailablePosition = this.getLastAvailablePosition();
@@ -462,7 +461,22 @@ export default class SmoothRepresentationIndex implements IRepresentationIndex {
462
461
  }
463
462
  this._refreshTimeline();
464
463
  const { timeline, timescale } = this._sharedSmoothTimeline;
465
- return isSegmentStillAvailable(segment, timeline, timescale, 0);
464
+ for (let i = 0; i < timeline.length; i++) {
465
+ const tSegment = timeline[i];
466
+ const tSegmentTime = tSegment.start / timescale;
467
+ if (tSegmentTime > segment.time) {
468
+ return false; // We went over it without finding it
469
+ } else if (tSegmentTime === segment.time) {
470
+ return true;
471
+ } else { // tSegment.start < segment.time
472
+ if (tSegment.repeatCount >= 0 && tSegment.duration !== undefined) {
473
+ const timeDiff = tSegmentTime - tSegment.start;
474
+ const repeat = (timeDiff / tSegment.duration) - 1;
475
+ return repeat % 1 === 0 && repeat <= tSegment.repeatCount;
476
+ }
477
+ }
478
+ }
479
+ return false;
466
480
  }
467
481
 
468
482
  /**
@@ -500,9 +514,9 @@ export default class SmoothRepresentationIndex implements IRepresentationIndex {
500
514
  }
501
515
 
502
516
  /**
503
- * Returns `true` if the last segments in this index have already been
517
+ * Returns `false` if the last segments in this index have already been
504
518
  * generated.
505
- * Returns `false` if the index is still waiting on future segments to be
519
+ * Returns `true` if the index is still waiting on future segments to be
506
520
  * generated.
507
521
  *
508
522
  * For Smooth, it should only depend on whether the content is a live content
@@ -510,8 +524,8 @@ export default class SmoothRepresentationIndex implements IRepresentationIndex {
510
524
  * TODO What about Smooth live content that finishes at some point?
511
525
  * @returns {boolean}
512
526
  */
513
- isFinished() : boolean {
514
- return !this._isLive;
527
+ isStillAwaitingFutureSegments() : boolean {
528
+ return this._isLive;
515
529
  }
516
530
 
517
531
  /**
@@ -529,8 +543,8 @@ export default class SmoothRepresentationIndex implements IRepresentationIndex {
529
543
  * Add segments to a `SharedSmoothSegmentTimeline` that were predicted to come
530
544
  * after `currentSegment`.
531
545
  * @param {Array.<Object>} nextSegments - The segment information parsed.
532
- * @param {Object} segment - Information on the segment which contained that
533
- * new segment information.
546
+ * @param {Object} currentSegment - Information on the segment which contained
547
+ * that new segment information.
534
548
  */
535
549
  addPredictedSegments(
536
550
  nextSegments : Array<{ duration : number; time : number; timescale : number }>,
@@ -30,7 +30,7 @@ function generateRepresentationIndex(
30
30
  awaitSegmentBetween() : undefined { return ; },
31
31
  checkDiscontinuity() : number | null { return null; },
32
32
  isSegmentStillAvailable() : undefined { return ; },
33
- isFinished() { return false; },
33
+ isStillAwaitingFutureSegments() { return true; },
34
34
  canBeOutOfSyncError() : true { return true; },
35
35
  isInitialized() : true { return true; },
36
36
  initialize() : void { return ; },
@@ -30,7 +30,7 @@ function generateRepresentationIndex(
30
30
  awaitSegmentBetween() : undefined { return ; },
31
31
  checkDiscontinuity() : number | null { return null; },
32
32
  isSegmentStillAvailable() : undefined { return ; },
33
- isFinished() { return false; },
33
+ isStillAwaitingFutureSegments() { return true; },
34
34
  isInitialized() : true { return true; },
35
35
  initialize() : void { return ; },
36
36
  addPredictedSegments() : void { return ; },
@@ -136,7 +136,7 @@ export function getTimescaledRange(
136
136
  * timescaled time.
137
137
  * Returns -1 if the given time is lower than the start of the first available
138
138
  * segment.
139
- * @param {Object} index
139
+ * @param {Object} timeline
140
140
  * @param {Number} timeTScaled
141
141
  * @returns {Number}
142
142
  */