rx-player 3.27.0 → 3.27.1-dev.2022041500

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 (79) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/VERSION +1 -1
  3. package/dist/_esm5.processed/core/abr/abr_manager.d.ts +7 -3
  4. package/dist/_esm5.processed/core/abr/abr_manager.js +4 -3
  5. package/dist/_esm5.processed/core/abr/representation_estimator.d.ts +13 -8
  6. package/dist/_esm5.processed/core/abr/representation_estimator.js +4 -4
  7. package/dist/_esm5.processed/core/api/public_api.js +13 -14
  8. package/dist/_esm5.processed/core/init/content_time_boundaries_observer.d.ts +52 -0
  9. package/dist/_esm5.processed/core/init/content_time_boundaries_observer.js +223 -0
  10. package/dist/_esm5.processed/core/init/create_stream_playback_observer.js +17 -6
  11. package/dist/_esm5.processed/core/init/get_initial_time.d.ts +30 -5
  12. package/dist/_esm5.processed/core/init/get_initial_time.js +20 -13
  13. package/dist/_esm5.processed/core/init/load_on_media_source.js +16 -3
  14. package/dist/_esm5.processed/core/init/media_duration_updater.d.ts +56 -0
  15. package/dist/_esm5.processed/core/init/media_duration_updater.js +188 -0
  16. package/dist/_esm5.processed/core/stream/adaptation/adaptation_stream.d.ts +2 -5
  17. package/dist/_esm5.processed/core/stream/adaptation/create_representation_estimator.d.ts +3 -2
  18. package/dist/_esm5.processed/core/stream/adaptation/create_representation_estimator.js +3 -3
  19. package/dist/_esm5.processed/core/stream/orchestrator/stream_orchestrator.js +2 -22
  20. package/dist/_esm5.processed/core/stream/period/period_stream.d.ts +2 -5
  21. package/dist/_esm5.processed/core/stream/period/period_stream.js +6 -4
  22. package/dist/_esm5.processed/core/stream/representation/get_buffer_status.d.ts +4 -2
  23. package/dist/_esm5.processed/core/stream/representation/get_buffer_status.js +85 -42
  24. package/dist/_esm5.processed/core/stream/representation/representation_stream.js +3 -3
  25. package/dist/_esm5.processed/manifest/manifest.d.ts +14 -5
  26. package/dist/_esm5.processed/manifest/manifest.js +31 -12
  27. package/dist/_esm5.processed/manifest/period.d.ts +6 -0
  28. package/dist/_esm5.processed/manifest/period.js +9 -0
  29. package/dist/_esm5.processed/manifest/representation_index/types.d.ts +7 -2
  30. package/dist/_esm5.processed/parsers/manifest/dash/common/get_minimum_and_maximum_positions.d.ts +5 -1
  31. package/dist/_esm5.processed/parsers/manifest/dash/common/get_minimum_and_maximum_positions.js +6 -4
  32. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/base.js +2 -1
  33. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/list.d.ts +4 -0
  34. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/list.js +4 -2
  35. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/template.js +4 -2
  36. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +3 -3
  37. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_mpd.js +28 -20
  38. package/dist/_esm5.processed/parsers/manifest/local/parse_local_manifest.js +3 -2
  39. package/dist/_esm5.processed/parsers/manifest/metaplaylist/metaplaylist_parser.js +9 -3
  40. package/dist/_esm5.processed/parsers/manifest/smooth/create_parser.js +26 -17
  41. package/dist/_esm5.processed/parsers/manifest/types.d.ts +45 -17
  42. package/dist/_esm5.processed/parsers/manifest/utils/{get_maximum_position.d.ts → get_maximum_positions.d.ts} +4 -1
  43. package/dist/_esm5.processed/parsers/manifest/utils/{get_maximum_position.js → get_maximum_positions.js} +10 -6
  44. package/dist/rx-player.js +854 -351
  45. package/dist/rx-player.min.js +1 -1
  46. package/package.json +1 -1
  47. package/sonar-project.properties +1 -1
  48. package/src/core/abr/abr_manager.ts +11 -3
  49. package/src/core/abr/representation_estimator.ts +17 -10
  50. package/src/core/api/public_api.ts +13 -15
  51. package/src/core/init/content_time_boundaries_observer.ts +312 -0
  52. package/src/core/init/create_stream_playback_observer.ts +18 -7
  53. package/src/core/init/get_initial_time.ts +52 -19
  54. package/src/core/init/load_on_media_source.ts +22 -5
  55. package/src/core/init/media_duration_updater.ts +268 -0
  56. package/src/core/stream/adaptation/adaptation_stream.ts +2 -5
  57. package/src/core/stream/adaptation/create_representation_estimator.ts +6 -3
  58. package/src/core/stream/orchestrator/stream_orchestrator.ts +2 -29
  59. package/src/core/stream/period/period_stream.ts +12 -9
  60. package/src/core/stream/representation/get_buffer_status.ts +102 -41
  61. package/src/core/stream/representation/representation_stream.ts +3 -3
  62. package/src/manifest/__tests__/manifest.test.ts +94 -68
  63. package/src/manifest/manifest.ts +73 -33
  64. package/src/manifest/period.ts +10 -0
  65. package/src/manifest/representation_index/types.ts +7 -2
  66. package/src/parsers/manifest/dash/common/get_minimum_and_maximum_positions.ts +10 -5
  67. package/src/parsers/manifest/dash/common/indexes/base.ts +4 -3
  68. package/src/parsers/manifest/dash/common/indexes/list.ts +8 -1
  69. package/src/parsers/manifest/dash/common/indexes/template.ts +8 -3
  70. package/src/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.ts +7 -7
  71. package/src/parsers/manifest/dash/common/parse_mpd.ts +38 -20
  72. package/src/parsers/manifest/local/parse_local_manifest.ts +3 -2
  73. package/src/parsers/manifest/metaplaylist/metaplaylist_parser.ts +9 -4
  74. package/src/parsers/manifest/smooth/create_parser.ts +36 -18
  75. package/src/parsers/manifest/types.ts +45 -17
  76. package/src/parsers/manifest/utils/{get_maximum_position.ts → get_maximum_positions.ts} +13 -7
  77. package/dist/_esm5.processed/core/init/duration_updater.d.ts +0 -27
  78. package/dist/_esm5.processed/core/init/duration_updater.js +0 -136
  79. package/src/core/init/duration_updater.ts +0 -206
