shaka-player 3.3.5 → 4.0.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 (184) hide show
  1. package/.github/config.yml +1 -0
  2. package/.github/workflows/demo-version-index.yaml +8 -0
  3. package/.github/workflows/release-please.yaml +18 -2
  4. package/.github/workflows/sync-labels.yaml +33 -0
  5. package/.github/workflows/update-issues.yaml +29 -0
  6. package/.github/workflows/validate-pr-title.yaml +35 -0
  7. package/AUTHORS +1 -0
  8. package/CHANGELOG.md +215 -41
  9. package/CONTRIBUTORS +1 -0
  10. package/README.md +14 -11
  11. package/app-engine/demo-version-index/README.md +3 -3
  12. package/app-engine/demo-version-index/app.yaml +27 -1
  13. package/app-engine/demo-version-index/generate.py +164 -0
  14. package/app-engine/demo-version-index/main.py +4 -155
  15. package/app-engine/demo-version-index/requirements.txt +0 -1
  16. package/build/checkversion.py +1 -1
  17. package/build/compiler.py +1 -1
  18. package/build/misspellings.txt +1 -0
  19. package/build/shaka-lab.yaml +0 -2
  20. package/build/types/polyfill +0 -3
  21. package/demo/common/asset.js +17 -1
  22. package/demo/common/assets.js +29 -0
  23. package/demo/common/message_ids.js +6 -3
  24. package/demo/config.js +10 -11
  25. package/demo/custom.js +39 -0
  26. package/demo/demo.less +0 -1
  27. package/demo/demo_utils.js +0 -1
  28. package/demo/locales/en.json +6 -3
  29. package/demo/locales/source.json +22 -10
  30. package/demo/main.js +9 -6
  31. package/demo/search.js +2 -1
  32. package/dist/controls.css +3 -3
  33. package/dist/controls.css.map +1 -1
  34. package/dist/demo.compiled.debug.js +71 -64
  35. package/dist/demo.compiled.debug.map +3 -3
  36. package/dist/demo.compiled.js +71 -64
  37. package/dist/demo.compiled.map +3 -3
  38. package/dist/demo.css +1 -1
  39. package/dist/demo.css.map +1 -1
  40. package/dist/deps.js +17 -20
  41. package/dist/locales.js +33 -31
  42. package/dist/receiver.compiled.debug.js +32 -28
  43. package/dist/receiver.compiled.debug.map +3 -3
  44. package/dist/receiver.compiled.js +32 -28
  45. package/dist/receiver.compiled.map +3 -3
  46. package/dist/shaka-player.compiled.d.ts +311 -314
  47. package/dist/shaka-player.compiled.debug.d.ts +311 -314
  48. package/dist/shaka-player.compiled.debug.externs.js +126 -126
  49. package/dist/shaka-player.compiled.debug.js +430 -484
  50. package/dist/shaka-player.compiled.debug.map +4 -4
  51. package/dist/shaka-player.compiled.externs.js +126 -126
  52. package/dist/shaka-player.compiled.js +829 -845
  53. package/dist/shaka-player.compiled.map +4 -4
  54. package/dist/shaka-player.ui.d.ts +357 -358
  55. package/dist/shaka-player.ui.debug.d.ts +357 -358
  56. package/dist/shaka-player.ui.debug.externs.js +134 -126
  57. package/dist/shaka-player.ui.debug.js +489 -541
  58. package/dist/shaka-player.ui.debug.map +4 -4
  59. package/dist/shaka-player.ui.externs.js +134 -126
  60. package/dist/shaka-player.ui.js +988 -1000
  61. package/dist/shaka-player.ui.map +4 -4
  62. package/docs/tutorials/config.md +0 -2
  63. package/docs/tutorials/drm-config.md +5 -0
  64. package/docs/tutorials/fairplay.md +7 -22
  65. package/docs/tutorials/faq.md +0 -11
  66. package/docs/tutorials/index.json +2 -8
  67. package/docs/tutorials/plugins.md +1 -3
  68. package/docs/tutorials/upgrade.md +85 -11
  69. package/externs/polyfill.js +15 -0
  70. package/externs/shaka/manifest.js +5 -1
  71. package/externs/shaka/net.js +12 -0
  72. package/externs/shaka/offline.js +5 -1
  73. package/externs/shaka/player.js +39 -21
  74. package/externs/shaka/text.js +12 -12
  75. package/externs/sourcebuffer.js +15 -0
  76. package/lib/abr/simple_abr_manager.js +2 -1
  77. package/lib/ads/client_side_ad.js +13 -2
  78. package/lib/ads/client_side_ad_manager.js +22 -4
  79. package/lib/cast/cast_utils.js +0 -1
  80. package/lib/dash/content_protection.js +85 -5
  81. package/lib/dash/dash_parser.js +1 -0
  82. package/lib/hls/hls_parser.js +390 -747
  83. package/lib/hls/manifest_text_parser.js +2 -3
  84. package/lib/media/drm_engine.js +105 -37
  85. package/lib/media/gap_jumping_controller.js +10 -45
  86. package/lib/media/media_source_engine.js +150 -30
  87. package/lib/media/playhead.js +2 -5
  88. package/lib/media/presentation_timeline.js +1 -2
  89. package/lib/media/segment_index.js +13 -46
  90. package/lib/media/segment_reference.js +47 -1
  91. package/lib/media/streaming_engine.js +28 -11
  92. package/lib/media/time_ranges_utils.js +4 -9
  93. package/lib/net/networking_engine.js +3 -0
  94. package/lib/offline/indexeddb/v1_storage_cell.js +1 -0
  95. package/lib/offline/indexeddb/v2_storage_cell.js +1 -0
  96. package/lib/offline/manifest_converter.js +1 -0
  97. package/lib/offline/storage.js +8 -41
  98. package/lib/player.js +17 -201
  99. package/lib/polyfill/media_capabilities.js +12 -6
  100. package/lib/polyfill/mediasource.js +0 -28
  101. package/lib/polyfill/patchedmediakeys_nop.js +2 -0
  102. package/lib/polyfill/patchedmediakeys_webkit.js +2 -0
  103. package/lib/text/cue.js +0 -6
  104. package/lib/text/lrc_text_parser.js +8 -0
  105. package/lib/text/mp4_ttml_parser.js +8 -0
  106. package/lib/text/mp4_vtt_parser.js +8 -0
  107. package/lib/text/sbv_text_parser.js +8 -0
  108. package/lib/text/simple_text_displayer.js +1 -7
  109. package/lib/text/srt_text_parser.js +8 -0
  110. package/lib/text/ssa_text_parser.js +8 -0
  111. package/lib/text/text_engine.js +19 -3
  112. package/lib/text/ttml_text_parser.js +8 -0
  113. package/lib/text/ui_text_displayer.js +1 -7
  114. package/lib/text/vtt_text_parser.js +27 -5
  115. package/lib/text/web_vtt_generator.js +1 -7
  116. package/lib/util/error.js +9 -13
  117. package/lib/util/fairplay_utils.js +109 -0
  118. package/lib/util/functional.js +0 -42
  119. package/lib/util/mime_utils.js +16 -5
  120. package/lib/util/platform.js +45 -0
  121. package/lib/util/player_configuration.js +17 -6
  122. package/lib/util/pssh.js +23 -4
  123. package/lib/util/stream_utils.js +92 -22
  124. package/lib/util/uint8array_utils.js +0 -16
  125. package/lib/util/xml_utils.js +1 -1
  126. package/package.json +5 -2
  127. package/roadmap.md +19 -19
  128. package/shaka-player.uncompiled.js +0 -3
  129. package/test/dash/dash_parser_content_protection_unit.js +44 -0
  130. package/test/dash/dash_parser_segment_template_unit.js +3 -4
  131. package/test/demo/demo_unit.js +2 -1
  132. package/test/hls/hls_live_unit.js +155 -230
  133. package/test/hls/hls_parser_unit.js +515 -432
  134. package/test/media/drm_engine_unit.js +86 -120
  135. package/test/media/media_source_engine_integration.js +25 -3
  136. package/test/media/media_source_engine_unit.js +3 -2
  137. package/test/media/playhead_unit.js +27 -191
  138. package/test/media/segment_index_unit.js +15 -25
  139. package/test/media/streaming_engine_integration.js +2 -39
  140. package/test/media/streaming_engine_unit.js +3 -2
  141. package/test/media/time_ranges_utils_unit.js +0 -5
  142. package/test/offline/manifest_convert_unit.js +34 -4
  143. package/test/offline/offline_manifest_parser_unit.js +1 -0
  144. package/test/offline/storage_integration.js +5 -4
  145. package/test/player_external.js +0 -6
  146. package/test/player_integration.js +16 -0
  147. package/test/player_unit.js +26 -0
  148. package/test/test/util/fake_media_source_engine.js +11 -4
  149. package/test/test/util/manifest_generator.js +3 -1
  150. package/test/test/util/manifest_parser_util.js +4 -1
  151. package/test/test/util/offline_utils.js +1 -0
  152. package/test/test/util/streaming_engine_util.js +1 -0
  153. package/test/test/util/test_scheme.js +24 -1
  154. package/test/test/util/util.js +4 -4
  155. package/test/text/cue_integration.js +2 -2
  156. package/test/text/lrc_text_parser_unit.js +6 -7
  157. package/test/text/mp4_ttml_parser_unit.js +6 -4
  158. package/test/text/mp4_vtt_parser_unit.js +6 -5
  159. package/test/text/sbv_text_parser_unit.js +5 -6
  160. package/test/text/srt_text_parser_unit.js +5 -6
  161. package/test/text/ssa_text_parser_unit.js +17 -29
  162. package/test/text/text_engine_unit.js +45 -5
  163. package/test/text/ttml_text_parser_unit.js +77 -77
  164. package/test/text/vtt_text_parser_unit.js +116 -59
  165. package/test/ui/ui_integration.js +0 -16
  166. package/test/ui/ui_unit.js +27 -0
  167. package/test/util/cmcd_manager_unit.js +3 -0
  168. package/test/util/stream_utils_unit.js +23 -7
  169. package/ui/controls.js +65 -40
  170. package/ui/fullscreen_button.js +26 -6
  171. package/ui/less/containers.less +4 -4
  172. package/ui/less/general.less +1 -1
  173. package/ui/less/range_elements.less +1 -0
  174. package/ui/locales/en.json +1 -0
  175. package/ui/locales/source.json +5 -0
  176. package/ui/resolution_selection.js +31 -33
  177. package/ui/ui.js +0 -17
  178. package/.github/pull_request_template.md +0 -10
  179. package/docs/tutorials/upgrade-v2-5.md +0 -441
  180. package/docs/tutorials/upgrade-v3.md +0 -38
  181. package/lib/polyfill/mathround.js +0 -49
  182. package/lib/polyfill/patchedmediakeys_apple.js +0 -744
  183. package/lib/polyfill/patchedmediakeys_ms.js +0 -698
  184. package/test/util/functional_unit.js +0 -82
