hls.js 1.6.0-beta.4.0.canary.11068 → 1.6.0-rc.1

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.
package/dist/hls.light.js CHANGED
@@ -1044,7 +1044,7 @@
1044
1044
  // Some browsers don't allow to use bind on console object anyway
1045
1045
  // fallback to default if needed
1046
1046
  try {
1047
- newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.6.0-beta.4.0.canary.11068");
1047
+ newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.6.0-rc.1");
1048
1048
  } catch (e) {
1049
1049
  /* log fn threw an exception. All logger methods are no-ops. */
1050
1050
  return createLogger();
@@ -1842,6 +1842,7 @@
1842
1842
  var sampleEntriesEnd = sampleEntries.subarray(8 + 78);
1843
1843
  var fourCC = bin2str(sampleEntries.subarray(4, 8));
1844
1844
  var codec = fourCC;
1845
+ var supplemental;
1845
1846
  var encrypted = fourCC === 'enca' || fourCC === 'encv';
1846
1847
  if (encrypted) {
1847
1848
  var encBox = findBox(sampleEntries, [fourCC])[0];
@@ -1861,6 +1862,7 @@
1861
1862
  }
1862
1863
  });
1863
1864
  }
1865
+ var codecFourCC = codec;
1864
1866
  switch (codec) {
1865
1867
  case 'avc1':
1866
1868
  case 'avc2':
@@ -1870,6 +1872,7 @@
1870
1872
  // extract profile + compatibility + level out of avcC box
1871
1873
  var avcCBox = findBox(sampleEntriesEnd, ['avcC'])[0];
1872
1874
  codec += '.' + toHex(avcCBox[1]) + toHex(avcCBox[2]) + toHex(avcCBox[3]);
1875
+ supplemental = parseSupplementalDoViCodec(codecFourCC === 'avc1' ? 'dva1' : 'dvav', sampleEntriesEnd);
1873
1876
  break;
1874
1877
  }
1875
1878
  case 'mp4a':
@@ -1920,55 +1923,59 @@
1920
1923
  case 'hvc1':
1921
1924
  case 'hev1':