@@ -378,8 +378,12 @@ function createSmoothStreamingParser(parserOptions) {
378
378
  var firstAudioAdaptation = adaptations.audio !== undefined ?
379
379
  adaptations.audio[0] :
380
380
  undefined;
381
- var firstTimeReference;
382
- var lastTimeReference;
381
+ /** Minimum time that can be reached regardless of the StreamIndex chosen. */
382
+ var safeMinimumTime;
383
+ /** Maximum time that can be reached regardless of the StreamIndex chosen. */
384
+ var safeMaximumTime;
385
+ /** Maximum time that can be reached in absolute on the content. */
386
+ var unsafeMaximumTime;
383
387
  if (firstVideoAdaptation !== undefined || firstAudioAdaptation !== undefined) {
384
388
  var firstTimeReferences = [];
385
389
  var lastTimeReferences = [];
@@ -410,40 +414,45 @@ function createSmoothStreamingParser(parserOptions) {
410
414
  }
411
415
  }
412
416
  if (firstTimeReferences.length > 0) {
413
- firstTimeReference = Math.max.apply(Math, firstTimeReferences);
417
+ safeMinimumTime = Math.max.apply(Math, firstTimeReferences);
414
418
  }
415
419
  if (lastTimeReferences.length > 0) {
416
- lastTimeReference = Math.min.apply(Math, lastTimeReferences);
420
+ safeMaximumTime = Math.min.apply(Math, lastTimeReferences);
421
+ unsafeMaximumTime = Math.max.apply(Math, lastTimeReferences);
417
422
  }
418
423
  }
419
424
  var manifestDuration = root.getAttribute("Duration");
420
- var duration = (manifestDuration != null && +manifestDuration !== 0) ?
425
+ var duration = (manifestDuration !== null && +manifestDuration !== 0) ?
421
426
  (+manifestDuration / timescale) : undefined;
