rx-player 3.29.0-dev.2022091600 → 3.29.0-dev.2022103100

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 (184) hide show
  1. package/CHANGELOG.md +22 -10
  2. package/MAINTAINERS.md +2 -1
  3. package/VERSION +1 -1
  4. package/dist/_esm5.processed/compat/browser_detection.d.ts +4 -1
  5. package/dist/_esm5.processed/compat/browser_detection.js +7 -1
  6. package/dist/_esm5.processed/compat/can_reuse_media_keys.d.ts +12 -0
  7. package/dist/_esm5.processed/compat/can_reuse_media_keys.js +15 -0
  8. package/dist/_esm5.processed/compat/enable_audio_track.d.ts +11 -0
  9. package/dist/_esm5.processed/compat/enable_audio_track.js +26 -0
  10. package/dist/_esm5.processed/compat/index.d.ts +4 -2
  11. package/dist/_esm5.processed/compat/index.js +4 -2
  12. package/dist/_esm5.processed/compat/{should_renew_media_keys.d.ts → should_renew_media_key_system_access.d.ts} +3 -3
  13. package/dist/_esm5.processed/compat/{should_renew_media_keys.js → should_renew_media_key_system_access.js} +3 -3
  14. package/dist/_esm5.processed/config.d.ts +1 -0
  15. package/dist/_esm5.processed/core/api/playback_observer.d.ts +14 -5
  16. package/dist/_esm5.processed/core/api/playback_observer.js +54 -22
  17. package/dist/_esm5.processed/core/api/public_api.d.ts +7 -4
  18. package/dist/_esm5.processed/core/api/public_api.js +79 -61
  19. package/dist/_esm5.processed/core/api/tracks_management/media_element_track_choice_manager.js +9 -10
  20. package/dist/_esm5.processed/core/decrypt/__tests__/__global__/utils.js +1 -1
  21. package/dist/_esm5.processed/core/decrypt/find_key_system.js +3 -3
  22. package/dist/_esm5.processed/core/decrypt/get_media_keys.js +4 -1
  23. package/dist/_esm5.processed/core/fetchers/cdn_prioritizer.d.ts +98 -0
  24. package/dist/_esm5.processed/core/fetchers/cdn_prioritizer.js +173 -0
  25. package/dist/_esm5.processed/core/fetchers/manifest/manifest_fetcher.js +4 -4
  26. package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher.d.ts +2 -1
  27. package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher.js +15 -16
  28. package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher_creator.d.ts +3 -1
  29. package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher_creator.js +5 -2
  30. package/dist/_esm5.processed/core/fetchers/utils/schedule_request.d.ts +103 -0
  31. package/dist/_esm5.processed/core/fetchers/utils/schedule_request.js +414 -0
  32. package/dist/_esm5.processed/core/init/content_time_boundaries_observer.d.ts +4 -3
  33. package/dist/_esm5.processed/core/init/content_time_boundaries_observer.js +21 -22
  34. package/dist/_esm5.processed/core/init/initialize_media_source.d.ts +18 -4
  35. package/dist/_esm5.processed/core/init/initialize_media_source.js +10 -2
  36. package/dist/_esm5.processed/core/init/load_on_media_source.js +7 -1
  37. package/dist/_esm5.processed/core/init/stall_avoider.js +3 -1
  38. package/dist/_esm5.processed/default_config.d.ts +11 -0
  39. package/dist/_esm5.processed/default_config.js +11 -0
  40. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +1 -1
  41. package/dist/_esm5.processed/manifest/manifest.js +11 -2
  42. package/dist/_esm5.processed/manifest/representation.d.ts +12 -1
  43. package/dist/_esm5.processed/manifest/representation.js +1 -0
  44. package/dist/_esm5.processed/manifest/representation_index/static.d.ts +1 -1
  45. package/dist/_esm5.processed/manifest/representation_index/static.js +2 -2
  46. package/dist/_esm5.processed/manifest/representation_index/types.d.ts +32 -15
  47. package/dist/_esm5.processed/manifest/update_period_in_place.js +1 -0
  48. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/base.d.ts +10 -9
  49. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/base.js +11 -11
  50. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/get_init_segment.d.ts +1 -1
  51. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/get_init_segment.js +3 -3
  52. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/get_segments_from_timeline.d.ts +1 -1
  53. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/get_segments_from_timeline.js +4 -4
  54. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/list.d.ts +7 -7
  55. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/list.js +12 -8
  56. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/template.d.ts +5 -6
  57. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/template.js +16 -16
  58. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts +11 -10
  59. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +14 -13
  60. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/tokens.d.ts +3 -4
  61. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/tokens.js +4 -12
  62. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_mpd.js +2 -4
  63. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representation_index.js +1 -3
  64. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representations.js +6 -2
  65. package/dist/_esm5.processed/parsers/manifest/dash/common/resolve_base_urls.d.ts +1 -2
  66. package/dist/_esm5.processed/parsers/manifest/dash/common/resolve_base_urls.js +3 -8
  67. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/BaseURL.d.ts +1 -1
  68. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/BaseURL.js +2 -20
  69. package/dist/_esm5.processed/parsers/manifest/dash/node_parser_types.d.ts +0 -6
  70. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/BaseURL.js +0 -11
  71. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/types.d.ts +5 -1
  72. package/dist/_esm5.processed/parsers/manifest/local/parse_local_manifest.js +2 -1
  73. package/dist/_esm5.processed/parsers/manifest/local/representation_index.js +2 -2
  74. package/dist/_esm5.processed/parsers/manifest/metaplaylist/metaplaylist_parser.js +7 -1
  75. package/dist/_esm5.processed/parsers/manifest/smooth/create_parser.js +17 -11
  76. package/dist/_esm5.processed/parsers/manifest/smooth/representation_index.js +2 -2
  77. package/dist/_esm5.processed/parsers/manifest/types.d.ts +24 -0
  78. package/dist/_esm5.processed/parsers/texttracks/ttml/html/apply_extent.js +8 -1
  79. package/dist/_esm5.processed/parsers/texttracks/ttml/html/apply_origin.js +9 -1
  80. package/dist/_esm5.processed/parsers/texttracks/ttml/html/create_element.js +2 -1
  81. package/dist/_esm5.processed/transports/dash/construct_segment_url.d.ts +18 -0
  82. package/dist/_esm5.processed/transports/dash/construct_segment_url.js +21 -0
  83. package/dist/_esm5.processed/transports/dash/image_pipelines.d.ts +3 -2
  84. package/dist/_esm5.processed/transports/dash/image_pipelines.js +5 -3
  85. package/dist/_esm5.processed/transports/dash/segment_loader.js +4 -2
  86. package/dist/_esm5.processed/transports/dash/text_loader.js +4 -2
  87. package/dist/_esm5.processed/transports/dash/text_parser.js +3 -1
  88. package/dist/_esm5.processed/transports/local/segment_loader.d.ts +3 -2
  89. package/dist/_esm5.processed/transports/local/segment_loader.js +2 -2
  90. package/dist/_esm5.processed/transports/metaplaylist/pipelines.js +8 -8
  91. package/dist/_esm5.processed/transports/smooth/pipelines.js +11 -7
  92. package/dist/_esm5.processed/transports/smooth/utils.d.ts +4 -2
  93. package/dist/_esm5.processed/transports/smooth/utils.js +7 -1
  94. package/dist/_esm5.processed/transports/types.d.ts +5 -3
  95. package/dist/_esm5.processed/utils/event_emitter.d.ts +1 -2
  96. package/dist/_esm5.processed/utils/resolve_url.d.ts +7 -4
  97. package/dist/_esm5.processed/utils/resolve_url.js +11 -8
  98. package/dist/mpd-parser.wasm +0 -0
  99. package/dist/rx-player.js +5656 -13236
  100. package/dist/rx-player.min.js +1 -1
  101. package/jest.config.js +28 -23
  102. package/package.json +29 -29
  103. package/sonar-project.properties +1 -1
  104. package/src/compat/__tests__/can_reuse_media_keys.test.ts +54 -0
  105. package/src/compat/__tests__/enable_audio_track.test.ts +341 -0
  106. package/src/compat/__tests__/{should_renew_media_keys.test.ts → should_renew_media_key_system_access.test.ts} +7 -5
  107. package/src/compat/browser_detection.ts +10 -0
  108. package/src/compat/can_reuse_media_keys.ts +19 -0
  109. package/src/compat/enable_audio_track.ts +33 -0
  110. package/src/compat/index.ts +6 -2
  111. package/src/compat/{should_renew_media_keys.ts → should_renew_media_key_system_access.ts} +3 -3
  112. package/src/core/api/playback_observer.ts +97 -33
  113. package/src/core/api/public_api.ts +126 -74
  114. package/src/core/api/tracks_management/media_element_track_choice_manager.ts +3 -11
  115. package/src/core/decrypt/__tests__/__global__/media_keys.test.ts +182 -0
  116. package/src/core/decrypt/__tests__/__global__/utils.ts +2 -0
  117. package/src/core/decrypt/find_key_system.ts +3 -3
  118. package/src/core/decrypt/get_media_keys.ts +5 -1
  119. package/src/core/fetchers/cdn_prioritizer.ts +198 -0
  120. package/src/core/fetchers/manifest/manifest_fetcher.ts +7 -11
  121. package/src/core/fetchers/segment/segment_fetcher.ts +12 -10
  122. package/src/core/fetchers/segment/segment_fetcher_creator.ts +10 -1
  123. package/src/core/fetchers/utils/schedule_request.ts +482 -0
  124. package/src/core/init/content_time_boundaries_observer.ts +12 -12
  125. package/src/core/init/initialize_media_source.ts +31 -4
  126. package/src/core/init/load_on_media_source.ts +11 -2
  127. package/src/core/init/stall_avoider.ts +4 -1
  128. package/src/core/stream/orchestrator/stream_orchestrator.ts +0 -1
  129. package/src/default_config.ts +12 -0
  130. package/src/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.ts +1 -0
  131. package/src/manifest/manifest.ts +11 -2
  132. package/src/manifest/representation.ts +15 -0
  133. package/src/manifest/representation_index/__tests__/static.test.ts +1 -1
  134. package/src/manifest/representation_index/static.ts +3 -3
  135. package/src/manifest/representation_index/types.ts +33 -15
  136. package/src/manifest/update_period_in_place.ts +1 -0
  137. package/src/parsers/manifest/dash/common/indexes/base.ts +22 -23
  138. package/src/parsers/manifest/dash/common/indexes/get_init_segment.ts +6 -4
  139. package/src/parsers/manifest/dash/common/indexes/get_segments_from_timeline.ts +5 -5
  140. package/src/parsers/manifest/dash/common/indexes/list.ts +19 -20
  141. package/src/parsers/manifest/dash/common/indexes/template.ts +23 -27
  142. package/src/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.ts +25 -23
  143. package/src/parsers/manifest/dash/common/indexes/tokens.ts +7 -18
  144. package/src/parsers/manifest/dash/common/parse_mpd.ts +2 -4
  145. package/src/parsers/manifest/dash/common/parse_representation_index.ts +1 -6
  146. package/src/parsers/manifest/dash/common/parse_representations.ts +9 -0
  147. package/src/parsers/manifest/dash/common/resolve_base_urls.ts +5 -9
  148. package/src/parsers/manifest/dash/js-parser/node_parsers/BaseURL.ts +2 -29
  149. package/src/parsers/manifest/dash/js-parser/node_parsers/__tests__/AdaptationSet.test.ts +7 -11
  150. package/src/parsers/manifest/dash/node_parser_types.ts +0 -7
  151. package/src/parsers/manifest/dash/wasm-parser/rs/events.rs +3 -1
  152. package/src/parsers/manifest/dash/wasm-parser/rs/processor/attributes.rs +1 -8
  153. package/src/parsers/manifest/dash/wasm-parser/ts/generators/BaseURL.ts +0 -13
  154. package/src/parsers/manifest/dash/wasm-parser/ts/types.ts +8 -0
  155. package/src/parsers/manifest/local/parse_local_manifest.ts +1 -0
  156. package/src/parsers/manifest/local/representation_index.ts +2 -2
  157. package/src/parsers/manifest/metaplaylist/metaplaylist_parser.ts +7 -1
  158. package/src/parsers/manifest/smooth/create_parser.ts +17 -13
  159. package/src/parsers/manifest/smooth/representation_index.ts +2 -2
  160. package/src/parsers/manifest/types.ts +26 -1
  161. package/src/parsers/manifest/utils/__tests__/get_first_time_from_adaptations.test.ts +15 -0
  162. package/src/parsers/manifest/utils/__tests__/get_last_time_from_adaptation.test.ts +15 -0
  163. package/src/parsers/texttracks/ttml/html/apply_extent.ts +8 -1
  164. package/src/parsers/texttracks/ttml/html/apply_origin.ts +9 -1
  165. package/src/parsers/texttracks/ttml/html/create_element.ts +2 -2
  166. package/src/transports/dash/construct_segment_url.ts +28 -0
  167. package/src/transports/dash/image_pipelines.ts +5 -2
  168. package/src/transports/dash/segment_loader.ts +5 -2
  169. package/src/transports/dash/text_loader.ts +5 -2
  170. package/src/transports/dash/text_parser.ts +3 -1
  171. package/src/transports/local/segment_loader.ts +3 -2
  172. package/src/transports/metaplaylist/pipelines.ts +28 -9
  173. package/src/transports/smooth/pipelines.ts +12 -6
  174. package/src/transports/smooth/utils.ts +13 -1
  175. package/src/transports/types.ts +6 -3
  176. package/src/utils/__tests__/event_emitter.test.ts +72 -67
  177. package/src/utils/__tests__/initialization_segment_cache.test.ts +7 -7
  178. package/src/utils/__tests__/resolve_url.test.ts +27 -23
  179. package/src/utils/event_emitter.ts +1 -3
  180. package/src/utils/resolve_url.ts +11 -8
  181. package/dist/_esm5.processed/core/fetchers/utils/try_urls_with_backoff.d.ts +0 -85
  182. package/dist/_esm5.processed/core/fetchers/utils/try_urls_with_backoff.js +0 -264
  183. package/dummy +0 -1
  184. package/src/core/fetchers/utils/try_urls_with_backoff.ts +0 -287
