shaka-player 4.12.5 → 4.12.7

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 (58) hide show
  1. package/dist/controls.css +1 -1
  2. package/dist/controls.css.map +1 -1
  3. package/dist/deps.js +3 -3
  4. package/dist/locales.js +34 -34
  5. package/dist/shaka-player.compiled.d.ts +12 -4
  6. package/dist/shaka-player.compiled.debug.d.ts +12 -4
  7. package/dist/shaka-player.compiled.debug.externs.js +10 -6
  8. package/dist/shaka-player.compiled.debug.js +439 -425
  9. package/dist/shaka-player.compiled.debug.map +3 -3
  10. package/dist/shaka-player.compiled.externs.js +10 -6
  11. package/dist/shaka-player.compiled.js +1352 -1345
  12. package/dist/shaka-player.compiled.map +3 -3
  13. package/dist/shaka-player.ui.d.ts +12 -4
  14. package/dist/shaka-player.ui.debug.d.ts +12 -4
  15. package/dist/shaka-player.ui.debug.externs.js +10 -6
  16. package/dist/shaka-player.ui.debug.js +439 -425
  17. package/dist/shaka-player.ui.debug.map +3 -3
  18. package/dist/shaka-player.ui.externs.js +10 -6
  19. package/dist/shaka-player.ui.js +1596 -1588
  20. package/dist/shaka-player.ui.map +3 -3
  21. package/externs/shaka/codecs.js +21 -0
  22. package/externs/shaka/offline.js +4 -0
  23. package/lib/cast/cast_utils.js +1 -0
  24. package/lib/cea/cea708_service.js +27 -2
  25. package/lib/cea/dtvcc_packet_builder.js +15 -0
  26. package/lib/dash/dash_parser.js +5 -2
  27. package/lib/dash/mpd_utils.js +7 -4
  28. package/lib/dash/segment_template.js +30 -17
  29. package/lib/hls/hls_parser.js +31 -7
  30. package/lib/media/drm_engine.js +55 -12
  31. package/lib/media/media_source_engine.js +127 -41
  32. package/lib/media/segment_utils.js +65 -47
  33. package/lib/net/http_fetch_plugin.js +1 -1
  34. package/lib/net/http_plugin_utils.js +3 -0
  35. package/lib/offline/download_info.js +5 -0
  36. package/lib/offline/download_manager.js +54 -0
  37. package/lib/offline/manifest_converter.js +1 -0
  38. package/lib/offline/storage.js +11 -2
  39. package/lib/player.js +53 -22
  40. package/lib/polyfill/media_capabilities.js +1 -1
  41. package/lib/text/simple_text_displayer.js +9 -1
  42. package/lib/text/ui_text_displayer.js +2 -14
  43. package/lib/transmuxer/aac_transmuxer.js +11 -3
  44. package/lib/transmuxer/ac3_transmuxer.js +11 -3
  45. package/lib/transmuxer/ec3_transmuxer.js +11 -3
  46. package/lib/transmuxer/h264.js +143 -70
  47. package/lib/transmuxer/mp3_transmuxer.js +11 -3
  48. package/lib/transmuxer/ts_transmuxer.js +68 -28
  49. package/lib/util/drm_utils.js +20 -0
  50. package/lib/util/stream_utils.js +0 -60
  51. package/lib/util/ts_parser.js +111 -85
  52. package/package.json +1 -1
  53. package/ui/audio_language_selection.js +1 -1
  54. package/ui/controls.js +4 -0
  55. package/ui/fast_forward_button.js +7 -0
  56. package/ui/play_button.js +1 -1
  57. package/ui/playback_rate_selection.js +1 -1
  58. package/ui/rewind_button.js +7 -0
@@ -27,6 +27,27 @@
27
27
  shaka.extern.MPEG_PES;
28
28
 
29
29
 
