shaka-player 3.1.3 → 3.2.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 (182) hide show
  1. package/AUTHORS +3 -0
  2. package/CHANGELOG.md +175 -3
  3. package/CONTRIBUTORS +3 -0
  4. package/README.md +4 -4
  5. package/build/generateExterns.js +1 -1
  6. package/build/types/polyfill +1 -0
  7. package/demo/common/asset.js +9 -7
  8. package/demo/common/assets.js +11 -2
  9. package/demo/common/message_ids.js +2 -1
  10. package/demo/config.js +5 -2
  11. package/demo/index.html +1 -1
  12. package/demo/locales/en.json +2 -1
  13. package/demo/locales/source.json +8 -4
  14. package/demo/main.js +2 -1
  15. package/dist/controls.css +2 -2
  16. package/dist/controls.css.map +1 -1
  17. package/dist/demo.compiled.debug.js +15 -15
  18. package/dist/demo.compiled.debug.map +2 -2
  19. package/dist/demo.compiled.js +15 -15
  20. package/dist/demo.compiled.map +2 -2
  21. package/dist/deps.js +22 -21
  22. package/dist/locales.js +36 -36
  23. package/dist/receiver.compiled.debug.js +9 -9
  24. package/dist/receiver.compiled.debug.map +2 -2
  25. package/dist/receiver.compiled.js +9 -9
  26. package/dist/receiver.compiled.map +2 -2
  27. package/dist/shaka-player.compiled.d.ts +58 -10
  28. package/dist/shaka-player.compiled.debug.d.ts +58 -10
  29. package/dist/shaka-player.compiled.debug.externs.js +777 -717
  30. package/dist/shaka-player.compiled.debug.js +639 -607
  31. package/dist/shaka-player.compiled.debug.map +4 -4
  32. package/dist/shaka-player.compiled.externs.js +777 -717
  33. package/dist/shaka-player.compiled.js +826 -819
  34. package/dist/shaka-player.compiled.map +4 -4
  35. package/dist/shaka-player.ui.d.ts +58 -10
  36. package/dist/shaka-player.ui.debug.d.ts +58 -10
  37. package/dist/shaka-player.ui.debug.externs.js +529 -469
  38. package/dist/shaka-player.ui.debug.js +676 -645
  39. package/dist/shaka-player.ui.debug.map +4 -4
  40. package/dist/shaka-player.ui.externs.js +529 -469
  41. package/dist/shaka-player.ui.js +963 -955
  42. package/dist/shaka-player.ui.map +4 -4
  43. package/docs/tutorials/fairplay.md +1 -1
  44. package/docs/tutorials/ui.md +5 -5
  45. package/externs/aria.js +6 -0
  46. package/externs/shaka/ads.js +24 -1
  47. package/externs/shaka/manifest.js +6 -1
  48. package/externs/shaka/offline.js +5 -0
  49. package/externs/shaka/player.js +53 -9
  50. package/externs/shaka/text.js +10 -10
  51. package/externs/texttrack.js +3 -0
  52. package/karma.conf.js +1 -0
  53. package/lib/ads/ad_manager.js +16 -15
  54. package/lib/ads/client_side_ad_manager.js +52 -88
  55. package/lib/ads/server_side_ad_manager.js +26 -12
  56. package/lib/cast/cast_proxy.js +11 -2
  57. package/lib/cast/cast_receiver.js +2 -1
  58. package/lib/cast/cast_sender.js +2 -2
  59. package/lib/cast/cast_utils.js +6 -1
  60. package/lib/cea/cea608_data_channel.js +56 -56
  61. package/lib/cea/cea608_memory.js +33 -33
  62. package/lib/cea/cea708_service.js +43 -43
  63. package/lib/cea/cea708_window.js +38 -38
  64. package/lib/cea/cea_decoder.js +13 -14
  65. package/lib/cea/cea_utils.js +23 -23
  66. package/lib/cea/dtvcc_packet_builder.js +7 -7
  67. package/lib/cea/i_caption_decoder.js +2 -3
  68. package/lib/cea/i_cea_parser.js +2 -2
  69. package/lib/cea/mp4_cea_parser.js +6 -6
  70. package/lib/dash/dash_parser.js +98 -2
  71. package/lib/dash/segment_list.js +1 -1
  72. package/lib/dash/segment_template.js +1 -1
  73. package/lib/hls/hls_parser.js +159 -29
  74. package/lib/media/closed_caption_parser.js +1 -2
  75. package/lib/media/drm_engine.js +169 -192
  76. package/lib/media/gap_jumping_controller.js +4 -2
  77. package/lib/media/media_source_engine.js +1 -2
  78. package/lib/media/segment_index.js +3 -1
  79. package/lib/media/segment_reference.js +19 -2
  80. package/lib/media/streaming_engine.js +8 -7
  81. package/lib/net/networking_engine.js +3 -1
  82. package/lib/offline/download_manager.js +1 -2
  83. package/lib/offline/indexeddb/v1_storage_cell.js +1 -0
  84. package/lib/offline/indexeddb/v2_storage_cell.js +1 -0
  85. package/lib/offline/manifest_converter.js +3 -1
  86. package/lib/offline/storage.js +12 -14
  87. package/lib/player.js +437 -167
  88. package/lib/polyfill/aria.js +82 -0
  89. package/lib/polyfill/media_capabilities.js +7 -1
  90. package/lib/polyfill/mediasource.js +6 -0
  91. package/lib/polyfill/orientation.js +1 -1
  92. package/lib/polyfill/patchedmediakeys_apple.js +4 -4
  93. package/lib/polyfill/patchedmediakeys_ms.js +4 -4
  94. package/lib/polyfill/patchedmediakeys_webkit.js +4 -4
  95. package/lib/routing/walker.js +2 -3
  96. package/lib/text/mp4_ttml_parser.js +3 -0
  97. package/lib/text/srt_text_parser.js +4 -4
  98. package/lib/text/text_engine.js +16 -4
  99. package/lib/text/ttml_text_parser.js +5 -0
  100. package/lib/text/ui_text_displayer.js +85 -37
  101. package/lib/text/vtt_text_parser.js +2 -2
  102. package/lib/text/web_vtt_generator.js +55 -12
  103. package/lib/util/error.js +6 -0
  104. package/lib/util/fake_event.js +53 -7
  105. package/lib/util/manifest_parser_utils.js +1 -0
  106. package/lib/util/mp4_box_parsers.js +20 -20
  107. package/lib/util/multi_map.js +8 -0
  108. package/lib/util/periods.js +4 -1
  109. package/lib/util/platform.js +13 -1
  110. package/lib/util/player_configuration.js +13 -1
  111. package/lib/util/stream_utils.js +153 -85
  112. package/lib/util/xml_utils.js +31 -12
  113. package/package.json +1 -1
  114. package/roadmap.md +24 -22
  115. package/shaka-player.uncompiled.js +1 -0
  116. package/test/cast/cast_proxy_unit.js +12 -6
  117. package/test/cast/cast_utils_unit.js +2 -1
  118. package/test/cea/cea608_memory_unit.js +1 -1
  119. package/test/cea/cea708_service_unit.js +8 -8
  120. package/test/cea/cea708_window_unit.js +6 -6
  121. package/test/cea/cea_decoder_unit.js +1 -1
  122. package/test/cea/dtvcc_packet_builder_unit.js +2 -2
  123. package/test/dash/dash_parser_manifest_unit.js +230 -2
  124. package/test/hls/hls_parser_unit.js +255 -1
  125. package/test/media/closed_caption_parser_unit.js +6 -1
  126. package/test/media/drm_engine_integration.js +86 -12
  127. package/test/media/drm_engine_unit.js +353 -450
  128. package/test/offline/manifest_convert_unit.js +2 -0
  129. package/test/offline/storage_integration.js +9 -19
  130. package/test/player_integration.js +90 -0
  131. package/test/player_src_equals_integration.js +52 -0
  132. package/test/player_unit.js +11 -33
  133. package/test/test/assets/3675/chunk-stream0-00001.m4s +0 -0
  134. package/test/test/assets/3675/chunk-stream0-00002.m4s +0 -0
  135. package/test/test/assets/3675/chunk-stream0-00003.m4s +0 -0
  136. package/test/test/assets/3675/chunk-stream0-00004.m4s +0 -0
  137. package/test/test/assets/3675/chunk-stream0-00005.m4s +0 -0
  138. package/test/test/assets/3675/chunk-stream0-00006.m4s +0 -0
  139. package/test/test/assets/3675/chunk-stream0-00007.m4s +0 -0
  140. package/test/test/assets/3675/dash_0.mpd +30 -0
  141. package/test/test/assets/3675/dash_1.mpd +30 -0
  142. package/test/test/assets/3675/dash_2.mpd +30 -0
  143. package/test/test/assets/3675/dash_3.mpd +30 -0
  144. package/test/test/assets/3675/dash_4.mpd +30 -0
  145. package/test/test/assets/3675/dash_5.mpd +26 -0
  146. package/test/test/assets/3675/init-stream0.m4s +0 -0
  147. package/test/test/assets/chapters.srt +11 -0
  148. package/test/test/assets/chapters.vtt +10 -0
  149. package/test/test/util/cea_utils.js +12 -12
  150. package/test/test/util/fake_ad_manager.js +8 -1
  151. package/test/test/util/manifest_generator.js +2 -0
  152. package/test/test/util/manifest_parser_util.js +3 -1
  153. package/test/text/ttml_text_parser_unit.js +9 -0
  154. package/test/text/ui_text_displayer_unit.js +29 -17
  155. package/test/text/web_vtt_generator_unit.js +81 -7
  156. package/test/ui/localization_unit.js +15 -14
  157. package/test/ui/text_displayer_layout_unit.js +13 -1
  158. package/test/util/stream_utils_unit.js +153 -10
  159. package/ui/airplay_button.js +1 -1
  160. package/ui/audio_language_selection.js +2 -5
  161. package/ui/cast_button.js +6 -9
  162. package/ui/constants.js +0 -3
  163. package/ui/controls.js +4 -6
  164. package/ui/fast_forward_button.js +2 -3
  165. package/ui/fullscreen_button.js +1 -3
  166. package/ui/language_utils.js +1 -1
  167. package/ui/less/containers.less +3 -7
  168. package/ui/locales/ru.json +6 -6
  169. package/ui/localization.js +28 -51
  170. package/ui/loop_button.js +1 -3
  171. package/ui/mute_button.js +1 -3
  172. package/ui/overflow_menu.js +2 -3
  173. package/ui/pip_button.js +7 -10
  174. package/ui/playback_rate_selection.js +3 -6
  175. package/ui/presentation_time.js +1 -3
  176. package/ui/resolution_selection.js +4 -7
  177. package/ui/rewind_button.js +2 -3
  178. package/ui/seek_bar.js +2 -4
  179. package/ui/spacer.js +1 -1
  180. package/ui/text_selection.js +8 -11
  181. package/ui/ui_utils.js +1 -1
  182. package/ui/volume_bar.js +1 -3