@@ -37,10 +37,9 @@ import isSegmentStillAvailable from "../../../../utils/is_segment_still_availabl
37
37
  import updateSegmentTimeline from "../../../../utils/update_segment_timeline";
38
38
  import { ISegmentTimelineElement } from "../../../node_parser_types";
39
39
  import ManifestBoundsCalculator from "../../manifest_bounds_calculator";
40
- import { IResolvedBaseUrl } from "../../resolve_base_urls";
41
40
  import getInitSegment from "../get_init_segment";
42
41
  import getSegmentsFromTimeline from "../get_segments_from_timeline";
43
- import { createIndexURLs } from "../tokens";
42
+ import { constructRepresentationUrl } from "../tokens";
44
43
  import { getSegmentTimeRoundingError } from "../utils";
45
44
  import constructTimelineFromElements from "./construct_timeline_from_elements";
46
45
  // eslint-disable-next-line max-len
@@ -71,16 +70,22 @@ export interface ITimelineIndex {
71
70
  indexTimeOffset : number;
72
71
  /** Information on the initialization segment. */
73
72
  initialization? : {
74
- /** URLs to access the initialization segment. */
75
- mediaURLs: string[] | null;
73
+ /**
74
+ * URL path, to add to the wanted CDN, to access the initialization segment.
75
+ * `null` if no URL exists.
76
+ */
77
+ url: string | null;
76
78
  /** possible byte range to request it. */
77
79
  range?: [number, number] | undefined;
78
80
  } | undefined;
79
81
  /**
80
- * Base URL(s) to access any segment. Can contain tokens to replace to convert
81
- * it to real URLs.
82
+ * Template for the URL suffix (to concatenate to the wanted CDN), to access any
83
+ * media segment.
84
+ * Can contain tokens to replace to convert it to real URLs.
85
+ *
86
+ * `null` if no URL exists.
82
87
  */
83
- mediaURLs : string[] | null ;
88
+ segmentUrlTemplate : string | null ;
84
89
  /** Number from which the first segments in this index starts with. */
85
90
  startNumber? : number | undefined;
86
91
  /**
@@ -158,8 +163,6 @@ export interface ITimelineIndexContextArgument {
158
163
  * index was received
159
164
  */
160
165
  receivedTime? : number | undefined;
161
- /** Base URL for the Representation concerned. */
162
- representationBaseURLs : IResolvedBaseUrl[];
163
166
  /** ID of the Representation concerned. */
164
167
  representationId? : string | undefined;
165
168
  /** Bitrate of the Representation concerned. */
@@ -247,7 +250,6 @@ export default class TimelineRepresentationIndex implements IRepresentationIndex
247
250
  manifestBoundsCalculator,
248
251
  isDynamic,
249
252
  isLastPeriod,
250
- representationBaseURLs,
251
253
  representationId,
252
254
  representationBitrate,
253
255
  periodStart,
@@ -284,23 +286,25 @@ export default class TimelineRepresentationIndex implements IRepresentationIndex
284
286
 
285
287
  this._isDynamic = isDynamic;
286
288
  this._parseTimeline = index.timelineParser ?? null;
287
- const urlSources : string[] = representationBaseURLs.map(b => b.url);
289
+ const initializationUrl = index.initialization?.media === undefined ?
290
+ null :
291
+ constructRepresentationUrl(index.initialization.media,
292
+ representationId,
293
+ representationBitrate);
294
+
295
+ const segmentUrlTemplate = index.media === undefined ?
296
+ null :
297
+ constructRepresentationUrl(index.media, representationId, representationBitrate);
288
298
  this._index = { availabilityTimeComplete,
289
299
  indexRange: index.indexRange,
290
300
  indexTimeOffset,
291
301
  initialization: index.initialization == null ?
292
302
  undefined :
293
303
  {
294
- mediaURLs: createIndexURLs(urlSources,
295
- index.initialization.media,
296
- representationId,
297
- representationBitrate),
304
+ url: initializationUrl,
298
305
  range: index.initialization.range,
299
306
  },
300
- mediaURLs: createIndexURLs(urlSources,
301
- index.media,
302
- representationId,
303
- representationBitrate),
307
+ segmentUrlTemplate,
304
308
  startNumber: index.startNumber,
305
309
  timeline: index.timeline ?? null,
306
310
  timescale };
@@ -330,12 +334,12 @@ export default class TimelineRepresentationIndex implements IRepresentationIndex
330
334
  }