30
+ /**
31
+ * @typedef {{
32
+ * data: !Uint8Array,
33
+ * frame: boolean,
34
+ * isKeyframe: boolean,
35
+ * pts: ?number,
36
+ * dts: ?number,
37
+ * nalus: !Array.<!shaka.extern.VideoNalu>
38
+ * }}
39
+ *
40
+ * @summary VideoSample.
41
+ * @property {!Uint8Array} data
42
+ * @property {boolean} frame
43
+ * @property {boolean} isKeyframe
44
+ * @property {?number} pts
45
+ * @property {?number} dts
46
+ * @property {!Array.<!shaka.extern.VideoNalu>} nalus
47
+ */
48
+ shaka.extern.VideoSample;
49
+
50
+
30
51
  /**
31
52
  * @typedef {{
32
53
  * data: !Uint8Array,
@@ -141,6 +141,7 @@ shaka.extern.ManifestDB;
141
141
  * spatialAudio: boolean,
142
142
  * closedCaptions: Map.<string, string>,
143
143
  * tilesLayout: (string|undefined),
144
+ * mssPrivateData: (shaka.extern.MssPrivateData|undefined),
144
145
  * external: boolean,
145
146
  * fastSwitching: boolean,
146
147
  * isAudioMuxedInVideo: boolean
@@ -214,6 +215,9 @@ shaka.extern.ManifestDB;
214
215
  * The value is a grid-item-dimension consisting of two positive decimal
215
216
  * integers in the format: column-x-row ('4x3'). It describes the arrangement
216
217
  * of Images in a Grid. The minimum valid LAYOUT is '1x1'.
218
+ * @property {(shaka.extern.MssPrivateData|undefined)} mssPrivateData
219
+ * <i>Microsoft Smooth Streaming only.</i> <br>
220
+ * Private MSS data that is necessary to be able to do transmuxing.
217
221
  * @property {boolean} external
218
222
  * Indicate if the stream was added externally.
219
223
  * Eg: external text tracks.
@@ -329,6 +329,7 @@ shaka.cast.CastUtils.PlayerGetterMethods = {
329
329
  'getLoadMode': 10,
330
330
  'getManifestType': 10,
331
331
  'isFullyLoaded': 1,
332
+ 'isEnded': 1,
332
333
  };
333
334
 
334
335
 
@@ -60,7 +60,7 @@ shaka.cea.Cea708Service = class {
60
60
  // Control codes are in 1 of 4 logical groups:
61
61
  // CL (C0, C2), CR (C1, C3), GL (G0, G2), GR (G1, G2).
62
62
  if (controlCode >= 0x00 && controlCode <= 0x1f) {
63
- return this.handleC0_(controlCode, pts);
63
+ return this.handleC0_(dtvccPacket, controlCode, pts);
64
64
  } else if (controlCode >= 0x80 && controlCode <= 0x9f) {
65
65
  return this.handleC1_(dtvccPacket, controlCode, pts);
66
66
  } else if (controlCode >= 0x1000 && controlCode <= 0x101f) {
@@ -153,17 +153,42 @@ shaka.cea.Cea708Service = class {
153
153
 
154
154
  /**
155
155
  * Handles C0 group data.
156
+ * @param {!shaka.cea.DtvccPacket} dtvccPacket
156
157
  * @param {number} controlCode
157
158
  * @param {number} pts
158
159
  * @return {?shaka.extern.ICaptionDecoder.ClosedCaption}
159
160
  * @private
160
161
  */