1922
1925
  {
1923
- var hvcCBox = findBox(sampleEntriesEnd, ['hvcC'])[0];
1924
- var profileByte = hvcCBox[1];
1925
- var profileSpace = ['', 'A', 'B', 'C'][profileByte >> 6];
1926
- var generalProfileIdc = profileByte & 0x1f;
1927
- var profileCompat = readUint32(hvcCBox, 2);
1928
- var tierFlag = (profileByte & 0x20) >> 5 ? 'H' : 'L';
1929
- var levelIDC = hvcCBox[12];
1930
- var constraintIndicator = hvcCBox.subarray(6, 12);
1931
- codec += '.' + profileSpace + generalProfileIdc;
1932
- codec += '.' + profileCompat.toString(16).toUpperCase();
1933
- codec += '.' + tierFlag + levelIDC;
1934
- var constraintString = '';
1935
- for (var _i = constraintIndicator.length; _i--;) {
1936
- var _byte = constraintIndicator[_i];
1937
- if (_byte || constraintString) {
1938
- var encodedByte = _byte.toString(16).toUpperCase();
1939
- constraintString = '.' + encodedByte + constraintString;
1926
+ var hvcCBoxes = findBox(sampleEntriesEnd, ['hvcC']);
1927
+ if (hvcCBoxes) {
1928
+ var hvcCBox = hvcCBoxes[0];
1929
+ var profileByte = hvcCBox[1];
1930
+ var profileSpace = ['', 'A', 'B', 'C'][profileByte >> 6];
1931
+ var generalProfileIdc = profileByte & 0x1f;
1932
+ var profileCompat = readUint32(hvcCBox, 2);
1933
+ var tierFlag = (profileByte & 0x20) >> 5 ? 'H' : 'L';
1934
+ var levelIDC = hvcCBox[12];
1935
+ var constraintIndicator = hvcCBox.subarray(6, 12);
1936
+ codec += '.' + profileSpace + generalProfileIdc;
1937
+ codec += '.' + profileCompat.toString(16).toUpperCase();
1938
+ codec += '.' + tierFlag + levelIDC;
1939
+ var constraintString = '';
1940
+ for (var _i = constraintIndicator.length; _i--;) {
1941
+ var _byte = constraintIndicator[_i];
1942
+ if (_byte || constraintString) {
1943
+ var encodedByte = _byte.toString(16).toUpperCase();
1944
+ constraintString = '.' + encodedByte + constraintString;
1945
+ }
1940
1946
  }
1947
+ codec += constraintString;
1941
1948
  }
1942
- codec += constraintString;
1949
+ supplemental = parseSupplementalDoViCodec(codecFourCC == 'hev1' ? 'dvhe' : 'dvh1', sampleEntriesEnd);
1943
1950
  break;
1944
1951
  }
1945
1952
  case 'dvh1':
1946
1953
  case 'dvhe':
1954
+ case 'dvav':
1955
+ case 'dva1':
1956
+ case 'dav1':
1947
1957
  {
1948
- var dvcCBox = findBox(sampleEntriesEnd, ['dvcC'])[0];
1949
- var profile = dvcCBox[2] >> 1 & 0x7f;
1950
- var level = dvcCBox[2] << 5 & 0x20 | dvcCBox[3] >> 3 & 0x1f;
1951
- codec += '.' + addLeadingZero(profile) + '.' + addLeadingZero(level);
1958
+ codec = parseSupplementalDoViCodec(codec, sampleEntriesEnd) || codec;
1952
1959
  break;
1953
1960
  }
1954
1961
  case 'vp09':
1955
1962
  {
1956
1963
  var vpcCBox = findBox(sampleEntriesEnd, ['vpcC'])[0];
1957
- var _profile = vpcCBox[4];
1958
- var _level = vpcCBox[5];
1964
+ var profile = vpcCBox[4];
1965
+ var level = vpcCBox[5];
1959
1966
  var bitDepth = vpcCBox[6] >> 4 & 0x0f;
1960
- codec += '.' + addLeadingZero(_profile) + '.' + addLeadingZero(_level) + '.' + addLeadingZero(bitDepth);
1967
+ codec += '.' + addLeadingZero(profile) + '.' + addLeadingZero(level) + '.' + addLeadingZero(bitDepth);
1961
1968
  break;
1962
1969
  }
1963
1970
  case 'av01':
1964
1971
  {
1965
1972
  var av1CBox = findBox(sampleEntriesEnd, ['av1C'])[0];
1966
- var _profile2 = av1CBox[1] >>> 5;
1967
- var _level2 = av1CBox[1] & 0x1f;
1973
+ var _profile = av1CBox[1] >>> 5;
1974
+ var _level = av1CBox[1] & 0x1f;
1968
1975
  var _tierFlag = av1CBox[2] >>> 7 ? 'H' : 'M';
1969
1976
  var highBitDepth = (av1CBox[2] & 0x40) >> 6;
1970
1977
  var twelveBit = (av1CBox[2] & 0x20) >> 5;
1971
- var _bitDepth = _profile2 === 2 && highBitDepth ? twelveBit ? 12 : 10 : highBitDepth ? 10 : 8;
1978
+ var _bitDepth = _profile === 2 && highBitDepth ? twelveBit ? 12 : 10 : highBitDepth ? 10 : 8;
1972
1979
  var monochrome = (av1CBox[2] & 0x10) >> 4;
1973
1980
  var chromaSubsamplingX = (av1CBox[2] & 0x08) >> 3;
1974
1981
  var chromaSubsamplingY = (av1CBox[2] & 0x04) >> 2;
@@ -1980,15 +1987,26 @@
1980
1987
  var transferCharacteristics = 1;
1981
1988
  var matrixCoefficients = 1;
1982
1989
  var videoFullRangeFlag = 0;
1983
- codec += '.' + _profile2 + '.' + addLeadingZero(_level2) + _tierFlag + '.' + addLeadingZero(_bitDepth) + '.' + monochrome + '.' + chromaSubsamplingX + chromaSubsamplingY + chromaSamplePosition + '.' + addLeadingZero(colorPrimaries) + '.' + addLeadingZero(transferCharacteristics) + '.' + addLeadingZero(matrixCoefficients) + '.' + videoFullRangeFlag;
1990
+ codec += '.' + _profile + '.' + addLeadingZero(_level) + _tierFlag + '.' + addLeadingZero(_bitDepth) + '.' + monochrome + '.' + chromaSubsamplingX + chromaSubsamplingY + chromaSamplePosition + '.' + addLeadingZero(colorPrimaries) + '.' + addLeadingZero(transferCharacteristics) + '.' + addLeadingZero(matrixCoefficients) + '.' + videoFullRangeFlag;
1991
+ supplemental = parseSupplementalDoViCodec('dav1', sampleEntriesEnd);
1984
1992
  break;
1985
1993
  }
1986
1994
  }
1987
1995
  return {
1988
1996
  codec: codec,
1989
- encrypted: encrypted
1997
+ encrypted: encrypted,
1998
+ supplemental: supplemental
1990
1999
  };
1991
2000
  }