422
427
  if (isLive) {
423
428
  suggestedPresentationDelay = parserOptions.suggestedPresentationDelay;
424
429
  availabilityStartTime = referenceDateTime;
425
- minimumTime = firstTimeReference !== null && firstTimeReference !== void 0 ? firstTimeReference : availabilityStartTime;
426
- var maximumTime = lastTimeReference != null ?
427
- lastTimeReference :
428
- (Date.now() / 1000 - availabilityStartTime);
429
- maximumTimeData = { isLinear: true,
430
- value: maximumTime,
431
- time: performance.now() };
430
+ minimumTime = safeMinimumTime !== null && safeMinimumTime !== void 0 ? safeMinimumTime : availabilityStartTime;
431
+ var livePosition = unsafeMaximumTime;
432
+ if (livePosition === undefined) {
433
+ livePosition = (Date.now() / 1000 - availabilityStartTime);
434
+ }
435
+ var maximumSafePosition = safeMaximumTime;
436
+ if (maximumSafePosition === undefined) {
437
+ maximumSafePosition = livePosition;
438
+ }
439
+ maximumTimeData = { isLinear: true, maximumSafePosition: maximumSafePosition, livePosition: livePosition, time: performance.now() };
432
440
  timeshiftDepth = timeShiftBufferDepth !== null && timeShiftBufferDepth !== void 0 ? timeShiftBufferDepth : null;
433
441
  }
434
442
  else {
435
- minimumTime = firstTimeReference !== null && firstTimeReference !== void 0 ? firstTimeReference : 0;
436
- var maximumTime = lastTimeReference !== undefined ? lastTimeReference :
443
+ minimumTime = safeMinimumTime !== null && safeMinimumTime !== void 0 ? safeMinimumTime : 0;
444
+ var maximumTime = safeMaximumTime !== undefined ? safeMaximumTime :
437
445
  duration !== undefined ? minimumTime + duration :
438
446
  Infinity;
439
447
  maximumTimeData = { isLinear: false,
440
- value: maximumTime,
448
+ maximumSafePosition: maximumTime,
449
+ livePosition: undefined,
441
450
  time: performance.now() };
442
451
  }
443
452
  var periodStart = isLive ? 0 :
444
453
  minimumTime;
445
454
  var periodEnd = isLive ? undefined :