161
- handleC0_(controlCode, pts) {
162
+ handleC0_(dtvccPacket, controlCode, pts) {
162
163
  // All these commands pertain to the current window, so ensure it exists.
163
164
  if (!this.currentWindow_) {
164
165
  return null;
165
166
  }
166
167
 
168
+ if (controlCode == 0x18) {
169
+ const firstByte = dtvccPacket.readByte().value;
170
+ const secondByte = dtvccPacket.readByte().value;
171
+
172
+ const isTextBlock = (b) => {
173
+ return (b >= 0x20 && b <= 0x7f) || (b >= 0xa0 && b <= 0xff);
174
+ };
175
+
176
+ if (isTextBlock(firstByte) && isTextBlock(secondByte)) {
177
+ const toHexString = (byteArray) => {
178
+ return byteArray.map((byte) => {
179
+ return ('0' + (byte & 0xFF).toString(16)).slice(-2);
180
+ }).join('');
181
+ };
182
+ const unicode = toHexString([firstByte, secondByte]);
183
+ // Takes a unicode hex string and creates a single character.
184
+ const char = String.fromCharCode(parseInt(unicode, 16));
185
+ this.currentWindow_.setCharacter(char);
186
+ return null;
187
+ } else {
188
+ dtvccPacket.rewind(2);
189
+ }
190
+ }
191
+
167
192
  const window = this.currentWindow_;
168
193
  let parsedClosedCaption = null;
169
194
 
@@ -161,6 +161,21 @@ shaka.cea.DtvccPacket = class {
161
161
  }
162
162
  this.pos_ += numBlocks;
163
163
  }
164
+
165
+ /**
166
+ * Rewinds the provided number of blocks in the buffer.
167
+ * @param {number} numBlocks
168
+ * @throws {!shaka.util.Error}
169
+ */
170
+ rewind(numBlocks) {
171
+ if (this.pos_ - numBlocks < 0) {
172
+ throw new shaka.util.Error(
173
+ shaka.util.Error.Severity.CRITICAL,
174
+ shaka.util.Error.Category.TEXT,
175
+ shaka.util.Error.Code.BUFFER_READ_OUT_OF_BOUNDS);
176
+ }
177
+ this.pos_ -= numBlocks;
178
+ }
164
179
  };
165
180
 