2001
+ function parseSupplementalDoViCodec(fourCC, sampleEntriesEnd) {
2002
+ var dvvCResult = findBox(sampleEntriesEnd, ['dvvC']); // used by DoVi Profile 8 to 10
2003
+ var dvXCBox = dvvCResult.length ? dvvCResult[0] : findBox(sampleEntriesEnd, ['dvcC'])[0]; // used by DoVi Profiles up to 7 and 20
2004
+ if (dvXCBox) {
2005
+ var doViProfile = dvXCBox[2] >> 1 & 0x7f;
2006
+ var doViLevel = dvXCBox[2] << 5 & 0x20 | dvXCBox[3] >> 3 & 0x1f;
2007
+ return fourCC + '.' + addLeadingZero(doViProfile) + '.' + addLeadingZero(doViLevel);
2008
+ }
2009
+ }
1992
2010
  function skipBERInteger(bytes, i) {
1993
2011
  var limit = i + 5;
1994
2012
  while (bytes[i++] & 0x80 && i < limit) {
@@ -2744,6 +2762,7 @@
2744
2762
  avc4: 1,
2745
2763
  avcp: 1,
2746
2764
  av01: 0.8,
2765
+ dav1: 0.8,
2747
2766
  drac: 1,
2748
2767
  dva1: 1,
2749
2768
  dvav: 1,
@@ -2980,6 +2999,7 @@
2980
2999
  this.height = void 0;
2981
3000
  this.id = void 0;
2982
3001
  this.name = void 0;
3002
+ this.supplemental = void 0;
2983
3003
  this.videoCodec = void 0;
2984
3004
  this.width = void 0;
2985
3005
  this.details = void 0;
@@ -3013,6 +3033,14 @@
3013
3033
  }).map(function (s) {
3014
3034
  return s.substring(0, 4);
3015
3035
  }).join(',');
3036
+ if ('supplemental' in data) {
3037
+ var _data$supplemental;
3038
+ this.supplemental = data.supplemental;
3039
+ var supplementalVideo = (_data$supplemental = data.supplemental) == null ? void 0 : _data$supplemental.videoCodec;
3040
+ if (supplementalVideo && supplementalVideo !== data.videoCodec) {
3041
+ this.codecSet += "," + supplementalVideo.substring(0, 4);
3042
+ }
3043
+ }
3016
3044
  this.addGroupId('audio', data.attrs.AUDIO);
3017
3045
  this.addGroupId('text', data.attrs.SUBTITLES);
3018
3046
  }
@@ -5475,7 +5503,8 @@
5475
5503
  codec = parsedTrack.codec,
