rx-player 4.0.0-beta.1 → 4.0.0-beta.2

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 (169) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/CONTRIBUTING.md +48 -168
  3. package/FILES.md +40 -92
  4. package/VERSION +1 -1
  5. package/dist/_esm5.processed/compat/browser_detection.d.ts +3 -1
  6. package/dist/_esm5.processed/compat/browser_detection.js +7 -2
  7. package/dist/_esm5.processed/compat/eme/load_session.js +1 -1
  8. package/dist/_esm5.processed/compat/has_issues_with_high_media_source_duration.d.ts +21 -0
  9. package/dist/_esm5.processed/compat/has_issues_with_high_media_source_duration.js +26 -0
  10. package/dist/_esm5.processed/config.d.ts +2 -0
  11. package/dist/_esm5.processed/core/adaptive/adaptive_representation_selector.js +5 -4
  12. package/dist/_esm5.processed/core/adaptive/buffer_based_chooser.d.ts +18 -1
  13. package/dist/_esm5.processed/core/adaptive/buffer_based_chooser.js +106 -25
  14. package/dist/_esm5.processed/core/adaptive/guess_based_chooser.js +6 -6
  15. package/dist/_esm5.processed/core/adaptive/network_analyzer.js +8 -5
  16. package/dist/_esm5.processed/core/adaptive/utils/representation_score_calculator.d.ts +19 -1
  17. package/dist/_esm5.processed/core/adaptive/utils/representation_score_calculator.js +1 -1
  18. package/dist/_esm5.processed/core/api/debug/render.js +1 -1
  19. package/dist/_esm5.processed/core/api/playback_observer.js +1 -0
  20. package/dist/_esm5.processed/core/api/public_api.d.ts +54 -1
  21. package/dist/_esm5.processed/core/api/public_api.js +232 -35
  22. package/dist/_esm5.processed/core/api/track_management/media_element_tracks_store.js +10 -1
  23. package/dist/_esm5.processed/core/api/track_management/track_dispatcher.d.ts +13 -1
  24. package/dist/_esm5.processed/core/api/track_management/track_dispatcher.js +30 -15
  25. package/dist/_esm5.processed/core/api/track_management/tracks_store.d.ts +3 -1
  26. package/dist/_esm5.processed/core/api/track_management/tracks_store.js +67 -152
  27. package/dist/_esm5.processed/core/api/utils.d.ts +10 -0
  28. package/dist/_esm5.processed/core/api/utils.js +20 -0
  29. package/dist/_esm5.processed/core/decrypt/session_events_listener.js +7 -1
  30. package/dist/_esm5.processed/core/decrypt/utils/clean_old_loaded_sessions.js +2 -0
  31. package/dist/_esm5.processed/core/decrypt/utils/loaded_sessions_store.js +5 -1
  32. package/dist/_esm5.processed/core/init/directfile_content_initializer.js +1 -1
  33. package/dist/_esm5.processed/core/init/media_source_content_initializer.js +47 -10
  34. package/dist/_esm5.processed/core/init/types.d.ts +9 -1
  35. package/dist/_esm5.processed/core/init/utils/content_time_boundaries_observer.d.ts +28 -1
  36. package/dist/_esm5.processed/core/init/utils/content_time_boundaries_observer.js +22 -9
  37. package/dist/_esm5.processed/core/init/utils/media_source_duration_updater.d.ts +58 -0
  38. package/dist/_esm5.processed/core/init/utils/{media_duration_updater.js → media_source_duration_updater.js} +84 -87
  39. package/dist/_esm5.processed/core/init/utils/rebuffering_controller.d.ts +36 -2
  40. package/dist/_esm5.processed/core/init/utils/rebuffering_controller.js +82 -2
  41. package/dist/_esm5.processed/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.d.ts +18 -7
  42. package/dist/_esm5.processed/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.js +31 -40
  43. package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/html_text_segment_buffer.d.ts +8 -0
  44. package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/html_text_segment_buffer.js +12 -0
  45. package/dist/_esm5.processed/core/segment_buffers/implementations/text/native/native_text_segment_buffer.d.ts +8 -0
  46. package/dist/_esm5.processed/core/segment_buffers/implementations/text/native/native_text_segment_buffer.js +12 -0
  47. package/dist/_esm5.processed/core/segment_buffers/implementations/types.d.ts +11 -4
  48. package/dist/_esm5.processed/core/segment_buffers/index.d.ts +2 -2
  49. package/dist/_esm5.processed/core/stream/adaptation/utils/create_representation_estimator.d.ts +47 -0
  50. package/dist/_esm5.processed/core/stream/adaptation/utils/create_representation_estimator.js +70 -0
  51. package/dist/_esm5.processed/core/stream/orchestrator/stream_orchestrator.js +15 -8
  52. package/dist/_esm5.processed/core/stream/period/period_stream.js +1 -1
  53. package/dist/_esm5.processed/core/stream/representation/representation_stream.js +22 -13
  54. package/dist/_esm5.processed/core/stream/representation/utils/append_segment_to_buffer.d.ts +4 -2
  55. package/dist/_esm5.processed/core/stream/representation/utils/append_segment_to_buffer.js +2 -2
  56. package/dist/_esm5.processed/core/stream/representation/utils/push_init_segment.d.ts +3 -2
  57. package/dist/_esm5.processed/core/stream/representation/utils/push_init_segment.js +8 -8
  58. package/dist/_esm5.processed/core/stream/representation/utils/push_media_segment.d.ts +2 -2
  59. package/dist/_esm5.processed/core/stream/representation/utils/push_media_segment.js +2 -3
  60. package/dist/_esm5.processed/default_config.d.ts +25 -0
  61. package/dist/_esm5.processed/default_config.js +27 -2
  62. package/dist/_esm5.processed/errors/index.d.ts +2 -2
  63. package/dist/_esm5.processed/errors/media_error.d.ts +23 -1
  64. package/dist/_esm5.processed/errors/media_error.js +18 -5
  65. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/load_and_push_segment.d.ts +1 -1
  66. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/load_and_push_segment.js +8 -7
  67. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +17 -9
  68. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/index.js +0 -2
  69. package/dist/_esm5.processed/manifest/adaptation.d.ts +21 -2
  70. package/dist/_esm5.processed/manifest/adaptation.js +76 -1
  71. package/dist/_esm5.processed/manifest/manifest.js +1 -1
  72. package/dist/_esm5.processed/manifest/period.js +2 -2
  73. package/dist/_esm5.processed/manifest/representation.d.ts +33 -2
  74. package/dist/_esm5.processed/manifest/representation.js +21 -0
  75. package/dist/_esm5.processed/manifest/utils.js +1 -3
  76. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/parse_from_document.d.ts +1 -1
  77. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/parse_from_document.js +1 -1
  78. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/dash-wasm-parser.js +1 -0
  79. package/dist/_esm5.processed/public_types.d.ts +13 -3
  80. package/dist/_esm5.processed/tools/TextTrackRenderer/text_track_renderer.js +1 -1
  81. package/dist/_esm5.processed/transports/smooth/isobmff/create_boxes.d.ts +4 -6
  82. package/dist/_esm5.processed/transports/smooth/isobmff/create_boxes.js +4 -6
  83. package/dist/_esm5.processed/utils/is_null_or_undefined.d.ts +1 -1
  84. package/dist/_esm5.processed/utils/is_null_or_undefined.js +1 -1
  85. package/dist/mpd-parser.wasm +0 -0
  86. package/dist/rx-player.js +4709 -4218
  87. package/dist/rx-player.min.js +1 -1
  88. package/package.json +42 -36
  89. package/scripts/build/generate_build.js +1 -1
  90. package/scripts/fast_demo_build.js +4 -3
  91. package/scripts/generate_full_demo.js +1 -1
  92. package/sonar-project.properties +1 -1
  93. package/src/compat/browser_detection.ts +7 -1
  94. package/src/compat/eme/load_session.ts +1 -1
  95. package/src/compat/has_issues_with_high_media_source_duration.ts +27 -0
  96. package/src/core/adaptive/__tests__/buffer_based_chooser.test.ts +147 -48
  97. package/src/core/adaptive/adaptive_representation_selector.ts +7 -4
  98. package/src/core/adaptive/buffer_based_chooser.ts +144 -26
  99. package/src/core/adaptive/guess_based_chooser.ts +9 -8
  100. package/src/core/adaptive/network_analyzer.ts +9 -4
  101. package/src/core/adaptive/utils/representation_score_calculator.ts +22 -2
  102. package/src/core/api/debug/render.ts +1 -1
  103. package/src/core/api/playback_observer.ts +1 -0
  104. package/src/core/api/public_api.ts +277 -44
  105. package/src/core/api/track_management/media_element_tracks_store.ts +17 -8
  106. package/src/core/api/track_management/track_dispatcher.ts +37 -14
  107. package/src/core/api/track_management/tracks_store.ts +77 -167
  108. package/src/core/api/utils.ts +26 -0
  109. package/src/core/decrypt/session_events_listener.ts +6 -1
  110. package/src/core/decrypt/utils/clean_old_loaded_sessions.ts +2 -1
  111. package/src/core/decrypt/utils/loaded_sessions_store.ts +8 -1
  112. package/src/core/init/directfile_content_initializer.ts +1 -0
  113. package/src/core/init/media_source_content_initializer.ts +52 -9
  114. package/src/core/init/types.ts +9 -1
  115. package/src/core/init/utils/content_time_boundaries_observer.ts +46 -10
  116. package/src/core/init/utils/{media_duration_updater.ts → media_source_duration_updater.ts} +100 -112
  117. package/src/core/init/utils/rebuffering_controller.ts +114 -3
  118. package/src/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.ts +56 -55
  119. package/src/core/segment_buffers/implementations/text/html/html_text_segment_buffer.ts +16 -0
  120. package/src/core/segment_buffers/implementations/text/native/native_text_segment_buffer.ts +16 -0
  121. package/src/core/segment_buffers/implementations/types.ts +16 -4
  122. package/src/core/segment_buffers/index.ts +2 -0
  123. package/src/core/stream/adaptation/utils/create_representation_estimator.ts +114 -0
  124. package/src/core/stream/orchestrator/stream_orchestrator.ts +16 -8
  125. package/src/core/stream/period/period_stream.ts +2 -1
  126. package/src/core/stream/representation/representation_stream.ts +34 -22
  127. package/src/core/stream/representation/utils/append_segment_to_buffer.ts +8 -3
  128. package/src/core/stream/representation/utils/push_init_segment.ts +11 -6
  129. package/src/core/stream/representation/utils/push_media_segment.ts +3 -3
  130. package/src/default_config.ts +29 -2
  131. package/src/errors/__tests__/media_error.test.ts +6 -6
  132. package/src/errors/index.ts +4 -1
  133. package/src/errors/media_error.ts +67 -1
  134. package/src/experimental/tools/VideoThumbnailLoader/load_and_push_segment.ts +10 -7
  135. package/src/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.ts +17 -6
  136. package/src/experimental/tools/mediaCapabilitiesProber/index.ts +0 -4
  137. package/src/manifest/__tests__/manifest.test.ts +7 -7
  138. package/src/manifest/__tests__/period.test.ts +90 -45
  139. package/src/manifest/adaptation.ts +89 -1
  140. package/src/manifest/manifest.ts +1 -1
  141. package/src/manifest/period.ts +4 -2
  142. package/src/manifest/representation.ts +67 -1
  143. package/src/manifest/utils.ts +1 -3
  144. package/src/parsers/manifest/dash/js-parser/parse_from_document.ts +1 -1
  145. package/src/parsers/manifest/dash/wasm-parser/ts/dash-wasm-parser.ts +1 -0
  146. package/src/parsers/texttracks/ttml/parse_ttml.ts +1 -1
  147. package/src/public_types.ts +16 -1
  148. package/src/tools/TextTrackRenderer/text_track_renderer.ts +1 -1
  149. package/src/transports/smooth/isobmff/create_boxes.ts +4 -6
  150. package/src/typings/globals.d.ts +20 -20
  151. package/src/utils/is_null_or_undefined.ts +1 -1
  152. package/dist/_esm5.processed/core/init/utils/media_duration_updater.d.ts +0 -56
  153. package/scripts/doc-generator/construct_table_of_contents.js +0 -76
  154. package/scripts/doc-generator/convert_MD_to_HMTL.js +0 -26
  155. package/scripts/doc-generator/create_documentation.js +0 -331
  156. package/scripts/doc-generator/create_documentation_page.js +0 -209
  157. package/scripts/doc-generator/create_page.js +0 -210
  158. package/scripts/doc-generator/generate_header_html.js +0 -147
  159. package/scripts/doc-generator/generate_page_html.js +0 -115
  160. package/scripts/doc-generator/generate_page_list_html.js +0 -92
  161. package/scripts/doc-generator/generate_sidebar_html.js +0 -85
  162. package/scripts/doc-generator/get_search_data_for_content.js +0 -137
  163. package/scripts/doc-generator/index.js +0 -34
  164. package/scripts/doc-generator/parse_doc_configs.js +0 -327
  165. package/scripts/doc-generator/scripts/lunr.js +0 -10
  166. package/scripts/doc-generator/scripts/script.js +0 -451
  167. package/scripts/doc-generator/styles/code.css +0 -99
  168. package/scripts/doc-generator/styles/style.css +0 -835
  169. package/scripts/doc-generator/utils.js +0 -74