166
181
  /**
@@ -2295,8 +2295,12 @@ shaka.dash.DashParser = class {
2295
2295
  return element.attributes['schemeIdUri'] == expectedUri &&
2296
2296
  element.attributes['value'] == expectedValue;
2297
2297
  });
2298
+ const codecs = context.representation.codecs;
2299
+ // Detect the presence of Dolby Atmos audio content based on the codec and
2300
+ // bandwidth. Bandwidth above 384 kbps is a good indicator of Atmos content.
2301
+ const isAtmos = codecs.includes('ec-3') && context.bandwidth >= 384000;
2298
2302
  let spatialAudio = false;
2299
- if (hasJoc) {
2303
+ if (hasJoc || isAtmos) {
2300
2304
  spatialAudio = true;
2301
2305
  }
2302
2306
 
@@ -2328,7 +2332,6 @@ shaka.dash.DashParser = class {
2328
2332
 
2329
2333
  let hdr;
2330
2334
  const profiles = context.profiles;
2331
- const codecs = context.representation.codecs;
2332
2335
 
2333
2336
  const hevcHDR = 'http://dashif.org/guidelines/dash-if-uhd#hevc-hdr-pq10';
2334
2337
  if (profiles.includes(hevcHDR) && (codecs.includes('hvc1.2.4.L153.B0') ||
@@ -279,10 +279,9 @@ shaka.dash.MpdUtils = class {
279
279
 
280
280
  const durationStr =
281
281
  MpdUtils.inheritAttribute(context, callback, 'duration');
282
- let segmentDuration = TXml.parsePositiveInt(durationStr || '');
283
- if (segmentDuration) {
284
- segmentDuration /= timescale;
285
- }
282
+ const unscaledSegmentDuration = TXml.parsePositiveInt(durationStr || '');
283
+ const segmentDuration = unscaledSegmentDuration ?
284
+ unscaledSegmentDuration / timescale : null;
286
285
 
287
286
  const startNumberStr =
288
287
  MpdUtils.inheritAttribute(context, callback, 'startNumber');
@@ -309,6 +308,7 @@ shaka.dash.MpdUtils = class {
309
308
  (unscaledPresentationTimeOffset / timescale) || 0;
310
309
  return {
311
310
  timescale: timescale,
311
+ unscaledSegmentDuration: unscaledSegmentDuration,
312
312
  segmentDuration: segmentDuration,
313
313
  startNumber: startNumber,
314
314
  scaledPresentationTimeOffset: scaledPresentationTimeOffset,
@@ -564,6 +564,7 @@ shaka.dash.MpdUtils = class {
564
564
  /**
565
565
  * @typedef {{
566
566
  * timescale: number,
567
+ * unscaledSegmentDuration: ?number,
567
568
  * segmentDuration: ?number,
568
569
  * startNumber: number,
569
570
  * scaledPresentationTimeOffset: number,
@@ -576,6 +577,8 @@ shaka.dash.MpdUtils = class {
576
577
  *
577
578
  * @property {number} timescale
578
579
  * The time-scale of the representation.
580
+ * @property {?number} unscaledSegmentDuration
581
+ * The duration of the segments in timescale units, if given.
579
582
  * @property {?number} segmentDuration
580
583
  * The duration of the segments in seconds, if given.
581
584
  * @property {number} startNumber
@@ -277,6 +277,7 @@ shaka.dash.SegmentTemplate = class {
277
277
  }
278
278
 
279
279
  return {
280
+ unscaledSegmentDuration: segmentInfo.unscaledSegmentDuration,
280
281
  segmentDuration: segmentInfo.segmentDuration,
281
282
  timescale: segmentInfo.timescale,
282
283
  startNumber: segmentInfo.startNumber,
@@ -325,10 +326,12 @@ shaka.dash.SegmentTemplate = class {
325
326
  if (info.indexTemplate) {
326
327
  shaka.log.info('Using the index URL template by default.');
327
328
  info.timeline = null;
329
+ info.unscaledSegmentDuration = null;
328
330
  info.segmentDuration = null;
329
331
  } else {
330
332
  goog.asserts.assert(info.timeline, 'There should be a timeline');
331
333
  shaka.log.info('Using the SegmentTimeline by default.');
334
+ info.unscaledSegmentDuration = null;
332
335
  info.segmentDuration = null;
333
336
  }
334
337
  }
@@ -421,7 +424,6 @@ shaka.dash.SegmentTemplate = class {
421
424
  segmentDuration != null, 'Segment duration must not be null!');
422
425
 
423
426
  const startNumber = info.startNumber;
424
- const timescale = info.timescale;
425
427
 
426
428
  const template = info.mediaTemplate;
427
429
  const bandwidth = context.bandwidth || null;
@@ -505,10 +507,18 @@ shaka.dash.SegmentTemplate = class {
505
507
  const positionWithinPeriod = position - startNumber;
506
508
  const segmentPeriodTime = positionWithinPeriod * segmentDuration;
507
509
 
508
- // What will appear in the actual segment files. The media timestamp is
509
- // what is expected in the $Time$ template.
510
- const segmentMediaTime = segmentPeriodTime +
511
- info.scaledPresentationTimeOffset;
510
+ const unscaledSegmentDuration = info.unscaledSegmentDuration;
511
+ goog.asserts.assert(unscaledSegmentDuration != null,
512
+ 'Segment duration must not be null!');
513
+
514
+ // The original media timestamp from the timeline is what is expected in
515
+ // the $Time$ template. (Or based on duration, in this case.) It should
516
+ // not be adjusted with presentationTimeOffset or the Period start.
517
+ let timeReplacement = positionWithinPeriod * unscaledSegmentDuration;
518
+ if ('BigInt' in window && timeReplacement > Number.MAX_SAFE_INTEGER) {
519
+ timeReplacement =
520
+ BigInt(positionWithinPeriod) * BigInt(unscaledSegmentDuration);
521
+ }
512
522
 
513
523
  // Relative to the presentation.
514
524
  const segmentStart = segmentPeriodTime + periodStart;
@@ -533,12 +543,8 @@ shaka.dash.SegmentTemplate = class {
533
543
  const end = start + partialDuration;
534
544
  const subNumber = i + 1;
535
545
  const getPartialUris = () => {
536
- let time = segmentMediaTime * timescale;
537
- if ('BigInt' in window && time > Number.MAX_SAFE_INTEGER) {
538
- time = BigInt(segmentMediaTime) * BigInt(timescale);
539
- }
540
546
  const mediaUri = MpdUtils.fillUriTemplate(
541
- template, id, position, subNumber, bandwidth, time);
547
+ template, id, position, subNumber, bandwidth, timeReplacement);
542
548
  return ManifestParserUtils.resolveUris(
543
549
  getBaseUris(), [mediaUri], urlParams());
544
550
  };
@@ -575,12 +581,9 @@ shaka.dash.SegmentTemplate = class {
575
581
  if (numChunks) {
576
582
  return [];
577
583
  }
578
- let time = segmentMediaTime * timescale;
579
- if ('BigInt' in window && time > Number.MAX_SAFE_INTEGER) {
580
- time = BigInt(segmentMediaTime) * BigInt(timescale);
581
- }
582
584
  const mediaUri = MpdUtils.fillUriTemplate(
583
- template, id, position, /* subNumber= */ null, bandwidth, time);
585
+ template, id, position, /* subNumber= */ null, bandwidth,
586
+ timeReplacement);
584
587
  return ManifestParserUtils.resolveUris(
585
588
  getBaseUris(), [mediaUri], urlParams());