@@ -135,12 +135,16 @@ shaka.media.SegmentReference = class {
135
135
  * presentation. Any content from after this time will be removed by
136
136
  * MediaSource.
137
137
  * @param {!Array.<!shaka.media.SegmentReference>=} partialReferences
138
- A list of SegmentReferences for the partial segments.
138
+ * A list of SegmentReferences for the partial segments.
139
+ * @param {?string=} tilesLayout
140
+ * The value is a grid-item-dimension consisting of two positive decimal
141
+ * integers in the format: column-x-row ('4x3'). It describes the
142
+ * arrangement of Images in a Grid. The minimum valid LAYOUT is '1x1'.
139
143
  */
140
144
  constructor(
141
145
  startTime, endTime, uris, startByte, endByte, initSegmentReference,
142
146
  timestampOffset, appendWindowStart, appendWindowEnd,
143
- partialReferences = []) {
147
+ partialReferences = [], tilesLayout = '') {
144
148
  // A preload hinted Partial Segment has the same startTime and endTime.
145
149
  goog.asserts.assert(startTime <= endTime,
146
150
  'startTime must be less than or equal to endTime');
@@ -184,6 +188,9 @@ shaka.media.SegmentReference = class {
184
188
 
185
189
  /** @type {!Array.<!shaka.media.SegmentReference>} */
186
190
  this.partialReferences = partialReferences;
191
+
192
+ /** @type {?string} */
193
+ this.tilesLayout = tilesLayout;
187
194
  }
188
195
 
189
196
  /**
@@ -258,6 +265,16 @@ shaka.media.SegmentReference = class {
258
265
  hasPartialSegments() {
259
266
  return this.partialReferences.length > 0;
260
267
  }
268
+
269
+ /**
270
+ * Returns the segment's tiles layout. Only defined in image segments.
271
+ *
272
+ * @return {?string}
273
+ * @export
274
+ */
275
+ getTilesLayout() {
276
+ return this.tilesLayout;
277
+ }
261
278
  };
262
279
 
263
280
 
@@ -1001,10 +1001,10 @@ shaka.media.StreamingEngine = class {
1001
1001
  if (bufferedAhead >= scaledBufferingGoal) {
1002
1002
  shaka.log.v2(logPrefix, 'buffering goal met');
1003
1003
 
1004
- // Do not try to predict the next update. Just poll twice every second.
1005
- // The playback rate can change at any time, so any prediction we make now
1006
- // could be terribly invalid soon.
1007
- return 0.5;
1004
+ // Do not try to predict the next update. Just poll according to
1005
+ // configuration (seconds). The playback rate can change at any time, so
1006
+ // any prediction we make now could be terribly invalid soon.
1007
+ return this.config_.updateIntervalSeconds / 2;
1008
1008
  }
1009
1009
 
1010
1010
  const bufferEnd =
@@ -1016,7 +1016,7 @@ shaka.media.StreamingEngine = class {
1016
1016
  // In any case just try again... if the manifest is incomplete or is not
1017
1017
  // being updated then we'll idle forever; otherwise, we'll end up getting
1018
1018
  // a SegmentReference eventually.
1019
- return 1;
1019
+ return this.config_.updateIntervalSeconds;
1020
1020
  }
1021
1021
 
1022
1022
  // Do not let any one stream get far ahead of any other.
@@ -1047,7 +1047,7 @@ shaka.media.StreamingEngine = class {
1047
1047
  // For example, let video buffering catch up to audio buffering before
1048
1048
  // fetching another audio segment.
1049
1049
  shaka.log.v2(logPrefix, 'waiting for other streams to buffer');
1050
- return 1;
1050
+ return this.config_.updateIntervalSeconds;
1051
1051
  }
1052
1052
 
1053
1053
  const p = this.fetchAndAppend_(mediaState, presentationTime, reference);
@@ -1662,7 +1662,8 @@ shaka.media.StreamingEngine = class {
1662
1662
 
1663
1663
  // Dispatch an event to notify the application about the emsg box.
1664
1664
  const eventName = shaka.Player.EventName.Emsg;
1665
- const event = new shaka.util.FakeEvent(eventName, {'detail': emsg});
1665
+ const data = (new Map()).set('detail', emsg);
1666
+ const event = new shaka.util.FakeEvent(eventName, data);
1666
1667
  this.playerInterface_.onEvent(event);
1667
1668
  }
1668
1669
  }
@@ -544,7 +544,8 @@ shaka.net.NetworkingEngine = class extends shaka.util.FakeEventTarget {
544
544
  }
545
545
 
546
546
  if (error.severity == shaka.util.Error.Severity.RECOVERABLE) {
547
- const event = new shaka.util.FakeEvent('retry', {'error': error});
547
+ const data = (new Map()).set('error', error);
548
+ const event = new shaka.util.FakeEvent('retry', data);
548
549
  this.dispatchEvent(event);
549
550
 
550
551
  // Move to the next URI.
@@ -706,6 +707,7 @@ shaka.net.NetworkingEngine.RequestType = {
706
707
  'LICENSE': 2,
707
708
  'APP': 3,
708
709
  'TIMING': 4,
710
+ 'SERVER_CERTIFICATE': 5,
709
711
  };
710
712
 
711
713
 
@@ -44,9 +44,8 @@ shaka.offline.DownloadManager = class {
44
44
 
45
45
  /** @private {!shaka.util.Destroyer} */
46
46
  this.destroyer_ = new shaka.util.Destroyer(() => {
47
- const promises = Array.from(this.groups_.values());
48
47
  // Add a "catch" block to stop errors from being returned.
49
- return Promise.all(promises.map((p) => p.catch(() => {})));
48
+ return this.abortAll().catch(() => {});
50
49
  });
51
50
 
52
51
  /**
@@ -204,6 +204,7 @@ shaka.offline.indexeddb.V1StorageCell = class
204
204
  appendWindowStart,
205
205
  appendWindowEnd,
206
206
  timestampOffset,
207
+ tilesLayout: '',
207
208
  };
208
209
  }
209
210
 
@@ -148,6 +148,7 @@ shaka.offline.indexeddb.V2StorageCell = class
148
148
  appendWindowEnd: periodEnd,
149
149
  timestampOffset,
150
150
  dataKey: old.dataKey,
151
+ tilesLayout: '',
151
152
  };
152
153
  }
153
154
  };
@@ -229,7 +229,9 @@ shaka.offline.ManifestConverter = class {
229
229
  initSegmentReference,
230
230
  segmentDB.timestampOffset,
231
231
  segmentDB.appendWindowStart,
232
- segmentDB.appendWindowEnd);
232
+ segmentDB.appendWindowEnd,
233
+ /* partialReferences= */ [],
234
+ segmentDB.tilesLayout || '');
233
235
  }
234
236
 
235
237
  /**
@@ -484,25 +484,23 @@ shaka.offline.Storage = class {
484
484
  const maxHwRes = {width: Infinity, height: Infinity};
485
485
  StreamUtils.filterByRestrictions(manifest, config.restrictions, maxHwRes);
486
486
 
487
- // Filter the manifest based on what we know media source will be able to
488
- // play later (no point storing something we can't play).
489
- if (config.useMediaCapabilities) {
490
- StreamUtils.filterManifestByMediaCapabilities(
491
- manifest, config.offline.usePersistentLicense);
492
- } else {
493
- StreamUtils.filterManifestByMediaSource(manifest);
494
- // Filter the manifest based on what we know our drm system will support
495
- // playing later.
496
- StreamUtils.filterManifestByDrm(manifest, drmEngine);
497
- }
487
+ // Filter the manifest based on what we know MediaCapabilities will be able
488
+ // to play later (no point storing something we can't play).
489
+ StreamUtils.filterManifestByMediaCapabilities(
490
+ manifest, config.offline.usePersistentLicense);
498
491
 
499
492
  // Gather all tracks.
500
493
  const allTracks = [];
501
494
 
502
495
  // Choose the codec that has the lowest average bandwidth.
503
496
  const preferredAudioChannelCount = config.preferredAudioChannelCount;
497
+ const preferredDecodingAttributes = config.preferredDecodingAttributes;
498
+ const preferredVideoCodecs = config.preferredVideoCodecs;
499
+ const preferredAudioCodecs = config.preferredAudioCodecs;
500
+
504
501
  StreamUtils.chooseCodecsAndFilterManifest(
505
- manifest, preferredAudioChannelCount);
502
+ manifest, preferredVideoCodecs, preferredAudioCodecs,
503
+ preferredAudioChannelCount, preferredDecodingAttributes);
506
504
 
507
505
  for (const variant of manifest.variants) {
508
506
  goog.asserts.assert(
@@ -1001,8 +999,7 @@ shaka.offline.Storage = class {
1001
999
 
1002
1000
  drmEngine.configure(config.drm);
1003
1001
  await drmEngine.initForStorage(
1004
- manifest.variants, config.offline.usePersistentLicense,
1005
- config.useMediaCapabilities);
1002
+ manifest.variants, config.offline.usePersistentLicense);
1006
1003
  await drmEngine.setServerCertificate();
1007
1004
  await drmEngine.createOrLoad();
1008
1005
 
@@ -1204,6 +1201,7 @@ shaka.offline.Storage = class {
1204
1201
  appendWindowStart: segment.appendWindowStart,
1205
1202
  appendWindowEnd: segment.appendWindowEnd,
1206
1203
  timestampOffset: segment.timestampOffset,
1204
+ tilesLayout: segment.tilesLayout,
1207
1205
  dataKey,
1208
1206
  });
1209
1207
  });