5476
5504
  levelCodec = parsedTrack.levelCodec,
5477
5505
  container = parsedTrack.container,
5478
- metadata = parsedTrack.metadata;
5506
+ metadata = parsedTrack.metadata,
5507
+ supplemental = parsedTrack.supplemental;
5479
5508
  var track = tracks[trackName];
5480
5509
  var transferredTrack = (_this9$transferData = _this9.transferData) == null ? void 0 : (_this9$transferData$t = _this9$transferData.tracks) == null ? void 0 : _this9$transferData$t[trackName];
5481
5510
  var sbTrack = transferredTrack != null && transferredTrack.buffer ? transferredTrack : track;
@@ -5486,6 +5515,7 @@
5486
5515
  buffer: undefined,
5487
5516
  listeners: [],
5488
5517
  codec: codec,
5518
+ supplemental: supplemental,
5489
5519
  container: container,
5490
5520
  levelCodec: levelCodec,
5491
5521
  metadata: metadata,
@@ -6098,6 +6128,7 @@
6098
6128
  buffer: buffer,
6099
6129
  container: track.container,
6100
6130
  codec: track.codec,
6131
+ supplemental: track.supplemental,
6101
6132
  levelCodec: track.levelCodec,
6102
6133
  id: track.id,
6103
6134
  metadata: track.metadata
@@ -6168,6 +6199,11 @@
6168
6199
  this.bufferCreated();
6169
6200
  };
6170
6201
  _proto.getTrackCodec = function getTrackCodec(track, trackName) {
6202
+ // Use supplemental video codec when supported when adding SourceBuffer (#5558)
6203
+ var supplementalCodec = track.supplemental;
6204
+ if (supplementalCodec && trackName === 'video' && areCodecsMediaSourceSupported(supplementalCodec, trackName)) {
6205
+ return supplementalCodec;
6206
+ }
6171
6207
  var codec = pickMostCompleteCodecName(track.codec, track.levelCodec);
6172
6208
  if (codec) {
6173
6209
  if (trackName.slice(0, 5) === 'audio') {
@@ -6189,6 +6225,7 @@
6189
6225
  codec: codec,
6190
6226
  container: track.container,
6191
6227
  levelCodec: track.levelCodec,
6228
+ supplemental: track.supplemental,
6192
6229
  metadata: track.metadata,
6193
6230
  id: track.id,
6194
6231
  listeners: []
@@ -7379,6 +7416,11 @@
7379
7416
  level.height = resolution.height;
7380
7417
  }
7381
7418
  setCodecs(attrs.CODECS, level);
7419
+ var supplementalCodecs = attrs['SUPPLEMENTAL-CODECS'];
7420
+ if (supplementalCodecs) {
7421
+ level.supplemental = {};
7422
+ setCodecs(supplementalCodecs, level.supplemental);
7423
+ }
7382
7424
  if (!((_level$unknownCodecs = level.unknownCodecs) != null && _level$unknownCodecs.length)) {
7383
7425
  levelsWithKnownCodecs.push(level);
7384
7426
  }
@@ -7956,7 +7998,9 @@
7956
7998
  });