586
589
  };
@@ -1007,8 +1010,15 @@ shaka.dash.TimelineSegmentIndex = class extends shaka.media.SegmentIndex {
1007
1010
  if (!ref) {
1008
1011
  const range = this.templateInfo_.timeline[correctedPosition];
1009
1012
  const segmentReplacement = range.segmentPosition;
1010
- const timeReplacement = this.templateInfo_
1011
- .unscaledPresentationTimeOffset + range.unscaledStart;
1013
+
1014
+ // The original media timestamp from the timeline is what is expected in
1015
+ // the $Time$ template. It should not be adjusted with
1016
+ // presentationTimeOffset or the Period start, but
1017
+ // unscaledPresentationTimeOffset was already subtracted from the times
1018
+ // in timeline.
1019
+ const timeReplacement = range.unscaledStart +
1020
+ this.templateInfo_.unscaledPresentationTimeOffset;
1021
+
1012
1022
  const timestampOffset = this.periodStart_ -
1013
1023
  this.templateInfo_.scaledPresentationTimeOffset;
1014
1024
  const trueSegmentEnd = this.periodStart_ + range.end;
@@ -1155,6 +1165,7 @@ shaka.dash.TimelineSegmentIndex = class extends shaka.media.SegmentIndex {
1155
1165
  /**
1156
1166
  * @typedef {{
1157
1167
  * timescale: number,
1168
+ * unscaledSegmentDuration: ?number,
1158
1169
  * segmentDuration: ?number,
1159
1170
  * startNumber: number,
1160
1171
  * scaledPresentationTimeOffset: number,
@@ -1173,6 +1184,8 @@ shaka.dash.TimelineSegmentIndex = class extends shaka.media.SegmentIndex {
1173
1184
  *
1174
1185
  * @property {number} timescale
1175
1186
  * The time-scale of the representation.
1187
+ * @property {?number} unscaledSegmentDuration
1188
+ * The duration of the segments in seconds, in timescale units.
1176
1189
  * @property {?number} segmentDuration
1177
1190
  * The duration of the segments in seconds, if given.
1178
1191
  * @property {number} startNumber
@@ -1136,8 +1136,9 @@ shaka.hls.HlsParser = class {
1136
1136
 
1137
1137
  if (shaka.util.TsParser.probe(
1138
1138
  shaka.util.BufferUtils.toUint8(data))) {
1139
- const basicInfo =
1140
- shaka.media.SegmentUtils.getBasicInfoFromTs(data);
1139
+ const basicInfo = shaka.media.SegmentUtils.getBasicInfoFromTs(
1140
+ data, this.config_.disableAudio, this.config_.disableVideo,
1141
+ this.config_.disableText);
1141
1142
  if (basicInfo) {
1142
1143
  return basicInfo;
1143
1144
  }
@@ -1145,7 +1146,7 @@ shaka.hls.HlsParser = class {
1145
1146
  validMp4MimeType.includes(contentMimeType) ||
1146
1147
  (initMimeType && validMp4MimeType.includes(initMimeType))) {
1147
1148
  const basicInfo = shaka.media.SegmentUtils.getBasicInfoFromMp4(
1148
- initData, data);
1149
+ initData, data, this.config_.disableText);
1149
1150
  if (basicInfo) {
1150
1151
  return basicInfo;
1151
1152
  }
@@ -2763,12 +2764,23 @@ shaka.hls.HlsParser = class {
2763
2764
  }
2764
2765
  }
2765
2766
  this.notifySegmentsForStreams_(streamInfos.map((s) => s.stream));
2766
- const liveWithNoProgramaDateTime =
2767
+
2768
+ const activeStreamInfos = Array.from(this.uriToStreamInfosMap_.values())
2769
+ .filter((s) => s.stream.segmentIndex);
2770
+ const ContentType = shaka.util.ManifestParserUtils.ContentType;
2771
+ const hasAudio =
2772
+ activeStreamInfos.some((s) => s.stream.type == ContentType.AUDIO);
2773
+ const hasVideo =
2774
+ activeStreamInfos.some((s) => s.stream.type == ContentType.VIDEO);
2775
+
2776
+ const liveWithNoProgramDateTime =
2767
2777
  this.isLive_() && !this.usesProgramDateTime_;
2778
+ const vodWithOnlyAudioOrVideo = !this.isLive_() &&
2779
+ this.usesProgramDateTime_ && !(hasAudio && hasVideo);
2768
2780
  if (this.config_.hls.ignoreManifestProgramDateTime ||
2769
- liveWithNoProgramaDateTime) {
2781
+ liveWithNoProgramDateTime || vodWithOnlyAudioOrVideo) {
2770
2782
  this.syncStreamsWithSequenceNumber_(
2771
- streamInfos, liveWithNoProgramaDateTime);
2783
+ streamInfos, liveWithNoProgramDateTime);
2772
2784
  } else {
2773
2785
  this.syncStreamsWithProgramDateTime_(streamInfos);
2774
2786
  if (this.config_.hls.ignoreManifestProgramDateTimeForTypes.length > 0) {
@@ -2906,6 +2918,16 @@ shaka.hls.HlsParser = class {
2906
2918
 
2907
2919
  if (!mimeType) {
2908
2920
  mimeType = await this.guessMimeType_(type, codecs, segments);
2921
+
2922
+ // Some manifests don't say what text codec they use, this is a problem
2923
+ // if the cmft extension is used because we identify the mimeType as
2924
+ // application/mp4. In this case if we don't detect initialization
2925
+ // segments, we assume that the mimeType is text/vtt.
2926
+ if (type == shaka.util.ManifestParserUtils.ContentType.TEXT &&
2927
+ !codecs && mimeType == 'application/mp4' &&
2928
+ segments[0] && !segments[0].initSegmentReference) {
2929
+ mimeType = 'text/vtt';
2930
+ }
2909
2931
  }
2910
2932
 
2911
2933
  const {drmInfos, keyIds, encrypted, aesEncrypted} =
@@ -3965,7 +3987,9 @@ shaka.hls.HlsParser = class {
3965
3987
  }
3966
3988
  let dateRangeTags =
3967
3989
  shaka.hls.Utils.filterTagsByName(tags, 'EXT-X-DATERANGE');
3968
- dateRangeTags = dateRangeTags.sort((a, b) => {
3990
+ dateRangeTags = dateRangeTags.filter((tag) => {
3991
+ return tag.getAttribute('START-DATE') != null;
3992
+ }).sort((a, b) => {
3969
3993
  const aStartDateValue = a.getRequiredAttrValue('START-DATE');
3970
3994
  const bStartDateValue = b.getRequiredAttrValue('START-DATE');
3971
3995
  if (aStartDateValue < bStartDateValue) {
@@ -1456,6 +1456,11 @@ shaka.media.DrmEngine = class {
1456
1456
  }
1457
1457
  // NOTE: allowCrossSiteCredentials can be set in a request filter.
1458
1458
 
1459
+ if (shaka.util.DrmUtils.isClearKeySystem(
1460
+ this.currentDrmInfo_.keySystem)) {
1461
+ this.fixClearKeyRequest_(request, this.currentDrmInfo_);
1462
+ }
1463
+
1459
1464
  if (shaka.util.DrmUtils.isPlayReadyKeySystem(
1460
1465
  this.currentDrmInfo_.keySystem)) {
1461
1466
  this.unpackPlayReadyRequest_(request);
@@ -1609,6 +1614,31 @@ shaka.media.DrmEngine = class {
1609
1614
  /** @type{string} */(shaka.util.TXml.getTextContents(challenge)));
1610
1615
  }
1611
1616
 
1617
+ /**
1618
+ * Some old ClearKey CDMs don't include the type in the body request.
1619
+ *
1620
+ * @param {shaka.extern.Request} request
1621
+ * @param {shaka.extern.DrmInfo} drmInfo
1622
+ * @private
1623
+ */
1624
+ fixClearKeyRequest_(request, drmInfo) {
1625
+ try {
1626
+ const body = shaka.util.StringUtils.fromBytesAutoDetect(request.body);
1627
+ if (body) {
1628
+ const licenseBody =
1629
+ /** @type {shaka.media.DrmEngine.ClearKeyLicenceRequestFormat} */ (
1630
+ JSON.parse(body));
1631
+ if (!licenseBody.type) {
1632
+ licenseBody.type = drmInfo.sessionType;
1633
+ request.body =
1634
+ shaka.util.StringUtils.toUTF8(JSON.stringify(licenseBody));
1635
+ }
1636
+ }
1637
+ } catch (e) {
1638
+ shaka.log.info('Error unpacking ClearKey license', e);
1639
+ }
1640
+ }
1641
+
1612
1642
  /**
1613
1643
  * @param {!Event} event
1614
1644
  * @private
@@ -2450,26 +2480,24 @@ shaka.media.DrmEngine = class {
2450
2480
  // The order of preference for drmInfo:
2451
2481
  // 1. Clear Key config, used for debugging, should override everything else.
2452
2482
  // (The application can still specify a clearkey license server.)
2453
- // 2. Application-configured servers, if any are present, should override
2454
- // anything from the manifest. Nuance: if key system A is in the
2455
- // manifest and key system B is in the player config, only B will be
2456
- // used, not A.
2483
+ // 2. Application-configured servers, if present, override
2484
+ // anything from the manifest.
2457
2485
  // 3. Manifest-provided license servers are only used if nothing else is
2458
2486
  // specified.
2459
2487
  // This is important because it allows the application a clear way to
2460
- // indicate which DRM systems should be used on platforms with multiple DRM
2461
- // systems.
2462
- // The only way to get license servers from the manifest is not to specify
2463
- // any in your player config.
2488
+ // indicate which DRM systems should be ignored on platforms with multiple
2489
+ // DRM systems.
2490
+ // Alternatively, use config.preferredKeySystems to specify the preferred
2491
+ // key system.
2464
2492
 
2465
2493
  if (originalKeySystem == 'org.w3.clearkey' && drmInfo.licenseServerUri) {
2466
2494
  // Preference 1: Clear Key with pre-configured keys will have a data URI
2467
2495
  // assigned as its license server. Don't change anything.
2468
2496
  return;
2469
- } else if (servers.size) {
2470
- // Preference 2: If anything is configured at the application level,
2471
- // override whatever was in the manifest.
2472
- const server = servers.get(originalKeySystem) || '';
2497
+ } else if (servers.size && servers.get(originalKeySystem)) {
2498
+ // Preference 2: If a license server for this keySystem is configured at
2499
+ // the application level, override whatever was in the manifest.
2500
+ const server = servers.get(originalKeySystem);
2473
2501
 
2474
2502
  drmInfo.licenseServerUri = server;
2475
2503
  } else {
@@ -2630,6 +2658,21 @@ shaka.media.DrmEngine.SessionMetaData;
2630
2658
  */
2631
2659
  shaka.media.DrmEngine.PlayerInterface;
2632
2660
 
2661
+ /**
2662
+ * @typedef {{
2663
+ * kids: !Array.<string>,
2664
+ * type: string
2665
+ * }}
2666
+ *
2667
+ * @property {!Array.<string>} kids
2668
+ * An array of key IDs. Each element of the array is the base64url encoding of
2669
+ * the octet sequence containing the key ID value.
2670
+ * @property {string} type
2671
+ * The requested MediaKeySessionType.
2672
+ * @see https://www.w3.org/TR/encrypted-media/#clear-key-request-format
2673
+ */
2674
+ shaka.media.DrmEngine.ClearKeyLicenceRequestFormat;
2675
+
2633
2676
  /**
2634
2677
  * The amount of time, in seconds, we wait to consider a session closed.
2635
2678
  * This allows us to work around Chrome bug https://crbug.com/1108158.