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

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 (336) hide show
  1. package/CHANGELOG.md +20 -60
  2. package/FILES.md +1 -1
  3. package/README.md +2 -33
  4. package/VERSION +1 -1
  5. package/dist/_esm5.processed/core/api/debug/buffer_graph.js +2 -6
  6. package/dist/_esm5.processed/core/api/debug/modules/general_info.js +20 -10
  7. package/dist/_esm5.processed/core/api/option_utils.d.ts +0 -2
  8. package/dist/_esm5.processed/core/api/option_utils.js +0 -6
  9. package/dist/_esm5.processed/core/api/public_api.d.ts +1 -2
  10. package/dist/_esm5.processed/core/api/public_api.js +9 -17
  11. package/dist/_esm5.processed/core/init/directfile_content_initializer.js +1 -1
  12. package/dist/_esm5.processed/core/init/media_source_content_initializer.js +3 -14
  13. package/dist/_esm5.processed/core/init/utils/rebuffering_controller.d.ts +2 -36
  14. package/dist/_esm5.processed/core/init/utils/rebuffering_controller.js +2 -82
  15. package/dist/_esm5.processed/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.js +9 -2
  16. package/dist/_esm5.processed/core/segment_buffers/implementations/image/image_segment_buffer.js +1 -1
  17. package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/html_text_segment_buffer.js +1 -1
  18. package/dist/_esm5.processed/core/segment_buffers/implementations/text/native/native_text_segment_buffer.js +1 -1
  19. package/dist/_esm5.processed/core/segment_buffers/index.d.ts +2 -2
  20. package/dist/_esm5.processed/core/segment_buffers/inventory/index.d.ts +2 -2
  21. package/dist/_esm5.processed/core/segment_buffers/inventory/segment_inventory.d.ts +25 -8
  22. package/dist/_esm5.processed/core/segment_buffers/inventory/segment_inventory.js +19 -10
  23. package/dist/_esm5.processed/core/stream/representation/utils/get_buffer_status.js +1 -1
  24. package/dist/_esm5.processed/core/stream/representation/utils/get_needed_segments.js +1 -1
  25. package/dist/_esm5.processed/parsers/texttracks/ttml/html/apply_extent.js +1 -8
  26. package/dist/_esm5.processed/parsers/texttracks/ttml/html/apply_line_height.js +2 -1
  27. package/dist/_esm5.processed/parsers/texttracks/ttml/html/apply_origin.js +1 -9
  28. package/dist/_esm5.processed/public_types.d.ts +2 -0
  29. package/dist/commonjs/compat/is_codec_supported.js +22 -1
  30. package/dist/commonjs/config.d.ts +2 -1
  31. package/dist/commonjs/core/adaptive/adaptive_representation_selector.d.ts +2 -19
  32. package/dist/commonjs/core/adaptive/adaptive_representation_selector.js +2 -2
  33. package/dist/commonjs/core/adaptive/network_analyzer.js +3 -3
  34. package/dist/commonjs/core/api/debug/buffer_graph.js +2 -6
  35. package/dist/commonjs/core/api/debug/modules/general_info.js +17 -10
  36. package/dist/commonjs/core/api/index.d.ts +1 -1
  37. package/dist/commonjs/core/api/option_utils.d.ts +2 -0
  38. package/dist/commonjs/core/api/option_utils.js +2 -3
  39. package/dist/commonjs/core/api/playback_observer.d.ts +128 -8
  40. package/dist/commonjs/core/api/playback_observer.js +217 -64
  41. package/dist/commonjs/core/api/public_api.d.ts +9 -0
  42. package/dist/commonjs/core/api/public_api.js +41 -16
  43. package/dist/commonjs/core/api/utils.js +1 -1
  44. package/dist/commonjs/core/decrypt/get_media_keys.js +2 -6
  45. package/dist/commonjs/core/fetchers/manifest/manifest_fetcher.d.ts +6 -0
  46. package/dist/commonjs/core/fetchers/manifest/manifest_fetcher.js +11 -3
  47. package/dist/commonjs/core/fetchers/segment/segment_fetcher.d.ts +8 -1
  48. package/dist/commonjs/core/fetchers/segment/segment_fetcher.js +8 -4
  49. package/dist/commonjs/core/fetchers/segment/segment_fetcher_creator.d.ts +1 -0
  50. package/dist/commonjs/core/fetchers/utils/schedule_request.js +1 -1
  51. package/dist/commonjs/core/init/directfile_content_initializer.js +29 -8
  52. package/dist/commonjs/core/init/media_source_content_initializer.d.ts +6 -0
  53. package/dist/commonjs/core/init/media_source_content_initializer.js +32 -20
  54. package/dist/commonjs/core/init/utils/content_time_boundaries_observer.d.ts +13 -12
  55. package/dist/commonjs/core/init/utils/content_time_boundaries_observer.js +17 -19
  56. package/dist/commonjs/core/init/utils/create_stream_playback_observer.d.ts +1 -5
  57. package/dist/commonjs/core/init/utils/create_stream_playback_observer.js +16 -14
  58. package/dist/commonjs/core/init/utils/get_initial_time.d.ts +17 -3
  59. package/dist/commonjs/core/init/utils/get_initial_time.js +9 -7
  60. package/dist/commonjs/core/init/utils/initial_seek_and_play.d.ts +9 -11
  61. package/dist/commonjs/core/init/utils/initial_seek_and_play.js +121 -91
  62. package/dist/commonjs/core/init/utils/rebuffering_controller.js +27 -70
  63. package/dist/commonjs/core/init/utils/stream_events_emitter/stream_events_emitter.js +4 -2
  64. package/dist/commonjs/core/segment_buffers/garbage_collector.js +1 -2
  65. package/dist/commonjs/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.js +9 -2
  66. package/dist/commonjs/core/segment_buffers/implementations/text/html/html_text_segment_buffer.js +1 -1
  67. package/dist/commonjs/core/segment_buffers/implementations/text/native/native_text_segment_buffer.js +1 -1
  68. package/dist/commonjs/core/segment_buffers/index.d.ts +2 -2
  69. package/dist/commonjs/core/segment_buffers/inventory/index.d.ts +2 -2
  70. package/dist/commonjs/core/segment_buffers/inventory/segment_inventory.d.ts +25 -8
  71. package/dist/commonjs/core/segment_buffers/inventory/segment_inventory.js +19 -10
  72. package/dist/commonjs/core/stream/adaptation/get_representations_switch_strategy.d.ts +2 -2
  73. package/dist/commonjs/core/stream/adaptation/get_representations_switch_strategy.js +16 -9
  74. package/dist/commonjs/core/stream/orchestrator/stream_orchestrator.js +14 -18
  75. package/dist/commonjs/core/stream/period/period_stream.js +5 -8
  76. package/dist/commonjs/core/stream/period/types.d.ts +2 -3
  77. package/dist/commonjs/core/stream/period/utils/get_adaptation_switch_strategy.d.ts +4 -5
  78. package/dist/commonjs/core/stream/period/utils/get_adaptation_switch_strategy.js +17 -13
  79. package/dist/commonjs/core/stream/representation/representation_stream.js +3 -4
  80. package/dist/commonjs/core/stream/representation/types.d.ts +2 -2
  81. package/dist/commonjs/core/stream/representation/utils/append_segment_to_buffer.js +11 -12
  82. package/dist/commonjs/core/stream/representation/utils/get_buffer_status.js +4 -4
  83. package/dist/commonjs/core/stream/representation/utils/get_needed_segments.js +1 -1
  84. package/dist/commonjs/default_config.d.ts +12 -16
  85. package/dist/commonjs/default_config.js +21 -16
  86. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +3 -1
  87. package/dist/commonjs/experimental/tools/createMetaplaylist/get_duration_from_manifest.js +2 -0
  88. package/dist/commonjs/manifest/adaptation.js +2 -1
  89. package/dist/commonjs/manifest/representation_index/static.d.ts +1 -1
  90. package/dist/commonjs/manifest/representation_index/static.js +2 -2
  91. package/dist/commonjs/manifest/representation_index/types.d.ts +4 -4
  92. package/dist/commonjs/parsers/manifest/dash/common/indexes/base.d.ts +6 -1
  93. package/dist/commonjs/parsers/manifest/dash/common/indexes/base.js +4 -3
  94. package/dist/commonjs/parsers/manifest/dash/common/indexes/get_segments_from_timeline.d.ts +5 -2
  95. package/dist/commonjs/parsers/manifest/dash/common/indexes/get_segments_from_timeline.js +15 -4
  96. package/dist/commonjs/parsers/manifest/dash/common/indexes/index.d.ts +5 -5
  97. package/dist/commonjs/parsers/manifest/dash/common/indexes/list.d.ts +1 -1
  98. package/dist/commonjs/parsers/manifest/dash/common/indexes/list.js +2 -2
  99. package/dist/commonjs/parsers/manifest/dash/common/indexes/template.d.ts +12 -5
  100. package/dist/commonjs/parsers/manifest/dash/common/indexes/template.js +42 -29
  101. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/index.d.ts +2 -1
  102. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts +99 -6
  103. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +250 -51
  104. package/dist/commonjs/parsers/manifest/dash/common/manifest_bounds_calculator.d.ts +40 -17
  105. package/dist/commonjs/parsers/manifest/dash/common/manifest_bounds_calculator.js +38 -18
  106. package/dist/commonjs/parsers/manifest/dash/common/parse_adaptation_sets.js +13 -10
  107. package/dist/commonjs/parsers/manifest/dash/common/parse_mpd.js +27 -14
  108. package/dist/commonjs/parsers/manifest/dash/common/parse_periods.d.ts +1 -1
  109. package/dist/commonjs/parsers/manifest/dash/common/parse_periods.js +17 -18
  110. package/dist/commonjs/parsers/manifest/dash/common/parse_representation_index.d.ts +19 -6
  111. package/dist/commonjs/parsers/manifest/dash/common/parse_representation_index.js +21 -8
  112. package/dist/commonjs/parsers/manifest/dash/common/parse_representations.js +7 -3
  113. package/dist/commonjs/parsers/manifest/local/representation_index.d.ts +1 -1
  114. package/dist/commonjs/parsers/manifest/local/representation_index.js +3 -3
  115. package/dist/commonjs/parsers/manifest/metaplaylist/representation_index.d.ts +1 -1
  116. package/dist/commonjs/parsers/manifest/metaplaylist/representation_index.js +2 -2
  117. package/dist/commonjs/parsers/manifest/smooth/representation_index.d.ts +5 -5
  118. package/dist/commonjs/parsers/manifest/smooth/representation_index.js +25 -9
  119. package/dist/commonjs/parsers/manifest/utils/index_helpers.js +1 -1
  120. package/dist/commonjs/parsers/texttracks/ttml/html/apply_line_height.js +2 -1
  121. package/dist/commonjs/public_types.d.ts +107 -36
  122. package/dist/commonjs/transports/dash/init_segment_loader.js +10 -5
  123. package/dist/commonjs/transports/dash/manifest_parser.js +5 -2
  124. package/dist/commonjs/transports/dash/segment_loader.js +2 -1
  125. package/dist/commonjs/transports/dash/text_loader.js +2 -0
  126. package/dist/commonjs/transports/metaplaylist/manifest_loader.js +2 -1
  127. package/dist/commonjs/transports/metaplaylist/pipelines.js +4 -1
  128. package/dist/commonjs/transports/smooth/pipelines.js +4 -2
  129. package/dist/commonjs/transports/smooth/segment_loader.js +2 -1
  130. package/dist/commonjs/transports/types.d.ts +12 -0
  131. package/dist/commonjs/transports/utils/generate_manifest_loader.js +6 -3
  132. package/dist/commonjs/utils/request/fetch.d.ts +6 -0
  133. package/dist/commonjs/utils/request/fetch.js +29 -8
  134. package/dist/commonjs/utils/request/xhr.d.ts +11 -5
  135. package/dist/commonjs/utils/request/xhr.js +29 -8
  136. package/dist/es2017/compat/is_codec_supported.js +22 -1
  137. package/dist/es2017/config.d.ts +2 -1
  138. package/dist/es2017/core/adaptive/adaptive_representation_selector.d.ts +2 -19
  139. package/dist/es2017/core/adaptive/adaptive_representation_selector.js +2 -2
  140. package/dist/es2017/core/adaptive/network_analyzer.js +3 -3
  141. package/dist/es2017/core/api/debug/buffer_graph.js +2 -6
  142. package/dist/es2017/core/api/debug/modules/general_info.js +17 -10
  143. package/dist/es2017/core/api/index.d.ts +1 -1
  144. package/dist/es2017/core/api/option_utils.d.ts +2 -0
  145. package/dist/es2017/core/api/option_utils.js +2 -3
  146. package/dist/es2017/core/api/playback_observer.d.ts +128 -8
  147. package/dist/es2017/core/api/playback_observer.js +217 -66
  148. package/dist/es2017/core/api/public_api.d.ts +9 -0
  149. package/dist/es2017/core/api/public_api.js +40 -15
  150. package/dist/es2017/core/api/utils.js +1 -1
  151. package/dist/es2017/core/decrypt/get_media_keys.js +2 -6
  152. package/dist/es2017/core/fetchers/manifest/manifest_fetcher.d.ts +6 -0
  153. package/dist/es2017/core/fetchers/manifest/manifest_fetcher.js +11 -3
  154. package/dist/es2017/core/fetchers/segment/segment_fetcher.d.ts +8 -1
  155. package/dist/es2017/core/fetchers/segment/segment_fetcher.js +8 -4
  156. package/dist/es2017/core/fetchers/segment/segment_fetcher_creator.d.ts +1 -0
  157. package/dist/es2017/core/fetchers/utils/schedule_request.js +1 -1
  158. package/dist/es2017/core/init/directfile_content_initializer.js +31 -8
  159. package/dist/es2017/core/init/media_source_content_initializer.d.ts +6 -0
  160. package/dist/es2017/core/init/media_source_content_initializer.js +34 -22
  161. package/dist/es2017/core/init/utils/content_time_boundaries_observer.d.ts +13 -12
  162. package/dist/es2017/core/init/utils/content_time_boundaries_observer.js +17 -17
  163. package/dist/es2017/core/init/utils/create_stream_playback_observer.d.ts +1 -5
  164. package/dist/es2017/core/init/utils/create_stream_playback_observer.js +16 -14
  165. package/dist/es2017/core/init/utils/get_initial_time.d.ts +17 -3
  166. package/dist/es2017/core/init/utils/get_initial_time.js +9 -7
  167. package/dist/es2017/core/init/utils/initial_seek_and_play.d.ts +9 -11
  168. package/dist/es2017/core/init/utils/initial_seek_and_play.js +120 -91
  169. package/dist/es2017/core/init/utils/rebuffering_controller.js +27 -70
  170. package/dist/es2017/core/init/utils/stream_events_emitter/stream_events_emitter.js +4 -2
  171. package/dist/es2017/core/segment_buffers/garbage_collector.js +1 -2
  172. package/dist/es2017/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.js +9 -2
  173. package/dist/es2017/core/segment_buffers/implementations/text/html/html_text_segment_buffer.js +1 -1
  174. package/dist/es2017/core/segment_buffers/implementations/text/native/native_text_segment_buffer.js +1 -1
  175. package/dist/es2017/core/segment_buffers/index.d.ts +2 -2
  176. package/dist/es2017/core/segment_buffers/inventory/index.d.ts +2 -2
  177. package/dist/es2017/core/segment_buffers/inventory/segment_inventory.d.ts +25 -8
  178. package/dist/es2017/core/segment_buffers/inventory/segment_inventory.js +19 -10
  179. package/dist/es2017/core/stream/adaptation/get_representations_switch_strategy.d.ts +2 -2
  180. package/dist/es2017/core/stream/adaptation/get_representations_switch_strategy.js +16 -9
  181. package/dist/es2017/core/stream/orchestrator/stream_orchestrator.js +16 -18
  182. package/dist/es2017/core/stream/period/period_stream.js +4 -7
  183. package/dist/es2017/core/stream/period/types.d.ts +2 -3
  184. package/dist/es2017/core/stream/period/utils/get_adaptation_switch_strategy.d.ts +4 -5
  185. package/dist/es2017/core/stream/period/utils/get_adaptation_switch_strategy.js +17 -13
  186. package/dist/es2017/core/stream/representation/representation_stream.js +3 -4
  187. package/dist/es2017/core/stream/representation/types.d.ts +2 -2
  188. package/dist/es2017/core/stream/representation/utils/append_segment_to_buffer.js +1 -2
  189. package/dist/es2017/core/stream/representation/utils/get_buffer_status.js +4 -4
  190. package/dist/es2017/core/stream/representation/utils/get_needed_segments.js +1 -1
  191. package/dist/es2017/default_config.d.ts +12 -16
  192. package/dist/es2017/default_config.js +21 -16
  193. package/dist/es2017/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +3 -1
  194. package/dist/es2017/experimental/tools/createMetaplaylist/get_duration_from_manifest.js +2 -0
  195. package/dist/es2017/manifest/adaptation.js +2 -1
  196. package/dist/es2017/manifest/representation_index/static.d.ts +1 -1
  197. package/dist/es2017/manifest/representation_index/static.js +2 -2
  198. package/dist/es2017/manifest/representation_index/types.d.ts +4 -4
  199. package/dist/es2017/parsers/manifest/dash/common/indexes/base.d.ts +6 -1
  200. package/dist/es2017/parsers/manifest/dash/common/indexes/base.js +4 -3
  201. package/dist/es2017/parsers/manifest/dash/common/indexes/get_segments_from_timeline.d.ts +5 -2
  202. package/dist/es2017/parsers/manifest/dash/common/indexes/get_segments_from_timeline.js +15 -4
  203. package/dist/es2017/parsers/manifest/dash/common/indexes/index.d.ts +5 -5
  204. package/dist/es2017/parsers/manifest/dash/common/indexes/list.d.ts +1 -1
  205. package/dist/es2017/parsers/manifest/dash/common/indexes/list.js +2 -2
  206. package/dist/es2017/parsers/manifest/dash/common/indexes/template.d.ts +12 -5
  207. package/dist/es2017/parsers/manifest/dash/common/indexes/template.js +40 -27
  208. package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/index.d.ts +2 -1
  209. package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts +99 -6
  210. package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +246 -51
  211. package/dist/es2017/parsers/manifest/dash/common/manifest_bounds_calculator.d.ts +40 -17
  212. package/dist/es2017/parsers/manifest/dash/common/manifest_bounds_calculator.js +38 -18
  213. package/dist/es2017/parsers/manifest/dash/common/parse_adaptation_sets.js +11 -8
  214. package/dist/es2017/parsers/manifest/dash/common/parse_mpd.js +27 -13
  215. package/dist/es2017/parsers/manifest/dash/common/parse_periods.d.ts +1 -1
  216. package/dist/es2017/parsers/manifest/dash/common/parse_periods.js +13 -16
  217. package/dist/es2017/parsers/manifest/dash/common/parse_representation_index.d.ts +19 -6
  218. package/dist/es2017/parsers/manifest/dash/common/parse_representation_index.js +10 -8
  219. package/dist/es2017/parsers/manifest/dash/common/parse_representations.js +7 -3
  220. package/dist/es2017/parsers/manifest/local/representation_index.d.ts +1 -1
  221. package/dist/es2017/parsers/manifest/local/representation_index.js +3 -3
  222. package/dist/es2017/parsers/manifest/metaplaylist/representation_index.d.ts +1 -1
  223. package/dist/es2017/parsers/manifest/metaplaylist/representation_index.js +2 -2
  224. package/dist/es2017/parsers/manifest/smooth/representation_index.d.ts +5 -5
  225. package/dist/es2017/parsers/manifest/smooth/representation_index.js +25 -9
  226. package/dist/es2017/parsers/manifest/utils/index_helpers.js +1 -1
  227. package/dist/es2017/parsers/texttracks/ttml/html/apply_line_height.js +2 -1
  228. package/dist/es2017/public_types.d.ts +107 -36
  229. package/dist/es2017/transports/dash/init_segment_loader.js +5 -0
  230. package/dist/es2017/transports/dash/manifest_parser.js +3 -0
  231. package/dist/es2017/transports/dash/segment_loader.js +1 -0
  232. package/dist/es2017/transports/dash/text_loader.js +2 -0
  233. package/dist/es2017/transports/metaplaylist/manifest_loader.js +1 -0
  234. package/dist/es2017/transports/metaplaylist/pipelines.js +4 -1
  235. package/dist/es2017/transports/smooth/pipelines.js +2 -0
  236. package/dist/es2017/transports/smooth/segment_loader.js +1 -0
  237. package/dist/es2017/transports/types.d.ts +12 -0
  238. package/dist/es2017/transports/utils/generate_manifest_loader.js +3 -0
  239. package/dist/es2017/utils/request/fetch.d.ts +6 -0
  240. package/dist/es2017/utils/request/fetch.js +29 -8
  241. package/dist/es2017/utils/request/xhr.d.ts +11 -5
  242. package/dist/es2017/utils/request/xhr.js +30 -9
  243. package/dist/mpd-parser.wasm +0 -0
  244. package/dist/rx-player.js +1335 -812
  245. package/dist/rx-player.min.js +1 -1
  246. package/package.json +7 -4
  247. package/scripts/canal-release.patch +78 -0
  248. package/scripts/make-dev-releases +65 -0
  249. package/scripts/update-version +7 -0
  250. package/sonar-project.properties +1 -1
  251. package/src/compat/is_codec_supported.ts +23 -1
  252. package/src/core/adaptive/adaptive_representation_selector.ts +4 -21
  253. package/src/core/adaptive/network_analyzer.ts +3 -3
  254. package/src/core/api/debug/buffer_graph.ts +2 -5
  255. package/src/core/api/debug/modules/general_info.ts +15 -10
  256. package/src/core/api/index.ts +1 -0
  257. package/src/core/api/option_utils.ts +3 -3
  258. package/src/core/api/playback_observer.ts +327 -107
  259. package/src/core/api/public_api.ts +42 -14
  260. package/src/core/api/utils.ts +3 -1
  261. package/src/core/decrypt/get_media_keys.ts +2 -8
  262. package/src/core/fetchers/manifest/manifest_fetcher.ts +21 -3
  263. package/src/core/fetchers/segment/segment_fetcher.ts +19 -5
  264. package/src/core/fetchers/segment/segment_fetcher_creator.ts +1 -0
  265. package/src/core/fetchers/utils/schedule_request.ts +1 -1
  266. package/src/core/init/directfile_content_initializer.ts +31 -15
  267. package/src/core/init/media_source_content_initializer.ts +40 -27
  268. package/src/core/init/utils/content_time_boundaries_observer.ts +24 -23
  269. package/src/core/init/utils/create_stream_playback_observer.ts +19 -20
  270. package/src/core/init/utils/get_initial_time.ts +25 -12
  271. package/src/core/init/utils/initial_seek_and_play.ts +140 -108
  272. package/src/core/init/utils/rebuffering_controller.ts +32 -77
  273. package/src/core/init/utils/stream_events_emitter/stream_events_emitter.ts +5 -2
  274. package/src/core/segment_buffers/garbage_collector.ts +1 -1
  275. package/src/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.ts +10 -2
  276. package/src/core/segment_buffers/implementations/text/html/html_text_segment_buffer.ts +1 -1
  277. package/src/core/segment_buffers/implementations/text/native/native_text_segment_buffer.ts +1 -1
  278. package/src/core/segment_buffers/index.ts +2 -0
  279. package/src/core/segment_buffers/inventory/index.ts +2 -0
  280. package/src/core/segment_buffers/inventory/segment_inventory.ts +49 -17
  281. package/src/core/stream/adaptation/get_representations_switch_strategy.ts +21 -12
  282. package/src/core/stream/orchestrator/stream_orchestrator.ts +14 -19
  283. package/src/core/stream/period/period_stream.ts +7 -8
  284. package/src/core/stream/period/types.ts +2 -3
  285. package/src/core/stream/period/utils/get_adaptation_switch_strategy.ts +21 -15
  286. package/src/core/stream/representation/representation_stream.ts +3 -5
  287. package/src/core/stream/representation/types.ts +2 -2
  288. package/src/core/stream/representation/utils/append_segment_to_buffer.ts +1 -1
  289. package/src/core/stream/representation/utils/get_buffer_status.ts +5 -4
  290. package/src/core/stream/representation/utils/get_needed_segments.ts +2 -2
  291. package/src/default_config.ts +22 -17
  292. package/src/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.ts +3 -1
  293. package/src/experimental/tools/createMetaplaylist/get_duration_from_manifest.ts +2 -0
  294. package/src/manifest/adaptation.ts +2 -1
  295. package/src/manifest/representation_index/static.ts +2 -2
  296. package/src/manifest/representation_index/types.ts +4 -4
  297. package/src/parsers/manifest/dash/common/__tests__/manifest_bounds_calculator.test.ts +182 -36
  298. package/src/parsers/manifest/dash/common/indexes/base.ts +12 -4
  299. package/src/parsers/manifest/dash/common/indexes/get_segments_from_timeline.ts +19 -5
  300. package/src/parsers/manifest/dash/common/indexes/index.ts +16 -4
  301. package/src/parsers/manifest/dash/common/indexes/list.ts +2 -2
  302. package/src/parsers/manifest/dash/common/indexes/template.ts +52 -31
  303. package/src/parsers/manifest/dash/common/indexes/timeline/index.ts +4 -1
  304. package/src/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.ts +366 -60
  305. package/src/parsers/manifest/dash/common/manifest_bounds_calculator.ts +63 -25
  306. package/src/parsers/manifest/dash/common/parse_adaptation_sets.ts +10 -4
  307. package/src/parsers/manifest/dash/common/parse_mpd.ts +28 -15
  308. package/src/parsers/manifest/dash/common/parse_periods.ts +12 -17
  309. package/src/parsers/manifest/dash/common/parse_representation_index.ts +50 -26
  310. package/src/parsers/manifest/dash/common/parse_representations.ts +9 -3
  311. package/src/parsers/manifest/local/representation_index.ts +3 -3
  312. package/src/parsers/manifest/metaplaylist/representation_index.ts +2 -2
  313. package/src/parsers/manifest/smooth/representation_index.ts +23 -9
  314. package/src/parsers/manifest/utils/__tests__/get_first_time_from_adaptations.test.ts +1 -1
  315. package/src/parsers/manifest/utils/__tests__/get_last_time_from_adaptation.test.ts +1 -1
  316. package/src/parsers/manifest/utils/index_helpers.ts +1 -1
  317. package/src/parsers/texttracks/ttml/html/apply_line_height.ts +3 -1
  318. package/src/public_types.ts +108 -36
  319. package/src/transports/dash/init_segment_loader.ts +5 -0
  320. package/src/transports/dash/manifest_parser.ts +6 -0
  321. package/src/transports/dash/segment_loader.ts +1 -0
  322. package/src/transports/dash/text_loader.ts +2 -0
  323. package/src/transports/metaplaylist/manifest_loader.ts +1 -0
  324. package/src/transports/metaplaylist/pipelines.ts +4 -1
  325. package/src/transports/smooth/pipelines.ts +2 -0
  326. package/src/transports/smooth/segment_loader.ts +1 -0
  327. package/src/transports/types.ts +12 -0
  328. package/src/transports/utils/generate_manifest_loader.ts +3 -0
  329. package/src/utils/request/fetch.ts +35 -8
  330. package/src/utils/request/xhr.ts +45 -14
  331. package/dist/commonjs/parsers/manifest/utils/is_segment_still_available.d.ts +0 -29
  332. package/dist/commonjs/parsers/manifest/utils/is_segment_still_available.js +0 -54
  333. package/dist/es2017/parsers/manifest/utils/is_segment_still_available.d.ts +0 -29
  334. package/dist/es2017/parsers/manifest/utils/is_segment_still_available.js +0 -51
  335. package/src/parsers/manifest/utils/is_segment_still_available.ts +0 -58
  336. package/src/typings/object-assign.d.ts +0 -48
