mediabunny 1.55.2 → 1.55.3
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/bundles/mediabunny.cjs +283 -179
- package/dist/bundles/mediabunny.min.cjs +11 -11
- package/dist/bundles/mediabunny.min.mjs +11 -11
- package/dist/bundles/mediabunny.mjs +283 -179
- package/dist/bundles/mediabunny.node.cjs +283 -179
- package/dist/modules/shared/aac-misc.d.ts +5 -4
- package/dist/modules/shared/aac-misc.d.ts.map +1 -1
- package/dist/modules/shared/aac-misc.js +100 -33
- package/dist/modules/src/adts/adts-demuxer.d.ts.map +1 -1
- package/dist/modules/src/adts/adts-demuxer.js +6 -6
- package/dist/modules/src/aes.d.ts.map +1 -1
- package/dist/modules/src/aes.js +2 -2
- package/dist/modules/src/flac/flac-demuxer.d.ts.map +1 -1
- package/dist/modules/src/flac/flac-demuxer.js +8 -8
- package/dist/modules/src/input-format.d.ts.map +1 -1
- package/dist/modules/src/input-format.js +52 -22
- package/dist/modules/src/input-track.d.ts.map +1 -1
- package/dist/modules/src/input-track.js +9 -9
- package/dist/modules/src/isobmff/isobmff-demuxer.d.ts.map +1 -1
- package/dist/modules/src/isobmff/isobmff-demuxer.js +42 -23
- package/dist/modules/src/isobmff/isobmff-muxer.js +2 -2
- package/dist/modules/src/matroska/ebml.js +3 -3
- package/dist/modules/src/matroska/matroska-demuxer.d.ts.map +1 -1
- package/dist/modules/src/matroska/matroska-demuxer.js +14 -14
- package/dist/modules/src/matroska/matroska-muxer.js +2 -2
- package/dist/modules/src/media-source.d.ts.map +1 -1
- package/dist/modules/src/media-source.js +5 -5
- package/dist/modules/src/misc.d.ts +4 -0
- package/dist/modules/src/misc.d.ts.map +1 -1
- package/dist/modules/src/misc.js +11 -0
- package/dist/modules/src/mp3/mp3-demuxer.d.ts.map +1 -1
- package/dist/modules/src/mp3/mp3-demuxer.js +8 -8
- package/dist/modules/src/mp3/mp3-reader.d.ts.map +1 -1
- package/dist/modules/src/mp3/mp3-reader.js +2 -1
- package/dist/modules/src/mpeg-ts/mpeg-ts-demuxer.d.ts.map +1 -1
- package/dist/modules/src/mpeg-ts/mpeg-ts-demuxer.js +18 -18
- package/dist/modules/src/ogg/ogg-demuxer.d.ts.map +1 -1
- package/dist/modules/src/ogg/ogg-demuxer.js +9 -9
- package/dist/modules/src/output.d.ts.map +1 -1
- package/dist/modules/src/output.js +4 -4
- package/dist/modules/src/reader.d.ts.map +1 -1
- package/dist/modules/src/reader.js +4 -4
- package/dist/modules/src/sample.d.ts.map +1 -1
- package/dist/modules/src/sample.js +4 -4
- package/dist/modules/src/source.d.ts.map +1 -1
- package/dist/modules/src/source.js +8 -8
- package/dist/modules/src/tsconfig.tsbuildinfo +1 -1
- package/dist/modules/src/wave/wave-demuxer.js +9 -9
- package/package.json +1 -1
- package/src/adts/adts-demuxer.ts +6 -5
- package/src/aes.ts +2 -2
- package/src/flac/flac-demuxer.ts +8 -7
- package/src/input-format.ts +50 -21
- package/src/input-track.ts +9 -9
- package/src/isobmff/isobmff-demuxer.ts +49 -26
- package/src/isobmff/isobmff-muxer.ts +2 -2
- package/src/matroska/ebml.ts +3 -3
- package/src/matroska/matroska-demuxer.ts +14 -13
- package/src/matroska/matroska-muxer.ts +2 -2
- package/src/media-source.ts +5 -4
- package/src/misc.ts +14 -0
- package/src/mp3/mp3-demuxer.ts +8 -7
- package/src/mp3/mp3-reader.ts +2 -1
- package/src/mpeg-ts/mpeg-ts-demuxer.ts +18 -17
- package/src/ogg/ogg-demuxer.ts +9 -8
- package/src/output.ts +13 -4
- package/src/reader.ts +4 -4
- package/src/sample.ts +4 -3
- package/src/source.ts +8 -7
- package/src/wave/wave-demuxer.ts +9 -9
|
@@ -746,6 +746,14 @@ var Mediabunny = (() => {
|
|
|
746
746
|
}
|
|
747
747
|
return `${className} is not available in this environment.`;
|
|
748
748
|
};
|
|
749
|
+
var NativePromiseConstructor = (async () => {
|
|
750
|
+
})().constructor;
|
|
751
|
+
var isThenable = (value) => {
|
|
752
|
+
if (value instanceof NativePromiseConstructor || value instanceof Promise) {
|
|
753
|
+
return true;
|
|
754
|
+
}
|
|
755
|
+
return typeof value?.then === "function";
|
|
756
|
+
};
|
|
749
757
|
var coalesceIndex = (a, b) => {
|
|
750
758
|
return a !== -1 ? a : b;
|
|
751
759
|
};
|
|
@@ -1422,71 +1430,127 @@ var Mediabunny = (() => {
|
|
|
1422
1430
|
throw new TypeError("AAC description must be at least 2 bytes long.");
|
|
1423
1431
|
}
|
|
1424
1432
|
const bitstream = new Bitstream(bytes2);
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
objectType = 32 + bitstream.readBits(6);
|
|
1428
|
-
}
|
|
1429
|
-
const frequencyIndex = bitstream.readBits(4);
|
|
1430
|
-
let sampleRate = null;
|
|
1431
|
-
if (frequencyIndex === 15) {
|
|
1432
|
-
sampleRate = bitstream.readBits(24);
|
|
1433
|
-
} else {
|
|
1434
|
-
if (frequencyIndex < aacFrequencyTable.length) {
|
|
1435
|
-
sampleRate = aacFrequencyTable[frequencyIndex];
|
|
1436
|
-
}
|
|
1437
|
-
}
|
|
1433
|
+
const objectType = readAacObjectType(bitstream);
|
|
1434
|
+
const { frequencyIndex, sampleRate } = readAacSamplingFrequency(bitstream);
|
|
1438
1435
|
const channelConfiguration = bitstream.readBits(4);
|
|
1439
1436
|
let numberOfChannels = null;
|
|
1440
1437
|
if (channelConfiguration >= 1 && channelConfiguration <= 7) {
|
|
1441
1438
|
numberOfChannels = aacChannelMap[channelConfiguration];
|
|
1442
1439
|
}
|
|
1440
|
+
let coreObjectType = objectType;
|
|
1441
|
+
let psPresent = false;
|
|
1442
|
+
let outputSampleRate = sampleRate;
|
|
1443
|
+
if (objectType === 5 || objectType === 29) {
|
|
1444
|
+
psPresent = objectType === 29;
|
|
1445
|
+
outputSampleRate = readAacSamplingFrequency(bitstream).sampleRate;
|
|
1446
|
+
coreObjectType = readAacObjectType(bitstream);
|
|
1447
|
+
if (coreObjectType === 22) {
|
|
1448
|
+
bitstream.skipBits(4);
|
|
1449
|
+
}
|
|
1450
|
+
} else {
|
|
1451
|
+
while (bitstream.getBitsLeft() > 15) {
|
|
1452
|
+
const searchStart = bitstream.pos;
|
|
1453
|
+
if (bitstream.readBits(11) !== 695) {
|
|
1454
|
+
bitstream.pos = searchStart + 1;
|
|
1455
|
+
continue;
|
|
1456
|
+
}
|
|
1457
|
+
if (readAacObjectType(bitstream) === 5 && bitstream.readBits(1)) {
|
|
1458
|
+
outputSampleRate = readAacSamplingFrequency(bitstream).sampleRate;
|
|
1459
|
+
if (bitstream.getBitsLeft() > 11 && bitstream.readBits(11) === 1352) {
|
|
1460
|
+
psPresent = !!bitstream.readBits(1);
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1463
|
+
break;
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
if (numberOfChannels !== null && numberOfChannels > 1) {
|
|
1467
|
+
psPresent = false;
|
|
1468
|
+
}
|
|
1443
1469
|
return {
|
|
1444
1470
|
objectType,
|
|
1471
|
+
coreObjectType,
|
|
1445
1472
|
frequencyIndex,
|
|
1446
|
-
sampleRate,
|
|
1447
1473
|
channelConfiguration,
|
|
1448
|
-
|
|
1474
|
+
outputSampleRate,
|
|
1475
|
+
outputNumberOfChannels: psPresent && numberOfChannels === 1 ? 2 : numberOfChannels
|
|
1449
1476
|
};
|
|
1450
1477
|
};
|
|
1451
|
-
var
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1478
|
+
var readAacObjectType = (bitstream) => {
|
|
1479
|
+
const objectType = bitstream.readBits(5);
|
|
1480
|
+
return objectType === 31 ? 32 + bitstream.readBits(6) : objectType;
|
|
1481
|
+
};
|
|
1482
|
+
var readAacSamplingFrequency = (bitstream) => {
|
|
1483
|
+
const frequencyIndex = bitstream.readBits(4);
|
|
1484
|
+
if (frequencyIndex === 15) {
|
|
1485
|
+
return {
|
|
1486
|
+
frequencyIndex,
|
|
1487
|
+
sampleRate: bitstream.readBits(24)
|
|
1488
|
+
};
|
|
1457
1489
|
}
|
|
1458
|
-
|
|
1490
|
+
return {
|
|
1491
|
+
frequencyIndex,
|
|
1492
|
+
sampleRate: frequencyIndex < aacFrequencyTable.length ? aacFrequencyTable[frequencyIndex] : null
|
|
1493
|
+
};
|
|
1494
|
+
};
|
|
1495
|
+
var buildAacAudioSpecificConfig = (config) => {
|
|
1496
|
+
const usesSbr = config.objectType === 5 || config.objectType === 29;
|
|
1497
|
+
const usesPs = config.objectType === 29;
|
|
1498
|
+
const coreSampleRate = usesSbr ? config.outputSampleRate / 2 : config.outputSampleRate;
|
|
1499
|
+
const coreNumberOfChannels = usesPs ? 1 : config.outputNumberOfChannels;
|
|
1500
|
+
const channelConfiguration = aacChannelMap.indexOf(coreNumberOfChannels);
|
|
1459
1501
|
if (channelConfiguration === -1) {
|
|
1460
|
-
throw new TypeError(`Unsupported number of channels: ${config.
|
|
1502
|
+
throw new TypeError(`Unsupported number of channels: ${config.outputNumberOfChannels}`);
|
|
1461
1503
|
}
|
|
1462
|
-
let bitCount = 5 + 4 + 4;
|
|
1504
|
+
let bitCount = 5 + 4 + 4 + 3;
|
|
1463
1505
|
if (config.objectType >= 32) {
|
|
1464
1506
|
bitCount += 6;
|
|
1465
1507
|
}
|
|
1466
|
-
if (
|
|
1508
|
+
if (findAacFrequencyIndex(coreSampleRate) === 15) {
|
|
1467
1509
|
bitCount += 24;
|
|
1468
1510
|
}
|
|
1511
|
+
if (usesSbr) {
|
|
1512
|
+
bitCount += 4 + 5;
|
|
1513
|
+
if (findAacFrequencyIndex(config.outputSampleRate) === 15) {
|
|
1514
|
+
bitCount += 24;
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1469
1517
|
const byteCount = Math.ceil(bitCount / 8);
|
|
1470
1518
|
const bytes2 = new Uint8Array(byteCount);
|
|
1471
1519
|
const bitstream = new Bitstream(bytes2);
|
|
1472
|
-
|
|
1473
|
-
|
|
1520
|
+
writeAacObjectType(bitstream, config.objectType);
|
|
1521
|
+
writeAacSamplingFrequency(bitstream, coreSampleRate);
|
|
1522
|
+
bitstream.writeBits(4, channelConfiguration);
|
|
1523
|
+
if (usesSbr) {
|
|
1524
|
+
writeAacSamplingFrequency(bitstream, config.outputSampleRate);
|
|
1525
|
+
writeAacObjectType(bitstream, 2);
|
|
1526
|
+
}
|
|
1527
|
+
bitstream.writeBits(3, 0);
|
|
1528
|
+
return bytes2;
|
|
1529
|
+
};
|
|
1530
|
+
var writeAacObjectType = (bitstream, objectType) => {
|
|
1531
|
+
if (objectType < 32) {
|
|
1532
|
+
bitstream.writeBits(5, objectType);
|
|
1474
1533
|
} else {
|
|
1475
1534
|
bitstream.writeBits(5, 31);
|
|
1476
|
-
bitstream.writeBits(6,
|
|
1535
|
+
bitstream.writeBits(6, objectType - 32);
|
|
1477
1536
|
}
|
|
1537
|
+
};
|
|
1538
|
+
var writeAacSamplingFrequency = (bitstream, sampleRate) => {
|
|
1539
|
+
const frequencyIndex = findAacFrequencyIndex(sampleRate);
|
|
1478
1540
|
bitstream.writeBits(4, frequencyIndex);
|
|
1479
1541
|
if (frequencyIndex === 15) {
|
|
1480
|
-
bitstream.writeBits(24,
|
|
1542
|
+
bitstream.writeBits(24, sampleRate);
|
|
1481
1543
|
}
|
|
1482
|
-
|
|
1483
|
-
|
|
1544
|
+
};
|
|
1545
|
+
var findAacFrequencyIndex = (sampleRate) => {
|
|
1546
|
+
const index = aacFrequencyTable.indexOf(sampleRate);
|
|
1547
|
+
return index === -1 ? 15 : index;
|
|
1484
1548
|
};
|
|
1485
1549
|
var buildAdtsHeaderTemplate = (config) => {
|
|
1486
1550
|
const header = new Uint8Array(7);
|
|
1487
1551
|
const bitstream = new Bitstream(header);
|
|
1488
|
-
const {
|
|
1489
|
-
const profile =
|
|
1552
|
+
const { coreObjectType, frequencyIndex, channelConfiguration } = config;
|
|
1553
|
+
const profile = coreObjectType - 1;
|
|
1490
1554
|
bitstream.writeBits(12, 4095);
|
|
1491
1555
|
bitstream.writeBits(1, 0);
|
|
1492
1556
|
bitstream.writeBits(2, 0);
|
|
@@ -5899,7 +5963,7 @@ var Mediabunny = (() => {
|
|
|
5899
5963
|
}
|
|
5900
5964
|
const requestedLength = CHUNK_SIZE + BLOCK_SIZE;
|
|
5901
5965
|
let nextSlice = reader.requestSliceRange(pos, 0, requestedLength);
|
|
5902
|
-
if (nextSlice
|
|
5966
|
+
if (isThenable(nextSlice)) nextSlice = await nextSlice;
|
|
5903
5967
|
if (!nextSlice || nextSlice.length === 0) {
|
|
5904
5968
|
throw new Error("Invalid ciphertext.");
|
|
5905
5969
|
}
|
|
@@ -5988,7 +6052,7 @@ var Mediabunny = (() => {
|
|
|
5988
6052
|
let foundMovieBoxes = false;
|
|
5989
6053
|
while (true) {
|
|
5990
6054
|
let slice = this.reader.requestSliceRange(currentPos, MIN_BOX_HEADER_SIZE, MAX_BOX_HEADER_SIZE);
|
|
5991
|
-
if (slice
|
|
6055
|
+
if (isThenable(slice)) slice = await slice;
|
|
5992
6056
|
if (!slice) break;
|
|
5993
6057
|
const startPos = currentPos;
|
|
5994
6058
|
const boxInfo = readBoxHeader(slice);
|
|
@@ -6000,7 +6064,7 @@ var Mediabunny = (() => {
|
|
|
6000
6064
|
this.isQuickTime = majorBrand === "qt ";
|
|
6001
6065
|
} else if (boxInfo.name === "moov") {
|
|
6002
6066
|
let moovSlice = this.reader.requestSlice(slice.filePos, boxInfo.contentSize);
|
|
6003
|
-
if (moovSlice
|
|
6067
|
+
if (isThenable(moovSlice)) moovSlice = await moovSlice;
|
|
6004
6068
|
if (!moovSlice) break;
|
|
6005
6069
|
this.moovSlice = moovSlice;
|
|
6006
6070
|
this.readContiguousBoxes(this.moovSlice);
|
|
@@ -6030,7 +6094,7 @@ var Mediabunny = (() => {
|
|
|
6030
6094
|
if (lookForMfraBox) {
|
|
6031
6095
|
assert(this.reader.fileSize !== null);
|
|
6032
6096
|
let lastWordSlice = this.reader.requestSlice(this.reader.fileSize - 4, 4);
|
|
6033
|
-
if (lastWordSlice
|
|
6097
|
+
if (isThenable(lastWordSlice)) lastWordSlice = await lastWordSlice;
|
|
6034
6098
|
assert(lastWordSlice);
|
|
6035
6099
|
const lastWord = readU32Be(lastWordSlice);
|
|
6036
6100
|
const potentialMfraPos = this.reader.fileSize - lastWord;
|
|
@@ -6040,12 +6104,12 @@ var Mediabunny = (() => {
|
|
|
6040
6104
|
MIN_BOX_HEADER_SIZE,
|
|
6041
6105
|
MAX_BOX_HEADER_SIZE
|
|
6042
6106
|
);
|
|
6043
|
-
if (mfraHeaderSlice
|
|
6107
|
+
if (isThenable(mfraHeaderSlice)) mfraHeaderSlice = await mfraHeaderSlice;
|
|
6044
6108
|
if (mfraHeaderSlice) {
|
|
6045
6109
|
const boxInfo = readBoxHeader(mfraHeaderSlice);
|
|
6046
6110
|
if (boxInfo && boxInfo.name === "mfra") {
|
|
6047
6111
|
let mfraSlice = this.reader.requestSlice(mfraHeaderSlice.filePos, boxInfo.contentSize);
|
|
6048
|
-
if (mfraSlice
|
|
6112
|
+
if (isThenable(mfraSlice)) mfraSlice = await mfraSlice;
|
|
6049
6113
|
if (mfraSlice) {
|
|
6050
6114
|
this.readContiguousBoxes(mfraSlice);
|
|
6051
6115
|
}
|
|
@@ -6212,12 +6276,12 @@ var Mediabunny = (() => {
|
|
|
6212
6276
|
return this.lastReadFragment;
|
|
6213
6277
|
}
|
|
6214
6278
|
let headerSlice = this.reader.requestSliceRange(startPos, MIN_BOX_HEADER_SIZE, MAX_BOX_HEADER_SIZE);
|
|
6215
|
-
if (headerSlice
|
|
6279
|
+
if (isThenable(headerSlice)) headerSlice = await headerSlice;
|
|
6216
6280
|
assert(headerSlice);
|
|
6217
6281
|
const moofBoxInfo = readBoxHeader(headerSlice);
|
|
6218
6282
|
assert(moofBoxInfo?.name === "moof");
|
|
6219
6283
|
let entireSlice = this.reader.requestSlice(startPos, moofBoxInfo.totalSize);
|
|
6220
|
-
if (entireSlice
|
|
6284
|
+
if (isThenable(entireSlice)) entireSlice = await entireSlice;
|
|
6221
6285
|
assert(entireSlice);
|
|
6222
6286
|
this.traverseBox(entireSlice);
|
|
6223
6287
|
const fragment = this.lastReadFragment;
|
|
@@ -7024,11 +7088,11 @@ var Mediabunny = (() => {
|
|
|
7024
7088
|
track.info.codecDescription = readBytes(slice, decoderSpecificInfoLength);
|
|
7025
7089
|
if (track.info.codec === "aac") {
|
|
7026
7090
|
const audioSpecificConfig = parseAacAudioSpecificConfig(track.info.codecDescription);
|
|
7027
|
-
if (audioSpecificConfig.
|
|
7028
|
-
track.info.numberOfChannels = audioSpecificConfig.
|
|
7091
|
+
if (audioSpecificConfig.outputNumberOfChannels !== null) {
|
|
7092
|
+
track.info.numberOfChannels = audioSpecificConfig.outputNumberOfChannels;
|
|
7029
7093
|
}
|
|
7030
|
-
if (audioSpecificConfig.
|
|
7031
|
-
track.info.sampleRate = audioSpecificConfig.
|
|
7094
|
+
if (audioSpecificConfig.outputSampleRate !== null) {
|
|
7095
|
+
track.info.sampleRate = audioSpecificConfig.outputSampleRate;
|
|
7032
7096
|
}
|
|
7033
7097
|
}
|
|
7034
7098
|
}
|
|
@@ -8388,20 +8452,26 @@ var Mediabunny = (() => {
|
|
|
8388
8452
|
sampleInfo.sampleOffset,
|
|
8389
8453
|
sampleInfo.sampleSize
|
|
8390
8454
|
);
|
|
8391
|
-
if (slice
|
|
8455
|
+
if (isThenable(slice)) slice = await slice;
|
|
8392
8456
|
if (!slice) {
|
|
8393
8457
|
return null;
|
|
8394
8458
|
}
|
|
8395
8459
|
data = readBytes(slice, sampleInfo.sampleSize);
|
|
8396
|
-
if (this.internalTrack.
|
|
8397
|
-
|
|
8398
|
-
|
|
8399
|
-
|
|
8400
|
-
|
|
8401
|
-
|
|
8402
|
-
|
|
8403
|
-
|
|
8404
|
-
|
|
8460
|
+
if (this.internalTrack.encryptionInfo) {
|
|
8461
|
+
let sampleEncryption = null;
|
|
8462
|
+
if (this.internalTrack.encryptionAuxInfo) {
|
|
8463
|
+
const entries = await resolveEncryptionAuxInfo(
|
|
8464
|
+
this.internalTrack.demuxer.reader,
|
|
8465
|
+
this.internalTrack.encryptionInfo,
|
|
8466
|
+
this.internalTrack.encryptionAuxInfo
|
|
8467
|
+
);
|
|
8468
|
+
if (sampleIndex < entries.length) {
|
|
8469
|
+
sampleEncryption = entries[sampleIndex];
|
|
8470
|
+
}
|
|
8471
|
+
}
|
|
8472
|
+
sampleEncryption ??= getDefaultSampleEncryption(this.internalTrack.encryptionInfo);
|
|
8473
|
+
if (sampleEncryption) {
|
|
8474
|
+
data = await decryptSample(this.internalTrack, sampleEncryption, data, null);
|
|
8405
8475
|
}
|
|
8406
8476
|
}
|
|
8407
8477
|
}
|
|
@@ -8433,13 +8503,16 @@ var Mediabunny = (() => {
|
|
|
8433
8503
|
fragmentSample.byteOffset,
|
|
8434
8504
|
fragmentSample.byteSize
|
|
8435
8505
|
);
|
|
8436
|
-
if (slice
|
|
8506
|
+
if (isThenable(slice)) slice = await slice;
|
|
8437
8507
|
if (!slice) {
|
|
8438
8508
|
return null;
|
|
8439
8509
|
}
|
|
8440
8510
|
data = readBytes(slice, fragmentSample.byteSize);
|
|
8441
|
-
if (
|
|
8442
|
-
|
|
8511
|
+
if (this.internalTrack.encryptionInfo) {
|
|
8512
|
+
const sampleEncryption = fragmentSample.encryption ?? getDefaultSampleEncryption(this.internalTrack.encryptionInfo);
|
|
8513
|
+
if (sampleEncryption) {
|
|
8514
|
+
data = await decryptSample(this.internalTrack, sampleEncryption, data, fragment);
|
|
8515
|
+
}
|
|
8443
8516
|
}
|
|
8444
8517
|
}
|
|
8445
8518
|
const timestamp = (fragmentSample.presentationTimestamp - this.internalTrack.editListOffset) / this.internalTrack.timescale;
|
|
@@ -8506,7 +8579,7 @@ var Mediabunny = (() => {
|
|
|
8506
8579
|
}
|
|
8507
8580
|
}
|
|
8508
8581
|
let slice = demuxer.reader.requestSliceRange(currentPos, MIN_BOX_HEADER_SIZE, MAX_BOX_HEADER_SIZE);
|
|
8509
|
-
if (slice
|
|
8582
|
+
if (isThenable(slice)) slice = await slice;
|
|
8510
8583
|
if (!slice) break;
|
|
8511
8584
|
const boxStartPos = currentPos;
|
|
8512
8585
|
const boxInfo = readBoxHeader(slice);
|
|
@@ -8827,7 +8900,7 @@ var Mediabunny = (() => {
|
|
|
8827
8900
|
}
|
|
8828
8901
|
}
|
|
8829
8902
|
let slice = reader.requestSlice(aux.offset, totalSize);
|
|
8830
|
-
if (slice
|
|
8903
|
+
if (isThenable(slice)) slice = await slice;
|
|
8831
8904
|
if (!slice) {
|
|
8832
8905
|
throw new Error("Failed to read auxiliary encryption info.");
|
|
8833
8906
|
}
|
|
@@ -8857,6 +8930,15 @@ var Mediabunny = (() => {
|
|
|
8857
8930
|
aux.resolved = entries;
|
|
8858
8931
|
return entries;
|
|
8859
8932
|
};
|
|
8933
|
+
var getDefaultSampleEncryption = (encryptionInfo) => {
|
|
8934
|
+
if (!encryptionInfo.defaultConstantIv) {
|
|
8935
|
+
return null;
|
|
8936
|
+
}
|
|
8937
|
+
return {
|
|
8938
|
+
iv: encryptionInfo.defaultConstantIv,
|
|
8939
|
+
subsamples: null
|
|
8940
|
+
};
|
|
8941
|
+
};
|
|
8860
8942
|
var decryptSample = async (track, sampleEncryption, data, fragment) => {
|
|
8861
8943
|
assert(track.encryptionInfo);
|
|
8862
8944
|
const encryptionInfo = track.encryptionInfo;
|
|
@@ -9447,7 +9529,7 @@ var Mediabunny = (() => {
|
|
|
9447
9529
|
let currentPos = startPos;
|
|
9448
9530
|
while (until === null || currentPos < until) {
|
|
9449
9531
|
let slice = reader.requestSliceRange(currentPos, MIN_HEADER_SIZE, MAX_HEADER_SIZE);
|
|
9450
|
-
if (slice
|
|
9532
|
+
if (isThenable(slice)) slice = await slice;
|
|
9451
9533
|
if (!slice) break;
|
|
9452
9534
|
const elementHeader = readElementHeader(slice);
|
|
9453
9535
|
if (!elementHeader) {
|
|
@@ -9467,7 +9549,7 @@ var Mediabunny = (() => {
|
|
|
9467
9549
|
let currentPos = startPos;
|
|
9468
9550
|
while (currentPos < until) {
|
|
9469
9551
|
let slice = reader.requestSliceRange(currentPos, 0, Math.min(CHUNK_SIZE, until - currentPos));
|
|
9470
|
-
if (slice
|
|
9552
|
+
if (isThenable(slice)) slice = await slice;
|
|
9471
9553
|
if (!slice) break;
|
|
9472
9554
|
if (slice.length < MAX_VAR_INT_SIZE) break;
|
|
9473
9555
|
for (let i = 0; i < slice.length - MAX_VAR_INT_SIZE; i++) {
|
|
@@ -9589,7 +9671,7 @@ var Mediabunny = (() => {
|
|
|
9589
9671
|
let currentPos = 0;
|
|
9590
9672
|
while (true) {
|
|
9591
9673
|
let slice = this.reader.requestSliceRange(currentPos, MIN_HEADER_SIZE, MAX_HEADER_SIZE);
|
|
9592
|
-
if (slice
|
|
9674
|
+
if (isThenable(slice)) slice = await slice;
|
|
9593
9675
|
if (!slice) break;
|
|
9594
9676
|
const header = readElementHeader(slice);
|
|
9595
9677
|
if (!header) {
|
|
@@ -9601,7 +9683,7 @@ var Mediabunny = (() => {
|
|
|
9601
9683
|
if (id === 440786851 /* EBML */) {
|
|
9602
9684
|
assertDefinedSize(size);
|
|
9603
9685
|
let slice2 = this.reader.requestSlice(dataStartPos, size);
|
|
9604
|
-
if (slice2
|
|
9686
|
+
if (isThenable(slice2)) slice2 = await slice2;
|
|
9605
9687
|
if (!slice2) break;
|
|
9606
9688
|
this.readContiguousElements(slice2);
|
|
9607
9689
|
} else if (id === 408125543 /* Segment */) {
|
|
@@ -9660,7 +9742,7 @@ var Mediabunny = (() => {
|
|
|
9660
9742
|
let currentPos = segmentDataStart;
|
|
9661
9743
|
while (this.currentSegment.elementEndPos === null || currentPos < this.currentSegment.elementEndPos) {
|
|
9662
9744
|
let slice = this.reader.requestSliceRange(currentPos, MIN_HEADER_SIZE, MAX_HEADER_SIZE);
|
|
9663
|
-
if (slice
|
|
9745
|
+
if (isThenable(slice)) slice = await slice;
|
|
9664
9746
|
if (!slice) break;
|
|
9665
9747
|
const elementStartPos = currentPos;
|
|
9666
9748
|
const header = readElementHeader(slice);
|
|
@@ -9686,7 +9768,7 @@ var Mediabunny = (() => {
|
|
|
9686
9768
|
this.currentSegment[field] = true;
|
|
9687
9769
|
assertDefinedSize(size);
|
|
9688
9770
|
let slice2 = this.reader.requestSlice(dataStartPos, size);
|
|
9689
|
-
if (slice2
|
|
9771
|
+
if (isThenable(slice2)) slice2 = await slice2;
|
|
9690
9772
|
if (slice2) {
|
|
9691
9773
|
this.readContiguousElements(slice2);
|
|
9692
9774
|
}
|
|
@@ -9698,7 +9780,7 @@ var Mediabunny = (() => {
|
|
|
9698
9780
|
}
|
|
9699
9781
|
assertDefinedSize(size);
|
|
9700
9782
|
let slice2 = this.reader.requestSlice(dataStartPos, size);
|
|
9701
|
-
if (slice2
|
|
9783
|
+
if (isThenable(slice2)) slice2 = await slice2;
|
|
9702
9784
|
if (slice2) {
|
|
9703
9785
|
this.readContiguousElements(slice2);
|
|
9704
9786
|
}
|
|
@@ -9725,7 +9807,7 @@ var Mediabunny = (() => {
|
|
|
9725
9807
|
MIN_HEADER_SIZE,
|
|
9726
9808
|
MAX_HEADER_SIZE
|
|
9727
9809
|
);
|
|
9728
|
-
if (slice
|
|
9810
|
+
if (isThenable(slice)) slice = await slice;
|
|
9729
9811
|
if (!slice) continue;
|
|
9730
9812
|
const header = readElementHeader(slice);
|
|
9731
9813
|
if (!header) continue;
|
|
@@ -9734,7 +9816,7 @@ var Mediabunny = (() => {
|
|
|
9734
9816
|
assertDefinedSize(size);
|
|
9735
9817
|
this.currentSegment[target.flag] = true;
|
|
9736
9818
|
let dataSlice = this.reader.requestSlice(slice.filePos, size);
|
|
9737
|
-
if (dataSlice
|
|
9819
|
+
if (isThenable(dataSlice)) dataSlice = await dataSlice;
|
|
9738
9820
|
if (!dataSlice) continue;
|
|
9739
9821
|
this.readContiguousElements(dataSlice);
|
|
9740
9822
|
}
|
|
@@ -9786,7 +9868,7 @@ var Mediabunny = (() => {
|
|
|
9786
9868
|
return segment.lastReadCluster;
|
|
9787
9869
|
}
|
|
9788
9870
|
let headerSlice = this.reader.requestSliceRange(startPos, MIN_HEADER_SIZE, MAX_HEADER_SIZE);
|
|
9789
|
-
if (headerSlice
|
|
9871
|
+
if (isThenable(headerSlice)) headerSlice = await headerSlice;
|
|
9790
9872
|
assert(headerSlice);
|
|
9791
9873
|
const elementStartPos = startPos;
|
|
9792
9874
|
const elementHeader = readElementHeader(headerSlice);
|
|
@@ -9805,7 +9887,7 @@ var Mediabunny = (() => {
|
|
|
9805
9887
|
size = nextElementPos.pos - dataStartPos;
|
|
9806
9888
|
}
|
|
9807
9889
|
let dataSlice = this.reader.requestSlice(dataStartPos, size);
|
|
9808
|
-
if (dataSlice
|
|
9890
|
+
if (isThenable(dataSlice)) dataSlice = await dataSlice;
|
|
9809
9891
|
const cluster = {
|
|
9810
9892
|
segment,
|
|
9811
9893
|
elementStartPos,
|
|
@@ -9993,7 +10075,7 @@ var Mediabunny = (() => {
|
|
|
9993
10075
|
MIN_HEADER_SIZE,
|
|
9994
10076
|
MAX_HEADER_SIZE
|
|
9995
10077
|
);
|
|
9996
|
-
if (slice
|
|
10078
|
+
if (isThenable(slice)) slice = await slice;
|
|
9997
10079
|
if (!slice) continue;
|
|
9998
10080
|
const header = readElementHeader(slice);
|
|
9999
10081
|
if (!header || header.id !== seekEntry.id) continue;
|
|
@@ -10002,7 +10084,7 @@ var Mediabunny = (() => {
|
|
|
10002
10084
|
assert(!this.currentSegment);
|
|
10003
10085
|
this.currentSegment = segment;
|
|
10004
10086
|
let dataSlice = this.reader.requestSlice(slice.filePos, size);
|
|
10005
|
-
if (dataSlice
|
|
10087
|
+
if (isThenable(dataSlice)) dataSlice = await dataSlice;
|
|
10006
10088
|
if (dataSlice) {
|
|
10007
10089
|
this.readContiguousElements(dataSlice);
|
|
10008
10090
|
}
|
|
@@ -11358,7 +11440,7 @@ var Mediabunny = (() => {
|
|
|
11358
11440
|
}
|
|
11359
11441
|
}
|
|
11360
11442
|
let slice = demuxer.reader.requestSliceRange(currentPos, MIN_HEADER_SIZE, MAX_HEADER_SIZE);
|
|
11361
|
-
if (slice
|
|
11443
|
+
if (isThenable(slice)) slice = await slice;
|
|
11362
11444
|
if (!slice) break;
|
|
11363
11445
|
const elementStartPos = currentPos;
|
|
11364
11446
|
const elementHeader = readElementHeader(slice);
|
|
@@ -11404,7 +11486,7 @@ var Mediabunny = (() => {
|
|
|
11404
11486
|
const endPos = dataStartPos + size;
|
|
11405
11487
|
if (segment.elementEndPos === null) {
|
|
11406
11488
|
let slice2 = demuxer.reader.requestSliceRange(endPos, MIN_HEADER_SIZE, MAX_HEADER_SIZE);
|
|
11407
|
-
if (slice2
|
|
11489
|
+
if (isThenable(slice2)) slice2 = await slice2;
|
|
11408
11490
|
if (!slice2) break;
|
|
11409
11491
|
const elementId = readElementId(slice2);
|
|
11410
11492
|
if (elementId === 408125543 /* Segment */) {
|
|
@@ -11551,7 +11633,7 @@ var Mediabunny = (() => {
|
|
|
11551
11633
|
while (until === null || currentPos < until) {
|
|
11552
11634
|
const maxLength = until !== null ? Math.min(CHUNK_SIZE, until - currentPos) : CHUNK_SIZE;
|
|
11553
11635
|
let slice = reader.requestSliceRange(currentPos, MP3_FRAME_HEADER_SIZE, maxLength);
|
|
11554
|
-
if (slice
|
|
11636
|
+
if (isThenable(slice)) slice = await slice;
|
|
11555
11637
|
if (!slice || slice.length < MP3_FRAME_HEADER_SIZE) break;
|
|
11556
11638
|
while (slice.remainingLength >= MP3_FRAME_HEADER_SIZE) {
|
|
11557
11639
|
const posBeforeRead = slice.filePos;
|
|
@@ -11609,7 +11691,7 @@ var Mediabunny = (() => {
|
|
|
11609
11691
|
if (this.lastLoadedPos === 0) {
|
|
11610
11692
|
while (true) {
|
|
11611
11693
|
let slice2 = this.reader.requestSlice(this.lastLoadedPos, ID3_V2_HEADER_SIZE);
|
|
11612
|
-
if (slice2
|
|
11694
|
+
if (isThenable(slice2)) slice2 = await slice2;
|
|
11613
11695
|
if (!slice2) {
|
|
11614
11696
|
this.lastSampleLoaded = true;
|
|
11615
11697
|
return;
|
|
@@ -11635,7 +11717,7 @@ var Mediabunny = (() => {
|
|
|
11635
11717
|
this.lastLoadedPos = result.startPos + header.totalSize - 1;
|
|
11636
11718
|
const xingOffset = getXingOffset(header.mpegVersionId, header.channel);
|
|
11637
11719
|
let slice = this.reader.requestSlice(result.startPos + xingOffset, 4);
|
|
11638
|
-
if (slice
|
|
11720
|
+
if (isThenable(slice)) slice = await slice;
|
|
11639
11721
|
if (slice) {
|
|
11640
11722
|
const word = readU32Be(slice);
|
|
11641
11723
|
const isXing = word === XING || word === INFO;
|
|
@@ -11646,7 +11728,7 @@ var Mediabunny = (() => {
|
|
|
11646
11728
|
}
|
|
11647
11729
|
if (!this.xingData) {
|
|
11648
11730
|
let xingDataSlice = this.reader.requestSlice(result.startPos + xingOffset + 4, 12);
|
|
11649
|
-
if (xingDataSlice
|
|
11731
|
+
if (isThenable(xingDataSlice)) xingDataSlice = await xingDataSlice;
|
|
11650
11732
|
if (xingDataSlice) {
|
|
11651
11733
|
const xingData = readBytes(xingDataSlice, 12);
|
|
11652
11734
|
const view2 = toDataView(xingData);
|
|
@@ -11694,7 +11776,7 @@ var Mediabunny = (() => {
|
|
|
11694
11776
|
let id3V2HeaderFound = false;
|
|
11695
11777
|
while (true) {
|
|
11696
11778
|
let headerSlice = this.reader.requestSlice(currentPos, ID3_V2_HEADER_SIZE);
|
|
11697
|
-
if (headerSlice
|
|
11779
|
+
if (isThenable(headerSlice)) headerSlice = await headerSlice;
|
|
11698
11780
|
if (!headerSlice) break;
|
|
11699
11781
|
const id3V2Header = readId3V2Header(headerSlice);
|
|
11700
11782
|
if (!id3V2Header) {
|
|
@@ -11702,14 +11784,14 @@ var Mediabunny = (() => {
|
|
|
11702
11784
|
}
|
|
11703
11785
|
id3V2HeaderFound = true;
|
|
11704
11786
|
let contentSlice = this.reader.requestSlice(headerSlice.filePos, id3V2Header.size);
|
|
11705
|
-
if (contentSlice
|
|
11787
|
+
if (isThenable(contentSlice)) contentSlice = await contentSlice;
|
|
11706
11788
|
if (!contentSlice) break;
|
|
11707
11789
|
parseId3V2Tag(contentSlice, id3V2Header, this.metadataTags);
|
|
11708
11790
|
currentPos = headerSlice.filePos + id3V2Header.size;
|
|
11709
11791
|
}
|
|
11710
11792
|
if (!id3V2HeaderFound && this.reader.fileSize !== null && this.reader.fileSize >= ID3_V1_TAG_SIZE) {
|
|
11711
11793
|
let slice = this.reader.requestSlice(this.reader.fileSize - ID3_V1_TAG_SIZE, ID3_V1_TAG_SIZE);
|
|
11712
|
-
if (slice
|
|
11794
|
+
if (isThenable(slice)) slice = await slice;
|
|
11713
11795
|
assert(slice);
|
|
11714
11796
|
const tag = readAscii(slice, 3);
|
|
11715
11797
|
if (tag === "TAG") {
|
|
@@ -11825,7 +11907,7 @@ var Mediabunny = (() => {
|
|
|
11825
11907
|
data = PLACEHOLDER_DATA;
|
|
11826
11908
|
} else {
|
|
11827
11909
|
let slice = this.demuxer.reader.requestSlice(rawSample.dataStart, rawSample.dataSize);
|
|
11828
|
-
if (slice
|
|
11910
|
+
if (isThenable(slice)) slice = await slice;
|
|
11829
11911
|
if (!slice) {
|
|
11830
11912
|
return null;
|
|
11831
11913
|
}
|
|
@@ -12031,7 +12113,7 @@ var Mediabunny = (() => {
|
|
|
12031
12113
|
let currentPos = 0;
|
|
12032
12114
|
while (true) {
|
|
12033
12115
|
let slice = this.reader.requestSliceRange(currentPos, MIN_PAGE_HEADER_SIZE, MAX_PAGE_HEADER_SIZE);
|
|
12034
|
-
if (slice
|
|
12116
|
+
if (isThenable(slice)) slice = await slice;
|
|
12035
12117
|
if (!slice) break;
|
|
12036
12118
|
const page = readPageHeader(slice);
|
|
12037
12119
|
if (!page) {
|
|
@@ -12182,7 +12264,7 @@ var Mediabunny = (() => {
|
|
|
12182
12264
|
outer:
|
|
12183
12265
|
while (true) {
|
|
12184
12266
|
let pageSlice = this.reader.requestSlice(currentPage.dataStartPos, currentPage.dataSize);
|
|
12185
|
-
if (pageSlice
|
|
12267
|
+
if (isThenable(pageSlice)) pageSlice = await pageSlice;
|
|
12186
12268
|
assert(pageSlice);
|
|
12187
12269
|
const pageData = readBytes(pageSlice, currentPage.dataSize);
|
|
12188
12270
|
while (true) {
|
|
@@ -12201,7 +12283,7 @@ var Mediabunny = (() => {
|
|
|
12201
12283
|
let currentPos = currentPage.headerStartPos + currentPage.totalSize;
|
|
12202
12284
|
while (true) {
|
|
12203
12285
|
let headerSlice = this.reader.requestSliceRange(currentPos, MIN_PAGE_HEADER_SIZE, MAX_PAGE_HEADER_SIZE);
|
|
12204
|
-
if (headerSlice
|
|
12286
|
+
if (isThenable(headerSlice)) headerSlice = await headerSlice;
|
|
12205
12287
|
if (!headerSlice) {
|
|
12206
12288
|
return null;
|
|
12207
12289
|
}
|
|
@@ -12247,7 +12329,7 @@ var Mediabunny = (() => {
|
|
|
12247
12329
|
let currentPos = lastPacket.endPage.headerStartPos + lastPacket.endPage.totalSize;
|
|
12248
12330
|
while (true) {
|
|
12249
12331
|
let slice = this.reader.requestSliceRange(currentPos, MIN_PAGE_HEADER_SIZE, MAX_PAGE_HEADER_SIZE);
|
|
12250
|
-
if (slice
|
|
12332
|
+
if (isThenable(slice)) slice = await slice;
|
|
12251
12333
|
if (!slice) {
|
|
12252
12334
|
return null;
|
|
12253
12335
|
}
|
|
@@ -12465,7 +12547,7 @@ var Mediabunny = (() => {
|
|
|
12465
12547
|
high - MIN_PAGE_HEADER_SIZE
|
|
12466
12548
|
);
|
|
12467
12549
|
let searchSlice = this.demuxer.reader.requestSlice(searchStartPos, until - searchStartPos);
|
|
12468
|
-
if (searchSlice
|
|
12550
|
+
if (isThenable(searchSlice)) searchSlice = await searchSlice;
|
|
12469
12551
|
assert(searchSlice);
|
|
12470
12552
|
const found = findNextPageHeader(searchSlice, until);
|
|
12471
12553
|
if (!found) {
|
|
@@ -12477,7 +12559,7 @@ var Mediabunny = (() => {
|
|
|
12477
12559
|
MIN_PAGE_HEADER_SIZE,
|
|
12478
12560
|
MAX_PAGE_HEADER_SIZE
|
|
12479
12561
|
);
|
|
12480
|
-
if (headerSlice
|
|
12562
|
+
if (isThenable(headerSlice)) headerSlice = await headerSlice;
|
|
12481
12563
|
assert(headerSlice);
|
|
12482
12564
|
const page = readPageHeader(headerSlice);
|
|
12483
12565
|
assert(page);
|
|
@@ -12486,7 +12568,7 @@ var Mediabunny = (() => {
|
|
|
12486
12568
|
pageValid = true;
|
|
12487
12569
|
} else {
|
|
12488
12570
|
let pageSlice = this.demuxer.reader.requestSlice(page.headerStartPos, page.totalSize);
|
|
12489
|
-
if (pageSlice
|
|
12571
|
+
if (isThenable(pageSlice)) pageSlice = await pageSlice;
|
|
12490
12572
|
assert(pageSlice);
|
|
12491
12573
|
const bytes2 = readBytes(pageSlice, page.totalSize);
|
|
12492
12574
|
const crc = computeOggPageCrc(bytes2);
|
|
@@ -12531,7 +12613,7 @@ var Mediabunny = (() => {
|
|
|
12531
12613
|
}
|
|
12532
12614
|
const nextPos = currentPage.headerStartPos + currentPage.totalSize;
|
|
12533
12615
|
let slice = this.demuxer.reader.requestSliceRange(nextPos, MIN_PAGE_HEADER_SIZE, MAX_PAGE_HEADER_SIZE);
|
|
12534
|
-
if (slice
|
|
12616
|
+
if (isThenable(slice)) slice = await slice;
|
|
12535
12617
|
assert(slice);
|
|
12536
12618
|
const nextPage = readPageHeader(slice);
|
|
12537
12619
|
assert(nextPage);
|
|
@@ -12789,7 +12871,7 @@ var Mediabunny = (() => {
|
|
|
12789
12871
|
async readMetadata() {
|
|
12790
12872
|
return this.metadataPromise ??= (async () => {
|
|
12791
12873
|
let slice = this.reader.requestSlice(0, 12);
|
|
12792
|
-
if (slice
|
|
12874
|
+
if (isThenable(slice)) slice = await slice;
|
|
12793
12875
|
assert(slice);
|
|
12794
12876
|
const riffType = readAscii(slice, 4);
|
|
12795
12877
|
const littleEndian = riffType !== "RIFX";
|
|
@@ -12805,7 +12887,7 @@ var Mediabunny = (() => {
|
|
|
12805
12887
|
let currentPos = slice.filePos;
|
|
12806
12888
|
while (totalFileSize === null || currentPos < totalFileSize) {
|
|
12807
12889
|
let slice2 = this.reader.requestSlice(currentPos, 8);
|
|
12808
|
-
if (slice2
|
|
12890
|
+
if (isThenable(slice2)) slice2 = await slice2;
|
|
12809
12891
|
if (!slice2) break;
|
|
12810
12892
|
const chunkId = readAscii(slice2, 4);
|
|
12811
12893
|
const chunkSize = readU32(slice2, littleEndian);
|
|
@@ -12824,7 +12906,7 @@ var Mediabunny = (() => {
|
|
|
12824
12906
|
}
|
|
12825
12907
|
} else if (chunkId === "ds64") {
|
|
12826
12908
|
let ds64Slice = this.reader.requestSlice(startPos, chunkSize);
|
|
12827
|
-
if (ds64Slice
|
|
12909
|
+
if (isThenable(ds64Slice)) ds64Slice = await ds64Slice;
|
|
12828
12910
|
if (!ds64Slice) break;
|
|
12829
12911
|
const riffChunkSize = readU64(ds64Slice, littleEndian);
|
|
12830
12912
|
dataChunkSize = readU64(ds64Slice, littleEndian);
|
|
@@ -12850,7 +12932,7 @@ var Mediabunny = (() => {
|
|
|
12850
12932
|
}
|
|
12851
12933
|
async parseFmtChunk(startPos, size, littleEndian) {
|
|
12852
12934
|
let slice = this.reader.requestSlice(startPos, size);
|
|
12853
|
-
if (slice
|
|
12935
|
+
if (isThenable(slice)) slice = await slice;
|
|
12854
12936
|
if (!slice) return;
|
|
12855
12937
|
let formatTag = readU16(slice, littleEndian);
|
|
12856
12938
|
const numChannels = readU16(slice, littleEndian);
|
|
@@ -12901,7 +12983,7 @@ var Mediabunny = (() => {
|
|
|
12901
12983
|
}
|
|
12902
12984
|
async parseListChunk(startPos, size, littleEndian) {
|
|
12903
12985
|
let slice = this.reader.requestSlice(startPos, size);
|
|
12904
|
-
if (slice
|
|
12986
|
+
if (isThenable(slice)) slice = await slice;
|
|
12905
12987
|
if (!slice) return;
|
|
12906
12988
|
const infoType = readAscii(slice, 4);
|
|
12907
12989
|
if (infoType !== "INFO" && infoType !== "INF0") {
|
|
@@ -13005,7 +13087,7 @@ var Mediabunny = (() => {
|
|
|
13005
13087
|
}
|
|
13006
13088
|
async parseId3Chunk(startPos, size) {
|
|
13007
13089
|
let slice = this.reader.requestSlice(startPos, size);
|
|
13008
|
-
if (slice
|
|
13090
|
+
if (isThenable(slice)) slice = await slice;
|
|
13009
13091
|
if (!slice) return;
|
|
13010
13092
|
const id3V2Header = readId3V2Header(slice);
|
|
13011
13093
|
if (id3V2Header) {
|
|
@@ -13148,7 +13230,7 @@ var Mediabunny = (() => {
|
|
|
13148
13230
|
);
|
|
13149
13231
|
if (this.demuxer.reader.fileSize === null) {
|
|
13150
13232
|
let slice = this.demuxer.reader.requestSlice(this.demuxer.dataStart + startOffset, sizeInBytes);
|
|
13151
|
-
if (slice
|
|
13233
|
+
if (isThenable(slice)) slice = await slice;
|
|
13152
13234
|
if (!slice) {
|
|
13153
13235
|
return null;
|
|
13154
13236
|
}
|
|
@@ -13158,7 +13240,7 @@ var Mediabunny = (() => {
|
|
|
13158
13240
|
data = PLACEHOLDER_DATA;
|
|
13159
13241
|
} else {
|
|
13160
13242
|
let slice = this.demuxer.reader.requestSlice(this.demuxer.dataStart + startOffset, sizeInBytes);
|
|
13161
|
-
if (slice
|
|
13243
|
+
if (isThenable(slice)) slice = await slice;
|
|
13162
13244
|
assert(slice);
|
|
13163
13245
|
data = readBytes(slice, sizeInBytes);
|
|
13164
13246
|
}
|
|
@@ -13303,7 +13385,7 @@ var Mediabunny = (() => {
|
|
|
13303
13385
|
if (this.lastLoadedPos === 0) {
|
|
13304
13386
|
while (true) {
|
|
13305
13387
|
let slice2 = this.reader.requestSlice(this.lastLoadedPos, ID3_V2_HEADER_SIZE);
|
|
13306
|
-
if (slice2
|
|
13388
|
+
if (isThenable(slice2)) slice2 = await slice2;
|
|
13307
13389
|
if (!slice2) {
|
|
13308
13390
|
this.lastSampleLoaded = true;
|
|
13309
13391
|
return;
|
|
@@ -13320,7 +13402,7 @@ var Mediabunny = (() => {
|
|
|
13320
13402
|
MIN_ADTS_FRAME_HEADER_SIZE,
|
|
13321
13403
|
MAX_ADTS_FRAME_HEADER_SIZE
|
|
13322
13404
|
);
|
|
13323
|
-
if (slice
|
|
13405
|
+
if (isThenable(slice)) slice = await slice;
|
|
13324
13406
|
if (!slice) {
|
|
13325
13407
|
this.lastSampleLoaded = true;
|
|
13326
13408
|
return;
|
|
@@ -13368,14 +13450,14 @@ var Mediabunny = (() => {
|
|
|
13368
13450
|
let currentPos = 0;
|
|
13369
13451
|
while (true) {
|
|
13370
13452
|
let headerSlice = this.reader.requestSlice(currentPos, ID3_V2_HEADER_SIZE);
|
|
13371
|
-
if (headerSlice
|
|
13453
|
+
if (isThenable(headerSlice)) headerSlice = await headerSlice;
|
|
13372
13454
|
if (!headerSlice) break;
|
|
13373
13455
|
const id3V2Header = readId3V2Header(headerSlice);
|
|
13374
13456
|
if (!id3V2Header) {
|
|
13375
13457
|
break;
|
|
13376
13458
|
}
|
|
13377
13459
|
let contentSlice = this.reader.requestSlice(headerSlice.filePos, id3V2Header.size);
|
|
13378
|
-
if (contentSlice
|
|
13460
|
+
if (isThenable(contentSlice)) contentSlice = await contentSlice;
|
|
13379
13461
|
if (!contentSlice) break;
|
|
13380
13462
|
parseId3V2Tag(contentSlice, id3V2Header, this.metadataTags);
|
|
13381
13463
|
currentPos = headerSlice.filePos + id3V2Header.size;
|
|
@@ -13475,7 +13557,7 @@ var Mediabunny = (() => {
|
|
|
13475
13557
|
data = PLACEHOLDER_DATA;
|
|
13476
13558
|
} else {
|
|
13477
13559
|
let slice = this.demuxer.reader.requestSlice(rawSample.dataStart, rawSample.dataSize);
|
|
13478
|
-
if (slice
|
|
13560
|
+
if (isThenable(slice)) slice = await slice;
|
|
13479
13561
|
if (!slice) {
|
|
13480
13562
|
return null;
|
|
13481
13563
|
}
|
|
@@ -13706,7 +13788,7 @@ var Mediabunny = (() => {
|
|
|
13706
13788
|
let currentPos = 0;
|
|
13707
13789
|
while (true) {
|
|
13708
13790
|
let headerSlice = this.reader.requestSlice(currentPos, ID3_V2_HEADER_SIZE);
|
|
13709
|
-
if (headerSlice
|
|
13791
|
+
if (isThenable(headerSlice)) headerSlice = await headerSlice;
|
|
13710
13792
|
if (!headerSlice) {
|
|
13711
13793
|
this.lastSampleLoaded = true;
|
|
13712
13794
|
return;
|
|
@@ -13716,7 +13798,7 @@ var Mediabunny = (() => {
|
|
|
13716
13798
|
break;
|
|
13717
13799
|
}
|
|
13718
13800
|
let contentSlice = this.reader.requestSlice(headerSlice.filePos, id3V2Header.size);
|
|
13719
|
-
if (contentSlice
|
|
13801
|
+
if (isThenable(contentSlice)) contentSlice = await contentSlice;
|
|
13720
13802
|
assert(contentSlice);
|
|
13721
13803
|
parseId3V2Tag(contentSlice, id3V2Header, this.metadataTags);
|
|
13722
13804
|
currentPos = headerSlice.filePos + id3V2Header.size;
|
|
@@ -13724,7 +13806,7 @@ var Mediabunny = (() => {
|
|
|
13724
13806
|
currentPos += 4;
|
|
13725
13807
|
while (this.reader.fileSize === null || currentPos < this.reader.fileSize) {
|
|
13726
13808
|
let sizeSlice = this.reader.requestSlice(currentPos, 4);
|
|
13727
|
-
if (sizeSlice
|
|
13809
|
+
if (isThenable(sizeSlice)) sizeSlice = await sizeSlice;
|
|
13728
13810
|
currentPos += 4;
|
|
13729
13811
|
if (sizeSlice === null) {
|
|
13730
13812
|
throw new Error(
|
|
@@ -13742,7 +13824,7 @@ var Mediabunny = (() => {
|
|
|
13742
13824
|
currentPos,
|
|
13743
13825
|
size
|
|
13744
13826
|
);
|
|
13745
|
-
if (streamInfoBlock
|
|
13827
|
+
if (isThenable(streamInfoBlock)) streamInfoBlock = await streamInfoBlock;
|
|
13746
13828
|
assert(streamInfoBlock);
|
|
13747
13829
|
if (streamInfoBlock === null) {
|
|
13748
13830
|
throw new Error(
|
|
@@ -13782,7 +13864,7 @@ var Mediabunny = (() => {
|
|
|
13782
13864
|
currentPos,
|
|
13783
13865
|
size
|
|
13784
13866
|
);
|
|
13785
|
-
if (vorbisCommentBlock
|
|
13867
|
+
if (isThenable(vorbisCommentBlock)) vorbisCommentBlock = await vorbisCommentBlock;
|
|
13786
13868
|
assert(vorbisCommentBlock);
|
|
13787
13869
|
readVorbisComments(
|
|
13788
13870
|
readBytes(vorbisCommentBlock, size),
|
|
@@ -13795,7 +13877,7 @@ var Mediabunny = (() => {
|
|
|
13795
13877
|
currentPos,
|
|
13796
13878
|
size
|
|
13797
13879
|
);
|
|
13798
|
-
if (pictureBlock
|
|
13880
|
+
if (isThenable(pictureBlock)) pictureBlock = await pictureBlock;
|
|
13799
13881
|
assert(pictureBlock);
|
|
13800
13882
|
const pictureType = readU32Be(pictureBlock);
|
|
13801
13883
|
const mediaTypeLength = readU32Be(pictureBlock);
|
|
@@ -14153,7 +14235,7 @@ var Mediabunny = (() => {
|
|
|
14153
14235
|
rawSample.byteOffset,
|
|
14154
14236
|
rawSample.byteSize
|
|
14155
14237
|
);
|
|
14156
|
-
if (slice
|
|
14238
|
+
if (isThenable(slice)) slice = await slice;
|
|
14157
14239
|
if (!slice) {
|
|
14158
14240
|
return null;
|
|
14159
14241
|
}
|
|
@@ -14221,7 +14303,7 @@ var Mediabunny = (() => {
|
|
|
14221
14303
|
return this.metadataPromise ??= (async () => {
|
|
14222
14304
|
const lengthToCheck = TS_PACKET_SIZE + 16 + 1;
|
|
14223
14305
|
let startingSlice = this.reader.requestSlice(0, lengthToCheck);
|
|
14224
|
-
if (startingSlice
|
|
14306
|
+
if (isThenable(startingSlice)) startingSlice = await startingSlice;
|
|
14225
14307
|
assert(startingSlice);
|
|
14226
14308
|
const startingBytes = readBytes(startingSlice, lengthToCheck);
|
|
14227
14309
|
if (startingBytes[0] === 71 && startingBytes[TS_PACKET_SIZE] === 71) {
|
|
@@ -14817,7 +14899,7 @@ var Mediabunny = (() => {
|
|
|
14817
14899
|
}
|
|
14818
14900
|
async readPacketHeader(pos) {
|
|
14819
14901
|
let slice = this.reader.requestSlice(pos, 4);
|
|
14820
|
-
if (slice
|
|
14902
|
+
if (isThenable(slice)) slice = await slice;
|
|
14821
14903
|
if (!slice) {
|
|
14822
14904
|
return null;
|
|
14823
14905
|
}
|
|
@@ -14842,7 +14924,7 @@ var Mediabunny = (() => {
|
|
|
14842
14924
|
}
|
|
14843
14925
|
async readPacket(pos) {
|
|
14844
14926
|
let slice = this.reader.requestSlice(pos, TS_PACKET_SIZE);
|
|
14845
|
-
if (slice
|
|
14927
|
+
if (isThenable(slice)) slice = await slice;
|
|
14846
14928
|
if (!slice) {
|
|
14847
14929
|
return null;
|
|
14848
14930
|
}
|
|
@@ -15612,7 +15694,7 @@ var Mediabunny = (() => {
|
|
|
15612
15694
|
let lastFirstMacroblockInSlice = 0;
|
|
15613
15695
|
while (true) {
|
|
15614
15696
|
let remaining = this.ensureBuffered(CHUNK_SIZE);
|
|
15615
|
-
if (remaining
|
|
15697
|
+
if (isThenable(remaining)) remaining = await remaining;
|
|
15616
15698
|
if (remaining === 0) {
|
|
15617
15699
|
break;
|
|
15618
15700
|
}
|
|
@@ -15714,7 +15796,7 @@ var Mediabunny = (() => {
|
|
|
15714
15796
|
const CHUNK_SIZE = 128;
|
|
15715
15797
|
while (true) {
|
|
15716
15798
|
let remaining = this.ensureBuffered(CHUNK_SIZE);
|
|
15717
|
-
if (remaining
|
|
15799
|
+
if (isThenable(remaining)) remaining = await remaining;
|
|
15718
15800
|
const startPos = this.currentPos;
|
|
15719
15801
|
while (this.currentPos - startPos < remaining) {
|
|
15720
15802
|
const byte = this.readU8();
|
|
@@ -15725,7 +15807,7 @@ var Mediabunny = (() => {
|
|
|
15725
15807
|
this.skip(-1);
|
|
15726
15808
|
const possibleHeaderStartPos = this.currentPos;
|
|
15727
15809
|
let remaining2 = this.ensureBuffered(MAX_ADTS_FRAME_HEADER_SIZE);
|
|
15728
|
-
if (remaining2
|
|
15810
|
+
if (isThenable(remaining2)) remaining2 = await remaining2;
|
|
15729
15811
|
if (remaining2 < MAX_ADTS_FRAME_HEADER_SIZE) {
|
|
15730
15812
|
return;
|
|
15731
15813
|
}
|
|
@@ -15734,7 +15816,7 @@ var Mediabunny = (() => {
|
|
|
15734
15816
|
if (header) {
|
|
15735
15817
|
this.seekTo(possibleHeaderStartPos);
|
|
15736
15818
|
let remaining3 = this.ensureBuffered(header.frameLength);
|
|
15737
|
-
if (remaining3
|
|
15819
|
+
if (isThenable(remaining3)) remaining3 = await remaining3;
|
|
15738
15820
|
return this.supplyPacket(
|
|
15739
15821
|
remaining3,
|
|
15740
15822
|
Math.round(SAMPLES_PER_AAC_FRAME * TIMESCALE / elementaryStream.info.sampleRate)
|
|
@@ -15749,7 +15831,7 @@ var Mediabunny = (() => {
|
|
|
15749
15831
|
this.skip(-1);
|
|
15750
15832
|
const possibleHeaderStartPos = this.currentPos;
|
|
15751
15833
|
let remaining2 = this.ensureBuffered(MP3_FRAME_HEADER_SIZE);
|
|
15752
|
-
if (remaining2
|
|
15834
|
+
if (isThenable(remaining2)) remaining2 = await remaining2;
|
|
15753
15835
|
if (remaining2 < MP3_FRAME_HEADER_SIZE) {
|
|
15754
15836
|
return;
|
|
15755
15837
|
}
|
|
@@ -15759,7 +15841,7 @@ var Mediabunny = (() => {
|
|
|
15759
15841
|
if (result.header) {
|
|
15760
15842
|
this.seekTo(possibleHeaderStartPos);
|
|
15761
15843
|
let remaining3 = this.ensureBuffered(result.header.totalSize);
|
|
15762
|
-
if (remaining3
|
|
15844
|
+
if (isThenable(remaining3)) remaining3 = await remaining3;
|
|
15763
15845
|
const duration = result.header.audioSamplesInFrame * TIMESCALE / elementaryStream.info.sampleRate;
|
|
15764
15846
|
return this.supplyPacket(remaining3, Math.round(duration));
|
|
15765
15847
|
} else {
|
|
@@ -15772,7 +15854,7 @@ var Mediabunny = (() => {
|
|
|
15772
15854
|
this.skip(-1);
|
|
15773
15855
|
const possibleSyncPos = this.currentPos;
|
|
15774
15856
|
let remaining2 = this.ensureBuffered(5);
|
|
15775
|
-
if (remaining2
|
|
15857
|
+
if (isThenable(remaining2)) remaining2 = await remaining2;
|
|
15776
15858
|
if (remaining2 < 5) {
|
|
15777
15859
|
return;
|
|
15778
15860
|
}
|
|
@@ -15791,7 +15873,7 @@ var Mediabunny = (() => {
|
|
|
15791
15873
|
assert(frameSize !== void 0);
|
|
15792
15874
|
this.seekTo(possibleSyncPos);
|
|
15793
15875
|
remaining2 = this.ensureBuffered(frameSize);
|
|
15794
|
-
if (remaining2
|
|
15876
|
+
if (isThenable(remaining2)) remaining2 = await remaining2;
|
|
15795
15877
|
const duration = Math.round(
|
|
15796
15878
|
AC3_SAMPLES_PER_FRAME * TIMESCALE / elementaryStream.info.sampleRate
|
|
15797
15879
|
);
|
|
@@ -15803,7 +15885,7 @@ var Mediabunny = (() => {
|
|
|
15803
15885
|
this.skip(-1);
|
|
15804
15886
|
const possibleSyncPos = this.currentPos;
|
|
15805
15887
|
let remaining2 = this.ensureBuffered(5);
|
|
15806
|
-
if (remaining2
|
|
15888
|
+
if (isThenable(remaining2)) remaining2 = await remaining2;
|
|
15807
15889
|
if (remaining2 < 5) {
|
|
15808
15890
|
return;
|
|
15809
15891
|
}
|
|
@@ -15819,7 +15901,7 @@ var Mediabunny = (() => {
|
|
|
15819
15901
|
const numblks = EAC3_NUMBLKS_TABLE[numblkscod];
|
|
15820
15902
|
this.seekTo(possibleSyncPos);
|
|
15821
15903
|
remaining2 = this.ensureBuffered(frameSize);
|
|
15822
|
-
if (remaining2
|
|
15904
|
+
if (isThenable(remaining2)) remaining2 = await remaining2;
|
|
15823
15905
|
const samplesPerFrame = numblks * 256;
|
|
15824
15906
|
const duration = Math.round(
|
|
15825
15907
|
samplesPerFrame * TIMESCALE / elementaryStream.info.sampleRate
|
|
@@ -15832,7 +15914,7 @@ var Mediabunny = (() => {
|
|
|
15832
15914
|
this.skip(-1);
|
|
15833
15915
|
const possibleSyncPos = this.currentPos;
|
|
15834
15916
|
let remaining2 = this.ensureBuffered(DTS_CORE_FRAME_HEADER_SIZE);
|
|
15835
|
-
if (remaining2
|
|
15917
|
+
if (isThenable(remaining2)) remaining2 = await remaining2;
|
|
15836
15918
|
if (remaining2 < DTS_CORE_FRAME_HEADER_SIZE) {
|
|
15837
15919
|
return;
|
|
15838
15920
|
}
|
|
@@ -15847,7 +15929,7 @@ var Mediabunny = (() => {
|
|
|
15847
15929
|
this.seekTo(possibleSyncPos);
|
|
15848
15930
|
const headerBound = Math.min(leadingExss.frameSize, DTS_EXSS_MAX_HEADER_SIZE);
|
|
15849
15931
|
let remaining3 = this.ensureBuffered(headerBound);
|
|
15850
|
-
if (remaining3
|
|
15932
|
+
if (isThenable(remaining3)) remaining3 = await remaining3;
|
|
15851
15933
|
leadingExss = parseDtsExssHeader(this.readBytes(remaining3)) ?? leadingExss;
|
|
15852
15934
|
}
|
|
15853
15935
|
let frameSize = core ? core.frameSize : leadingExss.frameSize;
|
|
@@ -15857,7 +15939,7 @@ var Mediabunny = (() => {
|
|
|
15857
15939
|
this.seekTo(possibleSyncPos);
|
|
15858
15940
|
const neededBytes = nextSubstreamPos + DTS_EXSS_HEADER_PREFIX_SIZE;
|
|
15859
15941
|
let remaining3 = this.ensureBuffered(neededBytes);
|
|
15860
|
-
if (remaining3
|
|
15942
|
+
if (isThenable(remaining3)) remaining3 = await remaining3;
|
|
15861
15943
|
if (remaining3 < neededBytes) {
|
|
15862
15944
|
break;
|
|
15863
15945
|
}
|
|
@@ -15877,7 +15959,7 @@ var Mediabunny = (() => {
|
|
|
15877
15959
|
}
|
|
15878
15960
|
this.seekTo(possibleSyncPos);
|
|
15879
15961
|
remaining2 = this.ensureBuffered(frameSize);
|
|
15880
|
-
if (remaining2
|
|
15962
|
+
if (isThenable(remaining2)) remaining2 = await remaining2;
|
|
15881
15963
|
const duration = Math.round(
|
|
15882
15964
|
sampleCount * TIMESCALE / elementaryStream.info.sampleRate
|
|
15883
15965
|
);
|
|
@@ -16676,7 +16758,7 @@ var Mediabunny = (() => {
|
|
|
16676
16758
|
ref.source._usedForHls ||= this._usedForHls;
|
|
16677
16759
|
return ref;
|
|
16678
16760
|
};
|
|
16679
|
-
if (result
|
|
16761
|
+
if (isThenable(result)) {
|
|
16680
16762
|
return result.then(handle);
|
|
16681
16763
|
} else {
|
|
16682
16764
|
return handle(result);
|
|
@@ -16705,7 +16787,7 @@ var Mediabunny = (() => {
|
|
|
16705
16787
|
this._rootRequest = null;
|
|
16706
16788
|
return ref;
|
|
16707
16789
|
};
|
|
16708
|
-
if (result
|
|
16790
|
+
if (isThenable(result)) {
|
|
16709
16791
|
this._rootRequest = result.then(handle);
|
|
16710
16792
|
} else {
|
|
16711
16793
|
handle(result);
|
|
@@ -16992,7 +17074,7 @@ var Mediabunny = (() => {
|
|
|
16992
17074
|
result2.offset -= this._offset;
|
|
16993
17075
|
return result2;
|
|
16994
17076
|
};
|
|
16995
|
-
if (result
|
|
17077
|
+
if (isThenable(result)) {
|
|
16996
17078
|
return result.then(processResult);
|
|
16997
17079
|
} else {
|
|
16998
17080
|
return processResult(result);
|
|
@@ -17201,7 +17283,7 @@ var Mediabunny = (() => {
|
|
|
17201
17283
|
this._orchestrator.queuedReads.length = 0;
|
|
17202
17284
|
for (const slice of uniqueSlices) {
|
|
17203
17285
|
const result = backing._read(slice.start, slice.start + slice.bytes.length);
|
|
17204
|
-
if (result
|
|
17286
|
+
if (isThenable(result)) {
|
|
17205
17287
|
result.then((readResult) => {
|
|
17206
17288
|
if (readResult) {
|
|
17207
17289
|
assert(readResult.offset === slice.start);
|
|
@@ -17342,7 +17424,7 @@ var Mediabunny = (() => {
|
|
|
17342
17424
|
return this._orchestrator.read(start, end, minReadPosition, maxReadPosition);
|
|
17343
17425
|
}
|
|
17344
17426
|
const result = this._options.getSize();
|
|
17345
|
-
if (result
|
|
17427
|
+
if (isThenable(result)) {
|
|
17346
17428
|
return result.then((size) => {
|
|
17347
17429
|
if (!Number.isInteger(size) || size < 0) {
|
|
17348
17430
|
throw new TypeError("options.getSize must return or resolve to a non-negative integer.");
|
|
@@ -17364,7 +17446,7 @@ var Mediabunny = (() => {
|
|
|
17364
17446
|
const originalCurrentPos = worker.currentPos;
|
|
17365
17447
|
const originalTargetPos = worker.targetPos;
|
|
17366
17448
|
let data = this._options.read(worker.currentPos, originalTargetPos);
|
|
17367
|
-
if (data
|
|
17449
|
+
if (isThenable(data)) data = await data;
|
|
17368
17450
|
if (worker.aborted) {
|
|
17369
17451
|
break;
|
|
17370
17452
|
}
|
|
@@ -18163,7 +18245,7 @@ var Mediabunny = (() => {
|
|
|
18163
18245
|
result2.offset -= this._offset;
|
|
18164
18246
|
return result2;
|
|
18165
18247
|
};
|
|
18166
|
-
if (result
|
|
18248
|
+
if (isThenable(result)) {
|
|
18167
18249
|
return result.then(processResult);
|
|
18168
18250
|
} else {
|
|
18169
18251
|
return processResult(result);
|
|
@@ -19448,7 +19530,7 @@ var Mediabunny = (() => {
|
|
|
19448
19530
|
/** @internal */
|
|
19449
19531
|
async _getMajorBrand(input) {
|
|
19450
19532
|
let slice = input._reader.requestSlice(0, 12);
|
|
19451
|
-
if (slice
|
|
19533
|
+
if (isThenable(slice)) slice = await slice;
|
|
19452
19534
|
if (!slice) return null;
|
|
19453
19535
|
slice.skip(4);
|
|
19454
19536
|
const fourCc = readAscii(slice, 4);
|
|
@@ -19469,11 +19551,33 @@ var Mediabunny = (() => {
|
|
|
19469
19551
|
if (majorBrand !== null) {
|
|
19470
19552
|
return majorBrand !== "qt ";
|
|
19471
19553
|
}
|
|
19472
|
-
let
|
|
19473
|
-
|
|
19474
|
-
|
|
19475
|
-
|
|
19476
|
-
|
|
19554
|
+
let pos = 0;
|
|
19555
|
+
for (let iter = 0; iter < 10; iter++) {
|
|
19556
|
+
let slice = input._reader.requestSlice(pos, 8);
|
|
19557
|
+
if (isThenable(slice)) slice = await slice;
|
|
19558
|
+
if (!slice) return false;
|
|
19559
|
+
let size = readU32Be(slice);
|
|
19560
|
+
let headerSize = 8;
|
|
19561
|
+
if (size === 1) {
|
|
19562
|
+
let sizeExtensionSlice = input._reader.requestSlice(pos + 8, 8);
|
|
19563
|
+
if (isThenable(sizeExtensionSlice)) sizeExtensionSlice = await sizeExtensionSlice;
|
|
19564
|
+
if (!sizeExtensionSlice) return false;
|
|
19565
|
+
size = readU64Be(sizeExtensionSlice);
|
|
19566
|
+
headerSize = 16;
|
|
19567
|
+
}
|
|
19568
|
+
if (size < headerSize) {
|
|
19569
|
+
return false;
|
|
19570
|
+
}
|
|
19571
|
+
const fourCc = readAscii(slice, 4);
|
|
19572
|
+
if (fourCc === "moof" || fourCc === "sidx") {
|
|
19573
|
+
return true;
|
|
19574
|
+
} else if (fourCc === "emsg" || fourCc === "prft" || fourCc === "free") {
|
|
19575
|
+
pos += size;
|
|
19576
|
+
} else {
|
|
19577
|
+
return false;
|
|
19578
|
+
}
|
|
19579
|
+
}
|
|
19580
|
+
return false;
|
|
19477
19581
|
}
|
|
19478
19582
|
get name() {
|
|
19479
19583
|
return "MP4";
|
|
@@ -19499,7 +19603,7 @@ var Mediabunny = (() => {
|
|
|
19499
19603
|
/** @internal */
|
|
19500
19604
|
async isSupportedEBMLOfDocType(input, desiredDocType) {
|
|
19501
19605
|
let headerSlice = input._reader.requestSlice(0, MAX_HEADER_SIZE);
|
|
19502
|
-
if (headerSlice
|
|
19606
|
+
if (isThenable(headerSlice)) headerSlice = await headerSlice;
|
|
19503
19607
|
if (!headerSlice) return false;
|
|
19504
19608
|
const varIntSize = readVarIntSize(headerSlice);
|
|
19505
19609
|
if (varIntSize === null) {
|
|
@@ -19517,7 +19621,7 @@ var Mediabunny = (() => {
|
|
|
19517
19621
|
return false;
|
|
19518
19622
|
}
|
|
19519
19623
|
let dataSlice = input._reader.requestSlice(headerSlice.filePos, dataSize);
|
|
19520
|
-
if (dataSlice
|
|
19624
|
+
if (isThenable(dataSlice)) dataSlice = await dataSlice;
|
|
19521
19625
|
if (!dataSlice) return false;
|
|
19522
19626
|
const startPos = headerSlice.filePos;
|
|
19523
19627
|
while (dataSlice.filePos <= startPos + dataSize - MIN_HEADER_SIZE) {
|
|
@@ -19601,7 +19705,7 @@ var Mediabunny = (() => {
|
|
|
19601
19705
|
let currentPos = 0;
|
|
19602
19706
|
while (true) {
|
|
19603
19707
|
let slice2 = input._reader.requestSlice(currentPos, ID3_V2_HEADER_SIZE);
|
|
19604
|
-
if (slice2
|
|
19708
|
+
if (isThenable(slice2)) slice2 = await slice2;
|
|
19605
19709
|
if (!slice2) break;
|
|
19606
19710
|
const id3V2Header = readId3V2Header(slice2);
|
|
19607
19711
|
if (!id3V2Header) {
|
|
@@ -19616,7 +19720,7 @@ var Mediabunny = (() => {
|
|
|
19616
19720
|
const firstHeader = firstResult.header;
|
|
19617
19721
|
const xingOffset = getXingOffset(firstHeader.mpegVersionId, firstHeader.channel);
|
|
19618
19722
|
let slice = input._reader.requestSlice(firstResult.startPos + xingOffset, 4);
|
|
19619
|
-
if (slice
|
|
19723
|
+
if (isThenable(slice)) slice = await slice;
|
|
19620
19724
|
if (!slice) return false;
|
|
19621
19725
|
const word = readU32Be(slice);
|
|
19622
19726
|
const isXing = word === XING || word === INFO;
|
|
@@ -19653,7 +19757,7 @@ var Mediabunny = (() => {
|
|
|
19653
19757
|
/** @internal */
|
|
19654
19758
|
async _canReadInput(input) {
|
|
19655
19759
|
let slice = input._reader.requestSlice(0, 12);
|
|
19656
|
-
if (slice
|
|
19760
|
+
if (isThenable(slice)) slice = await slice;
|
|
19657
19761
|
if (!slice) return false;
|
|
19658
19762
|
const riffType = readAscii(slice, 4);
|
|
19659
19763
|
if (riffType !== "RIFF" && riffType !== "RIFX" && riffType !== "RF64") {
|
|
@@ -19678,7 +19782,7 @@ var Mediabunny = (() => {
|
|
|
19678
19782
|
/** @internal */
|
|
19679
19783
|
async _canReadInput(input) {
|
|
19680
19784
|
let slice = input._reader.requestSlice(0, 4);
|
|
19681
|
-
if (slice
|
|
19785
|
+
if (isThenable(slice)) slice = await slice;
|
|
19682
19786
|
if (!slice) return false;
|
|
19683
19787
|
return readAscii(slice, 4) === "OggS";
|
|
19684
19788
|
}
|
|
@@ -19699,7 +19803,7 @@ var Mediabunny = (() => {
|
|
|
19699
19803
|
let currentPos = 0;
|
|
19700
19804
|
while (true) {
|
|
19701
19805
|
let slice2 = input._reader.requestSlice(currentPos, ID3_V2_HEADER_SIZE);
|
|
19702
|
-
if (slice2
|
|
19806
|
+
if (isThenable(slice2)) slice2 = await slice2;
|
|
19703
19807
|
if (!slice2) break;
|
|
19704
19808
|
const id3V2Header = readId3V2Header(slice2);
|
|
19705
19809
|
if (!id3V2Header) {
|
|
@@ -19708,7 +19812,7 @@ var Mediabunny = (() => {
|
|
|
19708
19812
|
currentPos = slice2.filePos + id3V2Header.size;
|
|
19709
19813
|
}
|
|
19710
19814
|
let slice = input._reader.requestSlice(currentPos, 4);
|
|
19711
|
-
if (slice
|
|
19815
|
+
if (isThenable(slice)) slice = await slice;
|
|
19712
19816
|
if (!slice) return false;
|
|
19713
19817
|
return readAscii(slice, 4) === "fLaC";
|
|
19714
19818
|
}
|
|
@@ -19729,7 +19833,7 @@ var Mediabunny = (() => {
|
|
|
19729
19833
|
let currentPos = 0;
|
|
19730
19834
|
while (true) {
|
|
19731
19835
|
let slice2 = input._reader.requestSlice(currentPos, ID3_V2_HEADER_SIZE);
|
|
19732
|
-
if (slice2
|
|
19836
|
+
if (isThenable(slice2)) slice2 = await slice2;
|
|
19733
19837
|
if (!slice2) break;
|
|
19734
19838
|
const id3V2Header = readId3V2Header(slice2);
|
|
19735
19839
|
if (!id3V2Header) {
|
|
@@ -19742,7 +19846,7 @@ var Mediabunny = (() => {
|
|
|
19742
19846
|
MIN_ADTS_FRAME_HEADER_SIZE,
|
|
19743
19847
|
MAX_ADTS_FRAME_HEADER_SIZE
|
|
19744
19848
|
);
|
|
19745
|
-
if (slice
|
|
19849
|
+
if (isThenable(slice)) slice = await slice;
|
|
19746
19850
|
if (!slice) return false;
|
|
19747
19851
|
const firstHeader = readAdtsFrameHeader(slice);
|
|
19748
19852
|
if (!firstHeader) {
|
|
@@ -19754,7 +19858,7 @@ var Mediabunny = (() => {
|
|
|
19754
19858
|
MIN_ADTS_FRAME_HEADER_SIZE,
|
|
19755
19859
|
MAX_ADTS_FRAME_HEADER_SIZE
|
|
19756
19860
|
);
|
|
19757
|
-
if (slice
|
|
19861
|
+
if (isThenable(slice)) slice = await slice;
|
|
19758
19862
|
if (!slice) return false;
|
|
19759
19863
|
const secondHeader = readAdtsFrameHeader(slice);
|
|
19760
19864
|
if (!secondHeader) {
|
|
@@ -19778,7 +19882,7 @@ var Mediabunny = (() => {
|
|
|
19778
19882
|
async _canReadInput(input) {
|
|
19779
19883
|
const lengthToCheck = TS_PACKET_SIZE + 16 + 1;
|
|
19780
19884
|
let slice = input._reader.requestSlice(0, lengthToCheck);
|
|
19781
|
-
if (slice
|
|
19885
|
+
if (isThenable(slice)) slice = await slice;
|
|
19782
19886
|
if (!slice) return false;
|
|
19783
19887
|
const bytes2 = readBytes(slice, lengthToCheck);
|
|
19784
19888
|
if (bytes2[0] === 71 && bytes2[TS_PACKET_SIZE] === 71) {
|
|
@@ -19805,7 +19909,7 @@ var Mediabunny = (() => {
|
|
|
19805
19909
|
/** @internal */
|
|
19806
19910
|
async _canReadInput(input) {
|
|
19807
19911
|
let slice = input._reader.requestSlice(0, 7);
|
|
19808
|
-
if (slice
|
|
19912
|
+
if (isThenable(slice)) slice = await slice;
|
|
19809
19913
|
if (!slice) return false;
|
|
19810
19914
|
const isM3u8 = readAscii(slice, 7) === "#EXTM3U";
|
|
19811
19915
|
if (!isM3u8) {
|
|
@@ -20535,7 +20639,7 @@ var Mediabunny = (() => {
|
|
|
20535
20639
|
let dataPlanes;
|
|
20536
20640
|
if (this._data instanceof VideoSampleResource) {
|
|
20537
20641
|
let result = this._data.getDataPlanes();
|
|
20538
|
-
if (result
|
|
20642
|
+
if (isThenable(result)) result = await result;
|
|
20539
20643
|
if (!Array.isArray(result) || result.some((x) => !(x.data instanceof Uint8Array) || !Number.isInteger(x.stride) || x.stride < 0)) {
|
|
20540
20644
|
throw new TypeError(
|
|
20541
20645
|
'getDataPlanes() must return an array of objects with a Uint8Array "data" property and a non-negative integer "stride" property.'
|
|
@@ -20628,7 +20732,7 @@ var Mediabunny = (() => {
|
|
|
20628
20732
|
);
|
|
20629
20733
|
}
|
|
20630
20734
|
const planes = this._data.getDataPlanes();
|
|
20631
|
-
if (planes
|
|
20735
|
+
if (isThenable(planes)) {
|
|
20632
20736
|
throw new Error(
|
|
20633
20737
|
"Cannot convert a VideoSampleResource-backed VideoSample to VideoFrame if getDataPlanes() returns a promise."
|
|
20634
20738
|
);
|
|
@@ -21008,7 +21112,7 @@ var Mediabunny = (() => {
|
|
|
21008
21112
|
};
|
|
21009
21113
|
for (const transformer of registeredVideoSampleTransformers) {
|
|
21010
21114
|
let result = transformer(this, description);
|
|
21011
|
-
if (result
|
|
21115
|
+
if (isThenable(result)) result = await result;
|
|
21012
21116
|
if (result !== null) {
|
|
21013
21117
|
return result;
|
|
21014
21118
|
}
|
|
@@ -25117,7 +25221,7 @@ var Mediabunny = (() => {
|
|
|
25117
25221
|
}
|
|
25118
25222
|
};
|
|
25119
25223
|
var requireSync = (value, getterName, asyncName) => {
|
|
25120
|
-
if (value
|
|
25224
|
+
if (isThenable(value)) {
|
|
25121
25225
|
throw new Error(
|
|
25122
25226
|
`'${getterName}' is deprecated and not available synchronously for this track. Use the preferred '${asyncName}()' instead.`
|
|
25123
25227
|
);
|
|
@@ -25136,7 +25240,7 @@ var Mediabunny = (() => {
|
|
|
25136
25240
|
return result2;
|
|
25137
25241
|
};
|
|
25138
25242
|
const result = predicate(track);
|
|
25139
|
-
if (result
|
|
25243
|
+
if (isThenable(result)) {
|
|
25140
25244
|
return result.then(handle);
|
|
25141
25245
|
}
|
|
25142
25246
|
return handle(result);
|
|
@@ -25581,7 +25685,7 @@ var Mediabunny = (() => {
|
|
|
25581
25685
|
return bool;
|
|
25582
25686
|
};
|
|
25583
25687
|
const result = query.filter(track);
|
|
25584
|
-
if (result
|
|
25688
|
+
if (isThenable(result)) {
|
|
25585
25689
|
return result.then(handle);
|
|
25586
25690
|
} else {
|
|
25587
25691
|
return handle(result);
|
|
@@ -25597,7 +25701,7 @@ var Mediabunny = (() => {
|
|
|
25597
25701
|
return value;
|
|
25598
25702
|
};
|
|
25599
25703
|
const result = query.sortBy(track);
|
|
25600
|
-
if (result
|
|
25704
|
+
if (isThenable(result)) {
|
|
25601
25705
|
return result.then(handle);
|
|
25602
25706
|
} else {
|
|
25603
25707
|
return handle(result);
|
|
@@ -25615,7 +25719,7 @@ var Mediabunny = (() => {
|
|
|
25615
25719
|
}
|
|
25616
25720
|
return queryB?.filter?.(track) ?? true;
|
|
25617
25721
|
};
|
|
25618
|
-
if (resultA
|
|
25722
|
+
if (isThenable(resultA)) {
|
|
25619
25723
|
return resultA.then(handleResultA);
|
|
25620
25724
|
} else {
|
|
25621
25725
|
return handleResultA(resultA);
|
|
@@ -25630,7 +25734,7 @@ var Mediabunny = (() => {
|
|
|
25630
25734
|
...Array.isArray(resultB2) ? resultB2 : [resultB2]
|
|
25631
25735
|
];
|
|
25632
25736
|
};
|
|
25633
|
-
if (resultA
|
|
25737
|
+
if (isThenable(resultA) || isThenable(resultB)) {
|
|
25634
25738
|
return Promise.all([resultA, resultB]).then(([resultA2, resultB2]) => {
|
|
25635
25739
|
return join(resultA2, resultB2);
|
|
25636
25740
|
});
|
|
@@ -25644,7 +25748,7 @@ var Mediabunny = (() => {
|
|
|
25644
25748
|
let matched = tracks;
|
|
25645
25749
|
if (query?.filter) {
|
|
25646
25750
|
const filterMatches = tracks.map((t) => query.filter(t));
|
|
25647
|
-
const hasAsyncFilter = filterMatches.some((x) => x
|
|
25751
|
+
const hasAsyncFilter = filterMatches.some((x) => isThenable(x));
|
|
25648
25752
|
if (hasAsyncFilter) {
|
|
25649
25753
|
const resolvedFilterMatches = await Promise.all(filterMatches);
|
|
25650
25754
|
matched = tracks.filter((_, i) => resolvedFilterMatches[i]);
|
|
@@ -25656,7 +25760,7 @@ var Mediabunny = (() => {
|
|
|
25656
25760
|
return matched;
|
|
25657
25761
|
}
|
|
25658
25762
|
const sortValues = matched.map((t) => query.sortBy(t));
|
|
25659
|
-
const hasAsyncSort = sortValues.some((x) => x
|
|
25763
|
+
const hasAsyncSort = sortValues.some((x) => isThenable(x));
|
|
25660
25764
|
const resolvedSortValues = hasAsyncSort ? await Promise.all(sortValues) : sortValues;
|
|
25661
25765
|
return matched.map((track, i) => ({ track, sortValue: resolvedSortValues[i] })).sort((a, b) => {
|
|
25662
25766
|
const aValues = Array.isArray(a.sortValue) ? a.sortValue : [a.sortValue];
|
|
@@ -26256,7 +26360,7 @@ var Mediabunny = (() => {
|
|
|
26256
26360
|
}
|
|
26257
26361
|
const end = start + length;
|
|
26258
26362
|
const result = this.source._read(start, end, DEFAULT_MIN_READ_POSITION, DEFAULT_MAX_READ_POSITION);
|
|
26259
|
-
if (result
|
|
26363
|
+
if (isThenable(result)) {
|
|
26260
26364
|
return result.then((x) => {
|
|
26261
26365
|
if (!x) {
|
|
26262
26366
|
return null;
|
|
@@ -26294,7 +26398,7 @@ var Mediabunny = (() => {
|
|
|
26294
26398
|
clamp(this.fileSizeNonStrict - start, minLength, maxLength)
|
|
26295
26399
|
);
|
|
26296
26400
|
};
|
|
26297
|
-
if (promisedAttempt
|
|
26401
|
+
if (isThenable(promisedAttempt)) {
|
|
26298
26402
|
return promisedAttempt.then(handleAttempt);
|
|
26299
26403
|
} else {
|
|
26300
26404
|
return handleAttempt(promisedAttempt);
|
|
@@ -26314,7 +26418,7 @@ var Mediabunny = (() => {
|
|
|
26314
26418
|
return this.requestSlice(0, this.fileSizeNonStrict);
|
|
26315
26419
|
}
|
|
26316
26420
|
let slice = this.requestSliceRange(currentSize, 0, CHUNK_SIZE);
|
|
26317
|
-
if (slice
|
|
26421
|
+
if (isThenable(slice)) slice = await slice;
|
|
26318
26422
|
if (!slice || slice.length === 0) {
|
|
26319
26423
|
break;
|
|
26320
26424
|
}
|
|
@@ -30571,8 +30675,8 @@ var Mediabunny = (() => {
|
|
|
30571
30675
|
}
|
|
30572
30676
|
decoderConfig.description = buildAacAudioSpecificConfig({
|
|
30573
30677
|
objectType: adtsFrame.objectType,
|
|
30574
|
-
sampleRate,
|
|
30575
|
-
numberOfChannels
|
|
30678
|
+
outputSampleRate: sampleRate,
|
|
30679
|
+
outputNumberOfChannels: numberOfChannels
|
|
30576
30680
|
});
|
|
30577
30681
|
requiresAdtsStripping = true;
|
|
30578
30682
|
}
|
|
@@ -32008,8 +32112,8 @@ var Mediabunny = (() => {
|
|
|
32008
32112
|
}
|
|
32009
32113
|
decoderConfig.description = buildAacAudioSpecificConfig({
|
|
32010
32114
|
objectType: adtsFrame.objectType,
|
|
32011
|
-
sampleRate,
|
|
32012
|
-
numberOfChannels
|
|
32115
|
+
outputSampleRate: sampleRate,
|
|
32116
|
+
outputNumberOfChannels: numberOfChannels
|
|
32013
32117
|
});
|
|
32014
32118
|
requiresAdtsStripping = true;
|
|
32015
32119
|
}
|
|
@@ -34343,7 +34447,7 @@ ${cue.notes ?? ""}`;
|
|
|
34343
34447
|
let samplesToEncode;
|
|
34344
34448
|
if (config.transform?.process) {
|
|
34345
34449
|
let processed = config.transform.process(videoSample);
|
|
34346
|
-
if (processed
|
|
34450
|
+
if (isThenable(processed)) {
|
|
34347
34451
|
processed = await processed;
|
|
34348
34452
|
}
|
|
34349
34453
|
if (processed === null) {
|
|
@@ -35410,7 +35514,7 @@ ${cue.notes ?? ""}`;
|
|
|
35410
35514
|
if (config.transform?.process) {
|
|
35411
35515
|
try {
|
|
35412
35516
|
let processed = config.transform.process(audioSample);
|
|
35413
|
-
if (processed
|
|
35517
|
+
if (isThenable(processed)) {
|
|
35414
35518
|
processed = await processed;
|
|
35415
35519
|
}
|
|
35416
35520
|
if (processed === null) {
|
|
@@ -35643,8 +35747,8 @@ ${cue.notes ?? ""}`;
|
|
|
35643
35747
|
const objectType = Number(last(encoderConfig.codec.split(".")));
|
|
35644
35748
|
meta.decoderConfig.description = buildAacAudioSpecificConfig({
|
|
35645
35749
|
objectType,
|
|
35646
|
-
|
|
35647
|
-
|
|
35750
|
+
outputNumberOfChannels: meta.decoderConfig.numberOfChannels,
|
|
35751
|
+
outputSampleRate: meta.decoderConfig.sampleRate
|
|
35648
35752
|
});
|
|
35649
35753
|
}
|
|
35650
35754
|
}
|
|
@@ -38224,7 +38328,7 @@ ${cue.notes ?? ""}`;
|
|
|
38224
38328
|
throw new TypeError(errorMessage);
|
|
38225
38329
|
}
|
|
38226
38330
|
const rootTargetResult = this._getRootTarget();
|
|
38227
|
-
if (rootTargetResult
|
|
38331
|
+
if (isThenable(rootTargetResult)) {
|
|
38228
38332
|
throw new TypeError(errorMessage);
|
|
38229
38333
|
}
|
|
38230
38334
|
return rootTargetResult;
|
|
@@ -38239,7 +38343,7 @@ ${cue.notes ?? ""}`;
|
|
|
38239
38343
|
}
|
|
38240
38344
|
return result2;
|
|
38241
38345
|
};
|
|
38242
|
-
if (result
|
|
38346
|
+
if (isThenable(result)) {
|
|
38243
38347
|
return result.then(handleResult);
|
|
38244
38348
|
} else {
|
|
38245
38349
|
return handleResult(result);
|
|
@@ -38309,7 +38413,7 @@ ${cue.notes ?? ""}`;
|
|
|
38309
38413
|
this._rootTarget = target;
|
|
38310
38414
|
return target;
|
|
38311
38415
|
};
|
|
38312
|
-
if (result
|
|
38416
|
+
if (isThenable(result)) {
|
|
38313
38417
|
return this._rootTargetPromise = result.then(handleResult);
|
|
38314
38418
|
} else {
|
|
38315
38419
|
return handleResult(result);
|