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
@@ -96,7 +96,9 @@ export default class SegmentInventory {
96
96
  log.debug(`SI: ${numberOfSegmentToDelete} segments GCed.`, bufferType);
97
97
  const removed = inventory.splice(indexBefore, numberOfSegmentToDelete);
98
98
  for (const seg of removed) {
99
- if (seg.bufferedStart === undefined && seg.bufferedEnd === undefined) {
99
+ if (seg.bufferedStart === undefined &&
100
+ seg.bufferedEnd === undefined &&
101
+ seg.status !== 2 /* ChunkStatus.Failed */) {
100
102
  this._bufferedHistory.addBufferedSegment(seg.infos, null);
101
103
  }
102
104
  }
@@ -154,7 +156,9 @@ export default class SegmentInventory {
154
156
  log.debug("SI: last segments have been GCed", bufferType, inventoryIndex, inventory.length);
155
157
  const removed = inventory.splice(inventoryIndex, inventory.length - inventoryIndex);
156
158
  for (const seg of removed) {
157
- if (seg.bufferedStart === undefined && seg.bufferedEnd === undefined) {
159
+ if (seg.bufferedStart === undefined &&
160
+ seg.bufferedEnd === undefined &&
161
+ seg.status !== 2 /* ChunkStatus.Failed */) {
158
162
  this._bufferedHistory.addBufferedSegment(seg.infos, null);
159
163
  }
160
164
  }
@@ -171,7 +175,7 @@ export default class SegmentInventory {
171
175
  * segment have been inserted, you should call the `completeSegment` method.
172
176
  * @param {Object} chunkInformation
173
177
  */
174
- insertChunk({ period, adaptation, representation, segment, chunkSize, start, end }) {
178
+ insertChunk({ period, adaptation, representation, segment, chunkSize, start, end }, succeed) {
175
179
  if (segment.isInit) {
176
180
  return;
177
181
  }
@@ -181,7 +185,8 @@ export default class SegmentInventory {
181
185
  return;
182
186
  }
183
187
  const inventory = this._inventory;
184
- const newSegment = { partiallyPushed: true,
188
+ const newSegment = { status: succeed ? 0 /* ChunkStatus.PartiallyPushed */ :
189
+ 2 /* ChunkStatus.Failed */,
185
190
  chunkSize,
186
191
  splitted: false,
187
192
  start,
@@ -379,7 +384,7 @@ export default class SegmentInventory {
379
384
  // newSegment : |====|
380
385
  // ===> : |--|====|-|
381
386
  log.warn("SI: Segment pushed is contained in a previous one", bufferType, start, end, segmentI.start, segmentI.end);
382
- const nextSegment = { partiallyPushed: segmentI.partiallyPushed,
387
+ const nextSegment = { status: segmentI.status,
383
388
  /**
384
389
  * Note: this sadly means we're doing as if
385
390
  * that chunk is present two times.
@@ -537,7 +542,9 @@ export default class SegmentInventory {
537
542
  this._inventory.splice(firstI + 1, length);
538
543
  i -= length;
539
544
  }
540
- this._inventory[firstI].partiallyPushed = false;
545
+ if (this._inventory[firstI].status === 0 /* ChunkStatus.PartiallyPushed */) {
546
+ this._inventory[firstI].status = 1 /* ChunkStatus.Complete */;
547
+ }
541
548
  this._inventory[firstI].chunkSize = segmentSize;
542
549
  this._inventory[firstI].end = lastEnd;
543
550
  this._inventory[firstI].bufferedEnd = lastBufferedEnd;
@@ -552,8 +559,10 @@ export default class SegmentInventory {
552
559
  this.synchronizeBuffered(newBuffered);
553
560
  for (const seg of resSegments) {
554
561
  if (seg.bufferedStart !== undefined && seg.bufferedEnd !== undefined) {
555
- this._bufferedHistory.addBufferedSegment(seg.infos, { start: seg.bufferedStart,
556
- end: seg.bufferedEnd });
562
+ if (seg.status !== 2 /* ChunkStatus.Failed */) {
563
+ this._bufferedHistory.addBufferedSegment(seg.infos, { start: seg.bufferedStart,
564
+ end: seg.bufferedEnd });
565
+ }
557
566
  }
558
567
  else {
559
568
  log.debug("SI: buffered range not known after sync. Skipping history.", seg.start, seg.end);
@@ -596,7 +605,7 @@ export default class SegmentInventory {
596
605
  */
597
606
  function bufferedStartLooksCoherent(thisSegment) {
598
607
  if (thisSegment.bufferedStart === undefined ||
599
- thisSegment.partiallyPushed) {
608
+ thisSegment.status !== 1 /* ChunkStatus.Complete */) {
600
609
  return false;
601
610
  }
602
611
  const { start, end } = thisSegment;
@@ -617,7 +626,7 @@ function bufferedStartLooksCoherent(thisSegment) {
617
626
  */
618
627
  function bufferedEndLooksCoherent(thisSegment) {
619
628
  if (thisSegment.bufferedEnd === undefined ||
620
- thisSegment.partiallyPushed) {
629
+ thisSegment.status !== 1 /* ChunkStatus.Complete */) {
621
630
  return false;
622
631
  }
623
632
  const { start, end } = thisSegment;
@@ -16,8 +16,8 @@
16
16
  import { Adaptation, Period } from "../../../manifest";
17
17
  import { IReadOnlyPlaybackObserver } from "../../api";
18
18
  import { SegmentBuffer } from "../../segment_buffers";
19
- import { IRepresentationsChoice } from "../representation";
20
- export default function getRepresentationsSwitchingStrategy(period: Period, adaptation: Adaptation, settings: IRepresentationsChoice, segmentBuffer: SegmentBuffer, playbackObserver: IReadOnlyPlaybackObserver<unknown>): IRepresentationSwitchStrategy;
19
+ import { IRepresentationStreamPlaybackObservation, IRepresentationsChoice } from "../representation";
20
+ export default function getRepresentationsSwitchingStrategy(period: Period, adaptation: Adaptation, settings: IRepresentationsChoice, segmentBuffer: SegmentBuffer, playbackObserver: IReadOnlyPlaybackObserver<IRepresentationStreamPlaybackObservation>): IRepresentationSwitchStrategy;
21
21
  export type IRepresentationSwitchStrategy = {
22
22
  type: "continue";
23
23
  value: undefined;
@@ -45,16 +45,22 @@ export default function getRepresentationsSwitchingStrategy(period, adaptation,
45
45
  if (unwantedRange.length === 0) {
46
46
  return { type: "continue", value: undefined };
47
47
  }
48
- const currentTime = playbackObserver.getCurrentTime();
49
48
  const readyState = playbackObserver.getReadyState();
50
- if (settings.switchingMode === "reload" &&
51
- // We're playing the current Period
52
- isTimeInRange({ start, end }, currentTime) &&
53
- // There is data for the current position
54
- readyState > 1 &&
55
- // We're not playing the current wanted video Adaptation
56
- !isTimeInRanges(rangesWithReps, currentTime)) {
57
- return { type: "needs-reload", value: undefined };
49
+ if (settings.switchingMode === "reload" && readyState > 1) {
50
+ const lastObservation = playbackObserver.getReference().getValue();
51
+ if (lastObservation.position.isAwaitingFuturePosition()) {
52
+ // We are not at the position we want to reach (e.g. initial seek, tizen
53
+ // seek-back...), just reload as checks here would be too complex
54
+ return { type: "needs-reload", value: undefined };
55
+ }
56
+ else {
57
+ const currentTime = playbackObserver.getCurrentTime();
58
+ if (isTimeInRange({ start, end }, currentTime) &&
59
+ // We're not playing the current wanted video Adaptation
60
+ !isTimeInRanges(rangesWithReps, currentTime)) {
61
+ return { type: "needs-reload", value: undefined };
62
+ }
63
+ }
58
64
  }
59
65
  // From here, clean-up data from the previous Adaptation, if one
60
66
  const shouldFlush = settings.switchingMode === "direct";
@@ -85,6 +91,7 @@ export default function getRepresentationsSwitchingStrategy(period, adaptation,
85
91
  if (paddingAfter == null) {
86
92
  paddingAfter = 0;
87
93
  }
94
+ const currentTime = playbackObserver.getCurrentTime();
88
95
  rangesToExclude.push({ start: currentTime - paddingBefore,
89
96
  end: currentTime + paddingAfter });
90
97
  }
@@ -69,22 +69,23 @@ import getTimeRangesForContent from "./get_time_ranges_for_content";
69
69
  export default function StreamOrchestrator(content, playbackObserver, representationEstimator, segmentBuffersStore, segmentFetcherCreator, options, callbacks, orchestratorCancelSignal) {
70
70
  const { manifest, initialPeriod } = content;
71
71
  const { maxBufferAhead, maxBufferBehind, wantedBufferAhead, maxVideoBufferSize } = options;
72
- const { MAXIMUM_MAX_BUFFER_AHEAD, MAXIMUM_MAX_BUFFER_BEHIND } = config.getCurrent();
72
+ const { MINIMUM_MAX_BUFFER_AHEAD, MAXIMUM_MAX_BUFFER_AHEAD, MAXIMUM_MAX_BUFFER_BEHIND } = config.getCurrent();
73
73
  // Keep track of a unique BufferGarbageCollector created per
74
74
  // SegmentBuffer.
75
75
  const garbageCollectors = new WeakMapMemory((segmentBuffer) => {
76
+ var _a, _b;
76
77
  const { bufferType } = segmentBuffer;
77
- const defaultMaxBehind = MAXIMUM_MAX_BUFFER_BEHIND[bufferType] != null ?
78
- MAXIMUM_MAX_BUFFER_BEHIND[bufferType] :
79
- Infinity;
80
- const defaultMaxAhead = MAXIMUM_MAX_BUFFER_AHEAD[bufferType] != null ?
81
- MAXIMUM_MAX_BUFFER_AHEAD[bufferType] :
82
- Infinity;
78
+ const defaultMaxBehind = (_a = MAXIMUM_MAX_BUFFER_BEHIND[bufferType]) !== null && _a !== void 0 ? _a : Infinity;
79
+ const maxAheadHigherBound = (_b = MAXIMUM_MAX_BUFFER_AHEAD[bufferType]) !== null && _b !== void 0 ? _b : Infinity;
83
80
  return (gcCancelSignal) => {
84
81
  BufferGarbageCollector({ segmentBuffer,
85
82
  playbackObserver,
86
83
  maxBufferBehind: createMappedReference(maxBufferBehind, (val) => Math.min(val, defaultMaxBehind), gcCancelSignal),
87
- maxBufferAhead: createMappedReference(maxBufferAhead, (val) => Math.min(val, defaultMaxAhead), gcCancelSignal) }, gcCancelSignal);
84
+ maxBufferAhead: createMappedReference(maxBufferAhead, (val) => {
85
+ var _a;
86
+ const lowerBound = Math.max(val, (_a = MINIMUM_MAX_BUFFER_AHEAD[bufferType]) !== null && _a !== void 0 ? _a : 0);
87
+ return Math.min(lowerBound, maxAheadHigherBound);
88
+ }, gcCancelSignal) }, gcCancelSignal);
88
89
  };
89
90
  });
90
91
  // Create automatically the right `PeriodStream` for every possible types
@@ -117,8 +118,8 @@ export default function StreamOrchestrator(content, playbackObserver, representa
117
118
  // Restart the current Stream when the wanted time is in another period
118
119
  // than the ones already considered
119
120
  playbackObserver.listen(({ position }) => {
120
- var _a, _b;
121
- const time = (_a = position.pending) !== null && _a !== void 0 ? _a : position.last;
121
+ var _a;
122
+ const time = position.getWanted();
122
123
  if (!enableOutOfBoundsCheck || !isOutOfPeriodList(time)) {
123
124
  return;
124
125
  }
@@ -132,7 +133,7 @@ export default function StreamOrchestrator(content, playbackObserver, representa
132
133
  currentCanceller.cancel();
133
134
  currentCanceller = new TaskCanceller();
134
135
  currentCanceller.linkToSignal(orchestratorCancelSignal);
135
- const nextPeriod = (_b = manifest.getPeriodForTime(time)) !== null && _b !== void 0 ? _b : manifest.getNextPeriod(time);
136
+ const nextPeriod = (_a = manifest.getPeriodForTime(time)) !== null && _a !== void 0 ? _a : manifest.getNextPeriod(time);
136
137
  if (nextPeriod === undefined) {
137
138
  log.warn("Stream: The wanted position is not found in the Manifest.");
138
139
  return;
@@ -266,7 +267,6 @@ export default function StreamOrchestrator(content, playbackObserver, representa
266
267
  // to reduce the risk of race conditions where the next observation
267
268
  // was going to be emitted synchronously.
268
269
  queueMicrotask(() => {
269
- var _a;
270
270
  if (orchestratorCancelSignal.isCancelled()) {
271
271
  return;
272
272
  }
@@ -284,7 +284,7 @@ export default function StreamOrchestrator(content, playbackObserver, representa
284
284
  return;
285
285
  }
286
286
  }
287
- const lastPosition = (_a = observation.position.pending) !== null && _a !== void 0 ? _a : observation.position.last;
287
+ const lastPosition = observation.position.getWanted();
288
288
  const newInitialPeriod = manifest.getPeriodForTime(lastPosition);
289
289
  if (newInitialPeriod == null) {
290
290
  callbacks.error(new MediaError("MEDIA_TIME_NOT_FOUND", "The wanted position is not found in the Manifest."));
@@ -338,10 +338,8 @@ export default function StreamOrchestrator(content, playbackObserver, representa
338
338
  // Stop current PeriodStream when the current position goes over the end of
339
339
  // that Period.
340
340
  playbackObserver.listen(({ position }, stopListeningObservations) => {
341
- var _a, _b;
342
- if (basePeriod.end !== undefined &&
343
- ((_a = position.pending) !== null && _a !== void 0 ? _a : position.last) >= basePeriod.end) {
344
- log.info("Stream: Destroying PeriodStream as the current playhead moved above it", bufferType, basePeriod.start, (_b = position.pending) !== null && _b !== void 0 ? _b : position.last, basePeriod.end);
341
+ if (basePeriod.end !== undefined && position.getWanted() >= basePeriod.end) {
342
+ log.info("Stream: Destroying PeriodStream as the current playhead moved above it", bufferType, basePeriod.start, position.getWanted(), basePeriod.end);
345
343
  stopListeningObservations();
346
344
  consecutivePeriodStreamCb.periodStreamCleared({ type: bufferType,
347
345
  manifest,
@@ -476,7 +474,7 @@ function needsFlushingAfterClean(observation, cleanedRanges) {
476
474
  if (cleanedRanges.length === 0) {
477
475
  return false;
478
476
  }
479
- const curPos = observation.position.last;
477
+ const curPos = observation.position.getPolled();
480
478
  // Based on the playback direction, we just check whether we may encounter
481
479
  // the corresponding ranges, without seeking or re-switching playback
482
480
  // direction which is expected to lead to a low-level flush anyway.
@@ -152,11 +152,8 @@ export default function PeriodStream({ bufferType, content, garbageCollectors, p
152
152
  if (streamCanceller.isUsed()) {
153
153
  return; // Previous call has provoken cancellation by side-effect
154
154
  }
155
- const readyState = playbackObserver.getReadyState();
156
155
  const segmentBuffer = createOrReuseSegmentBuffer(segmentBuffersStore, bufferType, adaptation, options);
157
- const playbackInfos = { currentTime: playbackObserver.getCurrentTime(),
158
- readyState };
159
- const strategy = getAdaptationSwitchStrategy(segmentBuffer, period, adaptation, choice.switchingMode, playbackInfos, options);
156
+ const strategy = getAdaptationSwitchStrategy(segmentBuffer, period, adaptation, choice.switchingMode, playbackObserver, options);
160
157
  if (strategy.type === "needs-reload") {
161
158
  return askForMediaSourceReload(relativePosAfterSwitch, true, streamCanceller.signal);
162
159
  }
@@ -315,7 +312,7 @@ function createAdaptationStreamPlaybackObserver(initialPlaybackObserver, segment
315
312
  function constructAdaptationStreamPlaybackObservation() {
316
313
  const baseObservation = observationRef.getValue();
317
314
  const buffered = segmentBuffer.getBufferedRanges();
318
- const bufferGap = getLeftSizeOfBufferedTimeRange(buffered, baseObservation.position.last);
315
+ const bufferGap = getLeftSizeOfBufferedTimeRange(buffered, baseObservation.position.getWanted());
319
316
  return objectAssign({}, baseObservation, { bufferGap });
320
317
  }
321
318
  function emitAdaptationStreamPlaybackObservation() {
@@ -343,15 +340,15 @@ function createEmptyAdaptationStream(playbackObserver, wantedBufferAhead, buffer
343
340
  function sendStatus() {
344
341
  const observation = playbackObserver.getReference().getValue();
345
342
  const wba = wantedBufferAhead.getValue();
346
- const position = observation.position.last;
343
+ const position = observation.position.getWanted();
347
344
  if (period.end !== undefined && position + wba >= period.end) {
348
345
  log.debug("Stream: full \"empty\" AdaptationStream", bufferType);
349
346
  hasFinishedLoading = true;
350
347
  }
351
348
  callbacks.streamStatusUpdate({ period,
352
349
  bufferType,
353
- position,
354
350
  imminentDiscontinuity: null,
351
+ position,
355
352
  isEmptyStream: true,
356
353
  hasFinishedLoading,
357
354
  neededSegments: [] });
@@ -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;
@@ -23,10 +23,10 @@ import { getFirstSegmentAfterPeriod, getLastSegmentBeforePeriod, } from "../../.
23
23
  * @param {Object} segmentBuffer
24
24
  * @param {Object} period
25
25
  * @param {Object} adaptation
26
- * @param {Object} playbackInfo
26
+ * @param {Object} playbackObserver
27
27
  * @returns {Object}
28
28
  */
29
- export default function getAdaptationSwitchStrategy(segmentBuffer, period, adaptation, switchingMode, playbackInfo, options) {
29
+ export default function getAdaptationSwitchStrategy(segmentBuffer, period, adaptation, switchingMode, playbackObserver, options) {
30
30
  if (segmentBuffer.codec !== undefined &&
31
31
  options.onCodecSwitch === "reload" &&
32
32
  !hasCompatibleCodec(adaptation, segmentBuffer.codec)) {
@@ -62,16 +62,20 @@ export default function getAdaptationSwitchStrategy(segmentBuffer, period, adapt
62
62
  if (unwantedRange.length === 0) {
63
63
  return { type: "continue", value: undefined };
64
64
  }
65
- const { currentTime } = playbackInfo;
66
- if (switchingMode === "reload" &&
67
- // We're playing the current Period
68
- isTimeInRange({ start, end }, currentTime) &&
69
- // There is data for the current position or the codecs are differents
70
- (playbackInfo.readyState > 1 || !adaptation.getPlayableRepresentations()
71
- .some(rep => { var _a; return areCodecsCompatible(rep.getMimeTypeString(), (_a = segmentBuffer.codec) !== null && _a !== void 0 ? _a : ""); })) &&
72
- // We're not playing the current wanted video Adaptation
73
- !isTimeInRanges(adaptationInBuffer, currentTime)) {
74
- return { type: "needs-reload", value: undefined };
65
+ const currentTime = playbackObserver.getCurrentTime();
66
+ const readyState = playbackObserver.getReadyState();
67
+ if (switchingMode === "reload" && readyState > 1) {
68
+ const lastObservation = playbackObserver.getReference().getValue();
69
+ if (lastObservation.position.isAwaitingFuturePosition()) {
70
+ // We are not at the position we want to reach (e.g. initial seek, tizen
71
+ // seek-back...), just reload as checks here would be too complex
72
+ return { type: "needs-reload", value: undefined };
73
+ }
74
+ else if (isTimeInRange({ start, end }, currentTime) &&
75
+ // We're not playing the current wanted video Adaptation
76
+ !isTimeInRanges(adaptationInBuffer, currentTime)) {
77
+ return { type: "needs-reload", value: undefined };
78
+ }
75
79
  }
76
80
  // From here, clean-up data from the previous Adaptation, if one
77
81
  const shouldCleanAll = switchingMode === "direct";
@@ -139,7 +143,7 @@ function hasCompatibleCodec(adaptation, segmentBufferCodec) {
139
143
  /**
140
144
  * Returns buffered ranges of what we know correspond to the given `adaptation`
141
145
  * in the SegmentBuffer.
142
- * @param {Object} segmentBuffer
146
+ * @param {Array.<Object>} inventory
143
147
  * @param {Object} period
144
148
  * @param {Object} adaptation
145
149
  * @returns {Array.<Object>}
@@ -183,12 +183,11 @@ export default function RepresentationStream({ content, options, playbackObserve
183
183
  * issues at the current time, calling the right callbacks if necessary.
184
184
  */
185
185
  function checkStatus() {
186
- var _a, _b;
187
186
  if (segmentsLoadingCanceller.isUsed()) {
188
187
  return; // Stop all buffer status checking if load operations are stopped
189
188
  }
190
189
  const observation = playbackObserver.getReference().getValue();
191
- const initialWantedTime = (_a = observation.position.pending) !== null && _a !== void 0 ? _a : observation.position.last;
190
+ const initialWantedTime = observation.position.getWanted();
192
191
  const status = getBufferStatus(content, initialWantedTime, playbackObserver, fastSwitchThreshold.getValue(), bufferGoal.getValue(), maxBufferSize.getValue(), segmentBuffer);
193
192
  const { neededSegments } = status;
194
193
  let neededInitSegment = null;
@@ -202,7 +201,7 @@ export default function RepresentationStream({ content, options, playbackObserve
202
201
  "initialization segment");
203
202
  }
204
203
  else {
205
- const wantedStart = (_b = observation.position.pending) !== null && _b !== void 0 ? _b : observation.position.last;
204
+ const wantedStart = observation.position.getWanted();
206
205
  neededInitSegment = { segment: initSegmentState.segment,
207
206
  priority: getSegmentPriority(period.start, wantedStart) };
208
207
  }
@@ -253,7 +252,7 @@ export default function RepresentationStream({ content, options, playbackObserve
253
252
  }
254
253
  }
255
254
  callbacks.streamStatusUpdate({ period,
256
- position: observation.position.last,
255
+ position: observation.position.getWanted(),
257
256
  bufferType,
258
257
  imminentDiscontinuity: status.imminentDiscontinuity,
259
258
  isEmptyStream: false,
@@ -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 {
@@ -30,7 +30,6 @@ import forceGarbageCollection from "./force_garbage_collection";
30
30
  * @returns {Promise}
31
31
  */
32
32
  export default async function appendSegmentToBuffer(playbackObserver, segmentBuffer, dataInfos, cancellationSignal) {
33
- var _a;
34
33
  try {
35
34
  await segmentBuffer.pushChunk(dataInfos, cancellationSignal);
36
35
  }
@@ -46,7 +45,7 @@ export default async function appendSegmentToBuffer(playbackObserver, segmentBuf
46
45
  throw new MediaError("BUFFER_APPEND_ERROR", reason, { adaptations: [dataInfos.inventoryInfos.adaptation] });
47
46
  }
48
47
  const { position } = playbackObserver.getReference().getValue();
49
- const currentPos = (_a = position.pending) !== null && _a !== void 0 ? _a : position.last;
48
+ const currentPos = position.getWanted();
50
49
  try {
51
50
  await forceGarbageCollection(currentPos, segmentBuffer, cancellationSignal);
52
51
  await segmentBuffer.pushChunk(dataInfos, cancellationSignal);
@@ -74,7 +74,7 @@ export default function getBufferStatus(content, initialWantedTime, playbackObse
74
74
  * needed segments for this Representation until the end of the Period.
75
75
  */
76
76
  const hasFinishedLoading = representation.index.isInitialized() &&
77
- representation.index.isFinished() &&
77
+ !representation.index.isStillAwaitingFutureSegments() &&
78
78
  neededRange.hasReachedPeriodEnd &&
79
79
  prioritizedNeededSegments.length === 0 &&
80
80
  segmentsOnHold.length === 0;
@@ -128,7 +128,7 @@ function getRangeOfNeededSegments(content, initialWantedTime, bufferGoal) {
128
128
  SegmentBuffersStore.isNative(content.adaptation.type) &&
129
129
  initialWantedTime >= lastIndexPosition &&
130
130
  representationIndex.isInitialized() &&
131
- representationIndex.isFinished() &&
131
+ !representationIndex.isStillAwaitingFutureSegments() &&
132
132
  isPeriodTheCurrentAndLastOne(manifest, period, initialWantedTime)) {
133
133
  wantedStartPosition = lastIndexPosition - 1;
134
134
  }
@@ -138,7 +138,7 @@ function getRangeOfNeededSegments(content, initialWantedTime, bufferGoal) {
138
138
  const wantedEndPosition = wantedStartPosition + bufferGoal;
139
139
  let hasReachedPeriodEnd;
140
140
  if (!representation.index.isInitialized() ||
141
- !representation.index.isFinished() ||
141
+ representation.index.isStillAwaitingFutureSegments() ||
142
142
  period.end === undefined) {
143
143
  hasReachedPeriodEnd = false;
144
144
  }
@@ -194,7 +194,7 @@ function getPlayableBufferedSegments(neededRange, segmentInventory) {
194
194
  for (let i = segmentInventory.length - 1; i >= 0; i--) {
195
195
  const eltInventory = segmentInventory[i];
196
196
  const { representation } = eltInventory.infos;
197
- if (!eltInventory.partiallyPushed &&
197
+ if (eltInventory.status === 1 /* ChunkStatus.Complete */ &&
198
198
  representation.decipherable !== false &&
199
199
  representation.isSupported) {
200
200
  const inventorySegment = eltInventory.infos.segment;
@@ -320,7 +320,7 @@ function doesEndSeemGarbageCollected(currentSeg, nextSeg, minimumEndTime) {
320
320
  }
321
321
  if (minimumEndTime > currentSeg.bufferedEnd &&
322
322
  currentSeg.end - currentSeg.bufferedEnd > MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT) {
323
- log.info("Stream: The end of the wanted segment has been garbage collected", currentSeg.start, currentSeg.bufferedStart);
323
+ log.info("Stream: The end of the wanted segment has been garbage collected", currentSeg.end, currentSeg.bufferedEnd);
324
324
  return true;
325
325
  }
326
326
  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
@@ -21,6 +21,11 @@ const DEFAULT_CONFIG = {
21
21
  * @type {Number}
22
22
  */
23
23
  DEFAULT_REQUEST_TIMEOUT: 30 * 1000,
24
+ /**
25
+ * Default connection time after which a request will timeout, in ms.
26
+ * @type {Number}
27
+ */
28
+ DEFAULT_CONNECTION_TIMEOUT: 15 * 1000,
24
29
  /**
25
30
  * Can be either:
26
31
  * - "native": Subtitles are all displayed in a <track> element
@@ -144,6 +149,22 @@ const DEFAULT_CONFIG = {
144
149
  },
145
150
  /* eslint-enable @typescript-eslint/consistent-type-assertions */
146
151
  /* eslint-disable @typescript-eslint/consistent-type-assertions */
152
+ /**
153
+ * Minimum possible buffer ahead for each type of buffer, to avoid Garbage
154
+ * Collecting too much data when it would have adverse effects.
155
+ * Equal to `0` if not defined here.
156
+ * @type {Object}
157
+ */
158
+ MINIMUM_MAX_BUFFER_AHEAD: {
159
+ // Text segments are both much lighter on resources and might
160
+ // actually be much larger than other types of segments in terms
161
+ // of duration. Let's make an exception here by authorizing a
162
+ // larger text buffer ahead, to avoid unnecesarily reloading the
163
+ // same text track.
164
+ text: 2 * 60,
165
+ },
166
+ /* eslint-enable @typescript-eslint/consistent-type-assertions */
167
+ /* eslint-disable @typescript-eslint/consistent-type-assertions */
147
168
  /**
148
169
  * Maximum possible buffer behind for each type of buffer, to avoid too much
149
170
  * memory usage when playing for a long time.
@@ -209,22 +230,6 @@ const DEFAULT_CONFIG = {
209
230
  * @type {Number}
210
231
  */
211
232
  BUFFER_DISCONTINUITY_THRESHOLD: 0.2,
212
- /**
213
- * When encountering small discontinuities, the RxPlayer may want, in specific
214
- * conditions, ignore those and let the browser seek over them iself (this
215
- * allows for example to avoid conflicts when both the browser and the
216
- * RxPlayer want to seek at a different position, sometimes leading to a
217
- * seeking loop).
218
- * In this case, we however still want to seek it ourselves if the browser
219
- * doesn't take the opportunity soon enough.
220
- *
221
- * This value specifies a delay after which a discontinuity ignored by the
222
- * RxPlayer is finally considered.
223
- * We want to maintain high enough to be sure the browser will not seek yet
224
- * small enough so this (arguably rare) situation won't lead to too much
225
- * waiting time.
226
- */
227
- FORCE_DISCONTINUITY_SEEK_DELAY: 5000,
228
233
  /**
229
234
  * Ratio used to know if an already loaded segment should be re-buffered.
230
235
  * We re-load the given segment if the current one times that ratio is
@@ -128,7 +128,9 @@ export default class VideoThumbnailLoader {
128
128
  {}, { baseDelay: 0,
129
129
  maxDelay: 0,
130
130
  maxRetry: 0,
131
- requestTimeout: config.getCurrent().DEFAULT_REQUEST_TIMEOUT });
131
+ requestTimeout: config.getCurrent().DEFAULT_REQUEST_TIMEOUT,
132
+ connectionTimeout: config.getCurrent().DEFAULT_CONNECTION_TIMEOUT,
133
+ });
132
134
  const initSegment = content.representation.index.getInitSegment();
133
135
  const initSegmentUniqueId = initSegment !== null ?
134
136
  content.representation.uniqueId :
@@ -69,6 +69,7 @@ async function getDurationFromManifest(url, transport) {
69
69
  url,
70
70
  responseType: "document",
71
71
  timeout: config.getCurrent().DEFAULT_REQUEST_TIMEOUT,
72
+ connectionTimeout: config.getCurrent().DEFAULT_CONNECTION_TIMEOUT,
72
73
  // We won't cancel
73
74
  cancelSignal: new TaskCanceller().signal,
74
75
  });
@@ -106,6 +107,7 @@ async function getDurationFromManifest(url, transport) {
106
107
  url,
107
108
  responseType: "text",
108
109
  timeout: config.getCurrent().DEFAULT_REQUEST_TIMEOUT,
110
+ connectionTimeout: config.getCurrent().DEFAULT_CONNECTION_TIMEOUT,
109
111
  // We won't cancel
110
112
  cancelSignal: new TaskCanceller().signal,
111
113
  });
@@ -78,7 +78,8 @@ export default class Adaptation {
78
78
  const reprObject = {
79
79
  id: representation.id,
80
80
  bitrate: representation.bitrate,
81
- codec: representation.codec,
81
+ codecs: representation.codec === undefined ? [] :
82
+ [representation.codec],
82
83
  height: representation.height,
83
84
  width: representation.width,
84
85
  frameRate: representation.frameRate,