package/FILES.md CHANGED
@@ -1,44 +1,14 @@
1
- # File architecture ############################################################
1
+ # File architecture
2
2
 
3
3
  This page describes how the player files are organized. Each chapter go through
4
4
  a single directory or subdirectory, in alphabetical order.
5
5
 
6
6
 
7
- ## Table of Contents ###########################################################
8
-
9
- - [demo/: Demos of rx-player implementations](#demo)
10
- - [dist/: Player builds](#dist)
11
- - [doc/: Player documentation](#doc)
12
- - [scripts/: Tools and scripts](#scripts)
13
- - [src/: the source code](#src)
14
- - [src/compat/: The compatibility files](#src-compat)
15
- - [src/core/: The core files](#src-core)
16
- - [src/errors/: Error definitions](#src-errors)
17
- - [src/experimental/: Experimental features](#src-experimental)
18
- - [src/features/: Feature switching](#src-features)
19
- - [src/manifest/: The Manifest class](#src-manifest)
20
- - [src/transports/: The transport protocols](#src-transports)
21
- - [src/parsers/: The parsing files](#src-parsers)
22
- - [src/typings/: Typescript typings](#src-typings)
23
- - [src/utils/: The utils](#src-utils)
24
- - [src/core/: The core directory](#core)
25
- - [src/core/adaptive/: The adaptive bitrate code](#core-abr)
26
- - [src/core/api/: The API definition](#core-api)
27
- - [src/core/stream/: Load the right segments](#core-stream)
28
- - [src/core/decrypt/: Decryption management](#core-decrypt)
29
- - [src/core/fetchers/: The fetchers](#core-fetchers)
30
- - [src/core/segment_buffers/: The Media buffers](#core-sb)
31
- - [src/core/init/: Media streaming logic](#core-init)
32
- - [src/**/__tests__: the unit tests directories](#src-tests)
33
- - [tests/: the player's tests](#tests)
34
-
35
-
36
- <a name="demo"></a>
37
- ## The demo/ directory: Demos of rx-player implementations #####################
38
-
39
- Demonstration of functional codebases implementing the rx-player.
40
-
41
- At the time of writing, there are two demos:
7
+ ## `demo/`: Demo applications
8
+
9
+ The `demo/` directory contains demos of application using the RxPlayer.
10
+
11
+ At the time of writing, there are two distinct demos:
42
12
 
43
13
  - _full_: Demo with a graphic interface, written with the React library, to
44
14
  showcase what the player can do
@@ -48,36 +18,35 @@ At the time of writing, there are two demos:
48
18
  the displayed page.
49
19
 
50
20
 
51
- <a name="dist"></a>
52
- ## The dist/ directory: Player builds ##########################################
21
+ ## `dist/`: Builds
53
22
 
54
- Store the player builds of the last version released.
23
+ The `demo/` directory stores the player builds of the last version released.
55
24
 
56
- Contains two files: the minified (``rx-player.min.js``) and the non-minified
57
- files (``rx-player.js``). Both are automatically generated with scripts at every
58
- new release.
25
+ Contains the minified (``rx-player.min.js``) and the non-minified files
26
+ (``rx-player.js``). Both are automatically generated with scripts at every new
27
+ release.
59
28
 
60
29
  Two directories, namely ``_esm5.raw`` and ``_esm5.processed`` can also be
61
30
  generated in here if the right scripts are called.
62
31
  These allow to publish more modular codebases to npm.
63
32
 
64
33
 
65
- <a name="doc"></a>
66
- ## The doc/ directory: Player documentation ####################################
34
+ ## `doc/`: Documentation
67
35
 
68
- Documentation, mostly in markdown, of various subjects related to the rx-player:
36
+ The `doc/` directory contains the RxPlayer's documentation, mostly written in
37
+ markdown, on various subjects related to the rx-player:
69
38
  - API documentation
70
39
  - tutorials
71
40
  - list of deprecated APIs...
72
41
  - how to transition between RxPlayer versions
42
+ - how to contribute
73
43
  - etc.
74
44
 
75
45
 
76
- <a name="scripts"></a>
77
- ## The scripts/ directory: scripts #####################################
46
+ ## `scripts/`: Project-managing scripts
78
47
 
79
- Contains various scripts used to help the test and the management of the player
80
- code.
48
+ The `scripts/` directory contains various scripts used to help the test and the
49
+ management of the player code.
81
50
 
82
51
  For example:
83
52
  - generating one of the demo and starting the server to run it
@@ -86,16 +55,14 @@ For example:
86
55
  - generating the rx-player build before publishing on npm
87
56
 
88
57
 
89
- <a name="src"></a>
90
- ## The src/ directory: the source code #########################################
58
+ ## `src/`: The source code
91
59
 
92
- The src contains the entire source code of the rx-player.
60
+ The `src` directory contains the entire source code of the rx-player.
93
61
 
94
62
  It is subdivized into subdirectories which are defined here.
95
63
 
96
64
 
97
- <a name="src-compat"></a>
98
- ### src/compat/: The compatibility files #######################################
65
+ ### `src/compat/`: Compatibility files
99
66
 
100
67
  ``src/compat`` contains functions allowing to use browser APIs in a
101
68
  cross-browser manner.
@@ -110,8 +77,7 @@ Every functions needed in the rest of the code are exported in
110
77
  ``import { whatINeed } from "../compat";``)
111
78
 
112
79
 
113
- <a name="src-core"></a>
114
- ### src/core/: The core files ##################################################
80
+ ### `src/core/`: Core logic
115
81
 
116
82
  Defines the logic and behavior of the player, regardless of the browser and of
117
83
  the streaming technology used.
@@ -126,22 +92,19 @@ This directory contains other subdirectories which are listed in the next
126
92
  chapter.
127
93
 
128
94
 
129
- <a name="src-errors"></a>
130
- ### src/errors/: Error definitions #############################################
95
+ ### `src/errors/`: Error definitions
131
96
 
132
97
  Contains the definition of the error classes used in the rx-player and
133
98
  accessible through the API.
134
99
 
135
100
 
136
- <a name="src-experimental"></a>
137
- ### src/experimental/: Experimental features ###################################
101
+ ### `src/experimental/`: Experimental features
138
102
 
139
103
  You will find here experimental features. Those are tested features who might
140
104
  completely change their API in new player versions.
141
105
 
142
106
 
143
- <a name="src-features"></a>
144
- ### src/features/: Feature switching ###########################################
107
+ ### `src/features/`: Feature switching
145
108
 
146
109
  This manage activated or deactivated features (e.g. DASH, TTML subtitles
147
110
  parsing).
@@ -150,16 +113,14 @@ It exports an object defining the different activated features and provide utils
150
113
  to initialize and update them.
151
114
 
152
115
 
153
- <a name="src-manifest"></a>
154
- ### src/manifest/: The Manifest class ##########################################
116
+ ### `src/manifest/`: Manifest Object definition
155
117
 
156
118
  Defines a common `Manifest` class, regardless of the streaming technology (DASH,
157
119
  HSS...). This class is then used by the rest of the RxPlayer, to allow
158
120
  interaction with it without considering the underlying technology used.
159
121
 
160
122
 
161
- <a name="src-transports"></a>
162
- ### src/transports/: The transport protocols ###################################
123
+ ### `src/transports/`: Streaming protocols implementation
163
124
 
164
125
  Defines a common interface for multiple streaming technologies (DASH, HSS).
165
126
 
@@ -174,8 +135,7 @@ As in most of the code of the rx-player, everything used in the other parts of
174
135
  the code is exported in the index.js file at the root of this directory.
175
136
 
176
137
 
177
- <a name="src-parsers"></a>
178
- ### src/parsers/: The parsers ##################################################
138
+ ### `src/parsers/`: The parsers
179
139
 
180
140
  Functions to parse various formats into the same interface.
181
141
 
@@ -186,22 +146,19 @@ The parsed data being either:
186
146
  - image containers: BIF
187
147
 
188
148
 
189
- <a name="src-typings"></a>
190
- ### src/typings/: Typescript typings ###########################################
149
+ ### `src/typings/`: Typescript typings
191
150
 
192
151
  This directory contains only declaration files for TypeScript. It is
193
152
  automatically added as a `typeRoots` when the TypeScript code is transpiled.
194
153
 
195
154
 
196
- <a name="src-utils"></a>
197
- ### src/utils/: The utils ######################################################
155
+ ### `src/utils/`: Util functions
198
156
 
199
157
  This directory contains general helpers which are used in different parts of the
200
158
  rx-player code.
201
159
 
202
160
 
203
- <a name="core"></a>
204
- ## The src/core/ directory #####################################################
161
+ ## Inside `src/core/`
205
162
 
206
163
  As written in the previous chapter, this is the "core" of the player, where the
207
164
  logic is defined.
@@ -209,8 +166,7 @@ logic is defined.
209
166
  As this directory is versatile and complicated, it also deserves its own chapter.
210
167
 
211
168
 
212
- <a name="core-abr"></a>
213
- ### src/core/adaptive/: The adaptive bitrate code ##############################
169
+ ### `src/core/adaptive/`: Adaptive BitRate logic
214
170
 
215
171
  Defines functions which manages the adaptive streaming part of the player.
216
172
 
@@ -225,29 +181,25 @@ This allows to isolate this complex part and facilitate future refactoring and
225
181
  improvements.
226
182
 
227
183
 
228
- <a name="core-api"></a>
229
- ### src/core/api/: The API definition ##########################################
184
+ ### `src/core/api/`: API definition
230
185
 
231
186
  Defines the rx-player API. This is the part the library user will directly
232
187
  interact with.
233
188
 
234
189
 
235
- <a name="core-stream"></a>
236
- ### src/core/stream/: Load the right segments ##################################
190
+ ### `src/core/stream/`: Segment-picking logic
237
191
 
238
192
  The code there calculate which segments should be downloaded, ask for their
239
193
  download and push the segments into the `SegmentBuffers`.
240
194
 
241
195
 
242
- <a name="core-decrypt"></a>
243
- ### src/core/decrypt/: Decryption management ###################################
196
+ ### `src/core/decrypt/`: Decryption handling
244
197
 
245
198
  Defines functions allowing to handle encrypted contents through the EME browser
246
199
  APIs.
247
200
 
248
201
 
249
- <a name="core-fetchers"></a>
250
- ### src/core/fetchers/: The fetchers ###########################################
202
+ ### `src/core/fetchers/`: Load resources
251
203
 
252
204
  Handle the segments and Manifest downloading pipelines (load and parse) as
253
205
  defined in the ``src/transports/`` directory.
@@ -257,8 +209,7 @@ It facilitates the role of loading the Manifest and new segments for the rest of
257
209
  the core.
258
210
 
259
211
 
260
- <a name="core-sb"></a>
261
- ### src/core/segment_buffers/: The media buffers ###############################
212
+ ### `src/core/segment_buffers/`: Media buffers
262
213
 
263
214
  Code allowing to interact with the media buffers called `SegmentBuffers`.
264
215
 
@@ -271,8 +222,7 @@ for other type of contents (like subtitles), we rely on completely custom media
271
222
  buffers implementations.
272
223
 
273
224
 
274
- <a name="core-init"></a>
275
- ### src/core/init/: Content initialization #####################################
225
+ ### `src/core/init/`: Content initialization and orchestration
276
226
 
277
227
  This is the central part which download manifests, initialize MSE and EME APIs,
278
228
  instanciate the central `StreamOrchestrator` (which will allow to download and
@@ -280,8 +230,7 @@ push segments so the content can play) and link together many subparts of the
280
230
  player.
281
231
 
282
232
 
283
- <a name="src-tests"></a>
284
- ## src/**/__tests__: the unit tests directories ################################
233
+ ## `src/**/__tests__`: Unit tests
285
234
 
286
235
  You will find multiple directories named `__tests__` in the RxPlayer.
287
236
  Those contain unit tests and are put in the same directory than the code it
@@ -303,8 +252,7 @@ Their filename don't follow the same convention than single-source unit tests
303
252
  but should still be suffixed by `.test.ts`.
304
253
 
305
254
 
306
- <a name="tests"></a>
307
- ## The tests/ directory: the player's tests ####################################
255
+ ## `tests/`: The RxPlayer's general tests
308
256
 
309
257
  This directory contains most testing code for the RxPlayer.
310
258
 
package/VERSION CHANGED
@@ -1 +1 @@
1
- 4.0.0-beta.1
1
+ 4.0.0-beta.2
@@ -37,4 +37,6 @@ declare let isWebOs2021: boolean;
37
37
  declare let isWebOs2022: boolean;
38
38
  /** `true` for Panasonic devices. */
39
39
  declare let isPanasonic: boolean;
40
- export { isEdgeChromium, isIE11, isIEOrEdge, isFirefox, isPanasonic, isSafariDesktop, isSafariMobile, isSamsungBrowser, isTizen, isWebOs, isWebOs2021, isWebOs2022, };
40
+ /** `true` for the PlayStation 5 game console. */
41
+ declare let isPlayStation5: boolean;
42
+ export { isEdgeChromium, isIE11, isIEOrEdge, isFirefox, isPanasonic, isPlayStation5, isSafariDesktop, isSafariMobile, isSamsungBrowser, isTizen, isWebOs, isWebOs2021, isWebOs2022, };
@@ -38,6 +38,8 @@ var isWebOs2021 = false;
38
38
  var isWebOs2022 = false;
39
39
  /** `true` for Panasonic devices. */
40
40
  var isPanasonic = false;
41
+ /** `true` for the PlayStation 5 game console. */
42
+ var isPlayStation5 = false;
41
43
  ((function findCurrentBrowser() {
42
44
  var _a, _b;
43
45
  if (isNode) {
@@ -74,7 +76,10 @@ var isPanasonic = false;
74
76
  if (/SamsungBrowser/.test(navigator.userAgent)) {
75
77
  isSamsungBrowser = true;
76
78
  }
77
- if (/Tizen/.test(navigator.userAgent)) {
79
+ if (navigator.userAgent.indexOf("PlayStation 5") !== -1) {
80
+ isPlayStation5 = true;
81
+ }
82
+ else if (/Tizen/.test(navigator.userAgent)) {
78
83
  isTizen = true;
79
84
  // Inspired form: http://webostv.developer.lge.com/discover/specifications/web-engine/
80
85
  // Note: even that page doesn't correspond to what we've actually seen in the
@@ -95,4 +100,4 @@ var isPanasonic = false;
95
100
  isPanasonic = true;
96
101
  }
97
102
  })());
98
- export { isEdgeChromium, isIE11, isIEOrEdge, isFirefox, isPanasonic, isSafariDesktop, isSafariMobile, isSamsungBrowser, isTizen, isWebOs, isWebOs2021, isWebOs2022, };
103
+ export { isEdgeChromium, isIE11, isIEOrEdge, isFirefox, isPanasonic, isPlayStation5, isSafariDesktop, isSafariMobile, isSamsungBrowser, isTizen, isWebOs, isWebOs2021, isWebOs2022, };
@@ -70,7 +70,7 @@ export default function loadSession(session, sessionId) {
70
70
  return __generator(this, function (_a) {
71
71
  switch (_a.label) {
72
72
  case 0:
73
- log.info("Compat/DRM: Load persisted session", sessionId);
73
+ log.info("DRM: Load persisted session", sessionId);
74
74
  return [4 /*yield*/, session.load(sessionId)];
75
75
  case 1:
76
76
  isLoaded = _a.sent();
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Some platforms have issues when the `MediaSource`'s `duration` property
3
+ * is set to a very high value (playback freezes) but not when setting it
4
+ * to `Infinity`, which is what the HTML spec as of now (2023-05-15) recommends
5
+ * for live contents.
6
+ *
7
+ * However setting the `MediaSource`'s `duration` property to `Infinity` seems
8
+ * more risky, considering all platforms we now support, than setting it at a
9
+ * relatively high ~2**32 value which is what we do generally.
10
+ *
11
+ * Moreover, setting it to `Infinity` require us to use another MSE API,
12
+ * `setLiveSeekableRange` to properly allow seeking. We're used to MSE issues so
13
+ * I'm not too confident of using another MSE API for all platforms directly.
14
+ *
15
+ * So this methods just return `true` based on a whitelist of platform for which
16
+ * it has been detected that high `duration` values cause issues but setting it
17
+ * to Infinity AND playing with `setLiveSeekableRange` does not.
18
+ *
19
+ * @returns {boolean}
20
+ */
21
+ export default function hasIssuesWithHighMediaSourceDuration(): boolean;
@@ -0,0 +1,26 @@
1
+ import { isPlayStation5 } from "./browser_detection";
2
+ /**
3
+ * Some platforms have issues when the `MediaSource`'s `duration` property
4
+ * is set to a very high value (playback freezes) but not when setting it
5
+ * to `Infinity`, which is what the HTML spec as of now (2023-05-15) recommends
6
+ * for live contents.
7
+ *
8
+ * However setting the `MediaSource`'s `duration` property to `Infinity` seems
9
+ * more risky, considering all platforms we now support, than setting it at a
10
+ * relatively high ~2**32 value which is what we do generally.
11
+ *
12
+ * Moreover, setting it to `Infinity` require us to use another MSE API,
13
+ * `setLiveSeekableRange` to properly allow seeking. We're used to MSE issues so
14
+ * I'm not too confident of using another MSE API for all platforms directly.
15
+ *
16
+ * So this methods just return `true` based on a whitelist of platform for which
17
+ * it has been detected that high `duration` values cause issues but setting it
18
+ * to Infinity AND playing with `setLiveSeekableRange` does not.
19
+ *
20
+ * @returns {boolean}
21
+ */
22
+ export default function hasIssuesWithHighMediaSourceDuration() {
23
+ // For now only seen on the Webkit present in the PlayStation 5, for which the
24
+ // alternative is known to work.
25
+ return isPlayStation5;
26
+ }
@@ -65,6 +65,8 @@ declare class ConfigHandler {
65
65
  SAMPLING_INTERVAL_MEDIASOURCE: number;
66
66
  SAMPLING_INTERVAL_LOW_LATENCY: number;
67
67
  SAMPLING_INTERVAL_NO_MEDIASOURCE: number;
68
+ ABR_ENTER_BUFFER_BASED_ALGO: number;
69
+ ABR_EXIT_BUFFER_BASED_ALGO: number;
68
70
  ABR_MINIMUM_TOTAL_BYTES: number;
69
71
  ABR_MINIMUM_CHUNK_SIZE: number;
70
72
  ABR_STARVATION_FACTOR: {
@@ -13,6 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import config from "../../config";
16
17
  import log from "../../log";
17
18
  import noop from "../../utils/noop";
18
19
  import { getLeftSizeOfRange } from "../../utils/ranges";
@@ -177,8 +178,7 @@ function getEstimateReference(_a, stopAllEstimates) {
177
178
  var timeRanges = val.buffered;
178
179
  var bufferGap = getLeftSizeOfRange(timeRanges, position.last);
179
180
  var representation = val.content.representation;
180
- var scoreData = scoreCalculator.getEstimate(representation);
181
- var currentScore = scoreData === null || scoreData === void 0 ? void 0 : scoreData[0];
181
+ var currentScore = scoreCalculator.getEstimate(representation);
182
182
  var currentBitrate = representation.bitrate;
183
183
  var observation = { bufferGap: bufferGap, currentBitrate: currentBitrate, currentScore: currentScore, speed: speed };
184
184
  currentBufferBasedEstimate = bufferBasedChooser.getEstimate(observation);
@@ -209,12 +209,13 @@ function getEstimateReference(_a, stopAllEstimates) {
209
209
  stableRepresentation.bitrate / (lastPlaybackObservation.speed > 0 ?
210
210
  lastPlaybackObservation.speed :
211
211
  1);
212
- if (allowBufferBasedEstimates && bufferGap <= 5) {
212
+ var _b = config.getCurrent(), ABR_ENTER_BUFFER_BASED_ALGO = _b.ABR_ENTER_BUFFER_BASED_ALGO, ABR_EXIT_BUFFER_BASED_ALGO = _b.ABR_EXIT_BUFFER_BASED_ALGO;
213
+ if (allowBufferBasedEstimates && bufferGap <= ABR_EXIT_BUFFER_BASED_ALGO) {
213
214
  allowBufferBasedEstimates = false;
214
215
  }
215
216
  else if (!allowBufferBasedEstimates &&
216
217
  isFinite(bufferGap) &&
217
- bufferGap > 10) {
218
+ bufferGap >= ABR_ENTER_BUFFER_BASED_ALGO) {
218
219
  allowBufferBasedEstimates = true;
219
220
  }
220
221
  /**
@@ -13,6 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import { IRepresentationMaintainabilityScore } from "./utils/representation_score_calculator";
16
17
  /**
17
18
  * Choose a bitrate based on the currently available buffer.
18
19
  *
@@ -24,11 +25,27 @@
24
25
  * "maintanable" or not.
25
26
  * If so, we may switch to a better quality, or conversely to a worse quality.
26
27
  *
28
+ * It also rely on mechanisms to avoid fluctuating too much between qualities.
29
+ *
27
30
  * @class BufferBasedChooser
28
31
  */
29
32
  export default class BufferBasedChooser {
30
33
  private _levelsMap;
31
34
  private _bitrates;
35
+ /**
36
+ * Laast timestamp, in terms of `performance.now`, at which the current
37
+ * quality was seen as too high by this algorithm.
38
+ * Begins at `undefined`.
39
+ */
40
+ private _lastUnsuitableQualityTimestamp;
41
+ /**
42
+ * After lowering in quality, we forbid raising during a set amount of time.
43
+ * This amount is adaptive may continue to raise if it seems that quality
44
+ * is switching too much between low and high qualities.
45
+ *
46
+ * `_blockRaiseDelay` represents this time in milliseconds.
47
+ */
48
+ private _blockRaiseDelay;
32
49
  /**
33
50
  * @param {Array.<number>} bitrates
34
51
  */
@@ -50,7 +67,7 @@ export interface IBufferBasedChooserPlaybackObservation {
50
67
  /** The bitrate of the currently downloaded segments, in bps. */
51
68
  currentBitrate?: number | undefined;
52
69
  /** The "maintainability score" of the currently downloaded segments. */
53
- currentScore?: number | undefined;
70
+ currentScore?: IRepresentationMaintainabilityScore | undefined;
54
71
  /** Playback rate wanted (e.g. `1` is regular playback, `2` is double speed etc.). */
55
72
  speed: number;
56
73
  }
@@ -16,6 +16,45 @@
16
16
  import log from "../../log";
17
17
  import arrayFindIndex from "../../utils/array_find_index";
18
18
  import getBufferLevels from "./utils/get_buffer_levels";
19
+ /**
20
+ * Minimum amount of time, in milliseconds, during which we are blocked from
21
+ * raising in quality after it had been considered as too high.
22
+ */
23
+ var MINIMUM_BLOCK_RAISE_DELAY = 6000;
24
+ /**
25
+ * Maximum amount of time, in milliseconds, during which we are blocked from
26
+ * raising in quality after it had been considered as too high.
27
+ */
28
+ var MAXIMUM_BLOCK_RAISE_DELAY = 15000;
29
+ /**
30
+ * Amount of time, in milliseconds, with which the blocking time in raising
31
+ * the quality will be incremented if the current quality estimate is seen
32
+ * as too unstable.
33
+ */
34
+ var RAISE_BLOCKING_DELAY_INCREMENT = 3000;
35
+ /**
36
+ * Amount of time, in milliseconds, with which the blocking time in raising
37
+ * the quality will be dcremented if the current quality estimate is seen
38
+ * as relatively stable, until `MINIMUM_BLOCK_RAISE_DELAY` is reached.
39
+ */
40
+ var RAISE_BLOCKING_DELAY_DECREMENT = 1000;
41
+ /**
42
+ * Amount of time, in milliseconds, after the "raise blocking delay" currently
43
+ * in place (during which it is forbidden to raise up in quality), during which
44
+ * we might want to raise the "raise blocking delay" if the last chosen quality
45
+ * seems unsuitable.
46
+ *
47
+ * For example, let's consider that the current raise blocking delay is at
48
+ * `4000`, or 4 seconds, and that this `STABILITY_CHECK_DELAY` is at `5000`, or
49
+ * 5 seconds.
50
+ * Here it means that if the estimated quality is found to be unsuitable less
51
+ * than 4+5 = 9 seconds after it last was, we will increment the raise blocking
52
+ * delay by `RAISE_BLOCKING_DELAY_INCREMENT` (unless `MAXIMUM_BLOCK_RAISE_DELAY`
53
+ * is reached).
54
+ * Else, if takes more than 9 seconds, the raise blocking delay might be
55
+ * decremented.
56
+ */
57
+ var STABILITY_CHECK_DELAY = 9000;
19
58
  /**
20
59
  * Choose a bitrate based on the currently available buffer.
21
60
  *
@@ -27,6 +66,8 @@ import getBufferLevels from "./utils/get_buffer_levels";
27
66
  * "maintanable" or not.
28
67
  * If so, we may switch to a better quality, or conversely to a worse quality.
29
68
  *
69
+ * It also rely on mechanisms to avoid fluctuating too much between qualities.
70
+ *
30
71
  * @class BufferBasedChooser
31
72
  */
32
73
  var BufferBasedChooser = /** @class */ (function () {
@@ -34,8 +75,13 @@ var BufferBasedChooser = /** @class */ (function () {
34
75
  * @param {Array.<number>} bitrates
35
76
  */
36
77
  function BufferBasedChooser(bitrates) {
37
- this._levelsMap = getBufferLevels(bitrates);
78
+ this._levelsMap = getBufferLevels(bitrates).map(function (bl) {
79
+ return bl + 4; // Add some buffer security as it will be used conjointly with
80
+ // other algorithms anyway
81
+ });
38
82
  this._bitrates = bitrates;
83
+ this._lastUnsuitableQualityTimestamp = undefined;
84
+ this._blockRaiseDelay = MINIMUM_BLOCK_RAISE_DELAY;
39
85
  log.debug("ABR: Steps for buffer based chooser.", this._levelsMap.map(function (l, i) { return "bufferLevel: ".concat(l, ", bitrate: ").concat(bitrates[i]); })
40
86
  .join(" ,"));
41
87
  }
@@ -50,40 +96,75 @@ var BufferBasedChooser = /** @class */ (function () {
50
96
  if (currentBitrate == null) {
51
97
  return bitrates[0];
52
98
  }
53
- var currentBitrateIndex = arrayFindIndex(bitrates, function (b) { return b === currentBitrate; });
99
+ var currentBitrateIndex = -1;
100
+ for (var i = 0; i < bitrates.length; i++) {
101
+ // There could be bitrate duplicates. Only take the last one to simplify
102
+ var bitrate = bitrates[i];
103
+ if (bitrate === currentBitrate) {
104
+ currentBitrateIndex = i;
105
+ }
106
+ else if (bitrate > currentBitrate) {
107
+ break;
108
+ }
109
+ }
54
110
  if (currentBitrateIndex < 0 || bitrates.length !== bufferLevels.length) {
55
111
  log.error("ABR: Current Bitrate not found in the calculated levels");
56
112
  return bitrates[0];
57
113
  }
58
114
  var scaledScore;
59
- if (currentScore != null) {
60
- scaledScore = speed === 0 ? currentScore : (currentScore / speed);
115
+ if (currentScore !== undefined) {
116
+ scaledScore = speed === 0 ? currentScore.score : (currentScore.score / speed);
61
117
  }
62
- if (scaledScore != null && scaledScore > 1) {
63
- var currentBufferLevel_1 = bufferLevels[currentBitrateIndex];
64
- var nextIndex = (function () {
65
- for (var i = currentBitrateIndex + 1; i < bufferLevels.length; i++) {
66
- if (bufferLevels[i] > currentBufferLevel_1) {
67
- return i;
68
- }
69
- }
70
- })();
71
- if (nextIndex != null) {
72
- var nextBufferLevel = bufferLevels[nextIndex];
73
- if (bufferGap >= nextBufferLevel) {
74
- return bitrates[nextIndex];
118
+ var actualBufferGap = isFinite(bufferGap) ?
119
+ bufferGap :
120
+ 0;
121
+ var now = performance.now();
122
+ if (actualBufferGap < bufferLevels[currentBitrateIndex] ||
123
+ (scaledScore !== undefined && scaledScore < 1 &&
124
+ (currentScore === null || currentScore === void 0 ? void 0 : currentScore.confidenceLevel) === 1 /* ScoreConfidenceLevel.HIGH */)) {
125
+ var timeSincePrev = this._lastUnsuitableQualityTimestamp === undefined ?
126
+ -1 :
127
+ now - this._lastUnsuitableQualityTimestamp;
128
+ if (timeSincePrev < this._blockRaiseDelay + STABILITY_CHECK_DELAY) {
129
+ var newDelay = this._blockRaiseDelay + RAISE_BLOCKING_DELAY_INCREMENT;
130
+ this._blockRaiseDelay = Math.min(newDelay, MAXIMUM_BLOCK_RAISE_DELAY);
131
+ log.debug("ABR: Incrementing blocking raise in BufferBasedChooser due " +
132
+ "to unstable quality", this._blockRaiseDelay);
133
+ }
134
+ else {
135
+ var newDelay = this._blockRaiseDelay - RAISE_BLOCKING_DELAY_DECREMENT;
136
+ this._blockRaiseDelay = Math.max(MINIMUM_BLOCK_RAISE_DELAY, newDelay);
137
+ log.debug("ABR: Lowering quality in BufferBasedChooser", this._blockRaiseDelay);
138
+ }
139
+ this._lastUnsuitableQualityTimestamp = now;
140
+ // Security if multiple bitrates are equal, we now take the first one
141
+ var baseIndex = arrayFindIndex(bitrates, function (b) { return b === currentBitrate; });
142
+ for (var i = baseIndex - 1; i >= 0; i--) {
143
+ if (actualBufferGap >= bufferLevels[i]) {
144
+ return bitrates[i];
75
145
  }
76
146
  }
147
+ return bitrates[0];
77
148
  }
78
- if (scaledScore == null || scaledScore < 1.15) {
79
- var currentBufferLevel = bufferLevels[currentBitrateIndex];
80
- if (bufferGap < currentBufferLevel) {
81
- for (var i = currentBitrateIndex - 1; i >= 0; i--) {
82
- if (bitrates[i] < currentBitrate) {
83
- return bitrates[i];
84
- }
149
+ if ((this._lastUnsuitableQualityTimestamp !== undefined &&
150
+ now - this._lastUnsuitableQualityTimestamp < this._blockRaiseDelay) ||
151
+ scaledScore === undefined || scaledScore < 1.15 ||
152
+ (currentScore === null || currentScore === void 0 ? void 0 : currentScore.confidenceLevel) !== 1 /* ScoreConfidenceLevel.HIGH */) {
153
+ return currentBitrate;
154
+ }
155
+ var currentBufferLevel = bufferLevels[currentBitrateIndex];
156
+ var nextIndex = (function () {
157
+ for (var i = currentBitrateIndex + 1; i < bufferLevels.length; i++) {
158
+ if (bufferLevels[i] > currentBufferLevel) {
159
+ return i;
85
160
  }
86
- return currentBitrate;
161
+ }
162
+ })();
163
+ if (nextIndex !== undefined) {
164
+ var nextBufferLevel = bufferLevels[nextIndex];
165
+ if (bufferGap >= nextBufferLevel) {
166
+ log.debug("ABR: Raising quality in BufferBasedChooser", bitrates[nextIndex]);
167
+ return bitrates[nextIndex];
87
168
  }
88
169
  }
89
170
  return currentBitrate;