446
- maximumTimeData.value;
455
+ maximumTimeData.maximumSafePosition;
447
456
  var manifest = {
448
457
  availabilityStartTime: availabilityStartTime === undefined ?
449
458
  0 :
@@ -452,7 +461,7 @@ function createSmoothStreamingParser(parserOptions) {
452
461
  isLive: isLive,
453
462
  isDynamic: isLive,
454
463
  isLastPeriodKnown: true,
455
- timeBounds: { absoluteMinimumTime: minimumTime, timeshiftDepth: timeshiftDepth, maximumTimeData: maximumTimeData },
464
+ timeBounds: { minimumSafePosition: minimumTime, timeshiftDepth: timeshiftDepth, maximumTimeData: maximumTimeData },
456
465
  periods: [{ adaptations: adaptations, duration: periodEnd !== undefined ?
457
466
  periodEnd - periodStart : duration,
458
467
  end: periodEnd,
@@ -250,10 +250,15 @@ export interface IParsedManifest {
250
250
  */
251
251
  timeBounds: {
252
252
  /**
253
- * The minimum time, in seconds, available in this Manifest.
254
- * `undefined` if that value is unknown.
253
+ * This is the theoretical minimum playable position on the content
254
+ * regardless of the current Adaptation chosen, as estimated at parsing
255
+ * time.
256
+ * `undefined` if unknown.
257
+ *
258
+ * More technically, the `minimumSafePosition` is the maximum between all
259
+ * the minimum positions reachable in any of the audio and video Adaptation.
255
260
  */
256
- absoluteMinimumTime?: number | undefined;
261
+ minimumSafePosition?: number | undefined;
257
262
  /**
258
263
  * Some dynamic contents have the concept of a "window depth" (or "buffer
259
264
  * depth") which allows to set a minimum position for all reachable
@@ -270,27 +275,50 @@ export interface IParsedManifest {
270
275
  timeshiftDepth: number | null;
271
276
  /** Data allowing to calculate the maximum position at any given time. */
272
277
  maximumTimeData: {
273
- /** Maximum seekable time in milliseconds calculated at `time`. */
274
- value: number;
275
278
  /**
276
- * `Performance.now()` output at the time `value` was calculated.
277
- * This can be used to retrieve the maximum position from `value` when it
278
- * linearly evolves over time (see `isLinear` property).
279
+ * Current position representing live content.
280
+ * Only makes sense for un-ended live contents.
281
+ *
282
+ * `undefined` if unknown or if it doesn't make sense in the current context.
279
283
  */
280
- time: number;
284
+ livePosition: number | undefined;
281
285
  /**
282
- * Whether the maximum seekable position evolves linearly over time.
286
+ * Whether the maximum positions should evolve linearly over time.
283
287
  *
284
- * If set to `false`, `value` indicates the constant maximum position.
285
- *
286
- * If set to `true`, the maximum seekable time continuously increase at
288
+ * If set to `true`, the maximum seekable position continuously increase at
287
289
  * the same rate than the time since `time` does.
288
- * For example, a `value` of 50000 (50 seconds) will indicate a maximum time
289
- * of 51 seconds after 1 second have passed, of 56 seconds after 6 seconds
290
- * have passed (we know how many seconds have passed since the initial
291
- * calculation of value by checking the `time` property) etc.
290
+ *
291
+ * For example, a `maximumSafePosition` of 50000 (50 seconds) will
292
+ * indicate a maximum time of 51 seconds after 1 second have passed, of 56
293
+ * seconds after 6 seconds have passed (we know how many seconds have
294
+ * passed since the initial calculation of the maximum position by
295
+ * checking the `time` property) etc.
292
296
  */
293
297
  isLinear: boolean;
298
+ /**
299
+ * This is the theoretical maximum playable position on the content,
300
+ * regardless of the current Adaptation chosen, as estimated at parsing
301
+ * time.
302
+ *
303
+ * More technically, the `maximumSafePosition` is the minimum between all
304
+ * attributes indicating the duration of the content in the Manifest.
305
+ *
306
+ * That is the minimum between:
307
+ * - The Manifest original attributes relative to its duration
308
+ * - The minimum between all known maximum audio positions
309
+ * - The minimum between all known maximum video positions
310
+ *
311
+ * This can for example be understood as the safe maximum playable
312
+ * position through all possible tacks.
313
+ */
314
+ maximumSafePosition: number;
315
+ /**
316
+ * `Performance.now()` output at the time both `maximumSafePosition` and
317
+ * `maximumPositionWithMediaData` were calculated.
318
+ * This can be used to retrieve a new maximum position from them when they
319
+ * linearly evolves over time (see `isLinear` property).
320
+ */
321
+ time: number;
294
322
  };
295
323
  };
296
324
  /**
@@ -18,4 +18,7 @@ import { IParsedPeriod } from "../types";
18
18
  * @param {Object} manifest
19
19
  * @returns {number | undefined}
20
20
  */
21
- export default function getMaximumPosition(periods: IParsedPeriod[]): number | undefined;
21
+ export default function getMaximumPosition(periods: IParsedPeriod[]): {
22
+ safe: number | undefined;
23
+ unsafe: number | undefined;
24
+ };
@@ -36,14 +36,14 @@ export default function getMaximumPosition(periods) {
36
36
  if (firstAudioAdaptationFromPeriod !== undefined) {
37
37
  var lastPosition = getLastPositionFromAdaptation(firstAudioAdaptationFromPeriod);
38
38
  if (lastPosition === undefined) {
39
- return undefined;
39
+ return { safe: undefined, unsafe: undefined };
40
40
  }
41
41
  maximumAudioPosition = lastPosition;
42
42
  }
43
43
  if (firstVideoAdaptationFromPeriod !== undefined) {
44
44
  var lastPosition = getLastPositionFromAdaptation(firstVideoAdaptationFromPeriod);
45
45
  if (lastPosition === undefined) {
46
- return undefined;
46
+ return { safe: undefined, unsafe: undefined };
47
47
  }
48
48
  maximumVideoPosition = lastPosition;
49
49
  }
@@ -52,17 +52,21 @@ export default function getMaximumPosition(periods) {
52
52
  (firstVideoAdaptationFromPeriod !== undefined &&
53
53
  maximumVideoPosition === null)) {
54
54
  log.info("Parser utils: found Period with no segment. ", "Going to previous one to calculate last position");
55
- return undefined;
55
+ return { safe: undefined, unsafe: undefined };
56
56
  }
57
57
  if (maximumVideoPosition !== null) {
58
58
  if (maximumAudioPosition !== null) {
59
- return Math.min(maximumAudioPosition, maximumVideoPosition);
59
+ return { safe: Math.min(maximumAudioPosition, maximumVideoPosition),
60
+ unsafe: Math.max(maximumAudioPosition, maximumVideoPosition) };
60
61
  }
61
- return maximumVideoPosition;
62
+ return { safe: maximumVideoPosition,
63
+ unsafe: maximumVideoPosition };
62
64
  }
63
65
  if (maximumAudioPosition !== null) {
64
- return maximumAudioPosition;
66
+ return { safe: maximumAudioPosition,
67
+ unsafe: maximumAudioPosition };
65
68
  }
66
69
  }
67
70
  }
71
+ return { safe: undefined, unsafe: undefined };
68
72
  }