hls.js 1.6.0-beta.2.0.canary.10873 → 1.6.0-beta.2.0.canary.10876

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.
@@ -401,7 +401,7 @@ function enableLogs(debugConfig, context, id) {
401
401
  // Some browsers don't allow to use bind on console object anyway
402
402
  // fallback to default if needed
403
403
  try {
404
- newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.6.0-beta.2.0.canary.10873"}`);
404
+ newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.6.0-beta.2.0.canary.10876"}`);
405
405
  } catch (e) {
406
406
  /* log fn threw an exception. All logger methods are no-ops. */
407
407
  return createLogger();
@@ -14345,7 +14345,6 @@ function parsePMT(data, offset, typeSupported, isSampleAes, observer, logger) {
14345
14345
  // logger.log('AVC PID:' + pid);
14346
14346
  if (result.videoPid === -1) {
14347
14347
  result.videoPid = pid;
14348
- result.segmentVideoCodec = 'avc';
14349
14348
  }
14350
14349
  break;
14351
14350
 
@@ -14768,7 +14767,7 @@ class MP4 {
14768
14767
  0x00, 0x00]));
14769
14768
  }
14770
14769
  static mdia(track) {
14771
- return MP4.box(MP4.types.mdia, MP4.mdhd(track.timescale, track.duration), MP4.hdlr(track.type), MP4.minf(track));
14770
+ return MP4.box(MP4.types.mdia, MP4.mdhd(track.timescale || 0, track.duration || 0), MP4.hdlr(track.type), MP4.minf(track));
14772
14771
  }