7957
7999
  if (filtered.length) {
7958
8000
  // Comma separated list of all codecs for type
7959
- level[type + "Codec"] = filtered.join(',');
8001
+ level[type + "Codec"] = filtered.map(function (c) {
8002
+ return c.split('/')[0];
8003
+ }).join(',');
7960
8004
  // Remove known codecs so that only unknownCodecs are left after iterating through each type
7961
8005
  codecs = codecs.filter(function (codec) {
7962
8006
  return filtered.indexOf(codec) === -1;
@@ -10657,10 +10701,12 @@
10657
10701
  var _initData$video = initData.video,
10658
10702
  id = _initData$video.id,
10659
10703
  timescale = _initData$video.timescale,
10660
- codec = _initData$video.codec;
10704
+ codec = _initData$video.codec,
10705
+ supplemental = _initData$video.supplemental;
10661
10706
  videoTrack.id = id;
10662
10707
  videoTrack.timescale = captionTrack.timescale = timescale;
10663
10708
  videoTrack.codec = codec;
10709
+ videoTrack.supplemental = supplemental;
10664
10710
  }
10665
10711
  if (initData.audio) {
10666
10712
  var _initData$audio = initData.audio,
@@ -13917,6 +13963,7 @@
13917
13963
  tracks.video = {
13918
13964
  container: 'video/mp4',
13919
13965
  codec: videoCodec,
13966
+ supplemental: initData.video.supplemental,
13920
13967
  initSegment: initSegment,
13921
13968
  id: 'main'
13922
13969
  };
@@ -19424,6 +19471,7 @@
19424
19471
  videoCodecFound || (videoCodecFound = !!videoCodec);
19425
19472
  audioCodecFound || (audioCodecFound = !!audioCodec);
19426
19473
  if (unknownUnsupportedCodecCount || audioCodec && !_this2.isAudioSupported(audioCodec) || videoCodec && !_this2.isVideoSupported(videoCodec)) {
19474
+ _this2.log("Some or all CODECS not supported \"" + attributes.CODECS + "\"");
19427
19475
  return;
19428
19476
  }
19429
19477
  var CODECS = attributes.CODECS,
@@ -19435,7 +19483,7 @@
19435
19483
  var contentSteeringPrefix = (PATHWAY || '.') + "-";
19436
19484
  var levelKey = "" + contentSteeringPrefix + levelParsed.bitrate + "-" + RESOLUTION + "-" + FRAMERATE + "-" + CODECS + "-" + VIDEO_RANGE + "-" + HDCP;
19437
19485
  if (!redundantSet[levelKey]) {
19438
- var level = new Level(levelParsed);
19486
+ var level = _this2.createLevel(levelParsed);
19439
19487
  redundantSet[levelKey] = level;
19440
19488
  generatePathwaySet[levelKey] = 1;
19441
19489
  levels.push(level);
@@ -19444,7 +19492,7 @@
19444
19492
  // Content Steering controller to handles Pathway fallback on error
19445
19493
  var pathwayCount = generatePathwaySet[levelKey] += 1;
19446
19494
  levelParsed.attrs['PATHWAY-ID'] = new Array(pathwayCount + 1).join('.');
19447
- var _level = new Level(levelParsed);
19495
+ var _level = _this2.createLevel(levelParsed);
19448
19496
  redundantSet[levelKey] = _level;
19449
19497
  levels.push(_level);
19450
19498
  } else {
@@ -19454,6 +19502,16 @@
19454
19502
  });
19455
19503
  this.filterAndSortMediaOptions(levels, data, resolutionFound, videoCodecFound, audioCodecFound);
19456
19504
  };
19505
+ _proto.createLevel = function createLevel(levelParsed) {
19506
+ var level = new Level(levelParsed);
19507
+ var supplemental = levelParsed.supplemental;
19508
+ if (supplemental != null && supplemental.videoCodec && !this.isVideoSupported(supplemental.videoCodec)) {
19509
+ var error = new Error("SUPPLEMENTAL-CODECS not supported \"" + supplemental.videoCodec + "\"");
19510
+ this.log(error.message);
19511
+ level.supportedResult = emptyExports.getUnsupportedResult(error, []);
19512
+ }
19513
+ return level;
19514
+ };
19457
19515
  _proto.isAudioSupported = function isAudioSupported(codec) {
19458
19516
  return areCodecsMediaSourceSupported(codec, 'audio', this.hls.config.preferManagedMediaSource);
19459
19517
  };
@@ -19480,17 +19538,25 @@
19480
19538
  // Dispatch error after MANIFEST_LOADED is done propagating
19481
19539
  Promise.resolve().then(function () {
19482
19540
  if (_this3.hls) {
19541
+ var message = 'no level with compatible codecs found in manifest';
19542
+ var reason = message;
19483
19543
  if (data.levels.length) {
19484
- _this3.warn("One or more CODECS in variant not supported: " + stringify(data.levels[0].attrs));
19544
+ reason = "one or more CODECS in variant not supported: " + stringify(data.levels.map(function (level) {
19545
+ return level.attrs.CODECS;
19546
+ }).filter(function (value, index, array) {
19547
+ return array.indexOf(value) === index;
19548
+ }));
19549
+ _this3.warn(reason);
19550
+ message += " (" + reason + ")";
19485
19551
  }
19486
- var error = new Error('no level with compatible codecs found in manifest');
19552
+ var error = new Error(message);
19487
19553
  _this3.hls.trigger(Events.ERROR, {
19488
19554
  type: ErrorTypes.MEDIA_ERROR,
19489
19555
  details: ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,
19490
19556
  fatal: true,
19491
19557
  url: data.url,
19492
19558
  error: error,
19493
- reason: error.message
19559
+ reason: reason
19494
19560
  });
19495
19561
  }
19496
19562
  });
@@ -20081,7 +20147,7 @@
20081
20147
  return !remuxResult.audio && !remuxResult.video && !remuxResult.text && !remuxResult.id3 && !remuxResult.initSegment;
20082
20148
  }