@@ -160,10 +160,8 @@ shaka.media.MediaSourcePlayhead = class {
160
160
  * @param {function()} onSeek
161
161
  * Called when the user agent seeks to a time within the presentation
162
162
  * timeline.
163
- * @param {function(!Event)} onEvent
164
- * Called when an event is raised to be sent to the application.
165
163
  */
166
- constructor(mediaElement, manifest, config, startTime, onSeek, onEvent) {
164
+ constructor(mediaElement, manifest, config, startTime, onSeek) {
167
165
  /**
168
166
  * The seek range must be at least this number of seconds long. If it is
169
167
  * smaller than this, change it to be this big so we don't repeatedly seek
@@ -199,8 +197,7 @@ shaka.media.MediaSourcePlayhead = class {
199
197
  mediaElement,
200
198
  manifest.presentationTimeline,
201
199
  config,
202
- this.createStallDetector_(mediaElement, config),
203
- onEvent);
200
+ this.createStallDetector_(mediaElement, config));
204
201
 
205
202
  /** @private {shaka.media.VideoWrapper} */
206
203
  this.videoWrapper_ = new shaka.media.VideoWrapper(
@@ -249,8 +249,7 @@ shaka.media.PresentationTimeline = class {
249
249
  * @param {number} startTime
250
250
  * @export
251
251
  */
252
- notifyMinSegmentStartTime(
253
- startTime) {
252
+ notifyMinSegmentStartTime(startTime) {
254
253
  if (this.minSegmentStartTime_ == null) {
255
254
  // No data yet, and Math.min(null, startTime) is always 0. So just store
256
255
  // startTime.
@@ -9,7 +9,6 @@ goog.provide('shaka.media.SegmentIndex');
9
9
  goog.provide('shaka.media.SegmentIterator');
10
10
 
11
11
  goog.require('goog.asserts');
12
- goog.require('shaka.Deprecate');
13
12
  goog.require('shaka.media.SegmentReference');
14
13
  goog.require('shaka.util.IReleasable');
15
14
  goog.require('shaka.util.Timer');
@@ -52,23 +51,6 @@ shaka.media.SegmentIndex = class {
52
51
  }
53
52
 
54
53
 
55
- /**
56
- * SegmentIndex used to be an IDestroyable. Now it is an IReleasable.
57
- * This method is provided for backward compatibility.
58
- *
59
- * @deprecated
60
- * @return {!Promise}
61
- * @export
62
- */
63
- destroy() {
64
- shaka.Deprecate.deprecateFeature(4,
65
- 'shaka.media.SegmentIndex',
66
- 'Please use release() instead of destroy().');
67
- this.release();
68
- return Promise.resolve();
69
- }
70
-
71
-
72
54
  /**
73
55
  * @override
74
56
  * @export
@@ -101,6 +83,17 @@ shaka.media.SegmentIndex = class {
101
83
  }
102
84
 
103
85
 
86
+ /**
87
+ * Iterates over all top-level segment references in this segment index.
88
+ * @param {function(!shaka.media.SegmentReference)} fn
89
+ */
90
+ forEachTopLevelReference(fn) {
91
+ for (const reference of this.references) {
92
+ fn(reference);
93
+ }
94
+ }
95
+
96
+
104
97
  /**
105
98
  * Finds the position of the segment for the given time, in seconds, relative
106
99
  * to the start of the presentation. Returns the position of the segment
@@ -191,9 +184,6 @@ shaka.media.SegmentIndex = class {
191
184
  * @param {!Array.<!shaka.media.SegmentReference>} references The list of
192
185
  * SegmentReferences, which must be sorted first by their start times
193
186
  * (ascending) and second by their end times (ascending).
194
- * @deprecated Not used directly by our own parsers, so will become private in
195
- * v4. Use mergeAndEvict() instead.
196
- * @export
197
187
  */
198
188
  merge(references) {
199
189
  if (goog.DEBUG) {
@@ -348,7 +338,8 @@ shaka.media.SegmentIndex = class {
348
338
  lastReference.appendWindowEnd,
349
339
  lastReference.partialReferences,
350
340
  lastReference.tilesLayout,
351
- lastReference.tileDuration);
341
+ lastReference.tileDuration,
342
+ lastReference.syncTime);
352
343
  }
353
344
 
354
345
 
@@ -513,30 +504,6 @@ shaka.media.SegmentIterator = class {
513
504
  this.currentPartialPosition_ = partialSegmentIndex;
514
505
  }
515
506
 
516
- /**
517
- * Move the iterator to a given timestamp in the underlying SegmentIndex.
518
- *
519
- * @param {number} time
520
- * @return {shaka.media.SegmentReference}
521
- * @deprecated Use SegmentIndex.getIteratorForTime instead
522
- * @export
523
- */
524
- seek(time) {
525
- shaka.Deprecate.deprecateFeature(
526
- 4, 'shaka.media.SegmentIterator',
527
- 'Please use SegmentIndex.getIteratorForTime instead of seek().');
528
-
529
- const iter = this.segmentIndex_.getIteratorForTime(time);
530
- if (iter) {
531
- this.currentPosition_ = iter.currentPosition_;
532
- this.currentPartialPosition_ = iter.currentPartialPosition_;
533
- } else {
534
- this.currentPosition_ = Number.MAX_VALUE;
535
- this.currentPartialPosition_ = 0;
536
- }
537
- return this.next().value;
538
- }
539
-
540
507
  /**
541
508
  * @return {shaka.media.SegmentReference}
542
509
  * @export
@@ -159,11 +159,18 @@ shaka.media.SegmentReference = class {
159
159
  * The explicit duration of an individual tile within the tiles grid.
160
160
  * If not provided, the duration should be automatically calculated based on
161
161
  * the duration of the reference.
162
+ * @param {?number=} syncTime
163
+ * A time value, expressed in the same scale as the start and end time, which
164
+ * is used to synchronize between streams.
165
+ * @param {shaka.media.SegmentReference.Status=} status
166
+ * The segment status is used to indicate that a segment does not exist or is
167
+ * not available.
162
168
  */
163
169
  constructor(
164
170
  startTime, endTime, uris, startByte, endByte, initSegmentReference,
165
171
  timestampOffset, appendWindowStart, appendWindowEnd,
166
- partialReferences = [], tilesLayout = '', tileDuration = null) {
172
+ partialReferences = [], tilesLayout = '', tileDuration = null,
173
+ syncTime = null, status = shaka.media.SegmentReference.Status.AVAILABLE) {
167
174
  // A preload hinted Partial Segment has the same startTime and endTime.
168
175
  goog.asserts.assert(startTime <= endTime,
169
176
  'startTime must be less than or equal to endTime');
@@ -213,6 +220,12 @@ shaka.media.SegmentReference = class {
213
220
 
214
221
  /** @type {?number} */
215
222
  this.tileDuration = tileDuration;
223
+
224
+ /** @type {?number} */
225
+ this.syncTime = syncTime;
226
+
227
+ /** @type {shaka.media.SegmentReference.Status} */
228
+ this.status = status;
216
229
  }
217
230
 
218
231
  /**
@@ -308,6 +321,39 @@ shaka.media.SegmentReference = class {
308
321
  getTileDuration() {
309
322
  return this.tileDuration;
310
323
  }
324
+
325
+ /**
326
+ * Returns the segment's status.
327
+ *
328
+ * @return {shaka.media.SegmentReference.Status}
329
+ * @export
330
+ */
331
+ getStatus() {
332
+ return this.status;
333
+ }
334
+
335
+ /**
336
+ * Mark the reference as unavailable.
337
+ *
338
+ * @export
339
+ */
340
+ markAsUnavailable() {
341
+ this.status = shaka.media.SegmentReference.Status.UNAVAILABLE;
342
+ }
343
+ };
344
+
345
+
346
+ /**
347
+ * Rather than using booleans to communicate what the state of the reference,
348
+ * we have this enum.
349
+ *
350
+ * @enum {number}
351
+ * @export
352
+ */
353
+ shaka.media.SegmentReference.Status = {
354
+ AVAILABLE: 0,
355
+ UNAVAILABLE: 1,
356
+ MISSING: 2,
311
357
  };
312
358
 
313
359
 
@@ -234,7 +234,8 @@ shaka.media.StreamingEngine = class {
234
234
 
235
235
  const mimeType = shaka.util.MimeUtils.getFullType(
236
236
  stream.mimeType, stream.codecs);
237
- this.playerInterface_.mediaSourceEngine.reinitText(mimeType);
237
+ this.playerInterface_.mediaSourceEngine.reinitText(
238
+ mimeType, this.manifest_.sequenceMode);
238
239
 
239
240
  const textDisplayer =
240
241
  this.playerInterface_.mediaSourceEngine.getTextDisplayer();
@@ -428,7 +429,8 @@ shaka.media.StreamingEngine = class {
428
429
  // init segment again.
429
430
  const fullMimeType = shaka.util.MimeUtils.getFullType(
430
431
  stream.mimeType, stream.codecs);
431
- this.playerInterface_.mediaSourceEngine.reinitText(fullMimeType);
432
+ this.playerInterface_.mediaSourceEngine.reinitText(
433
+ fullMimeType, this.manifest_.sequenceMode);
432
434
  }
433
435
 
434
436
  // Releases the segmentIndex of the old stream.
@@ -604,11 +606,10 @@ shaka.media.StreamingEngine = class {
604
606
  */
605
607
  seeked() {
606
608
  const presentationTime = this.playerInterface_.getPresentationTime();
607
- const smallGapLimit = this.config_.smallGapLimit;
608
609
  const ContentType = shaka.util.ManifestParserUtils.ContentType;
609
610
  const newTimeIsBuffered = (type) => {
610
611
  return this.playerInterface_.mediaSourceEngine.isBuffered(
611
- type, presentationTime, smallGapLimit);
612
+ type, presentationTime);
612
613
  };
613
614
 
614
615
  let streamCleared = false;
@@ -645,6 +646,10 @@ shaka.media.StreamingEngine = class {
645
646
  if (type === ContentType.TEXT) {
646
647
  this.playerInterface_.mediaSourceEngine.resetCaptionParser();
647
648
  }
649
+
650
+ // Mark the media state as having seeked, so that the new buffers know
651
+ // that they will need to be at a new position (for sequence mode).
652
+ mediaState.seeked = true;
648
653
  }
649
654
  }
650
655
 
@@ -764,7 +769,9 @@ shaka.media.StreamingEngine = class {
764
769
  const mediaSourceEngine = this.playerInterface_.mediaSourceEngine;
765
770
  const forceTransmuxTS = this.config_.forceTransmuxTS;
766
771
 
767
- await mediaSourceEngine.init(streamsByType, forceTransmuxTS);
772
+
773
+ await mediaSourceEngine.init(streamsByType, forceTransmuxTS,
774
+ this.manifest_.sequenceMode);
768
775
  this.destroyer_.ensureNotDestroyed();
769
776
 
770
777
  this.setDuration_();
@@ -805,6 +812,9 @@ shaka.media.StreamingEngine = class {
805
812
  clearBufferSafeMargin: 0,
806
813
  waitingToFlushBuffer: false,
807
814
  clearingBuffer: false,
815
+ // The playhead might be seeking on startup, if a start time is set, so
816
+ // start "seeked" as true.
817
+ seeked: true,
808
818
  recovering: false,
809
819
  hasError: false,
810
820
  operation: null,
@@ -1272,6 +1282,7 @@ shaka.media.StreamingEngine = class {
1272
1282
  this.scheduleUpdate_(mediaState, 0);
1273
1283
  return;
1274
1284
  }
1285
+
1275
1286
  await this.append_(
1276
1287
  mediaState, presentationTime, stream, reference, result);
1277
1288
  }
@@ -1508,7 +1519,7 @@ shaka.media.StreamingEngine = class {
1508
1519
 
1509
1520
  await this.playerInterface_.mediaSourceEngine.setStreamProperties(
1510
1521
  mediaState.type, timestampOffset, appendWindowStart,
1511
- appendWindowEnd);
1522
+ appendWindowEnd, this.manifest_.sequenceMode);
1512
1523
  } catch (error) {
1513
1524
  mediaState.lastAppendWindowStart = null;
1514
1525
  mediaState.lastAppendWindowEnd = null;
@@ -1565,8 +1576,7 @@ shaka.media.StreamingEngine = class {
1565
1576
  * @return {!Promise}
1566
1577
  * @private
1567
1578
  */
1568
- async append_(mediaState, presentationTime, stream, reference,
1569
- segment) {
1579
+ async append_(mediaState, presentationTime, stream, reference, segment) {
1570
1580
  const logPrefix = shaka.media.StreamingEngine.logPrefix_(mediaState);
1571
1581
 
1572
1582
  const hasClosedCaptions = stream.closedCaptions &&
@@ -1584,14 +1594,18 @@ shaka.media.StreamingEngine = class {
1584
1594
 
1585
1595
  await this.evict_(mediaState, presentationTime);
1586
1596
  this.destroyer_.ensureNotDestroyed();
1587
- shaka.log.v1(logPrefix, 'appending media segment');
1597
+ shaka.log.v1(logPrefix, 'appending media segment at',
1598
+ (reference.syncTime == null ? 'unknown' : reference.syncTime));
1588
1599
 
1600
+ const seeked = mediaState.seeked;
1601
+ mediaState.seeked = false;
1589
1602
  await this.playerInterface_.mediaSourceEngine.appendBuffer(
1590
1603
  mediaState.type,
1591
1604
  segment,
1592
- reference.startTime,
1605
+ reference.syncTime == null ? reference.startTime : reference.syncTime,
1593
1606
  reference.endTime,
1594
- hasClosedCaptions);
1607
+ hasClosedCaptions,
1608
+ seeked);
1595
1609
  this.destroyer_.ensureNotDestroyed();
1596
1610
  shaka.log.v2(logPrefix, 'appended media segment');
1597
1611
  }
@@ -2017,6 +2031,7 @@ shaka.media.StreamingEngine.PlayerInterface;
2017
2031
  * waitingToFlushBuffer: boolean,
2018
2032
  * clearBufferSafeMargin: number,
2019
2033
  * clearingBuffer: boolean,
2034
+ * seeked: boolean,
2020
2035
  * recovering: boolean,
2021
2036
  * hasError: boolean,
2022
2037
  * operation: shaka.net.NetworkingEngine.PendingRequest
@@ -2061,6 +2076,8 @@ shaka.media.StreamingEngine.PlayerInterface;
2061
2076
  * The amount of buffer to retain when clearing the buffer after the update.
2062
2077
  * @property {boolean} clearingBuffer
2063
2078
  * True indicates that the buffer is being cleared.
2079
+ * @property {boolean} seeked
2080
+ * True indicates that the presentation just seeked.
2064
2081
  * @property {boolean} recovering
2065
2082
  * True indicates that the last segment was not appended because it could not
2066
2083
  * fit in the buffer.
@@ -54,17 +54,13 @@ shaka.media.TimeRangesUtils = class {
54
54
 
55
55
 
56
56
  /**
57
- * Determines if the given time is inside a buffered range. This includes
58
- * gaps, meaning that if the playhead is in a gap, it is considered buffered.
59
- * If there is a small gap between the playhead and buffer start, consider it
60
- * as buffered.
57
+ * Determines if the given time is inside a buffered range.
61
58
  *
62
59
  * @param {TimeRanges} b
63
60
  * @param {number} time Playhead time
64
- * @param {number=} smallGapLimit Set in configuration
65
61
  * @return {boolean}
66
62
  */
67
- static isBuffered(b, time, smallGapLimit = 0) {
63
+ static isBuffered(b, time) {
68
64
  if (!b || !b.length) {
69
65
  return false;
70
66
  }
@@ -76,9 +72,8 @@ shaka.media.TimeRangesUtils = class {
76
72
  if (time > b.end(b.length - 1)) {
77
73
  return false;
78
74
  }
79
- // Push the time forward by the gap limit so that it is more likely to be in
80
- // the range.
81
- return (time + smallGapLimit >= b.start(0));
75
+
76
+ return time >= b.start(0);
82
77
  }
83
78
 
84
79
 
@@ -220,6 +220,9 @@ shaka.net.NetworkingEngine = class extends shaka.util.FakeEventTarget {
220
220
  retryParameters: retryParams,
221
221
  licenseRequestType: null,
222
222
  sessionId: null,
223
+ drmInfo: null,
224
+ initData: null,
225
+ initDataType: null,
223
226
  streamDataCallback: streamDataCallback,
224
227
  };
225
228
  }
@@ -99,6 +99,7 @@ shaka.offline.indexeddb.V1StorageCell = class
99
99
  sessionIds: old.sessionIds,
100
100
  drmInfo: old.drmInfo,
101
101
  appMetadata: old.appMetadata,
102
+ sequenceMode: false,
102
103
  };
103
104
  }
104
105
 
@@ -60,6 +60,7 @@ shaka.offline.indexeddb.V2StorageCell = class
60
60
  sessionIds: old.sessionIds,
61
61
  size: old.size,
62
62
  streams,
63
+ sequenceMode: false,
63
64
  };
64
65
  }
65
66
 
@@ -87,6 +87,7 @@ shaka.offline.ManifestConverter = class {
87
87
  variants: Array.from(variants.values()),
88
88
  textStreams: textStreams,
89
89
  imageStreams: imageStreams,
90
+ sequenceMode: manifestDB.sequenceMode || false,
90
91
  };
91
92
  }
92
93
 
@@ -7,7 +7,6 @@
7
7
  goog.provide('shaka.offline.Storage');
8
8
 
9
9
  goog.require('goog.asserts');
10
- goog.require('shaka.Deprecate');
11
10
  goog.require('shaka.Player');
12
11
  goog.require('shaka.log');
13
12
  goog.require('shaka.media.DrmEngine');
@@ -25,7 +24,6 @@ goog.require('shaka.util.ArrayUtils');
25
24
  goog.require('shaka.util.ConfigUtils');
26
25
  goog.require('shaka.util.Destroyer');
27
26
  goog.require('shaka.util.Error');
28
- goog.require('shaka.util.Functional');
29
27
  goog.require('shaka.util.IDestroyable');
30
28
  goog.require('shaka.util.Iterables');
31
29
  goog.require('shaka.util.MimeUtils');
@@ -194,20 +192,8 @@ shaka.offline.Storage = class {
194
192
  if (arguments.length == 2 && typeof(config) == 'string') {
195
193
  config = shaka.util.ConfigUtils.convertToConfigObject(config, value);
196
194
  }
197
-
198
195
  goog.asserts.assert(typeof(config) == 'object', 'Should be an object!');
199
196
 
200
- // Deprecate 'manifest.dash.defaultPresentationDelay' configuration.
201
- if (config['manifest'] && config['manifest']['dash'] &&
202
- 'defaultPresentationDelay' in config['manifest']['dash']) {
203
- shaka.Deprecate.deprecateFeature(4,
204
- 'manifest.dash.defaultPresentationDelay configuration',
205
- 'Please Use manifest.defaultPresentationDelay instead.');
206
- config['manifest']['defaultPresentationDelay'] =
207
- config['manifest']['dash']['defaultPresentationDelay'];
208
- delete config['manifest']['dash']['defaultPresentationDelay'];
209
- }
210
-
211
197
  goog.asserts.assert(
212
198
  this.config_, 'Cannot reconfigure storage after calling destroy.');
213
199
  return shaka.util.PlayerConfiguration.mergeConfigObjects(
@@ -291,7 +277,7 @@ shaka.offline.Storage = class {
291
277
  config.manifest.retryParameters,
292
278
  mimeType || null);
293
279
 
294
- return shaka.util.Functional.callFactory(factory);
280
+ return factory();
295
281
  };
296
282
 
297
283
  /** @type {!shaka.offline.DownloadManager} */
@@ -308,33 +294,9 @@ shaka.offline.Storage = class {
308
294
  shaka.util.ArrayUtils.remove(this.openDownloadManagers_, downloader);
309
295
  });
310
296
 
311
- // Provide a temporary shim for "then" for backward compatibility.
312
- /** @type {!Object} */ (abortableStoreOp)['then'] = (onSuccess) => {
313
- shaka.Deprecate.deprecateFeature(4,
314
- 'shaka.offline.Storage.store.then',
315
- 'Storage operations now return a shaka.util.AbortableOperation, ' +
316
- 'rather than a promise. Please update to conform to this new API; ' +
317
- 'you can use the |chain| method instead.');
318
- return abortableStoreOp.promise.then(onSuccess);
319
- };
320
-
321
297
  return this.startAbortableOperation_(abortableStoreOp);
322
298
  }
323
299
 
324
- /**
325
- * Returns true if an asset is currently downloading.
326
- *
327
- * @return {boolean}
328
- * @deprecated
329
- * @export
330
- */
331
- getStoreInProgress() {
332
- shaka.Deprecate.deprecateFeature(4,
333
- 'shaka.offline.Storage.getStoreInProgress',
334
- 'Multiple concurrent downloads are now supported.');
335
- return false;
336
- }
337
-
338
300
  /**
339
301
  * See |shaka.offline.Storage.store| for details.
340
302
  *
@@ -870,6 +832,7 @@ shaka.offline.Storage = class {
870
832
  drmInfo,
871
833
  appMetadata: metadata,
872
834
  isIncomplete: true,
835
+ sequenceMode: manifest.sequenceMode,
873
836
  };
874
837
 
875
838
  return {manifestDB, toDownload};
@@ -1365,6 +1328,9 @@ shaka.offline.Storage = class {
1365
1328
  const startTime =
1366
1329
  manifest.presentationTimeline.getSegmentAvailabilityStart();
1367
1330
 
1331
+ const numberOfParallelDownloads = config.offline.numberOfParallelDownloads;
1332
+ let groupId = 0;
1333
+
1368
1334
  shaka.offline.Storage.forEachSegment_(stream, startTime, (segment) => {
1369
1335
  const pendingSegmentRefId =
1370
1336
  shaka.offline.DownloadInfo.idForSegmentRef(segment);
@@ -1378,7 +1344,7 @@ shaka.offline.Storage = class {
1378
1344
  const segmentDownload = new shaka.offline.DownloadInfo(
1379
1345
  segment,
1380
1346
  estimateId,
1381
- stream.id,
1347
+ groupId,
1382
1348
  /* isInitSegment= */ false);
1383
1349
  toDownload.set(pendingSegmentRefId, segmentDownload);
1384
1350
  }
@@ -1393,7 +1359,7 @@ shaka.offline.Storage = class {
1393
1359
  const initDownload = new shaka.offline.DownloadInfo(
1394
1360
  segment.initSegmentReference,
1395
1361
  estimateId,
1396
- stream.id,
1362
+ groupId,
1397
1363
  /* isInitSegment= */ true);
1398
1364
  toDownload.set(pendingInitSegmentRefId, initDownload);
1399
1365
  }
@@ -1413,6 +1379,7 @@ shaka.offline.Storage = class {
1413
1379
  dataKey: 0,
1414
1380
  };
1415
1381
  streamDb.segments.push(segmentDB);
1382
+ groupId = (groupId + 1) % numberOfParallelDownloads;
1416
1383
  });
1417
1384
 
1418
1385
  return streamDb;