14773
14772
  static mfhd(sequenceNumber) {
14774
14773
  return MP4.box(MP4.types.mfhd, new Uint8Array([0x00, 0x00, 0x00, 0x00,
@@ -14792,7 +14791,7 @@ class MP4 {
14792
14791
  while (i--) {
14793
14792
  boxes[i] = MP4.trak(tracks[i]);
14794
14793
  }
14795
- return MP4.box.apply(null, [MP4.types.moov, MP4.mvhd(tracks[0].timescale, tracks[0].duration)].concat(boxes).concat(MP4.mvex(tracks)));
14794
+ return MP4.box.apply(null, [MP4.types.moov, MP4.mvhd(tracks[0].timescale || 0, tracks[0].duration || 0)].concat(boxes).concat(MP4.mvex(tracks)));
14796
14795
  }
14797
14796
  static mvex(tracks) {
14798
14797
  let i = tracks.length;
@@ -14978,7 +14977,7 @@ class MP4 {
14978
14977
  ]);
14979
14978
  }
14980
14979
  static audioStsd(track) {
14981
- const samplerate = track.samplerate;
14980
+ const samplerate = track.samplerate || 0;
14982
14981
  return new Uint8Array([0x00, 0x00, 0x00,
14983
14982
  // reserved
14984
14983
  0x00, 0x00, 0x00,
@@ -14987,7 +14986,7 @@ class MP4 {
14987
14986
  // data_reference_index
14988
14987
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14989
14988
  // reserved
14990
- 0x00, track.channelCount,
14989
+ 0x00, track.channelCount || 0,
14991
14990
  // channelcount
14992
14991
  0x00, 0x10,
14993
14992
  // sampleSize:16bits
@@ -15007,25 +15006,32 @@ class MP4 {
15007
15006
  return MP4.box(MP4.types['ac-3'], MP4.audioStsd(track), MP4.box(MP4.types.dac3, track.config));
15008
15007
  }
15009
15008
  static stsd(track) {
15009
+ const {
15010
+ segmentCodec
15011
+ } = track;
15010
15012
  if (track.type === 'audio') {
15011
- if (track.segmentCodec === 'mp3' && track.codec === 'mp3') {
15012
- return MP4.box(MP4.types.stsd, MP4.STSD, MP4.mp3(track));
15013
+ if (segmentCodec === 'aac') {
15014
+ return MP4.box(MP4.types.stsd, MP4.STSD, MP4.mp4a(track));
15013
15015
  }
15014
- if (track.segmentCodec === 'ac3') {
15015
- return MP4.box(MP4.types.stsd, MP4.STSD, MP4.ac3(track));
15016
+ if (segmentCodec === 'mp3' && track.codec === 'mp3') {
15017
+ return MP4.box(MP4.types.stsd, MP4.STSD, MP4.mp3(track));
15016
15018
  }
15017
- return MP4.box(MP4.types.stsd, MP4.STSD, MP4.mp4a(track));
15018
- } else if (track.segmentCodec === 'avc') {
15019
- return MP4.box(MP4.types.stsd, MP4.STSD, MP4.avc1(track));
15020
15019
  } else {
15021
- return MP4.box(MP4.types.stsd, MP4.STSD, MP4.hvc1(track));
15020
+ if (track.pps && track.sps) {
15021
+ if (segmentCodec === 'avc') {
15022
+ return MP4.box(MP4.types.stsd, MP4.STSD, MP4.avc1(track));
15023
+ }
15024
+ } else {
15025
+ throw new Error(`video track missing pps or sps`);
15026
+ }
15022
15027
  }
15028
+ throw new Error(`unsupported ${track.type} segment codec (${segmentCodec}/${track.codec})`);
15023
15029
  }
15024
15030
  static tkhd(track) {
15025
15031
  const id = track.id;
15026
- const duration = track.duration * track.timescale;
15027
- const width = track.width;
15028
- const height = track.height;
15032
+ const duration = (track.duration || 0) * (track.timescale || 0);
15033
+ const width = track.width || 0;
15034
+ const height = track.height || 0;
15029
15035
  const upperWordDuration = Math.floor(duration / (UINT32_MAX + 1));
15030
15036
  const lowerWordDuration = Math.floor(duration % (UINT32_MAX + 1));
15031
15037
  return MP4.box(MP4.types.tkhd, new Uint8Array([0x01,
@@ -15157,82 +15163,9 @@ class MP4 {
15157
15163
  return result;
15158
15164
  }
15159
15165
  static hvc1(track) {
15160
- const ps = track.params;
15161
- const units = [track.vps, track.sps, track.pps];
15162
- const NALuLengthSize = 4;
15163
- const config = new Uint8Array([0x01, ps.general_profile_space << 6 | (ps.general_tier_flag ? 32 : 0) | ps.general_profile_idc, ps.general_profile_compatibility_flags[0], ps.general_profile_compatibility_flags[1], ps.general_profile_compatibility_flags[2], ps.general_profile_compatibility_flags[3], ps.general_constraint_indicator_flags[0], ps.general_constraint_indicator_flags[1], ps.general_constraint_indicator_flags[2], ps.general_constraint_indicator_flags[3], ps.general_constraint_indicator_flags[4], ps.general_constraint_indicator_flags[5], ps.general_level_idc, 240 | ps.min_spatial_segmentation_idc >> 8, 255 & ps.min_spatial_segmentation_idc, 252 | ps.parallelismType, 252 | ps.chroma_format_idc, 248 | ps.bit_depth_luma_minus8, 248 | ps.bit_depth_chroma_minus8, 0x00, parseInt(ps.frame_rate.fps), NALuLengthSize - 1 | ps.temporal_id_nested << 2 | ps.num_temporal_layers << 3 | (ps.frame_rate.fixed ? 64 : 0), units.length]);
15164
-
15165
- // compute hvcC size in bytes
15166
- let length = config.length;
15167
- for (let i = 0; i < units.length; i += 1) {
15168
- length += 3;
15169
- for (let j = 0; j < units[i].length; j += 1) {
15170
- length += 2 + units[i][j].length;
15171
- }
15172
- }
15173
- const hvcC = new Uint8Array(length);
15174
- hvcC.set(config, 0);
15175
- length = config.length;
15176
- // append parameter set units: one vps, one or more sps and pps
15177
- const iMax = units.length - 1;
15178
- for (let i = 0; i < units.length; i += 1) {
15179
- hvcC.set(new Uint8Array([32 + i | (i === iMax ? 128 : 0), 0x00, units[i].length]), length);
15180
- length += 3;
15181
- for (let j = 0; j < units[i].length; j += 1) {
15182
- hvcC.set(new Uint8Array([units[i][j].length >> 8, units[i][j].length & 255]), length);
15183
- length += 2;
15184
- hvcC.set(units[i][j], length);
15185
- length += units[i][j].length;
15186
- }
15187
- }
15188
- const hvcc = MP4.box(MP4.types.hvcC, hvcC);
15189
- const width = track.width;
15190
- const height = track.height;
15191
- const hSpacing = track.pixelRatio[0];
15192
- const vSpacing = track.pixelRatio[1];
15193
- return MP4.box(MP4.types.hvc1, new Uint8Array([0x00, 0x00, 0x00,
15194
- // reserved
15195
- 0x00, 0x00, 0x00,
15196
- // reserved
15197
- 0x00, 0x01,
15198
- // data_reference_index
15199
- 0x00, 0x00,
15200
- // pre_defined
15201
- 0x00, 0x00,
15202
- // reserved
15203
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15204
- // pre_defined
15205
- width >> 8 & 0xff, width & 0xff,
15206
- // width
15207
- height >> 8 & 0xff, height & 0xff,
15208
- // height
15209
- 0x00, 0x48, 0x00, 0x00,
15210
- // horizresolution
15211
- 0x00, 0x48, 0x00, 0x00,
15212
- // vertresolution
15213
- 0x00, 0x00, 0x00, 0x00,
15214
- // reserved
15215
- 0x00, 0x01,
15216
- // frame_count
15217
- 0x12, 0x64, 0x61, 0x69, 0x6c,
15218
- // dailymotion/hls.js
15219
- 0x79, 0x6d, 0x6f, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x68, 0x6c, 0x73, 0x2e, 0x6a, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15220
- // compressorname
15221
- 0x00, 0x18,
15222
- // depth = 24
15223
- 0x11, 0x11]),
15224
- // pre_defined = -1
15225
- hvcc, MP4.box(MP4.types.btrt, new Uint8Array([0x00, 0x1c, 0x9c, 0x80,
15226
- // bufferSizeDB
15227
- 0x00, 0x2d, 0xc6, 0xc0,
15228
- // maxBitrate
15229
- 0x00, 0x2d, 0xc6, 0xc0])),
15230
- // avgBitrate
15231
- MP4.box(MP4.types.pasp, new Uint8Array([hSpacing >> 24,
15232
- // hSpacing
15233
- hSpacing >> 16 & 0xff, hSpacing >> 8 & 0xff, hSpacing & 0xff, vSpacing >> 24,
15234
- // vSpacing
15235
- vSpacing >> 16 & 0xff, vSpacing >> 8 & 0xff, vSpacing & 0xff])));
15166
+ {
15167
+ return new Uint8Array();
15168
+ }
15236
15169
  }
15237
15170
  }
15238
15171
  MP4.types = void 0;
@@ -15262,6 +15195,21 @@ const MPEG_AUDIO_SAMPLE_PER_FRAME = 1152;
15262
15195
  const AC3_SAMPLES_PER_FRAME = 1536;
15263
15196
  let chromeVersion = null;
15264
15197
  let safariWebkitVersion = null;
15198
+ function createMp4Sample(isKeyframe, duration, size, cts) {
15199
+ return {
15200
+ duration,
15201
+ size,
15202
+ cts,
15203
+ flags: {
15204
+ isLeading: 0,
15205
+ isDependedOn: 0,
15206
+ hasRedundancy: 0,
15207
+ degradPrio: 0,
15208
+ dependsOn: isKeyframe ? 2 : 1,
15209
+ isNonSync: isKeyframe ? 0 : 1
15210
+ }
15211
+ };
15212
+ }
15265
15213
  class MP4Remuxer {
15266
15214
  constructor(observer, config, typeSupported, logger) {
15267
15215
  this.logger = void 0;
@@ -15760,7 +15708,7 @@ class MP4Remuxer {
15760
15708
  maxDtsDelta = Math.max(maxDtsDelta, mp4SampleDuration);
15761
15709
  minPtsDelta = Math.min(minPtsDelta, ptsDelta);
15762
15710
  maxPtsDelta = Math.max(maxPtsDelta, ptsDelta);
15763
- outputSamples.push(new Mp4Sample(VideoSample.key, mp4SampleDuration, mp4SampleLength, compositionTimeOffset));
15711
+ outputSamples.push(createMp4Sample(VideoSample.key, mp4SampleDuration, mp4SampleLength, compositionTimeOffset));
15764
15712
  }
15765
15713
  if (outputSamples.length) {
15766
15714
  if (chromeVersion) {
@@ -15797,7 +15745,7 @@ class MP4Remuxer {
15797
15745
  this.nextAvcDts = nextAvcDts = lastDTS + mp4SampleDuration;
15798
15746
  this.videoSampleDuration = mp4SampleDuration;
15799
15747
  this.isVideoContiguous = true;
15800
- const moof = MP4.moof(track.sequenceNumber++, firstDTS, _extends({}, track, {
15748
+ const moof = MP4.moof(track.sequenceNumber++, firstDTS, _extends(track, {
15801
15749
  samples: outputSamples
15802
15750
  }));
15803
15751
  const type = 'video';
@@ -15999,7 +15947,7 @@ class MP4Remuxer {
15999
15947
  // Default the sample's duration to the computed mp4SampleDuration, which will either be 1024 for AAC or 1152 for MPEG
16000
15948
  // In the case that we have 1 sample, this will be the duration. If we have more than one sample, the duration
16001
15949
  // becomes the PTS diff with the previous sample
16002
- outputSamples.push(new Mp4Sample(true, mp4SampleDuration, unitLen, 0));
15950
+ outputSamples.push(createMp4Sample(true, mp4SampleDuration, unitLen, 0));
16003
15951
  lastPTS = pts;
16004
15952
  }
16005
15953
 
@@ -16105,25 +16053,6 @@ function flushTextTrackUserdataCueSamples(track, timeOffset, initPTS) {
16105
16053
  samples
16106
16054
  };
16107
16055
  }
16108
- class Mp4Sample {
16109
- constructor(isKeyframe, duration, size, cts) {
16110
- this.size = void 0;
16111
- this.duration = void 0;
16112
- this.cts = void 0;
16113
- this.flags = void 0;
16114
- this.duration = duration;
16115
- this.size = size;
16116
- this.cts = cts;
16117
- this.flags = {
16118
- isLeading: 0,
16119
- isDependedOn: 0,
16120
- hasRedundancy: 0,
16121
- degradPrio: 0,
16122
- dependsOn: isKeyframe ? 2 : 1,
16123
- isNonSync: isKeyframe ? 0 : 1
16124
- };
16125
- }
16126
- }
16127
16056
 
16128
16057
  class PassThroughRemuxer {
16129
16058
  constructor(observer, config, typeSupported, logger) {
@@ -19184,7 +19113,7 @@ class GapController extends Logger {
19184
19113
  }
19185
19114
  }
19186
19115
 
19187
- const version = "1.6.0-beta.2.0.canary.10873";
19116
+ const version = "1.6.0-beta.2.0.canary.10876";
19188
19117
 
19189
19118
  // ensure the worker ends up in the bundle
19190
19119
  // If the worker should not be included this gets aliased to empty.js