331
335
 
332
336
  // destructuring to please TypeScript
333
- const { mediaURLs,
337
+ const { segmentUrlTemplate,
334
338
  startNumber,
335
339
  timeline,
336
340
  timescale,
337
341
  indexTimeOffset } = this._index;
338
- return getSegmentsFromTimeline({ mediaURLs,
342
+ return getSegmentsFromTimeline({ segmentUrlTemplate,
339
343
  startNumber,
340
344
  timeline,
341
345
  timescale,
@@ -348,8 +352,6 @@ export default class TimelineRepresentationIndex implements IRepresentationIndex
348
352
 
349
353
  /**
350
354
  * Returns true if the index should be refreshed.
351
- * @param {Number} _up
352
- * @param {Number} to
353
355
  * @returns {Boolean}
354
356
  */
355
357
  shouldRefresh() : false {
@@ -15,7 +15,6 @@
15
15
  */
16
16
 
17
17
  import isNonEmptyString from "../../../../../utils/is_non_empty_string";
18
- import resolveURL from "../../../../../utils/resolve_url";
19
18
 
20
19
  /**
21
20
  * Pad with 0 in the left of the given n argument to reach l length
@@ -47,27 +46,17 @@ function processFormatedToken(
47
46
  }
48
47
 
49
48
  /**
50
- * @param {string} baseURLs
51
- * @param {string|undefined} media
52
- * @param {string|undefined} id
49
+ * @param {string} urlTemplate
50
+ * @param {string|undefined} representationId
53
51
  * @param {number|undefined} bitrate
54
52
  * @returns {string}
55
53
  */
56
- export function createIndexURLs(
57
- baseURLs : string[],
58
- media?: string,
59
- id?: string,
54
+ export function constructRepresentationUrl(
55
+ urlTemplate : string,
56
+ representationId?: string,
60
57
  bitrate?: number
61
- ): string[] | null {
62
- if (baseURLs.length === 0) {
63
- return media !== undefined ? [replaceRepresentationDASHTokens(media, id, bitrate)] :
64
- null;
65
- }
66
- return baseURLs.map(baseURL => {
67
- return replaceRepresentationDASHTokens(resolveURL(baseURL, media),
68
- id,
69
- bitrate);
70
- });
58
+ ): string {
59
+ return replaceRepresentationDASHTokens(urlTemplate, representationId, bitrate);
71
60
  }
72
61
 
73
62
  /**
@@ -18,7 +18,7 @@ import config from "../../../../config";
18
18
  import log from "../../../../log";
19
19
  import Manifest from "../../../../manifest";
20
20
  import arrayFind from "../../../../utils/array_find";
21
- import { normalizeBaseURL } from "../../../../utils/resolve_url";
21
+ import { getFilenameIndexInUrl } from "../../../../utils/resolve_url";
22
22
  import { IParsedManifest } from "../../types";
23
23
  import {
24
24
  IMPDIntermediateRepresentation,
@@ -241,9 +241,7 @@ function parseCompleteIntermediateRepresentation(
241
241
  attributes: rootAttributes } = mpdIR;
242
242
  const isDynamic : boolean = rootAttributes.type === "dynamic";
243
243
  const initialBaseUrl : IResolvedBaseUrl[] = args.url !== undefined ?
244
- [{ url: normalizeBaseURL(args.url),
245
- availabilityTimeOffset: 0,
246
- availabilityTimeComplete: true }] :
244
+ [{ url: args.url.substring(0, getFilenameIndexInUrl(args.url)) }] :
247
245
  [];
248
246
  const mpdBaseUrls = resolveBaseURLs(initialBaseUrl, rootChildren.baseURLs);
249
247
  const availabilityStartTime = parseAvailabilityStartTime(rootAttributes,
@@ -33,9 +33,7 @@ import {
33
33
  TimelineRepresentationIndex,
34
34
  } from "./indexes";
35
35
  import ManifestBoundsCalculator from "./manifest_bounds_calculator";
36
- import resolveBaseURLs, {
37
- IResolvedBaseUrl,
38
- } from "./resolve_base_urls";
36
+ import { IResolvedBaseUrl } from "./resolve_base_urls";
39
37
 
40
38
  /**
41
39
  * Parse the specific segment indexing information found in a representation
@@ -48,8 +46,6 @@ export default function parseRepresentationIndex(
48
46
  representation : IRepresentationIntermediateRepresentation,
49
47
  context : IRepresentationIndexContext
50
48
  ) : IRepresentationIndex {
51
- const representationBaseURLs = resolveBaseURLs(context.baseURLs,
52
- representation.children.baseURLs);
53
49
  const { aggressiveMode,
54
50
  availabilityTimeOffset,
55
51
  manifestBoundsCalculator,
@@ -80,7 +76,6 @@ export default function parseRepresentationIndex(
80
76
  periodEnd,
81
77
  periodStart,
82
78
  receivedTime,
83
- representationBaseURLs,
84
79
  representationBitrate: representation.attributes.bitrate,
85
80
  representationId: representation.attributes.id,
86
81
  timeShiftBufferDepth };
@@ -20,6 +20,7 @@ import { IHDRInformation } from "../../../../public_types";
20
20
  import arrayFind from "../../../../utils/array_find";
21
21
  import objectAssign from "../../../../utils/object_assign";
22
22
  import {
23
+ ICdnMetadata,
23
24
  IContentProtections,
24
25
  IParsedRepresentation,
25
26
  } from "../../types";
@@ -33,6 +34,7 @@ import { getWEBMHDRInformation } from "./get_hdr_information";
33
34
  import parseRepresentationIndex, {
34
35
  IRepresentationIndexContext,
35
36
  } from "./parse_representation_index";
37
+ import resolveBaseURLs from "./resolve_base_urls";
36
38
 
37
39
  /**
38
40
  * Combine inband event streams from representation and
@@ -159,9 +161,16 @@ export default function parseRepresentations(
159
161
  representationBitrate = representation.attributes.bitrate;
160
162
  }
161
163
 
164
+ const representationBaseURLs = resolveBaseURLs(context.baseURLs,
165
+ representation.children.baseURLs);
166
+ const cdnMetadata : ICdnMetadata[] = representationBaseURLs.map(x =>
167
+ ({ baseUrl: x.url, id: x.serviceLocation }));
168
+
169
+
162
170
  // Construct Representation Base
163
171
  const parsedRepresentation : IParsedRepresentation =
164
172
  { bitrate: representationBitrate,
173
+ cdnMetadata,
165
174
  index: representationIndex,
166
175
  id: representationID };
167
176
 
@@ -19,8 +19,7 @@ import { IBaseUrlIntermediateRepresentation } from "../node_parser_types";
19
19
 
20
20
  export interface IResolvedBaseUrl {
21
21
  url : string;
22
- availabilityTimeOffset : number;
23
- availabilityTimeComplete : boolean;
22
+ serviceLocation? : string | undefined;
24
23
  }
25
24
 
26
25
  /**
@@ -37,9 +36,7 @@ export default function resolveBaseURLs(
37
36
  }
38
37
 
39
38
  const newBaseUrls : IResolvedBaseUrl[] = newBaseUrlsIR.map(ir => {
40
- return { url: ir.value,
41
- availabilityTimeOffset: ir.attributes.availabilityTimeOffset ?? 0,
42
- availabilityTimeComplete: ir.attributes.availabilityTimeComplete ?? true };
39
+ return { url: ir.value };
43
40
  });
44
41
  if (currentBaseURLs.length === 0) {
45
42
  return newBaseUrls;
@@ -51,11 +48,10 @@ export default function resolveBaseURLs(
51
48
  for (let j = 0; j < newBaseUrls.length; j++) {
52
49
  const newBaseUrl = newBaseUrls[j];
53
50
  const newUrl = resolveURL(curBaseUrl.url, newBaseUrl.url);
54
- const newAvailabilityTimeOffset = curBaseUrl.availabilityTimeOffset +
55
- newBaseUrl.availabilityTimeOffset;
56
51
  result.push({ url: newUrl,
57
- availabilityTimeOffset: newAvailabilityTimeOffset,
58
- availabilityTimeComplete: newBaseUrl.availabilityTimeComplete });
52
+ serviceLocation: newBaseUrl.serviceLocation ??
53
+ curBaseUrl.serviceLocation });
54
+
59
55
  }
60
56
  }
61
57
  return result;
@@ -15,48 +15,21 @@
15
15
  */
16
16
 
17
17
  import { IBaseUrlIntermediateRepresentation } from "../../node_parser_types";
18
- import {
19
- parseBoolean,
20
- parseMPDFloat,
21
- ValueParser,
22
- } from "./utils";
23
18
 
24
19
  /**
25
20
  * Parse an BaseURL element into an BaseURL intermediate
26
21
  * representation.
27
- * @param {Element} adaptationSetElement - The BaseURL root element.
22
+ * @param {Element} root - The BaseURL root element.
28
23
  * @returns {Array.<Object|undefined>}
29
24
  */
30
25
  export default function parseBaseURL(
31
26
  root: Element
32
27
  ) : [IBaseUrlIntermediateRepresentation | undefined, Error[]] {
33
- const attributes : { availabilityTimeOffset?: number;
34
- availabilityTimeComplete?: boolean; } = {};
35
28
  const value = root.textContent;
36
-
37
29
  const warnings : Error[] = [];
38
- const parseValue = ValueParser(attributes, warnings);
39
30
  if (value === null || value.length === 0) {
40
31
  return [undefined, warnings];
41
32
  }
42
- for (let i = 0; i < root.attributes.length; i++) {
43
- const attribute = root.attributes[i];
44
-
45
- switch (attribute.name) {
46
- case "availabilityTimeOffset":
47
- parseValue(attribute.value, { asKey: "availabilityTimeOffset",
48
- parser: parseMPDFloat,
49
- dashName: "availabilityTimeOffset" });
50
- break;
51
-
52
- case "availabilityTimeComplete":
53
- parseValue(attribute.value, { asKey: "availabilityTimeComplete",
54
- parser: parseBoolean,
55
- dashName: "availabilityTimeComplete" });
56
- break;
57
- }
58
- }
59
-
60
- return [ { value, attributes },
33
+ return [ { value },
61
34
  warnings ];
62
35
  }
@@ -359,14 +359,13 @@ describe("DASH Node Parsers - AdaptationSet", () => {
359
359
  it("should correctly parse a non-empty baseURLs", () => {
360
360
  const element1 = new DOMParser()
361
361
  // eslint-disable-next-line max-len
362
- .parseFromString("<AdaptationSet><BaseURL availabilityTimeOffset=\"INF\">a</BaseURL></AdaptationSet>", "text/xml")
362
+ .parseFromString("<AdaptationSet><BaseURL serviceLocation=\"foo\">a</BaseURL></AdaptationSet>", "text/xml")
363
363
  .childNodes[0] as Element;
364
364
  expect(createAdaptationSetIntermediateRepresentation(element1))
365
365
  .toEqual([
366
366
  {
367
367
  attributes: {},
368
- children: { baseURLs: [{ attributes: { availabilityTimeOffset: Infinity },
369
- value: "a" }],
368
+ children: { baseURLs: [{ value: "a" }],
370
369
  representations: [] },
371
370
  },
372
371
  [],
@@ -375,15 +374,14 @@ describe("DASH Node Parsers - AdaptationSet", () => {
375
374
  const element2 = new DOMParser()
376
375
  .parseFromString(
377
376
  // eslint-disable-next-line max-len
378
- "<AdaptationSet><BaseURL availabilityTimeOffset=\"4\">foo bar</BaseURL></AdaptationSet>",
377
+ "<AdaptationSet><BaseURL serviceLocation=\"4\">foo bar</BaseURL></AdaptationSet>",
379
378
  "text/xml"
380
379
  ).childNodes[0] as Element;
381
380
  expect(createAdaptationSetIntermediateRepresentation(element2))
382
381
  .toEqual([
383
382
  {
384
383
  attributes: {},
385
- children: { baseURLs: [{ attributes: { availabilityTimeOffset: 4 },
386
- value: "foo bar" }],
384
+ children: { baseURLs: [{ value: "foo bar" }],
387
385
  representations: [] },
388
386
  },
389
387
  [],
@@ -393,16 +391,14 @@ describe("DASH Node Parsers - AdaptationSet", () => {
393
391
  it("should correctly parse multiple non-empty baseURLs", () => {
394
392
  const element1 = new DOMParser()
395
393
  // eslint-disable-next-line max-len
396
- .parseFromString("<AdaptationSet><BaseURL availabilityTimeOffset=\"INF\">a</BaseURL><BaseURL availabilityTimeOffset=\"12\">b</BaseURL></AdaptationSet>", "text/xml")
394
+ .parseFromString("<AdaptationSet><BaseURL serviceLocation=\"\">a</BaseURL><BaseURL serviceLocation=\"http://test.com\">b</BaseURL></AdaptationSet>", "text/xml")
397
395
  .childNodes[0] as Element;
398
396
  expect(createAdaptationSetIntermediateRepresentation(element1))
399
397
  .toEqual([
400
398
  {
401
399
  attributes: {},
402
- children: { baseURLs: [ { attributes: { availabilityTimeOffset: Infinity },
403
- value: "a" },
404
- { attributes: { availabilityTimeOffset: 12 },
405
- value: "b" } ],
400
+ children: { baseURLs: [ { value: "a" },
401
+ { value: "b" } ],
406
402
  representations: [] },
407
403
  },
408
404
  [],
@@ -368,13 +368,6 @@ export interface IBaseUrlIntermediateRepresentation {
368
368
  * This is the inner content of a BaseURL node.
369
369
  */
370
370
  value: string;
371
-
372
- /** Attributes assiociated to the BaseURL node. */
373
- attributes: {
374
- /** availabilityTimeOffset attribute assiociated to that BaseURL node. */
375
- availabilityTimeOffset?: number;
376
- availabilityTimeComplete?: boolean;
377
- };
378
371
  }
379
372
 
380
373
  /** Intermediate representation for a Node following a "scheme" format. */
@@ -278,8 +278,10 @@ pub enum AttributeName {
278
278
  /// format: the browser's `DOMParser` API needs to know all potential
279
279
  /// namespaces that will appear in it.
280
280
  Namespace = 70,
281
-
281
+
282
282
  Label = 71, // String
283
+
284
+ ServiceLocation = 72, // String
283
285
  }
284
286
 
285
287
  impl TagName {
@@ -142,14 +142,7 @@ pub fn report_base_url_attrs(tag_bs : &quick_xml::events::BytesStart) {
142
142
  for res_attr in tag_bs.attributes() {
143
143
  match res_attr {
144
144
  Ok(attr) => match attr.key {
145
- b"availabilityTimeOffset" => {
146
- match attr.value.as_ref() {
147
- b"INF" => AvailabilityTimeOffset.report(f64::INFINITY),
148
- _ => AvailabilityTimeOffset.try_report_as_u64(&attr),
149
- }
150
- },
151
- b"availabilityTimeComplete" =>
152
- AvailabilityTimeComplete.try_report_as_bool(&attr),
145
+ b"serviceLocation" => ServiceLocation.try_report_as_string(&attr),
153
146
  _ => {},
154
147
  },
155
148
  Err(err) => ParsingError::from(err).report_err(),
@@ -30,24 +30,11 @@ export function generateBaseUrlAttrParser(
30
30
  linearMemory : WebAssembly.Memory
31
31
  ) : IAttributeParser {
32
32
  const textDecoder = new TextDecoder();
33
- let dataView;
34
33
  return function onMPDAttribute(attr : number, ptr : number, len : number) {
35
34
  switch (attr) {
36
35
  case AttributeName.Text:
37
36
  baseUrlAttrs.value = parseString(textDecoder, linearMemory.buffer, ptr, len);
38
37
  break;
39
-
40
- case AttributeName.AvailabilityTimeOffset: {
41
- dataView = new DataView(linearMemory.buffer);
42
- baseUrlAttrs.attributes.availabilityTimeOffset = dataView.getFloat64(ptr, true);
43
- break;
44
- }
45
-
46
- case AttributeName.AvailabilityTimeComplete: {
47
- baseUrlAttrs.attributes.availabilityTimeComplete =
48
- new DataView(linearMemory.buffer).getUint8(0) === 0;
49
- break;
50
- }
51
38
  }
52
39
  };
53
40
  }
@@ -282,4 +282,12 @@ export const enum AttributeName {
282
282
  Namespace = 70,
283
283
 
284
284
  Label = 71, // String
285
+
286
+ ServiceLocation = 72, // String
287
+
288
+ QueryBeforeStart = 73, // Boolean
289
+
290
+ ProxyServerUrl = 74, // String
291
+
292
+ DefaultServiceLocation = 75,
285
293
  }
@@ -133,6 +133,7 @@ function parseRepresentation(
133
133
  undefined :
134
134
  formatContentProtections(representation.contentProtections);
135
135
  return { id,
136
+ cdnMetadata: null,
136
137
  bitrate: representation.bitrate,
137
138
  height: representation.height,
138
139
  width: representation.width,
@@ -43,7 +43,7 @@ export default class LocalRepresentationIndex implements IRepresentationIndex {
43
43
  end: 0,
44
44
  duration: 0,
45
45
  timescale: 1,
46
- mediaURLs: null,
46
+ url: null,
47
47
  complete: true,
48
48
  privateInfos: {
49
49
  localManifestInitSegment: { load: this._index.loadInitSegment } },
@@ -81,7 +81,7 @@ export default class LocalRepresentationIndex implements IRepresentationIndex {
81
81
  duration: wantedSegment.duration,
82
82
  timescale: 1,
83
83
  timestampOffset: wantedSegment.timestampOffset,
84
- mediaURLs: null,
84
+ url: null,
85
85
  complete: true,
86
86
  privateInfos: {
87
87
  localManifestSegment: { load: this._index.loadSegment,
@@ -20,6 +20,7 @@ import Manifest, {
20
20
  SUPPORTED_ADAPTATIONS_TYPE,
21
21
  } from "../../../manifest";
22
22
  import idGenerator from "../../../utils/id_generator";
23
+ import { getFilenameIndexInUrl } from "../../../utils/resolve_url";
23
24
  import {
24
25
  IParsedAdaptation,
25
26
  IParsedAdaptations,
@@ -213,6 +214,7 @@ function createManifest(
213
214
  representations.push({
214
215
  bitrate: currentRepresentation.bitrate,
215
216
  index: newIndex,
217
+ cdnMetadata: currentRepresentation.cdnMetadata,
216
218
  id: currentRepresentation.id,
217
219
  height: currentRepresentation.height,
218
220
  width: currentRepresentation.width,
@@ -244,6 +246,9 @@ function createManifest(
244
246
  const newTextAdaptations : IParsedAdaptation[] = textTracks.map((track) => {
245
247
  const adaptationID = "gen-text-ada-" + generateAdaptationID();
246
248
  const representationID = "gen-text-rep-" + generateRepresentationID();
249
+ const indexOfFilename = getFilenameIndexInUrl(track.url);
250
+ const cdnUrl = track.url.substring(0, indexOfFilename);
251
+ const filename = track.url.substring(indexOfFilename);
247
252
  return {
248
253
  id: adaptationID,
249
254
  type: "text",
@@ -252,10 +257,11 @@ function createManifest(
252
257
  manuallyAdded: true,
253
258
  representations: [
254
259
  { bitrate: 0,
260
+ cdnMetadata: [{ baseUrl: cdnUrl }],
255
261
  id: representationID,
256
262
  mimeType: track.mimeType,
257
263
  codecs: track.codecs,
258
- index: new StaticRepresentationIndex({ media: track.url }),
264
+ index: new StaticRepresentationIndex({ media: filename }),
259
265
  },
260
266
  ],
261
267
  };
@@ -24,9 +24,7 @@ import {
24
24
  } from "../../../utils/byte_parsing";
25
25
  import isNonEmptyString from "../../../utils/is_non_empty_string";
26
26
  import objectAssign from "../../../utils/object_assign";
27
- import resolveURL, {
28
- normalizeBaseURL,
29
- } from "../../../utils/resolve_url";
27
+ import { getFilenameIndexInUrl } from "../../../utils/resolve_url";
30
28
  import { hexToBytes } from "../../../utils/string_parsing";
31
29
  import takeFirstSet from "../../../utils/take_first_set";
32
30
  import { createBox } from "../../containers/isobmff";
@@ -60,7 +58,7 @@ import { replaceRepresentationSmoothTokens } from "./utils/tokens";
60
58
  const DEFAULT_AGGRESSIVE_MODE = false;
61
59
 
62
60
  interface IAdaptationParserArguments { root : Element;
63
- rootURL : string;
61
+ baseUrl : string;
64
62
  timescale : number;
65
63
  protections : IContentProtectionSmooth[];
66
64
  isLive : boolean;
@@ -280,7 +278,7 @@ function createSmoothStreamingParser(
280
278
  function parseAdaptation(args: IAdaptationParserArguments) : IParsedAdaptation|null {
281
279
  const { root,
282
280
  timescale,
283
- rootURL,
281
+ baseUrl,
284
282
  protections,
285
283
  timeShiftBufferDepth,
286
284
  manifestReceivedTime,
@@ -301,11 +299,11 @@ function createSmoothStreamingParser(
301
299
 
302
300
  const subType = root.getAttribute("Subtype");
303
301
  const language = root.getAttribute("Language");
304
- const baseURLAttr = root.getAttribute("Url");
305
- const baseURL = baseURLAttr === null ? "" :
306
- baseURLAttr;
302
+ const UrlAttr = root.getAttribute("Url");
303
+ const UrlPathWithTokens = UrlAttr === null ? "" :
304
+ UrlAttr;
307
305
  if (__ENVIRONMENT__.CURRENT_ENV === __ENVIRONMENT__.DEV as number) {
308
- assert(baseURL !== "");
306
+ assert(UrlPathWithTokens !== "");
309
307
  }
310
308
 
311
309
  const { qualityLevels, cNodes } =
@@ -347,11 +345,10 @@ function createSmoothStreamingParser(
347
345
  "");
348
346
 
349
347
  const representations = qualityLevels.map((qualityLevel) => {
350
- const path = resolveURL(rootURL, baseURL);
351
348
  const repIndex = {
352
349
  timeline: index.timeline,
353
350
  timescale: index.timescale,
354
- media: replaceRepresentationSmoothTokens(path,
351
+ media: replaceRepresentationSmoothTokens(UrlPathWithTokens,
355
352
  qualityLevel.bitrate,
356
353
  qualityLevel.customAttributes),
357
354
  };
@@ -404,6 +401,9 @@ function createSmoothStreamingParser(
404
401
  const representation : IParsedRepresentation = objectAssign({},
405
402
  qualityLevel,
406
403
  { index: reprIndex,
404
+ cdnMetadata: [
405
+ { baseUrl },
406
+ ],
407
407
  mimeType,
408
408
  codecs,
409
409
  id });
@@ -452,7 +452,11 @@ function createSmoothStreamingParser(
452
452
  url? : string,
453
453
  manifestReceivedTime? : number
454
454
  ) : IParsedManifest {
455
- const rootURL = normalizeBaseURL(url == null ? "" : url);
455
+ let baseUrl : string = "";
456
+ if (url !== undefined) {
457
+ const filenameIdx = getFilenameIndexInUrl(url);
458
+ baseUrl = url.substring(0, filenameIdx);
459
+ }
456
460
  const root = doc.documentElement;
457
461
  if (root == null || root.nodeName !== "SmoothStreamingMedia") {
458
462
  throw new Error("document root should be SmoothStreamingMedia");
@@ -510,7 +514,7 @@ function createSmoothStreamingParser(
510
514
  const adaptations: IParsedAdaptations = adaptationNodes
511
515
  .reduce((acc: IParsedAdaptations, node : Element) => {
512
516
  const adaptation = parseAdaptation({ root: node,
513
- rootURL,
517
+ baseUrl,
514
518
  timescale,
515
519
  protections,
516
520
  isLive,
@@ -307,7 +307,7 @@ export default class SmoothRepresentationIndex implements IRepresentationIndex {
307
307
  return { id: "init",
308
308
  isInit: true,
309
309
  privateInfos: { smoothInitSegment: this._initSegmentInfos },
310
- mediaURLs: null,
310
+ url: null,
311
311
  time: 0,
312
312
  end: 0,
313
313
  duration: 0,
@@ -361,7 +361,7 @@ export default class SmoothRepresentationIndex implements IRepresentationIndex {
361
361
  duration: duration / timescale,
362
362
  timescale: 1 as const,
363
363
  number,
364
- mediaURLs: [replaceSegmentSmoothTokens(media, time)],
364
+ url: replaceSegmentSmoothTokens(media, time),
365
365
  complete: true,
366
366
  privateInfos: { smoothMediaSegment: { time,
367
367
  duration } } };