20083
20149
 
20084
- var version = "1.6.0-beta.4.0.canary.11068";
20150
+ var version = "1.6.0-rc.1";
20085
20151
 
20086
20152
  // ensure the worker ends up in the bundle
20087
20153
  // If the worker should not be included this gets aliased to empty.js
@@ -21545,7 +21611,7 @@
21545
21611
  break;
21546
21612
  }
21547
21613
  }
21548
- this.log("Init video buffer, container:" + video.container + ", codecs[level/parsed]=[" + (currentLevel.videoCodec || '') + "/" + parsedVideoCodec + (video.codec !== parsedVideoCodec ? ' parsed-corrected=' + video.codec : '') + "}]");
21614
+ this.log("Init video buffer, container:" + video.container + ", codecs[level/parsed]=[" + (currentLevel.videoCodec || '') + "/" + parsedVideoCodec + "]" + (video.codec !== parsedVideoCodec ? ' parsed-corrected=' + video.codec : '') + (video.supplemental ? ' supplemental=' + video.supplemental : ''));
21549
21615
  delete tracks.audiovideo;
21550
21616
  }
21551
21617
  if (audiovideo) {
@@ -22532,6 +22598,18 @@
22532
22598
  smooth: true
22533
22599
  }]
22534
22600
  };
22601
+ function getUnsupportedResult(error, configurations) {
22602
+ return {
22603
+ supported: false,
22604
+ configurations: configurations,
22605
+ decodingInfoResults: [{
22606
+ supported: false,
22607
+ smooth: false,
22608
+ powerEfficient: false
22609
+ }],
22610
+ error: error
22611
+ };
22612
+ }
22535
22613
  var SUPPORTED_INFO_CACHE = {};
22536
22614
  function getMediaDecodingInfoPromise(level, audioTracksByGroup, mediaCapabilities) {
22537
22615
  var videoCodecs = level.videoCodec;
@@ -22558,16 +22636,7 @@
22558
22636
  if (videoCodecsArray.some(function (videoCodec) {
22559
22637
  return isHEVC(videoCodec);
22560
22638
  }) && userAgentHevcSupportIsInaccurate()) {
22561
- return Promise.resolve({
22562
- supported: false,
22563
- configurations: configurations,
22564
- decodingInfoResults: [{
22565
- supported: false,
22566
- smooth: false,
22567
- powerEfficient: false
22568
- }],
22569
- error: new Error("Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent sting: (" + ua + ")")
22570
- });
22639
+ return Promise.resolve(getUnsupportedResult(new Error("Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent sting: (" + ua + ")"), configurations));
22571
22640
  }
22572
22641
  configurations.push.apply(configurations, videoCodecsArray.map(function (videoCodec) {
22573
22642
  return {