@@ -134,7 +134,7 @@ function PeriodStream(_a, callbacks, parentCancelSignal) {
134
134
  adaptationRef.onUpdate(function (choice) {
135
135
  // As an IIFE to profit from async/await while respecting onUpdate's signature
136
136
  (function () { return __awaiter(_this, void 0, void 0, function () {
137
- var streamCanceller, segmentBufferStatus, periodEnd, DELTA_POSITION_AFTER_RELOAD, relativePosAfterSwitch, adaptation, representations, readyState, segmentBuffer, playbackInfos, strategy, _a, _b, _c, start, end, e_1_1;
137
+ var streamCanceller, segmentBufferStatus, periodEnd, DELTA_POSITION_AFTER_RELOAD, relativePosAfterSwitch, adaptation, representations, segmentBuffer, strategy, _a, _b, _c, start, end, e_1_1;
138
138
  var e_1, _d;
139
139
  var _e;
140
140
  return __generator(this, function (_f) {
@@ -235,10 +235,8 @@ function PeriodStream(_a, callbacks, parentCancelSignal) {
235
235
  if (streamCanceller.isUsed()) {
236
236
  return [2 /*return*/]; // Previous call has provoken cancellation by side-effect
237
237
  }
238
- readyState = playbackObserver.getReadyState();
239
238
  segmentBuffer = createOrReuseSegmentBuffer(segmentBuffersStore, bufferType, adaptation, options);
240
- playbackInfos = { currentTime: playbackObserver.getCurrentTime(), readyState: readyState };
241
- strategy = (0, get_adaptation_switch_strategy_1.default)(segmentBuffer, period, adaptation, choice.switchingMode, playbackInfos, options);
239
+ strategy = (0, get_adaptation_switch_strategy_1.default)(segmentBuffer, period, adaptation, choice.switchingMode, playbackObserver, options);
242
240
  if (strategy.type === "needs-reload") {
243
241
  return [2 /*return*/, askForMediaSourceReload(relativePosAfterSwitch, true, streamCanceller.signal)];
244
242
  }
@@ -415,7 +413,7 @@ function createAdaptationStreamPlaybackObserver(initialPlaybackObserver, segment
415
413
  function constructAdaptationStreamPlaybackObservation() {
416
414
  var baseObservation = observationRef.getValue();
417
415
  var buffered = segmentBuffer.getBufferedRanges();
418
- var bufferGap = (0, ranges_1.getLeftSizeOfBufferedTimeRange)(buffered, baseObservation.position.last);
416
+ var bufferGap = (0, ranges_1.getLeftSizeOfBufferedTimeRange)(buffered, baseObservation.position.getWanted());
419
417
  return (0, object_assign_1.default)({}, baseObservation, { bufferGap: bufferGap });
420
418
  }
421
419
  function emitAdaptationStreamPlaybackObservation() {
@@ -443,12 +441,11 @@ function createEmptyAdaptationStream(playbackObserver, wantedBufferAhead, buffer
443
441
  function sendStatus() {
444
442
  var observation = playbackObserver.getReference().getValue();
445
443
  var wba = wantedBufferAhead.getValue();
446
- var position = observation.position.last;
444
+ var position = observation.position.getWanted();
447
445
  if (period.end !== undefined && position + wba >= period.end) {
448
446
  log_1.default.debug("Stream: full \"empty\" AdaptationStream", bufferType);
449
447
  hasFinishedLoading = true;
450
448
  }
451
- callbacks.streamStatusUpdate({ period: period, bufferType: bufferType, position: position, imminentDiscontinuity: null,
452
- isEmptyStream: true, hasFinishedLoading: hasFinishedLoading, neededSegments: [] });
449
+ callbacks.streamStatusUpdate({ period: period, bufferType: bufferType, imminentDiscontinuity: null, position: position, isEmptyStream: true, hasFinishedLoading: hasFinishedLoading, neededSegments: [] });
453
450
  }
454
451
  }
@@ -3,11 +3,10 @@ import SharedReference, { IReadOnlySharedReference } from "../../../utils/refere
3
3
  import { CancellationSignal } from "../../../utils/task_canceller";
4
4
  import WeakMapMemory from "../../../utils/weak_map_memory";
5
5
  import { IRepresentationEstimator } from "../../adaptive";
6
- import { IReadOnlyPlaybackObserver } from "../../api";
6
+ import { IObservationPosition, IReadOnlyPlaybackObserver } from "../../api";
7
7
  import { SegmentFetcherCreator } from "../../fetchers";
8
8
  import SegmentBuffersStore, { IBufferType, ITextTrackSegmentBufferOptions, SegmentBuffer } from "../../segment_buffers";
9
9
  import { IAdaptationChoice, IAdaptationStreamCallbacks, IAdaptationStreamOptions, IPausedPlaybackObservation } from "../adaptation";
10
- import { IPositionPlaybackObservation } from "../representation";
11
10
  /** Callbacks called by the `AdaptationStream` on various events. */
12
11
  export interface IPeriodStreamCallbacks extends IAdaptationStreamCallbacks {
13
12
  /**
@@ -65,7 +64,7 @@ export interface IPeriodStreamPlaybackObservation {
65
64
  * Information on the current media position in seconds at the time of the
66
65
  * Observation.
67
66
  */
68
- position: IPositionPlaybackObservation;
67
+ position: IObservationPosition;
69
68
  /** `duration` property of the HTMLMediaElement. */
70
69
  duration: number;
71
70
  /** `readyState` property of the HTMLMediaElement. */
@@ -14,8 +14,10 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { Adaptation, Period } from "../../../../manifest";
17
+ import { IReadOnlyPlaybackObserver } from "../../../api";
17
18
  import { SegmentBuffer } from "../../../segment_buffers";
18
19
  import { ITrackSwitchingMode } from "../../adaptation";
20
+ import { IPeriodStreamPlaybackObservation } from "../types";
19
21
  export type IAdaptationSwitchStrategy =
20
22
  /** Do nothing special. */
21
23
  {
@@ -59,10 +61,7 @@ export interface IAdaptationSwitchOptions {
59
61
  * @param {Object} segmentBuffer
60
62
  * @param {Object} period
61
63
  * @param {Object} adaptation
62
- * @param {Object} playbackInfo
64
+ * @param {Object} playbackObserver
63
65
  * @returns {Object}
64
66
  */
65
- export default function getAdaptationSwitchStrategy(segmentBuffer: SegmentBuffer, period: Period, adaptation: Adaptation, switchingMode: ITrackSwitchingMode, playbackInfo: {
66
- currentTime: number;
67
- readyState: number;
68
- }, options: IAdaptationSwitchOptions): IAdaptationSwitchStrategy;
67
+ export default function getAdaptationSwitchStrategy(segmentBuffer: SegmentBuffer, period: Period, adaptation: Adaptation, switchingMode: ITrackSwitchingMode, playbackObserver: IReadOnlyPlaybackObserver<IPeriodStreamPlaybackObservation>, options: IAdaptationSwitchOptions): IAdaptationSwitchStrategy;
@@ -25,10 +25,10 @@ var segment_buffers_1 = require("../../../segment_buffers");
25
25
  * @param {Object} segmentBuffer
26
26
  * @param {Object} period
27
27
  * @param {Object} adaptation
28
- * @param {Object} playbackInfo
28
+ * @param {Object} playbackObserver
29
29
  * @returns {Object}
30
30
  */
31
- function getAdaptationSwitchStrategy(segmentBuffer, period, adaptation, switchingMode, playbackInfo, options) {
31
+ function getAdaptationSwitchStrategy(segmentBuffer, period, adaptation, switchingMode, playbackObserver, options) {
32
32
  if (segmentBuffer.codec !== undefined &&
33
33
  options.onCodecSwitch === "reload" &&
34
34
  !hasCompatibleCodec(adaptation, segmentBuffer.codec)) {
@@ -64,16 +64,20 @@ function getAdaptationSwitchStrategy(segmentBuffer, period, adaptation, switchin
64
64
  if (unwantedRange.length === 0) {
65
65
  return { type: "continue", value: undefined };
66
66
  }
67
- var currentTime = playbackInfo.currentTime;
68
- if (switchingMode === "reload" &&
69
- // We're playing the current Period
70
- (0, ranges_1.isTimeInRange)({ start: start, end: end }, currentTime) &&
71
- // There is data for the current position or the codecs are differents
72
- (playbackInfo.readyState > 1 || !adaptation.getPlayableRepresentations()
73
- .some(function (rep) { var _a; return (0, are_codecs_compatible_1.default)(rep.getMimeTypeString(), (_a = segmentBuffer.codec) !== null && _a !== void 0 ? _a : ""); })) &&
74
- // We're not playing the current wanted video Adaptation
75
- !(0, ranges_1.isTimeInRanges)(adaptationInBuffer, currentTime)) {
76
- return { type: "needs-reload", value: undefined };
67
+ var currentTime = playbackObserver.getCurrentTime();
68
+ var readyState = playbackObserver.getReadyState();
69
+ if (switchingMode === "reload" && readyState > 1) {
70
+ var lastObservation = playbackObserver.getReference().getValue();
71
+ if (lastObservation.position.isAwaitingFuturePosition()) {
72
+ // We are not at the position we want to reach (e.g. initial seek, tizen
73
+ // seek-back...), just reload as checks here would be too complex
74
+ return { type: "needs-reload", value: undefined };
75
+ }
76
+ else if ((0, ranges_1.isTimeInRange)({ start: start, end: end }, currentTime) &&
77
+ // We're not playing the current wanted video Adaptation
78
+ !(0, ranges_1.isTimeInRanges)(adaptationInBuffer, currentTime)) {
79
+ return { type: "needs-reload", value: undefined };
80
+ }
77
81
  }
78
82
  // From here, clean-up data from the previous Adaptation, if one
79
83
  var shouldCleanAll = switchingMode === "direct";
@@ -144,7 +148,7 @@ function hasCompatibleCodec(adaptation, segmentBufferCodec) {
144
148
  /**
145
149
  * Returns buffered ranges of what we know correspond to the given `adaptation`
146
150
  * in the SegmentBuffer.
147
- * @param {Object} segmentBuffer
151
+ * @param {Array.<Object>} inventory
148
152
  * @param {Object} period
149
153
  * @param {Object} adaptation
150
154
  * @returns {Array.<Object>}
@@ -197,12 +197,11 @@ function RepresentationStream(_a, callbacks, parentCancelSignal) {
197
197
  * issues at the current time, calling the right callbacks if necessary.
198
198
  */
199
199
  function checkStatus() {
200
- var _a, _b;
201
200
  if (segmentsLoadingCanceller.isUsed()) {
202
201
  return; // Stop all buffer status checking if load operations are stopped
203
202
  }
204
203
  var observation = playbackObserver.getReference().getValue();
205
- var initialWantedTime = (_a = observation.position.pending) !== null && _a !== void 0 ? _a : observation.position.last;
204
+ var initialWantedTime = observation.position.getWanted();
206
205
  var status = (0, get_buffer_status_1.default)(content, initialWantedTime, playbackObserver, fastSwitchThreshold.getValue(), bufferGoal.getValue(), maxBufferSize.getValue(), segmentBuffer);
207
206
  var neededSegments = status.neededSegments;
208
207
  var neededInitSegment = null;
@@ -216,7 +215,7 @@ function RepresentationStream(_a, callbacks, parentCancelSignal) {
216
215
  "initialization segment");
217
216
  }
218
217
  else {
219
- var wantedStart = (_b = observation.position.pending) !== null && _b !== void 0 ? _b : observation.position.last;
218
+ var wantedStart = observation.position.getWanted();
220
219
  neededInitSegment = { segment: initSegmentState.segment,
221
220
  priority: (0, get_segment_priority_1.default)(period.start, wantedStart) };
222
221
  }
@@ -266,7 +265,7 @@ function RepresentationStream(_a, callbacks, parentCancelSignal) {
266
265
  return;
267
266
  }
268
267
  }
269
- callbacks.streamStatusUpdate({ period: period, position: observation.position.last, bufferType: bufferType, imminentDiscontinuity: status.imminentDiscontinuity,
268
+ callbacks.streamStatusUpdate({ period: period, position: observation.position.getWanted(), bufferType: bufferType, imminentDiscontinuity: status.imminentDiscontinuity,
270
269
  isEmptyStream: false,
271
270
  hasFinishedLoading: status.hasFinishedLoading,
272
271
  neededSegments: status.neededSegments });
@@ -2,7 +2,7 @@ import Manifest, { Adaptation, ISegment, Period, Representation } from "../../..
2
2
  import { IEMSG } from "../../../parsers/containers/isobmff";
3
3
  import { IAudioRepresentationsSwitchingMode, IPlayerError, IVideoRepresentationsSwitchingMode } from "../../../public_types";
4
4
  import { IReadOnlySharedReference } from "../../../utils/reference";
5
- import { IReadOnlyPlaybackObserver } from "../../api";
5
+ import { IObservationPosition, IReadOnlyPlaybackObserver } from "../../api";
6
6
  import { IContentProtection } from "../../decrypt";
7
7
  import { IPrioritizedSegmentFetcher } from "../../fetchers";
8
8
  import { IBufferType, SegmentBuffer } from "../../segment_buffers";
@@ -163,7 +163,7 @@ export interface IRepresentationStreamPlaybackObservation {
163
163
  * Information on the current media position in seconds at the time of a
164
164
  * Playback Observation.
165
165
  */
166
- position: IPositionPlaybackObservation;
166
+ position: IObservationPosition;
167
167
  }
168
168
  /** Position-related information linked to an emitted Playback observation. */
169
169
  export interface IPositionPlaybackObservation {
@@ -68,19 +68,18 @@ var force_garbage_collection_1 = require("./force_garbage_collection");
68
68
  * @returns {Promise}
69
69
  */
70
70
  function appendSegmentToBuffer(playbackObserver, segmentBuffer, dataInfos, cancellationSignal) {
71
- var _a;
72
71
  return __awaiter(this, void 0, void 0, function () {
73
72
  var appendError_1, reason, position, currentPos, err2_1, reason;
74
- return __generator(this, function (_b) {
75
- switch (_b.label) {
73
+ return __generator(this, function (_a) {
74
+ switch (_a.label) {
76
75
  case 0:
77
- _b.trys.push([0, 2, , 8]);
76
+ _a.trys.push([0, 2, , 8]);
78
77
  return [4 /*yield*/, segmentBuffer.pushChunk(dataInfos, cancellationSignal)];
79
78
  case 1:
80
- _b.sent();
79
+ _a.sent();
81
80
  return [3 /*break*/, 8];
82
81
  case 2:
83
- appendError_1 = _b.sent();
82
+ appendError_1 = _a.sent();
84
83
  if (cancellationSignal.isCancelled() && appendError_1 instanceof task_canceller_1.CancellationError) {
85
84
  throw appendError_1;
86
85
  }
@@ -92,19 +91,19 @@ function appendSegmentToBuffer(playbackObserver, segmentBuffer, dataInfos, cance
92
91
  throw new errors_1.MediaError("BUFFER_APPEND_ERROR", reason, { adaptations: [dataInfos.inventoryInfos.adaptation] });
93
92
  }
94
93
  position = playbackObserver.getReference().getValue().position;
95
- currentPos = (_a = position.pending) !== null && _a !== void 0 ? _a : position.last;
96
- _b.label = 3;
94
+ currentPos = position.getWanted();
95
+ _a.label = 3;
97
96
  case 3:
98
- _b.trys.push([3, 6, , 7]);
97
+ _a.trys.push([3, 6, , 7]);
99
98
  return [4 /*yield*/, (0, force_garbage_collection_1.default)(currentPos, segmentBuffer, cancellationSignal)];
100
99
  case 4:
101
- _b.sent();
100
+ _a.sent();
102
101
  return [4 /*yield*/, segmentBuffer.pushChunk(dataInfos, cancellationSignal)];
103
102
  case 5:
104
- _b.sent();
103
+ _a.sent();
105
104
  return [3 /*break*/, 7];
106
105
  case 6:
107
- err2_1 = _b.sent();
106
+ err2_1 = _a.sent();
108
107
  reason = err2_1 instanceof Error ? err2_1.toString() :
109
108
  "Could not clean the buffer";
110
109
  throw new errors_1.MediaError("BUFFER_FULL_ERROR", reason, { adaptations: [dataInfos.inventoryInfos.adaptation] });
@@ -96,7 +96,7 @@ function getBufferStatus(content, initialWantedTime, playbackObserver, fastSwitc
96
96
  * needed segments for this Representation until the end of the Period.
97
97
  */
98
98
  var hasFinishedLoading = representation.index.isInitialized() &&
99
- representation.index.isFinished() &&
99
+ !representation.index.isStillAwaitingFutureSegments() &&
100
100
  neededRange.hasReachedPeriodEnd &&
101
101
  prioritizedNeededSegments.length === 0 &&
102
102
  segmentsOnHold.length === 0;
@@ -147,7 +147,7 @@ function getRangeOfNeededSegments(content, initialWantedTime, bufferGoal) {
147
147
  segment_buffers_1.default.isNative(content.adaptation.type) &&
148
148
  initialWantedTime >= lastIndexPosition &&
149
149
  representationIndex.isInitialized() &&
150
- representationIndex.isFinished() &&
150
+ !representationIndex.isStillAwaitingFutureSegments() &&
151
151
  isPeriodTheCurrentAndLastOne(manifest, period, initialWantedTime)) {
152
152
  wantedStartPosition = lastIndexPosition - 1;
153
153
  }
@@ -157,7 +157,7 @@ function getRangeOfNeededSegments(content, initialWantedTime, bufferGoal) {
157
157
  var wantedEndPosition = wantedStartPosition + bufferGoal;
158
158
  var hasReachedPeriodEnd;
159
159
  if (!representation.index.isInitialized() ||
160
- !representation.index.isFinished() ||
160
+ representation.index.isStillAwaitingFutureSegments() ||
161
161
  period.end === undefined) {
162
162
  hasReachedPeriodEnd = false;
163
163
  }
@@ -212,7 +212,7 @@ function getPlayableBufferedSegments(neededRange, segmentInventory) {
212
212
  for (var i = segmentInventory.length - 1; i >= 0; i--) {
213
213
  var eltInventory = segmentInventory[i];
214
214
  var representation = eltInventory.infos.representation;
215
- if (!eltInventory.partiallyPushed &&
215
+ if (eltInventory.status === 1 /* ChunkStatus.Complete */ &&
216
216
  representation.decipherable !== false &&
217
217
  representation.isSupported) {
218
218
  var inventorySegment = eltInventory.infos.segment;
@@ -324,7 +324,7 @@ function doesEndSeemGarbageCollected(currentSeg, nextSeg, minimumEndTime) {
324
324
  }
325
325
  if (minimumEndTime > currentSeg.bufferedEnd &&
326
326
  currentSeg.end - currentSeg.bufferedEnd > MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT) {
327
- log_1.default.info("Stream: The end of the wanted segment has been garbage collected", currentSeg.start, currentSeg.bufferedStart);
327
+ log_1.default.info("Stream: The end of the wanted segment has been garbage collected", currentSeg.end, currentSeg.bufferedEnd);
328
328
  return true;
329
329
  }
330
330
  return false;
@@ -21,6 +21,11 @@ declare const DEFAULT_CONFIG: {
21
21
  * @type {Number}
22
22
  */
23
23
  DEFAULT_REQUEST_TIMEOUT: number;
24
+ /**
25
+ * Default connection time after which a request will timeout, in ms.
26
+ * @type {Number}
27
+ */
28
+ DEFAULT_CONNECTION_TIMEOUT: number;
24
29
  /**
25
30
  * Can be either:
26
31
  * - "native": Subtitles are all displayed in a <track> element
@@ -141,6 +146,13 @@ declare const DEFAULT_CONFIG: {
141
146
  * @type {Object}
142
147
  */
143
148
  MAXIMUM_MAX_BUFFER_AHEAD: Partial<Record<"audio" | "video" | "text", number>>;
149
+ /**
150
+ * Minimum possible buffer ahead for each type of buffer, to avoid Garbage
151
+ * Collecting too much data when it would have adverse effects.
152
+ * Equal to `0` if not defined here.
153
+ * @type {Object}
154
+ */
155
+ MINIMUM_MAX_BUFFER_AHEAD: Partial<Record<"audio" | "video" | "image" | "text", number>>;
144
156
  /**
145
157
  * Maximum possible buffer behind for each type of buffer, to avoid too much
146
158
  * memory usage when playing for a long time.
@@ -203,22 +215,6 @@ declare const DEFAULT_CONFIG: {
203
215
  * @type {Number}
204
216
  */
205
217
  BUFFER_DISCONTINUITY_THRESHOLD: number;
206
- /**
207
- * When encountering small discontinuities, the RxPlayer may want, in specific
208
- * conditions, ignore those and let the browser seek over them iself (this
209
- * allows for example to avoid conflicts when both the browser and the
210
- * RxPlayer want to seek at a different position, sometimes leading to a
211
- * seeking loop).
212
- * In this case, we however still want to seek it ourselves if the browser
213
- * doesn't take the opportunity soon enough.
214
- *
215
- * This value specifies a delay after which a discontinuity ignored by the
216
- * RxPlayer is finally considered.
217
- * We want to maintain high enough to be sure the browser will not seek yet
218
- * small enough so this (arguably rare) situation won't lead to too much
219
- * waiting time.
220
- */
221
- FORCE_DISCONTINUITY_SEEK_DELAY: number;
222
218
  /**
223
219
  * Ratio used to know if an already loaded segment should be re-buffered.
224
220
  * We re-load the given segment if the current one times that ratio is
@@ -23,6 +23,11 @@ var DEFAULT_CONFIG = {
23
23
  * @type {Number}
24
24
  */
25
25
  DEFAULT_REQUEST_TIMEOUT: 30 * 1000,
26
+ /**
27
+ * Default connection time after which a request will timeout, in ms.
28
+ * @type {Number}
29
+ */
30
+ DEFAULT_CONNECTION_TIMEOUT: 15 * 1000,
26
31
  /**
27
32
  * Can be either:
28
33
  * - "native": Subtitles are all displayed in a <track> element
@@ -146,6 +151,22 @@ var DEFAULT_CONFIG = {
146
151
  },
147
152
  /* eslint-enable @typescript-eslint/consistent-type-assertions */
148
153
  /* eslint-disable @typescript-eslint/consistent-type-assertions */
154
+ /**
155
+ * Minimum possible buffer ahead for each type of buffer, to avoid Garbage
156
+ * Collecting too much data when it would have adverse effects.
157
+ * Equal to `0` if not defined here.
158
+ * @type {Object}
159
+ */
160
+ MINIMUM_MAX_BUFFER_AHEAD: {
161
+ // Text segments are both much lighter on resources and might
162
+ // actually be much larger than other types of segments in terms
163
+ // of duration. Let's make an exception here by authorizing a
164
+ // larger text buffer ahead, to avoid unnecesarily reloading the
165
+ // same text track.
166
+ text: 2 * 60,
167
+ },
168
+ /* eslint-enable @typescript-eslint/consistent-type-assertions */
169
+ /* eslint-disable @typescript-eslint/consistent-type-assertions */
149
170
  /**
150
171
  * Maximum possible buffer behind for each type of buffer, to avoid too much
151
172
  * memory usage when playing for a long time.
@@ -211,22 +232,6 @@ var DEFAULT_CONFIG = {
211
232
  * @type {Number}
212
233
  */
213
234
  BUFFER_DISCONTINUITY_THRESHOLD: 0.2,
214
- /**
215
- * When encountering small discontinuities, the RxPlayer may want, in specific
216
- * conditions, ignore those and let the browser seek over them iself (this
217
- * allows for example to avoid conflicts when both the browser and the
218
- * RxPlayer want to seek at a different position, sometimes leading to a
219
- * seeking loop).
220
- * In this case, we however still want to seek it ourselves if the browser
221
- * doesn't take the opportunity soon enough.
222
- *
223
- * This value specifies a delay after which a discontinuity ignored by the
224
- * RxPlayer is finally considered.
225
- * We want to maintain high enough to be sure the browser will not seek yet
226
- * small enough so this (arguably rare) situation won't lead to too much
227
- * waiting time.
228
- */
229
- FORCE_DISCONTINUITY_SEEK_DELAY: 5000,
230
235
  /**
231
236
  * Ratio used to know if an already loaded segment should be re-buffered.
232
237
  * We re-load the given segment if the current one times that ratio is
@@ -181,7 +181,9 @@ var VideoThumbnailLoader = /** @class */ (function () {
181
181
  {}, { baseDelay: 0,
182
182
  maxDelay: 0,
183
183
  maxRetry: 0,
184
- requestTimeout: config_1.default.getCurrent().DEFAULT_REQUEST_TIMEOUT });
184
+ requestTimeout: config_1.default.getCurrent().DEFAULT_REQUEST_TIMEOUT,
185
+ connectionTimeout: config_1.default.getCurrent().DEFAULT_CONNECTION_TIMEOUT,
186
+ });
185
187
  var initSegment_1 = content.representation.index.getInitSegment();
186
188
  var initSegmentUniqueId_1 = initSegment_1 !== null ?
187
189
  content.representation.uniqueId :
@@ -112,6 +112,7 @@ function getDurationFromManifest(url, transport) {
112
112
  url: url,
113
113
  responseType: "document",
114
114
  timeout: config_1.default.getCurrent().DEFAULT_REQUEST_TIMEOUT,
115
+ connectionTimeout: config_1.default.getCurrent().DEFAULT_CONNECTION_TIMEOUT,
115
116
  // We won't cancel
116
117
  cancelSignal: new task_canceller_1.default().signal,
117
118
  })];
@@ -148,6 +149,7 @@ function getDurationFromManifest(url, transport) {
148
149
  url: url,
149
150
  responseType: "text",
150
151
  timeout: config_1.default.getCurrent().DEFAULT_REQUEST_TIMEOUT,
152
+ connectionTimeout: config_1.default.getCurrent().DEFAULT_CONNECTION_TIMEOUT,
151
153
  // We won't cancel
152
154
  cancelSignal: new task_canceller_1.default().signal,
153
155
  })];
@@ -82,7 +82,8 @@ var Adaptation = /** @class */ (function () {
82
82
  var reprObject = {
83
83
  id: representation.id,
84
84
  bitrate: representation.bitrate,
85
- codec: representation.codec,
85
+ codecs: representation.codec === undefined ? [] :
86
+ [representation.codec],
86
87
  height: representation.height,
87
88
  width: representation.width,
88
89
  frameRate: representation.frameRate,
@@ -89,7 +89,7 @@ export default class StaticRepresentationIndex implements IRepresentationIndex {
89
89
  /**
90
90
  * @returns {Boolean}
91
91
  */
92
- isFinished(): true;
92
+ isStillAwaitingFutureSegments(): false;
93
93
  /**
94
94
  * @returns {Boolean}
95
95
  */
@@ -117,8 +117,8 @@ var StaticRepresentationIndex = /** @class */ (function () {
117
117
  /**
118
118
  * @returns {Boolean}
119
119
  */
120
- StaticRepresentationIndex.prototype.isFinished = function () {
121
- return true;
120
+ StaticRepresentationIndex.prototype.isStillAwaitingFutureSegments = function () {
121
+ return false;
122
122
  };
123
123
  /**
124
124
  * @returns {Boolean}
@@ -304,7 +304,7 @@ export interface IRepresentationIndex {
304
304
  getLastAvailablePosition(): number | null | undefined;
305
305
  /**
306
306
  * Returns the ending time, in seconds, of the Representation once it is
307
- * "finished" (@see isFinished).
307
+ * "finished" (@see isStillAwaitingFutureSegments).
308
308
  * Should thus be equivalent to `getLastAvailablePosition` once finished.
309
309
  *
310
310
  * Returns `null` if nothing is in the index
@@ -352,13 +352,13 @@ export interface IRepresentationIndex {
352
352
  */
353
353
  checkDiscontinuity(time: number): number | null;
354
354
  /**
355
- * Returns `true` if the last segments in this index have already been
355
+ * Returns `false` if the last segments in this index have already been
356
356
  * generated so that we can freely go to the next period.
357
- * Returns `false` if the index is still waiting on future segments to be
357
+ * Returns `true` if the index is still waiting on future segments to be
358
358
  * generated.
359
359
  * @returns {boolean}
360
360
  */
361
- isFinished(): boolean;
361
+ isStillAwaitingFutureSegments(): boolean;
362
362
  /**
363
363
  * Returns `true` if this index has all the data it needs to give the list
364
364
  * of available segments.
@@ -17,6 +17,7 @@ import { IRepresentationIndex, ISegment } from "../../../../../manifest";
17
17
  import { ISegmentInformation } from "../../../../../transports";
18
18
  import { IEMSG } from "../../../../containers/isobmff";
19
19
  import { IIndexSegment } from "../../../utils/index_helpers";
20
+ import ManifestBoundsCalculator from "../manifest_bounds_calculator";
20
21
  /**
21
22
  * Index property defined for a SegmentBase RepresentationIndex
22
23
  * This object contains every property needed to generate an ISegment for a
@@ -108,6 +109,8 @@ export interface IBaseIndexContextArgument {
108
109
  representationId?: string | undefined;
109
110
  /** Bitrate of the Representation concerned. */
110
111
  representationBitrate?: number | undefined;
112
+ /** Allows to obtain the minimum and maximum positions of a content. */
113
+ manifestBoundsCalculator: ManifestBoundsCalculator;
111
114
  isEMSGWhitelisted: (inbandEvent: IEMSG) => boolean;
112
115
  }
113
116
  export default class BaseRepresentationIndex implements IRepresentationIndex {
@@ -124,6 +127,8 @@ export default class BaseRepresentationIndex implements IRepresentationIndex {
124
127
  private _scaledPeriodStart;
125
128
  /** Absolute end of the period, timescaled and converted to index time. */
126
129
  private _scaledPeriodEnd;
130
+ /** Allows to obtain the minimum and maximum positions of a content. */
131
+ private _manifestBoundsCalculator;
127
132
  private _isEMSGWhitelisted;
128
133
  /**
129
134
  * @param {Object} index
@@ -205,7 +210,7 @@ export default class BaseRepresentationIndex implements IRepresentationIndex {
205
210
  * should become available in the future.
206
211
  * @returns {Boolean}
207
212
  */
208
- isFinished(): true;
213
+ isStillAwaitingFutureSegments(): false;
209
214
  /**
210
215
  * No segment in a `BaseRepresentationIndex` are known initially.
211
216
  * It is only defined generally in an "index segment" that will thus need to
@@ -80,6 +80,7 @@ var BaseRepresentationIndex = /** @class */ (function () {
80
80
  this._index = { indexRange: index.indexRange, indexTimeOffset: indexTimeOffset, initialization: { url: initializationUrl, range: range }, segmentUrlTemplate: segmentUrlTemplate, startNumber: index.startNumber,
81
81
  endNumber: index.endNumber,
82
82
  timeline: (_c = index.timeline) !== null && _c !== void 0 ? _c : [], timescale: timescale };
83
+ this._manifestBoundsCalculator = context.manifestBoundsCalculator;
83
84
  this._scaledPeriodStart = (0, index_helpers_1.toIndexTime)(periodStart, this._index);
84
85
  this._scaledPeriodEnd = periodEnd == null ? undefined :
85
86
  (0, index_helpers_1.toIndexTime)(periodEnd, this._index);
@@ -108,7 +109,7 @@ var BaseRepresentationIndex = /** @class */ (function () {
108
109
  * @returns {Array.<Object>}
109
110
  */
110
111
  BaseRepresentationIndex.prototype.getSegments = function (from, dur) {
111
- return (0, get_segments_from_timeline_1.default)(this._index, from, dur, this._isEMSGWhitelisted, this._scaledPeriodEnd);
112
+ return (0, get_segments_from_timeline_1.default)(this._index, from, dur, this._manifestBoundsCalculator, this._scaledPeriodEnd, this._isEMSGWhitelisted);
112
113
  };
113
114
  /**
114
115
  * Returns false as no Segment-Base based index should need to be refreshed.
@@ -192,8 +193,8 @@ var BaseRepresentationIndex = /** @class */ (function () {
192
193
  * should become available in the future.
193
194
  * @returns {Boolean}
194
195
  */
195
- BaseRepresentationIndex.prototype.isFinished = function () {
196
- return true;
196
+ BaseRepresentationIndex.prototype.isStillAwaitingFutureSegments = function () {
197
+ return false;
197
198
  };
198
199
  /**
199
200
  * No segment in a `BaseRepresentationIndex` are known initially.
@@ -16,21 +16,24 @@
16
16
  import { ISegment } from "../../../../../manifest";
17
17
  import { IEMSG } from "../../../../containers/isobmff";
18
18
  import { IIndexSegment } from "../../../utils/index_helpers";
19
+ import ManifestBoundsCalculator from "../manifest_bounds_calculator";
19
20
  /**
20
21
  * Get a list of Segments for the time range wanted.
21
22
  * @param {Object} index - index object, constructed by parsing the manifest.
22
23
  * @param {number} from - starting timestamp wanted, in seconds
23
24
  * @param {number} durationWanted - duration wanted, in seconds
25
+ * @param {Object} manifestBoundsCalculator
26
+ * @param {number|undefined} scaledPeriodEnd
24
27
  * @param {function} isEMSGWhitelisted
25
- * @param {number|undefined} maximumTime
26
28
  * @returns {Array.<Object>}
27
29
  */
28
30
  export default function getSegmentsFromTimeline(index: {
29
31
  availabilityTimeComplete?: boolean | undefined;
32
+ availabilityTimeOffset?: number | undefined;
30
33
  segmentUrlTemplate: string | null;
31
34
  startNumber?: number | undefined;
32
35
  endNumber?: number | undefined;
33
36
  timeline: IIndexSegment[];
34
37
  timescale: number;
35
38
  indexTimeOffset: number;
36
- }, from: number, durationWanted: number, isEMSGWhitelisted: (inbandEvent: IEMSG) => boolean, maximumTime?: number): ISegment[];
39
+ }, from: number, durationWanted: number, manifestBoundsCalculator: ManifestBoundsCalculator, scaledPeriodEnd: number | undefined, isEMSGWhitelisted: (inbandEvent: IEMSG) => boolean): ISegment[];
@@ -36,13 +36,17 @@ function getWantedRepeatIndex(segmentStartTime, segmentDuration, wantedTime) {
36
36
  * @param {Object} index - index object, constructed by parsing the manifest.
37
37
  * @param {number} from - starting timestamp wanted, in seconds
38
38
  * @param {number} durationWanted - duration wanted, in seconds
39
+ * @param {Object} manifestBoundsCalculator
40
+ * @param {number|undefined} scaledPeriodEnd
39
41
  * @param {function} isEMSGWhitelisted
40
- * @param {number|undefined} maximumTime
41
42
  * @returns {Array.<Object>}
42
43
  */
43
- function getSegmentsFromTimeline(index, from, durationWanted, isEMSGWhitelisted, maximumTime) {
44
+ function getSegmentsFromTimeline(index, from, durationWanted, manifestBoundsCalculator, scaledPeriodEnd, isEMSGWhitelisted) {
45
+ var _a;
46
+ var maximumTime = manifestBoundsCalculator.getEstimatedMaximumPosition((_a = index.availabilityTimeOffset) !== null && _a !== void 0 ? _a : 0);
47
+ var wantedMaximum = Math.min(from + durationWanted, maximumTime !== null && maximumTime !== void 0 ? maximumTime : Infinity);
44
48
  var scaledUp = (0, index_helpers_1.toIndexTime)(from, index);
45
- var scaledTo = (0, index_helpers_1.toIndexTime)(from + durationWanted, index);
49
+ var scaledTo = (0, index_helpers_1.toIndexTime)(wantedMaximum, index);
46
50
  var timeline = index.timeline, timescale = index.timescale, segmentUrlTemplate = index.segmentUrlTemplate, startNumber = index.startNumber, endNumber = index.endNumber;
47
51
  var currentNumber = startNumber !== null && startNumber !== void 0 ? startNumber : 1;
48
52
  var segments = [];
@@ -50,7 +54,14 @@ function getSegmentsFromTimeline(index, from, durationWanted, isEMSGWhitelisted,
50
54
  for (var i = 0; i < timelineLength; i++) {
51
55
  var timelineItem = timeline[i];
52
56
  var duration = timelineItem.duration, start = timelineItem.start, range = timelineItem.range;
53
- var repeat = (0, index_helpers_1.calculateRepeat)(timelineItem, timeline[i + 1], maximumTime);
57
+ var maxRepeatTime = void 0;
58
+ if (maximumTime === undefined) {
59
+ maxRepeatTime = scaledPeriodEnd;
60
+ }
61
+ else {
62
+ maxRepeatTime = Math.min(maximumTime * timescale, scaledPeriodEnd !== null && scaledPeriodEnd !== void 0 ? scaledPeriodEnd : Infinity);
63
+ }
64
+ var repeat = (0, index_helpers_1.calculateRepeat)(timelineItem, timeline[i + 1], maxRepeatTime);
54
65
  var complete = index.availabilityTimeComplete !== false ||
55
66
  i !== timelineLength - 1 &&
56
67
  repeat !== 0;