mediabunny 1.55.1 → 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 +318 -190
- package/dist/bundles/mediabunny.min.cjs +11 -11
- package/dist/bundles/mediabunny.min.mjs +11 -11
- package/dist/bundles/mediabunny.mjs +318 -190
- package/dist/bundles/mediabunny.node.cjs +318 -190
- 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 +62 -25
- 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-sink.d.ts.map +1 -1
- package/dist/modules/src/media-sink.js +9 -3
- package/dist/modules/src/media-source.d.ts.map +1 -1
- package/dist/modules/src/media-source.js +12 -11
- package/dist/modules/src/misc.d.ts +5 -0
- package/dist/modules/src/misc.d.ts.map +1 -1
- package/dist/modules/src/misc.js +19 -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/packet.js +3 -3
- 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 +70 -27
- 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-sink.ts +11 -2
- package/src/media-source.ts +13 -10
- package/src/misc.ts +24 -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/packet.ts +3 -3
- 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
|
@@ -740,6 +740,20 @@ var Mediabunny = (() => {
|
|
|
740
740
|
}
|
|
741
741
|
return chromiumVersionCache = Number(match[1]);
|
|
742
742
|
};
|
|
743
|
+
var missingWebCodecsClassMessage = (className) => {
|
|
744
|
+
if (typeof globalThis.isSecureContext !== "undefined" && !globalThis.isSecureContext) {
|
|
745
|
+
return `${className} is not available in this environment; this may be because this page is running in an insecure context. Try serving your page over HTTPS or use localhost.`;
|
|
746
|
+
}
|
|
747
|
+
return `${className} is not available in this environment.`;
|
|
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
|
+
};
|
|
743
757
|
var coalesceIndex = (a, b) => {
|
|
744
758
|
return a !== -1 ? a : b;
|
|
745
759
|
};
|
|
@@ -1416,71 +1430,127 @@ var Mediabunny = (() => {
|
|
|
1416
1430
|
throw new TypeError("AAC description must be at least 2 bytes long.");
|
|
1417
1431
|
}
|
|
1418
1432
|
const bitstream = new Bitstream(bytes2);
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
objectType = 32 + bitstream.readBits(6);
|
|
1422
|
-
}
|
|
1423
|
-
const frequencyIndex = bitstream.readBits(4);
|
|
1424
|
-
let sampleRate = null;
|
|
1425
|
-
if (frequencyIndex === 15) {
|
|
1426
|
-
sampleRate = bitstream.readBits(24);
|
|
1427
|
-
} else {
|
|
1428
|
-
if (frequencyIndex < aacFrequencyTable.length) {
|
|
1429
|
-
sampleRate = aacFrequencyTable[frequencyIndex];
|
|
1430
|
-
}
|
|
1431
|
-
}
|
|
1433
|
+
const objectType = readAacObjectType(bitstream);
|
|
1434
|
+
const { frequencyIndex, sampleRate } = readAacSamplingFrequency(bitstream);
|
|
1432
1435
|
const channelConfiguration = bitstream.readBits(4);
|
|
1433
1436
|
let numberOfChannels = null;
|
|
1434
1437
|
if (channelConfiguration >= 1 && channelConfiguration <= 7) {
|
|
1435
1438
|
numberOfChannels = aacChannelMap[channelConfiguration];
|
|
1436
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
|
+
}
|
|
1437
1469
|
return {
|
|
1438
1470
|
objectType,
|
|
1471
|
+
coreObjectType,
|
|
1439
1472
|
frequencyIndex,
|
|
1440
|
-
sampleRate,
|
|
1441
1473
|
channelConfiguration,
|
|
1442
|
-
|
|
1474
|
+
outputSampleRate,
|
|
1475
|
+
outputNumberOfChannels: psPresent && numberOfChannels === 1 ? 2 : numberOfChannels
|
|
1443
1476
|
};
|
|
1444
1477
|
};
|
|
1445
|
-
var
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
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
|
+
};
|
|
1451
1489
|
}
|
|
1452
|
-
|
|
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);
|
|
1453
1501
|
if (channelConfiguration === -1) {
|
|
1454
|
-
throw new TypeError(`Unsupported number of channels: ${config.
|
|
1502
|
+
throw new TypeError(`Unsupported number of channels: ${config.outputNumberOfChannels}`);
|
|
1455
1503
|
}
|
|
1456
|
-
let bitCount = 5 + 4 + 4;
|
|
1504
|
+
let bitCount = 5 + 4 + 4 + 3;
|
|
1457
1505
|
if (config.objectType >= 32) {
|
|
1458
1506
|
bitCount += 6;
|
|
1459
1507
|
}
|
|
1460
|
-
if (
|
|
1508
|
+
if (findAacFrequencyIndex(coreSampleRate) === 15) {
|
|
1461
1509
|
bitCount += 24;
|
|
1462
1510
|
}
|
|
1511
|
+
if (usesSbr) {
|
|
1512
|
+
bitCount += 4 + 5;
|
|
1513
|
+
if (findAacFrequencyIndex(config.outputSampleRate) === 15) {
|
|
1514
|
+
bitCount += 24;
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1463
1517
|
const byteCount = Math.ceil(bitCount / 8);
|
|
1464
1518
|
const bytes2 = new Uint8Array(byteCount);
|
|
1465
1519
|
const bitstream = new Bitstream(bytes2);
|
|
1466
|
-
|
|
1467
|
-
|
|
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);
|
|
1468
1533
|
} else {
|
|
1469
1534
|
bitstream.writeBits(5, 31);
|
|
1470
|
-
bitstream.writeBits(6,
|
|
1535
|
+
bitstream.writeBits(6, objectType - 32);
|
|
1471
1536
|
}
|
|
1537
|
+
};
|
|
1538
|
+
var writeAacSamplingFrequency = (bitstream, sampleRate) => {
|
|
1539
|
+
const frequencyIndex = findAacFrequencyIndex(sampleRate);
|
|
1472
1540
|
bitstream.writeBits(4, frequencyIndex);
|
|
1473
1541
|
if (frequencyIndex === 15) {
|
|
1474
|
-
bitstream.writeBits(24,
|
|
1542
|
+
bitstream.writeBits(24, sampleRate);
|
|
1475
1543
|
}
|
|
1476
|
-
|
|
1477
|
-
|
|
1544
|
+
};
|
|
1545
|
+
var findAacFrequencyIndex = (sampleRate) => {
|
|
1546
|
+
const index = aacFrequencyTable.indexOf(sampleRate);
|
|
1547
|
+
return index === -1 ? 15 : index;
|
|
1478
1548
|
};
|
|
1479
1549
|
var buildAdtsHeaderTemplate = (config) => {
|
|
1480
1550
|
const header = new Uint8Array(7);
|
|
1481
1551
|
const bitstream = new Bitstream(header);
|
|
1482
|
-
const {
|
|
1483
|
-
const profile =
|
|
1552
|
+
const { coreObjectType, frequencyIndex, channelConfiguration } = config;
|
|
1553
|
+
const profile = coreObjectType - 1;
|
|
1484
1554
|
bitstream.writeBits(12, 4095);
|
|
1485
1555
|
bitstream.writeBits(1, 0);
|
|
1486
1556
|
bitstream.writeBits(2, 0);
|
|
@@ -5533,7 +5603,7 @@ var Mediabunny = (() => {
|
|
|
5533
5603
|
throw new TypeError("Metadata-only packets cannot be converted to a video chunk.");
|
|
5534
5604
|
}
|
|
5535
5605
|
if (typeof EncodedVideoChunk === "undefined") {
|
|
5536
|
-
throw new Error("
|
|
5606
|
+
throw new Error("EncodedVideoChunk is not available in this environment.");
|
|
5537
5607
|
}
|
|
5538
5608
|
return new EncodedVideoChunk({
|
|
5539
5609
|
data: this.data,
|
|
@@ -5555,7 +5625,7 @@ var Mediabunny = (() => {
|
|
|
5555
5625
|
throw new TypeError("Metadata-only packets cannot be converted to a video chunk.");
|
|
5556
5626
|
}
|
|
5557
5627
|
if (typeof EncodedVideoChunk === "undefined") {
|
|
5558
|
-
throw new Error("
|
|
5628
|
+
throw new Error("EncodedVideoChunk is not available in this environment.");
|
|
5559
5629
|
}
|
|
5560
5630
|
return new EncodedVideoChunk({
|
|
5561
5631
|
data: this.sideData.alpha,
|
|
@@ -5572,7 +5642,7 @@ var Mediabunny = (() => {
|
|
|
5572
5642
|
throw new TypeError("Metadata-only packets cannot be converted to an audio chunk.");
|
|
5573
5643
|
}
|
|
5574
5644
|
if (typeof EncodedAudioChunk === "undefined") {
|
|
5575
|
-
throw new Error("
|
|
5645
|
+
throw new Error("EncodedAudioChunk is not available in this environment.");
|
|
5576
5646
|
}
|
|
5577
5647
|
return new EncodedAudioChunk({
|
|
5578
5648
|
data: this.data,
|
|
@@ -5893,7 +5963,7 @@ var Mediabunny = (() => {
|
|
|
5893
5963
|
}
|
|
5894
5964
|
const requestedLength = CHUNK_SIZE + BLOCK_SIZE;
|
|
5895
5965
|
let nextSlice = reader.requestSliceRange(pos, 0, requestedLength);
|
|
5896
|
-
if (nextSlice
|
|
5966
|
+
if (isThenable(nextSlice)) nextSlice = await nextSlice;
|
|
5897
5967
|
if (!nextSlice || nextSlice.length === 0) {
|
|
5898
5968
|
throw new Error("Invalid ciphertext.");
|
|
5899
5969
|
}
|
|
@@ -5982,7 +6052,7 @@ var Mediabunny = (() => {
|
|
|
5982
6052
|
let foundMovieBoxes = false;
|
|
5983
6053
|
while (true) {
|
|
5984
6054
|
let slice = this.reader.requestSliceRange(currentPos, MIN_BOX_HEADER_SIZE, MAX_BOX_HEADER_SIZE);
|
|
5985
|
-
if (slice
|
|
6055
|
+
if (isThenable(slice)) slice = await slice;
|
|
5986
6056
|
if (!slice) break;
|
|
5987
6057
|
const startPos = currentPos;
|
|
5988
6058
|
const boxInfo = readBoxHeader(slice);
|
|
@@ -5994,7 +6064,7 @@ var Mediabunny = (() => {
|
|
|
5994
6064
|
this.isQuickTime = majorBrand === "qt ";
|
|
5995
6065
|
} else if (boxInfo.name === "moov") {
|
|
5996
6066
|
let moovSlice = this.reader.requestSlice(slice.filePos, boxInfo.contentSize);
|
|
5997
|
-
if (moovSlice
|
|
6067
|
+
if (isThenable(moovSlice)) moovSlice = await moovSlice;
|
|
5998
6068
|
if (!moovSlice) break;
|
|
5999
6069
|
this.moovSlice = moovSlice;
|
|
6000
6070
|
this.readContiguousBoxes(this.moovSlice);
|
|
@@ -6024,7 +6094,7 @@ var Mediabunny = (() => {
|
|
|
6024
6094
|
if (lookForMfraBox) {
|
|
6025
6095
|
assert(this.reader.fileSize !== null);
|
|
6026
6096
|
let lastWordSlice = this.reader.requestSlice(this.reader.fileSize - 4, 4);
|
|
6027
|
-
if (lastWordSlice
|
|
6097
|
+
if (isThenable(lastWordSlice)) lastWordSlice = await lastWordSlice;
|
|
6028
6098
|
assert(lastWordSlice);
|
|
6029
6099
|
const lastWord = readU32Be(lastWordSlice);
|
|
6030
6100
|
const potentialMfraPos = this.reader.fileSize - lastWord;
|
|
@@ -6034,12 +6104,12 @@ var Mediabunny = (() => {
|
|
|
6034
6104
|
MIN_BOX_HEADER_SIZE,
|
|
6035
6105
|
MAX_BOX_HEADER_SIZE
|
|
6036
6106
|
);
|
|
6037
|
-
if (mfraHeaderSlice
|
|
6107
|
+
if (isThenable(mfraHeaderSlice)) mfraHeaderSlice = await mfraHeaderSlice;
|
|
6038
6108
|
if (mfraHeaderSlice) {
|
|
6039
6109
|
const boxInfo = readBoxHeader(mfraHeaderSlice);
|
|
6040
6110
|
if (boxInfo && boxInfo.name === "mfra") {
|
|
6041
6111
|
let mfraSlice = this.reader.requestSlice(mfraHeaderSlice.filePos, boxInfo.contentSize);
|
|
6042
|
-
if (mfraSlice
|
|
6112
|
+
if (isThenable(mfraSlice)) mfraSlice = await mfraSlice;
|
|
6043
6113
|
if (mfraSlice) {
|
|
6044
6114
|
this.readContiguousBoxes(mfraSlice);
|
|
6045
6115
|
}
|
|
@@ -6206,12 +6276,12 @@ var Mediabunny = (() => {
|
|
|
6206
6276
|
return this.lastReadFragment;
|
|
6207
6277
|
}
|
|
6208
6278
|
let headerSlice = this.reader.requestSliceRange(startPos, MIN_BOX_HEADER_SIZE, MAX_BOX_HEADER_SIZE);
|
|
6209
|
-
if (headerSlice
|
|
6279
|
+
if (isThenable(headerSlice)) headerSlice = await headerSlice;
|
|
6210
6280
|
assert(headerSlice);
|
|
6211
6281
|
const moofBoxInfo = readBoxHeader(headerSlice);
|
|
6212
6282
|
assert(moofBoxInfo?.name === "moof");
|
|
6213
6283
|
let entireSlice = this.reader.requestSlice(startPos, moofBoxInfo.totalSize);
|
|
6214
|
-
if (entireSlice
|
|
6284
|
+
if (isThenable(entireSlice)) entireSlice = await entireSlice;
|
|
6215
6285
|
assert(entireSlice);
|
|
6216
6286
|
this.traverseBox(entireSlice);
|
|
6217
6287
|
const fragment = this.lastReadFragment;
|
|
@@ -6826,6 +6896,9 @@ var Mediabunny = (() => {
|
|
|
6826
6896
|
break;
|
|
6827
6897
|
}
|
|
6828
6898
|
assert(track.info);
|
|
6899
|
+
if (boxInfo.contentSize === 0) {
|
|
6900
|
+
break;
|
|
6901
|
+
}
|
|
6829
6902
|
track.info.codecDescription = readBytes(slice, boxInfo.contentSize);
|
|
6830
6903
|
}
|
|
6831
6904
|
;
|
|
@@ -6837,6 +6910,9 @@ var Mediabunny = (() => {
|
|
|
6837
6910
|
break;
|
|
6838
6911
|
}
|
|
6839
6912
|
assert(track.info);
|
|
6913
|
+
if (boxInfo.contentSize === 0) {
|
|
6914
|
+
break;
|
|
6915
|
+
}
|
|
6840
6916
|
track.info.codecDescription = readBytes(slice, boxInfo.contentSize);
|
|
6841
6917
|
}
|
|
6842
6918
|
;
|
|
@@ -7012,11 +7088,11 @@ var Mediabunny = (() => {
|
|
|
7012
7088
|
track.info.codecDescription = readBytes(slice, decoderSpecificInfoLength);
|
|
7013
7089
|
if (track.info.codec === "aac") {
|
|
7014
7090
|
const audioSpecificConfig = parseAacAudioSpecificConfig(track.info.codecDescription);
|
|
7015
|
-
if (audioSpecificConfig.
|
|
7016
|
-
track.info.numberOfChannels = audioSpecificConfig.
|
|
7091
|
+
if (audioSpecificConfig.outputNumberOfChannels !== null) {
|
|
7092
|
+
track.info.numberOfChannels = audioSpecificConfig.outputNumberOfChannels;
|
|
7017
7093
|
}
|
|
7018
|
-
if (audioSpecificConfig.
|
|
7019
|
-
track.info.sampleRate = audioSpecificConfig.
|
|
7094
|
+
if (audioSpecificConfig.outputSampleRate !== null) {
|
|
7095
|
+
track.info.sampleRate = audioSpecificConfig.outputSampleRate;
|
|
7020
7096
|
}
|
|
7021
7097
|
}
|
|
7022
7098
|
}
|
|
@@ -8376,20 +8452,26 @@ var Mediabunny = (() => {
|
|
|
8376
8452
|
sampleInfo.sampleOffset,
|
|
8377
8453
|
sampleInfo.sampleSize
|
|
8378
8454
|
);
|
|
8379
|
-
if (slice
|
|
8455
|
+
if (isThenable(slice)) slice = await slice;
|
|
8380
8456
|
if (!slice) {
|
|
8381
8457
|
return null;
|
|
8382
8458
|
}
|
|
8383
8459
|
data = readBytes(slice, sampleInfo.sampleSize);
|
|
8384
|
-
if (this.internalTrack.
|
|
8385
|
-
|
|
8386
|
-
|
|
8387
|
-
|
|
8388
|
-
|
|
8389
|
-
|
|
8390
|
-
|
|
8391
|
-
|
|
8392
|
-
|
|
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);
|
|
8393
8475
|
}
|
|
8394
8476
|
}
|
|
8395
8477
|
}
|
|
@@ -8421,13 +8503,16 @@ var Mediabunny = (() => {
|
|
|
8421
8503
|
fragmentSample.byteOffset,
|
|
8422
8504
|
fragmentSample.byteSize
|
|
8423
8505
|
);
|
|
8424
|
-
if (slice
|
|
8506
|
+
if (isThenable(slice)) slice = await slice;
|
|
8425
8507
|
if (!slice) {
|
|
8426
8508
|
return null;
|
|
8427
8509
|
}
|
|
8428
8510
|
data = readBytes(slice, fragmentSample.byteSize);
|
|
8429
|
-
if (
|
|
8430
|
-
|
|
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
|
+
}
|
|
8431
8516
|
}
|
|
8432
8517
|
}
|
|
8433
8518
|
const timestamp = (fragmentSample.presentationTimestamp - this.internalTrack.editListOffset) / this.internalTrack.timescale;
|
|
@@ -8494,7 +8579,7 @@ var Mediabunny = (() => {
|
|
|
8494
8579
|
}
|
|
8495
8580
|
}
|
|
8496
8581
|
let slice = demuxer.reader.requestSliceRange(currentPos, MIN_BOX_HEADER_SIZE, MAX_BOX_HEADER_SIZE);
|
|
8497
|
-
if (slice
|
|
8582
|
+
if (isThenable(slice)) slice = await slice;
|
|
8498
8583
|
if (!slice) break;
|
|
8499
8584
|
const boxStartPos = currentPos;
|
|
8500
8585
|
const boxInfo = readBoxHeader(slice);
|
|
@@ -8575,7 +8660,13 @@ var Mediabunny = (() => {
|
|
|
8575
8660
|
return null;
|
|
8576
8661
|
}
|
|
8577
8662
|
return this.decoderConfigPromise ??= (async () => {
|
|
8578
|
-
if (this.internalTrack.info.codec === "
|
|
8663
|
+
if (this.internalTrack.info.codec === "avc" && !this.internalTrack.info.codecDescription) {
|
|
8664
|
+
const firstPacket = await this.getFirstPacket({});
|
|
8665
|
+
this.internalTrack.info.avcCodecInfo = firstPacket && extractAvcDecoderConfigurationRecord(firstPacket.data);
|
|
8666
|
+
} else if (this.internalTrack.info.codec === "hevc" && !this.internalTrack.info.codecDescription) {
|
|
8667
|
+
const firstPacket = await this.getFirstPacket({});
|
|
8668
|
+
this.internalTrack.info.hevcCodecInfo = firstPacket && extractHevcDecoderConfigurationRecord(firstPacket.data);
|
|
8669
|
+
} else if (this.internalTrack.info.codec === "vp9" && !this.internalTrack.info.vp9CodecInfo) {
|
|
8579
8670
|
const firstPacket = await this.getFirstPacket({});
|
|
8580
8671
|
this.internalTrack.info.vp9CodecInfo = firstPacket && extractVp9CodecInfoFromPacket(firstPacket.data);
|
|
8581
8672
|
} else if (this.internalTrack.info.codec === "av1" && !this.internalTrack.info.av1CodecInfo) {
|
|
@@ -8809,7 +8900,7 @@ var Mediabunny = (() => {
|
|
|
8809
8900
|
}
|
|
8810
8901
|
}
|
|
8811
8902
|
let slice = reader.requestSlice(aux.offset, totalSize);
|
|
8812
|
-
if (slice
|
|
8903
|
+
if (isThenable(slice)) slice = await slice;
|
|
8813
8904
|
if (!slice) {
|
|
8814
8905
|
throw new Error("Failed to read auxiliary encryption info.");
|
|
8815
8906
|
}
|
|
@@ -8839,6 +8930,15 @@ var Mediabunny = (() => {
|
|
|
8839
8930
|
aux.resolved = entries;
|
|
8840
8931
|
return entries;
|
|
8841
8932
|
};
|
|
8933
|
+
var getDefaultSampleEncryption = (encryptionInfo) => {
|
|
8934
|
+
if (!encryptionInfo.defaultConstantIv) {
|
|
8935
|
+
return null;
|
|
8936
|
+
}
|
|
8937
|
+
return {
|
|
8938
|
+
iv: encryptionInfo.defaultConstantIv,
|
|
8939
|
+
subsamples: null
|
|
8940
|
+
};
|
|
8941
|
+
};
|
|
8842
8942
|
var decryptSample = async (track, sampleEncryption, data, fragment) => {
|
|
8843
8943
|
assert(track.encryptionInfo);
|
|
8844
8944
|
const encryptionInfo = track.encryptionInfo;
|
|
@@ -9429,7 +9529,7 @@ var Mediabunny = (() => {
|
|
|
9429
9529
|
let currentPos = startPos;
|
|
9430
9530
|
while (until === null || currentPos < until) {
|
|
9431
9531
|
let slice = reader.requestSliceRange(currentPos, MIN_HEADER_SIZE, MAX_HEADER_SIZE);
|
|
9432
|
-
if (slice
|
|
9532
|
+
if (isThenable(slice)) slice = await slice;
|
|
9433
9533
|
if (!slice) break;
|
|
9434
9534
|
const elementHeader = readElementHeader(slice);
|
|
9435
9535
|
if (!elementHeader) {
|
|
@@ -9449,7 +9549,7 @@ var Mediabunny = (() => {
|
|
|
9449
9549
|
let currentPos = startPos;
|
|
9450
9550
|
while (currentPos < until) {
|
|
9451
9551
|
let slice = reader.requestSliceRange(currentPos, 0, Math.min(CHUNK_SIZE, until - currentPos));
|
|
9452
|
-
if (slice
|
|
9552
|
+
if (isThenable(slice)) slice = await slice;
|
|
9453
9553
|
if (!slice) break;
|
|
9454
9554
|
if (slice.length < MAX_VAR_INT_SIZE) break;
|
|
9455
9555
|
for (let i = 0; i < slice.length - MAX_VAR_INT_SIZE; i++) {
|
|
@@ -9571,7 +9671,7 @@ var Mediabunny = (() => {
|
|
|
9571
9671
|
let currentPos = 0;
|
|
9572
9672
|
while (true) {
|
|
9573
9673
|
let slice = this.reader.requestSliceRange(currentPos, MIN_HEADER_SIZE, MAX_HEADER_SIZE);
|
|
9574
|
-
if (slice
|
|
9674
|
+
if (isThenable(slice)) slice = await slice;
|
|
9575
9675
|
if (!slice) break;
|
|
9576
9676
|
const header = readElementHeader(slice);
|
|
9577
9677
|
if (!header) {
|
|
@@ -9583,7 +9683,7 @@ var Mediabunny = (() => {
|
|
|
9583
9683
|
if (id === 440786851 /* EBML */) {
|
|
9584
9684
|
assertDefinedSize(size);
|
|
9585
9685
|
let slice2 = this.reader.requestSlice(dataStartPos, size);
|
|
9586
|
-
if (slice2
|
|
9686
|
+
if (isThenable(slice2)) slice2 = await slice2;
|
|
9587
9687
|
if (!slice2) break;
|
|
9588
9688
|
this.readContiguousElements(slice2);
|
|
9589
9689
|
} else if (id === 408125543 /* Segment */) {
|
|
@@ -9642,7 +9742,7 @@ var Mediabunny = (() => {
|
|
|
9642
9742
|
let currentPos = segmentDataStart;
|
|
9643
9743
|
while (this.currentSegment.elementEndPos === null || currentPos < this.currentSegment.elementEndPos) {
|
|
9644
9744
|
let slice = this.reader.requestSliceRange(currentPos, MIN_HEADER_SIZE, MAX_HEADER_SIZE);
|
|
9645
|
-
if (slice
|
|
9745
|
+
if (isThenable(slice)) slice = await slice;
|
|
9646
9746
|
if (!slice) break;
|
|
9647
9747
|
const elementStartPos = currentPos;
|
|
9648
9748
|
const header = readElementHeader(slice);
|
|
@@ -9668,7 +9768,7 @@ var Mediabunny = (() => {
|
|
|
9668
9768
|
this.currentSegment[field] = true;
|
|
9669
9769
|
assertDefinedSize(size);
|
|
9670
9770
|
let slice2 = this.reader.requestSlice(dataStartPos, size);
|
|
9671
|
-
if (slice2
|
|
9771
|
+
if (isThenable(slice2)) slice2 = await slice2;
|
|
9672
9772
|
if (slice2) {
|
|
9673
9773
|
this.readContiguousElements(slice2);
|
|
9674
9774
|
}
|
|
@@ -9680,7 +9780,7 @@ var Mediabunny = (() => {
|
|
|
9680
9780
|
}
|
|
9681
9781
|
assertDefinedSize(size);
|
|
9682
9782
|
let slice2 = this.reader.requestSlice(dataStartPos, size);
|
|
9683
|
-
if (slice2
|
|
9783
|
+
if (isThenable(slice2)) slice2 = await slice2;
|
|
9684
9784
|
if (slice2) {
|
|
9685
9785
|
this.readContiguousElements(slice2);
|
|
9686
9786
|
}
|
|
@@ -9707,7 +9807,7 @@ var Mediabunny = (() => {
|
|
|
9707
9807
|
MIN_HEADER_SIZE,
|
|
9708
9808
|
MAX_HEADER_SIZE
|
|
9709
9809
|
);
|
|
9710
|
-
if (slice
|
|
9810
|
+
if (isThenable(slice)) slice = await slice;
|
|
9711
9811
|
if (!slice) continue;
|
|
9712
9812
|
const header = readElementHeader(slice);
|
|
9713
9813
|
if (!header) continue;
|
|
@@ -9716,7 +9816,7 @@ var Mediabunny = (() => {
|
|
|
9716
9816
|
assertDefinedSize(size);
|
|
9717
9817
|
this.currentSegment[target.flag] = true;
|
|
9718
9818
|
let dataSlice = this.reader.requestSlice(slice.filePos, size);
|
|
9719
|
-
if (dataSlice
|
|
9819
|
+
if (isThenable(dataSlice)) dataSlice = await dataSlice;
|
|
9720
9820
|
if (!dataSlice) continue;
|
|
9721
9821
|
this.readContiguousElements(dataSlice);
|
|
9722
9822
|
}
|
|
@@ -9768,7 +9868,7 @@ var Mediabunny = (() => {
|
|
|
9768
9868
|
return segment.lastReadCluster;
|
|
9769
9869
|
}
|
|
9770
9870
|
let headerSlice = this.reader.requestSliceRange(startPos, MIN_HEADER_SIZE, MAX_HEADER_SIZE);
|
|
9771
|
-
if (headerSlice
|
|
9871
|
+
if (isThenable(headerSlice)) headerSlice = await headerSlice;
|
|
9772
9872
|
assert(headerSlice);
|
|
9773
9873
|
const elementStartPos = startPos;
|
|
9774
9874
|
const elementHeader = readElementHeader(headerSlice);
|
|
@@ -9787,7 +9887,7 @@ var Mediabunny = (() => {
|
|
|
9787
9887
|
size = nextElementPos.pos - dataStartPos;
|
|
9788
9888
|
}
|
|
9789
9889
|
let dataSlice = this.reader.requestSlice(dataStartPos, size);
|
|
9790
|
-
if (dataSlice
|
|
9890
|
+
if (isThenable(dataSlice)) dataSlice = await dataSlice;
|
|
9791
9891
|
const cluster = {
|
|
9792
9892
|
segment,
|
|
9793
9893
|
elementStartPos,
|
|
@@ -9975,7 +10075,7 @@ var Mediabunny = (() => {
|
|
|
9975
10075
|
MIN_HEADER_SIZE,
|
|
9976
10076
|
MAX_HEADER_SIZE
|
|
9977
10077
|
);
|
|
9978
|
-
if (slice
|
|
10078
|
+
if (isThenable(slice)) slice = await slice;
|
|
9979
10079
|
if (!slice) continue;
|
|
9980
10080
|
const header = readElementHeader(slice);
|
|
9981
10081
|
if (!header || header.id !== seekEntry.id) continue;
|
|
@@ -9984,7 +10084,7 @@ var Mediabunny = (() => {
|
|
|
9984
10084
|
assert(!this.currentSegment);
|
|
9985
10085
|
this.currentSegment = segment;
|
|
9986
10086
|
let dataSlice = this.reader.requestSlice(slice.filePos, size);
|
|
9987
|
-
if (dataSlice
|
|
10087
|
+
if (isThenable(dataSlice)) dataSlice = await dataSlice;
|
|
9988
10088
|
if (dataSlice) {
|
|
9989
10089
|
this.readContiguousElements(dataSlice);
|
|
9990
10090
|
}
|
|
@@ -11340,7 +11440,7 @@ var Mediabunny = (() => {
|
|
|
11340
11440
|
}
|
|
11341
11441
|
}
|
|
11342
11442
|
let slice = demuxer.reader.requestSliceRange(currentPos, MIN_HEADER_SIZE, MAX_HEADER_SIZE);
|
|
11343
|
-
if (slice
|
|
11443
|
+
if (isThenable(slice)) slice = await slice;
|
|
11344
11444
|
if (!slice) break;
|
|
11345
11445
|
const elementStartPos = currentPos;
|
|
11346
11446
|
const elementHeader = readElementHeader(slice);
|
|
@@ -11386,7 +11486,7 @@ var Mediabunny = (() => {
|
|
|
11386
11486
|
const endPos = dataStartPos + size;
|
|
11387
11487
|
if (segment.elementEndPos === null) {
|
|
11388
11488
|
let slice2 = demuxer.reader.requestSliceRange(endPos, MIN_HEADER_SIZE, MAX_HEADER_SIZE);
|
|
11389
|
-
if (slice2
|
|
11489
|
+
if (isThenable(slice2)) slice2 = await slice2;
|
|
11390
11490
|
if (!slice2) break;
|
|
11391
11491
|
const elementId = readElementId(slice2);
|
|
11392
11492
|
if (elementId === 408125543 /* Segment */) {
|
|
@@ -11533,7 +11633,7 @@ var Mediabunny = (() => {
|
|
|
11533
11633
|
while (until === null || currentPos < until) {
|
|
11534
11634
|
const maxLength = until !== null ? Math.min(CHUNK_SIZE, until - currentPos) : CHUNK_SIZE;
|
|
11535
11635
|
let slice = reader.requestSliceRange(currentPos, MP3_FRAME_HEADER_SIZE, maxLength);
|
|
11536
|
-
if (slice
|
|
11636
|
+
if (isThenable(slice)) slice = await slice;
|
|
11537
11637
|
if (!slice || slice.length < MP3_FRAME_HEADER_SIZE) break;
|
|
11538
11638
|
while (slice.remainingLength >= MP3_FRAME_HEADER_SIZE) {
|
|
11539
11639
|
const posBeforeRead = slice.filePos;
|
|
@@ -11591,7 +11691,7 @@ var Mediabunny = (() => {
|
|
|
11591
11691
|
if (this.lastLoadedPos === 0) {
|
|
11592
11692
|
while (true) {
|
|
11593
11693
|
let slice2 = this.reader.requestSlice(this.lastLoadedPos, ID3_V2_HEADER_SIZE);
|
|
11594
|
-
if (slice2
|
|
11694
|
+
if (isThenable(slice2)) slice2 = await slice2;
|
|
11595
11695
|
if (!slice2) {
|
|
11596
11696
|
this.lastSampleLoaded = true;
|
|
11597
11697
|
return;
|
|
@@ -11617,7 +11717,7 @@ var Mediabunny = (() => {
|
|
|
11617
11717
|
this.lastLoadedPos = result.startPos + header.totalSize - 1;
|
|
11618
11718
|
const xingOffset = getXingOffset(header.mpegVersionId, header.channel);
|
|
11619
11719
|
let slice = this.reader.requestSlice(result.startPos + xingOffset, 4);
|
|
11620
|
-
if (slice
|
|
11720
|
+
if (isThenable(slice)) slice = await slice;
|
|
11621
11721
|
if (slice) {
|
|
11622
11722
|
const word = readU32Be(slice);
|
|
11623
11723
|
const isXing = word === XING || word === INFO;
|
|
@@ -11628,7 +11728,7 @@ var Mediabunny = (() => {
|
|
|
11628
11728
|
}
|
|
11629
11729
|
if (!this.xingData) {
|
|
11630
11730
|
let xingDataSlice = this.reader.requestSlice(result.startPos + xingOffset + 4, 12);
|
|
11631
|
-
if (xingDataSlice
|
|
11731
|
+
if (isThenable(xingDataSlice)) xingDataSlice = await xingDataSlice;
|
|
11632
11732
|
if (xingDataSlice) {
|
|
11633
11733
|
const xingData = readBytes(xingDataSlice, 12);
|
|
11634
11734
|
const view2 = toDataView(xingData);
|
|
@@ -11676,7 +11776,7 @@ var Mediabunny = (() => {
|
|
|
11676
11776
|
let id3V2HeaderFound = false;
|
|
11677
11777
|
while (true) {
|
|
11678
11778
|
let headerSlice = this.reader.requestSlice(currentPos, ID3_V2_HEADER_SIZE);
|
|
11679
|
-
if (headerSlice
|
|
11779
|
+
if (isThenable(headerSlice)) headerSlice = await headerSlice;
|
|
11680
11780
|
if (!headerSlice) break;
|
|
11681
11781
|
const id3V2Header = readId3V2Header(headerSlice);
|
|
11682
11782
|
if (!id3V2Header) {
|
|
@@ -11684,14 +11784,14 @@ var Mediabunny = (() => {
|
|
|
11684
11784
|
}
|
|
11685
11785
|
id3V2HeaderFound = true;
|
|
11686
11786
|
let contentSlice = this.reader.requestSlice(headerSlice.filePos, id3V2Header.size);
|
|
11687
|
-
if (contentSlice
|
|
11787
|
+
if (isThenable(contentSlice)) contentSlice = await contentSlice;
|
|
11688
11788
|
if (!contentSlice) break;
|
|
11689
11789
|
parseId3V2Tag(contentSlice, id3V2Header, this.metadataTags);
|
|
11690
11790
|
currentPos = headerSlice.filePos + id3V2Header.size;
|
|
11691
11791
|
}
|
|
11692
11792
|
if (!id3V2HeaderFound && this.reader.fileSize !== null && this.reader.fileSize >= ID3_V1_TAG_SIZE) {
|
|
11693
11793
|
let slice = this.reader.requestSlice(this.reader.fileSize - ID3_V1_TAG_SIZE, ID3_V1_TAG_SIZE);
|
|
11694
|
-
if (slice
|
|
11794
|
+
if (isThenable(slice)) slice = await slice;
|
|
11695
11795
|
assert(slice);
|
|
11696
11796
|
const tag = readAscii(slice, 3);
|
|
11697
11797
|
if (tag === "TAG") {
|
|
@@ -11807,7 +11907,7 @@ var Mediabunny = (() => {
|
|
|
11807
11907
|
data = PLACEHOLDER_DATA;
|
|
11808
11908
|
} else {
|
|
11809
11909
|
let slice = this.demuxer.reader.requestSlice(rawSample.dataStart, rawSample.dataSize);
|
|
11810
|
-
if (slice
|
|
11910
|
+
if (isThenable(slice)) slice = await slice;
|
|
11811
11911
|
if (!slice) {
|
|
11812
11912
|
return null;
|
|
11813
11913
|
}
|
|
@@ -12013,7 +12113,7 @@ var Mediabunny = (() => {
|
|
|
12013
12113
|
let currentPos = 0;
|
|
12014
12114
|
while (true) {
|
|
12015
12115
|
let slice = this.reader.requestSliceRange(currentPos, MIN_PAGE_HEADER_SIZE, MAX_PAGE_HEADER_SIZE);
|
|
12016
|
-
if (slice
|
|
12116
|
+
if (isThenable(slice)) slice = await slice;
|
|
12017
12117
|
if (!slice) break;
|
|
12018
12118
|
const page = readPageHeader(slice);
|
|
12019
12119
|
if (!page) {
|
|
@@ -12164,7 +12264,7 @@ var Mediabunny = (() => {
|
|
|
12164
12264
|
outer:
|
|
12165
12265
|
while (true) {
|
|
12166
12266
|
let pageSlice = this.reader.requestSlice(currentPage.dataStartPos, currentPage.dataSize);
|
|
12167
|
-
if (pageSlice
|
|
12267
|
+
if (isThenable(pageSlice)) pageSlice = await pageSlice;
|
|
12168
12268
|
assert(pageSlice);
|
|
12169
12269
|
const pageData = readBytes(pageSlice, currentPage.dataSize);
|
|
12170
12270
|
while (true) {
|
|
@@ -12183,7 +12283,7 @@ var Mediabunny = (() => {
|
|
|
12183
12283
|
let currentPos = currentPage.headerStartPos + currentPage.totalSize;
|
|
12184
12284
|
while (true) {
|
|
12185
12285
|
let headerSlice = this.reader.requestSliceRange(currentPos, MIN_PAGE_HEADER_SIZE, MAX_PAGE_HEADER_SIZE);
|
|
12186
|
-
if (headerSlice
|
|
12286
|
+
if (isThenable(headerSlice)) headerSlice = await headerSlice;
|
|
12187
12287
|
if (!headerSlice) {
|
|
12188
12288
|
return null;
|
|
12189
12289
|
}
|
|
@@ -12229,7 +12329,7 @@ var Mediabunny = (() => {
|
|
|
12229
12329
|
let currentPos = lastPacket.endPage.headerStartPos + lastPacket.endPage.totalSize;
|
|
12230
12330
|
while (true) {
|
|
12231
12331
|
let slice = this.reader.requestSliceRange(currentPos, MIN_PAGE_HEADER_SIZE, MAX_PAGE_HEADER_SIZE);
|
|
12232
|
-
if (slice
|
|
12332
|
+
if (isThenable(slice)) slice = await slice;
|
|
12233
12333
|
if (!slice) {
|
|
12234
12334
|
return null;
|
|
12235
12335
|
}
|
|
@@ -12447,7 +12547,7 @@ var Mediabunny = (() => {
|
|
|
12447
12547
|
high - MIN_PAGE_HEADER_SIZE
|
|
12448
12548
|
);
|
|
12449
12549
|
let searchSlice = this.demuxer.reader.requestSlice(searchStartPos, until - searchStartPos);
|
|
12450
|
-
if (searchSlice
|
|
12550
|
+
if (isThenable(searchSlice)) searchSlice = await searchSlice;
|
|
12451
12551
|
assert(searchSlice);
|
|
12452
12552
|
const found = findNextPageHeader(searchSlice, until);
|
|
12453
12553
|
if (!found) {
|
|
@@ -12459,7 +12559,7 @@ var Mediabunny = (() => {
|
|
|
12459
12559
|
MIN_PAGE_HEADER_SIZE,
|
|
12460
12560
|
MAX_PAGE_HEADER_SIZE
|
|
12461
12561
|
);
|
|
12462
|
-
if (headerSlice
|
|
12562
|
+
if (isThenable(headerSlice)) headerSlice = await headerSlice;
|
|
12463
12563
|
assert(headerSlice);
|
|
12464
12564
|
const page = readPageHeader(headerSlice);
|
|
12465
12565
|
assert(page);
|
|
@@ -12468,7 +12568,7 @@ var Mediabunny = (() => {
|
|
|
12468
12568
|
pageValid = true;
|
|
12469
12569
|
} else {
|
|
12470
12570
|
let pageSlice = this.demuxer.reader.requestSlice(page.headerStartPos, page.totalSize);
|
|
12471
|
-
if (pageSlice
|
|
12571
|
+
if (isThenable(pageSlice)) pageSlice = await pageSlice;
|
|
12472
12572
|
assert(pageSlice);
|
|
12473
12573
|
const bytes2 = readBytes(pageSlice, page.totalSize);
|
|
12474
12574
|
const crc = computeOggPageCrc(bytes2);
|
|
@@ -12513,7 +12613,7 @@ var Mediabunny = (() => {
|
|
|
12513
12613
|
}
|
|
12514
12614
|
const nextPos = currentPage.headerStartPos + currentPage.totalSize;
|
|
12515
12615
|
let slice = this.demuxer.reader.requestSliceRange(nextPos, MIN_PAGE_HEADER_SIZE, MAX_PAGE_HEADER_SIZE);
|
|
12516
|
-
if (slice
|
|
12616
|
+
if (isThenable(slice)) slice = await slice;
|
|
12517
12617
|
assert(slice);
|
|
12518
12618
|
const nextPage = readPageHeader(slice);
|
|
12519
12619
|
assert(nextPage);
|
|
@@ -12771,7 +12871,7 @@ var Mediabunny = (() => {
|
|
|
12771
12871
|
async readMetadata() {
|
|
12772
12872
|
return this.metadataPromise ??= (async () => {
|
|
12773
12873
|
let slice = this.reader.requestSlice(0, 12);
|
|
12774
|
-
if (slice
|
|
12874
|
+
if (isThenable(slice)) slice = await slice;
|
|
12775
12875
|
assert(slice);
|
|
12776
12876
|
const riffType = readAscii(slice, 4);
|
|
12777
12877
|
const littleEndian = riffType !== "RIFX";
|
|
@@ -12787,7 +12887,7 @@ var Mediabunny = (() => {
|
|
|
12787
12887
|
let currentPos = slice.filePos;
|
|
12788
12888
|
while (totalFileSize === null || currentPos < totalFileSize) {
|
|
12789
12889
|
let slice2 = this.reader.requestSlice(currentPos, 8);
|
|
12790
|
-
if (slice2
|
|
12890
|
+
if (isThenable(slice2)) slice2 = await slice2;
|
|
12791
12891
|
if (!slice2) break;
|
|
12792
12892
|
const chunkId = readAscii(slice2, 4);
|
|
12793
12893
|
const chunkSize = readU32(slice2, littleEndian);
|
|
@@ -12806,7 +12906,7 @@ var Mediabunny = (() => {
|
|
|
12806
12906
|
}
|
|
12807
12907
|
} else if (chunkId === "ds64") {
|
|
12808
12908
|
let ds64Slice = this.reader.requestSlice(startPos, chunkSize);
|
|
12809
|
-
if (ds64Slice
|
|
12909
|
+
if (isThenable(ds64Slice)) ds64Slice = await ds64Slice;
|
|
12810
12910
|
if (!ds64Slice) break;
|
|
12811
12911
|
const riffChunkSize = readU64(ds64Slice, littleEndian);
|
|
12812
12912
|
dataChunkSize = readU64(ds64Slice, littleEndian);
|
|
@@ -12832,7 +12932,7 @@ var Mediabunny = (() => {
|
|
|
12832
12932
|
}
|
|
12833
12933
|
async parseFmtChunk(startPos, size, littleEndian) {
|
|
12834
12934
|
let slice = this.reader.requestSlice(startPos, size);
|
|
12835
|
-
if (slice
|
|
12935
|
+
if (isThenable(slice)) slice = await slice;
|
|
12836
12936
|
if (!slice) return;
|
|
12837
12937
|
let formatTag = readU16(slice, littleEndian);
|
|
12838
12938
|
const numChannels = readU16(slice, littleEndian);
|
|
@@ -12883,7 +12983,7 @@ var Mediabunny = (() => {
|
|
|
12883
12983
|
}
|
|
12884
12984
|
async parseListChunk(startPos, size, littleEndian) {
|
|
12885
12985
|
let slice = this.reader.requestSlice(startPos, size);
|
|
12886
|
-
if (slice
|
|
12986
|
+
if (isThenable(slice)) slice = await slice;
|
|
12887
12987
|
if (!slice) return;
|
|
12888
12988
|
const infoType = readAscii(slice, 4);
|
|
12889
12989
|
if (infoType !== "INFO" && infoType !== "INF0") {
|
|
@@ -12987,7 +13087,7 @@ var Mediabunny = (() => {
|
|
|
12987
13087
|
}
|
|
12988
13088
|
async parseId3Chunk(startPos, size) {
|
|
12989
13089
|
let slice = this.reader.requestSlice(startPos, size);
|
|
12990
|
-
if (slice
|
|
13090
|
+
if (isThenable(slice)) slice = await slice;
|
|
12991
13091
|
if (!slice) return;
|
|
12992
13092
|
const id3V2Header = readId3V2Header(slice);
|
|
12993
13093
|
if (id3V2Header) {
|
|
@@ -13130,7 +13230,7 @@ var Mediabunny = (() => {
|
|
|
13130
13230
|
);
|
|
13131
13231
|
if (this.demuxer.reader.fileSize === null) {
|
|
13132
13232
|
let slice = this.demuxer.reader.requestSlice(this.demuxer.dataStart + startOffset, sizeInBytes);
|
|
13133
|
-
if (slice
|
|
13233
|
+
if (isThenable(slice)) slice = await slice;
|
|
13134
13234
|
if (!slice) {
|
|
13135
13235
|
return null;
|
|
13136
13236
|
}
|
|
@@ -13140,7 +13240,7 @@ var Mediabunny = (() => {
|
|
|
13140
13240
|
data = PLACEHOLDER_DATA;
|
|
13141
13241
|
} else {
|
|
13142
13242
|
let slice = this.demuxer.reader.requestSlice(this.demuxer.dataStart + startOffset, sizeInBytes);
|
|
13143
|
-
if (slice
|
|
13243
|
+
if (isThenable(slice)) slice = await slice;
|
|
13144
13244
|
assert(slice);
|
|
13145
13245
|
data = readBytes(slice, sizeInBytes);
|
|
13146
13246
|
}
|
|
@@ -13285,7 +13385,7 @@ var Mediabunny = (() => {
|
|
|
13285
13385
|
if (this.lastLoadedPos === 0) {
|
|
13286
13386
|
while (true) {
|
|
13287
13387
|
let slice2 = this.reader.requestSlice(this.lastLoadedPos, ID3_V2_HEADER_SIZE);
|
|
13288
|
-
if (slice2
|
|
13388
|
+
if (isThenable(slice2)) slice2 = await slice2;
|
|
13289
13389
|
if (!slice2) {
|
|
13290
13390
|
this.lastSampleLoaded = true;
|
|
13291
13391
|
return;
|
|
@@ -13302,7 +13402,7 @@ var Mediabunny = (() => {
|
|
|
13302
13402
|
MIN_ADTS_FRAME_HEADER_SIZE,
|
|
13303
13403
|
MAX_ADTS_FRAME_HEADER_SIZE
|
|
13304
13404
|
);
|
|
13305
|
-
if (slice
|
|
13405
|
+
if (isThenable(slice)) slice = await slice;
|
|
13306
13406
|
if (!slice) {
|
|
13307
13407
|
this.lastSampleLoaded = true;
|
|
13308
13408
|
return;
|
|
@@ -13350,14 +13450,14 @@ var Mediabunny = (() => {
|
|
|
13350
13450
|
let currentPos = 0;
|
|
13351
13451
|
while (true) {
|
|
13352
13452
|
let headerSlice = this.reader.requestSlice(currentPos, ID3_V2_HEADER_SIZE);
|
|
13353
|
-
if (headerSlice
|
|
13453
|
+
if (isThenable(headerSlice)) headerSlice = await headerSlice;
|
|
13354
13454
|
if (!headerSlice) break;
|
|
13355
13455
|
const id3V2Header = readId3V2Header(headerSlice);
|
|
13356
13456
|
if (!id3V2Header) {
|
|
13357
13457
|
break;
|
|
13358
13458
|
}
|
|
13359
13459
|
let contentSlice = this.reader.requestSlice(headerSlice.filePos, id3V2Header.size);
|
|
13360
|
-
if (contentSlice
|
|
13460
|
+
if (isThenable(contentSlice)) contentSlice = await contentSlice;
|
|
13361
13461
|
if (!contentSlice) break;
|
|
13362
13462
|
parseId3V2Tag(contentSlice, id3V2Header, this.metadataTags);
|
|
13363
13463
|
currentPos = headerSlice.filePos + id3V2Header.size;
|
|
@@ -13457,7 +13557,7 @@ var Mediabunny = (() => {
|
|
|
13457
13557
|
data = PLACEHOLDER_DATA;
|
|
13458
13558
|
} else {
|
|
13459
13559
|
let slice = this.demuxer.reader.requestSlice(rawSample.dataStart, rawSample.dataSize);
|
|
13460
|
-
if (slice
|
|
13560
|
+
if (isThenable(slice)) slice = await slice;
|
|
13461
13561
|
if (!slice) {
|
|
13462
13562
|
return null;
|
|
13463
13563
|
}
|
|
@@ -13688,7 +13788,7 @@ var Mediabunny = (() => {
|
|
|
13688
13788
|
let currentPos = 0;
|
|
13689
13789
|
while (true) {
|
|
13690
13790
|
let headerSlice = this.reader.requestSlice(currentPos, ID3_V2_HEADER_SIZE);
|
|
13691
|
-
if (headerSlice
|
|
13791
|
+
if (isThenable(headerSlice)) headerSlice = await headerSlice;
|
|
13692
13792
|
if (!headerSlice) {
|
|
13693
13793
|
this.lastSampleLoaded = true;
|
|
13694
13794
|
return;
|
|
@@ -13698,7 +13798,7 @@ var Mediabunny = (() => {
|
|
|
13698
13798
|
break;
|
|
13699
13799
|
}
|
|
13700
13800
|
let contentSlice = this.reader.requestSlice(headerSlice.filePos, id3V2Header.size);
|
|
13701
|
-
if (contentSlice
|
|
13801
|
+
if (isThenable(contentSlice)) contentSlice = await contentSlice;
|
|
13702
13802
|
assert(contentSlice);
|
|
13703
13803
|
parseId3V2Tag(contentSlice, id3V2Header, this.metadataTags);
|
|
13704
13804
|
currentPos = headerSlice.filePos + id3V2Header.size;
|
|
@@ -13706,7 +13806,7 @@ var Mediabunny = (() => {
|
|
|
13706
13806
|
currentPos += 4;
|
|
13707
13807
|
while (this.reader.fileSize === null || currentPos < this.reader.fileSize) {
|
|
13708
13808
|
let sizeSlice = this.reader.requestSlice(currentPos, 4);
|
|
13709
|
-
if (sizeSlice
|
|
13809
|
+
if (isThenable(sizeSlice)) sizeSlice = await sizeSlice;
|
|
13710
13810
|
currentPos += 4;
|
|
13711
13811
|
if (sizeSlice === null) {
|
|
13712
13812
|
throw new Error(
|
|
@@ -13724,7 +13824,7 @@ var Mediabunny = (() => {
|
|
|
13724
13824
|
currentPos,
|
|
13725
13825
|
size
|
|
13726
13826
|
);
|
|
13727
|
-
if (streamInfoBlock
|
|
13827
|
+
if (isThenable(streamInfoBlock)) streamInfoBlock = await streamInfoBlock;
|
|
13728
13828
|
assert(streamInfoBlock);
|
|
13729
13829
|
if (streamInfoBlock === null) {
|
|
13730
13830
|
throw new Error(
|
|
@@ -13764,7 +13864,7 @@ var Mediabunny = (() => {
|
|
|
13764
13864
|
currentPos,
|
|
13765
13865
|
size
|
|
13766
13866
|
);
|
|
13767
|
-
if (vorbisCommentBlock
|
|
13867
|
+
if (isThenable(vorbisCommentBlock)) vorbisCommentBlock = await vorbisCommentBlock;
|
|
13768
13868
|
assert(vorbisCommentBlock);
|
|
13769
13869
|
readVorbisComments(
|
|
13770
13870
|
readBytes(vorbisCommentBlock, size),
|
|
@@ -13777,7 +13877,7 @@ var Mediabunny = (() => {
|
|
|
13777
13877
|
currentPos,
|
|
13778
13878
|
size
|
|
13779
13879
|
);
|
|
13780
|
-
if (pictureBlock
|
|
13880
|
+
if (isThenable(pictureBlock)) pictureBlock = await pictureBlock;
|
|
13781
13881
|
assert(pictureBlock);
|
|
13782
13882
|
const pictureType = readU32Be(pictureBlock);
|
|
13783
13883
|
const mediaTypeLength = readU32Be(pictureBlock);
|
|
@@ -14135,7 +14235,7 @@ var Mediabunny = (() => {
|
|
|
14135
14235
|
rawSample.byteOffset,
|
|
14136
14236
|
rawSample.byteSize
|
|
14137
14237
|
);
|
|
14138
|
-
if (slice
|
|
14238
|
+
if (isThenable(slice)) slice = await slice;
|
|
14139
14239
|
if (!slice) {
|
|
14140
14240
|
return null;
|
|
14141
14241
|
}
|
|
@@ -14203,7 +14303,7 @@ var Mediabunny = (() => {
|
|
|
14203
14303
|
return this.metadataPromise ??= (async () => {
|
|
14204
14304
|
const lengthToCheck = TS_PACKET_SIZE + 16 + 1;
|
|
14205
14305
|
let startingSlice = this.reader.requestSlice(0, lengthToCheck);
|
|
14206
|
-
if (startingSlice
|
|
14306
|
+
if (isThenable(startingSlice)) startingSlice = await startingSlice;
|
|
14207
14307
|
assert(startingSlice);
|
|
14208
14308
|
const startingBytes = readBytes(startingSlice, lengthToCheck);
|
|
14209
14309
|
if (startingBytes[0] === 71 && startingBytes[TS_PACKET_SIZE] === 71) {
|
|
@@ -14799,7 +14899,7 @@ var Mediabunny = (() => {
|
|
|
14799
14899
|
}
|
|
14800
14900
|
async readPacketHeader(pos) {
|
|
14801
14901
|
let slice = this.reader.requestSlice(pos, 4);
|
|
14802
|
-
if (slice
|
|
14902
|
+
if (isThenable(slice)) slice = await slice;
|
|
14803
14903
|
if (!slice) {
|
|
14804
14904
|
return null;
|
|
14805
14905
|
}
|
|
@@ -14824,7 +14924,7 @@ var Mediabunny = (() => {
|
|
|
14824
14924
|
}
|
|
14825
14925
|
async readPacket(pos) {
|
|
14826
14926
|
let slice = this.reader.requestSlice(pos, TS_PACKET_SIZE);
|
|
14827
|
-
if (slice
|
|
14927
|
+
if (isThenable(slice)) slice = await slice;
|
|
14828
14928
|
if (!slice) {
|
|
14829
14929
|
return null;
|
|
14830
14930
|
}
|
|
@@ -15594,7 +15694,7 @@ var Mediabunny = (() => {
|
|
|
15594
15694
|
let lastFirstMacroblockInSlice = 0;
|
|
15595
15695
|
while (true) {
|
|
15596
15696
|
let remaining = this.ensureBuffered(CHUNK_SIZE);
|
|
15597
|
-
if (remaining
|
|
15697
|
+
if (isThenable(remaining)) remaining = await remaining;
|
|
15598
15698
|
if (remaining === 0) {
|
|
15599
15699
|
break;
|
|
15600
15700
|
}
|
|
@@ -15696,7 +15796,7 @@ var Mediabunny = (() => {
|
|
|
15696
15796
|
const CHUNK_SIZE = 128;
|
|
15697
15797
|
while (true) {
|
|
15698
15798
|
let remaining = this.ensureBuffered(CHUNK_SIZE);
|
|
15699
|
-
if (remaining
|
|
15799
|
+
if (isThenable(remaining)) remaining = await remaining;
|
|
15700
15800
|
const startPos = this.currentPos;
|
|
15701
15801
|
while (this.currentPos - startPos < remaining) {
|
|
15702
15802
|
const byte = this.readU8();
|
|
@@ -15707,7 +15807,7 @@ var Mediabunny = (() => {
|
|
|
15707
15807
|
this.skip(-1);
|
|
15708
15808
|
const possibleHeaderStartPos = this.currentPos;
|
|
15709
15809
|
let remaining2 = this.ensureBuffered(MAX_ADTS_FRAME_HEADER_SIZE);
|
|
15710
|
-
if (remaining2
|
|
15810
|
+
if (isThenable(remaining2)) remaining2 = await remaining2;
|
|
15711
15811
|
if (remaining2 < MAX_ADTS_FRAME_HEADER_SIZE) {
|
|
15712
15812
|
return;
|
|
15713
15813
|
}
|
|
@@ -15716,7 +15816,7 @@ var Mediabunny = (() => {
|
|
|
15716
15816
|
if (header) {
|
|
15717
15817
|
this.seekTo(possibleHeaderStartPos);
|
|
15718
15818
|
let remaining3 = this.ensureBuffered(header.frameLength);
|
|
15719
|
-
if (remaining3
|
|
15819
|
+
if (isThenable(remaining3)) remaining3 = await remaining3;
|
|
15720
15820
|
return this.supplyPacket(
|
|
15721
15821
|
remaining3,
|
|
15722
15822
|
Math.round(SAMPLES_PER_AAC_FRAME * TIMESCALE / elementaryStream.info.sampleRate)
|
|
@@ -15731,7 +15831,7 @@ var Mediabunny = (() => {
|
|
|
15731
15831
|
this.skip(-1);
|
|
15732
15832
|
const possibleHeaderStartPos = this.currentPos;
|
|
15733
15833
|
let remaining2 = this.ensureBuffered(MP3_FRAME_HEADER_SIZE);
|
|
15734
|
-
if (remaining2
|
|
15834
|
+
if (isThenable(remaining2)) remaining2 = await remaining2;
|
|
15735
15835
|
if (remaining2 < MP3_FRAME_HEADER_SIZE) {
|
|
15736
15836
|
return;
|
|
15737
15837
|
}
|
|
@@ -15741,7 +15841,7 @@ var Mediabunny = (() => {
|
|
|
15741
15841
|
if (result.header) {
|
|
15742
15842
|
this.seekTo(possibleHeaderStartPos);
|
|
15743
15843
|
let remaining3 = this.ensureBuffered(result.header.totalSize);
|
|
15744
|
-
if (remaining3
|
|
15844
|
+
if (isThenable(remaining3)) remaining3 = await remaining3;
|
|
15745
15845
|
const duration = result.header.audioSamplesInFrame * TIMESCALE / elementaryStream.info.sampleRate;
|
|
15746
15846
|
return this.supplyPacket(remaining3, Math.round(duration));
|
|
15747
15847
|
} else {
|
|
@@ -15754,7 +15854,7 @@ var Mediabunny = (() => {
|
|
|
15754
15854
|
this.skip(-1);
|
|
15755
15855
|
const possibleSyncPos = this.currentPos;
|
|
15756
15856
|
let remaining2 = this.ensureBuffered(5);
|
|
15757
|
-
if (remaining2
|
|
15857
|
+
if (isThenable(remaining2)) remaining2 = await remaining2;
|
|
15758
15858
|
if (remaining2 < 5) {
|
|
15759
15859
|
return;
|
|
15760
15860
|
}
|
|
@@ -15773,7 +15873,7 @@ var Mediabunny = (() => {
|
|
|
15773
15873
|
assert(frameSize !== void 0);
|
|
15774
15874
|
this.seekTo(possibleSyncPos);
|
|
15775
15875
|
remaining2 = this.ensureBuffered(frameSize);
|
|
15776
|
-
if (remaining2
|
|
15876
|
+
if (isThenable(remaining2)) remaining2 = await remaining2;
|
|
15777
15877
|
const duration = Math.round(
|
|
15778
15878
|
AC3_SAMPLES_PER_FRAME * TIMESCALE / elementaryStream.info.sampleRate
|
|
15779
15879
|
);
|
|
@@ -15785,7 +15885,7 @@ var Mediabunny = (() => {
|
|
|
15785
15885
|
this.skip(-1);
|
|
15786
15886
|
const possibleSyncPos = this.currentPos;
|
|
15787
15887
|
let remaining2 = this.ensureBuffered(5);
|
|
15788
|
-
if (remaining2
|
|
15888
|
+
if (isThenable(remaining2)) remaining2 = await remaining2;
|
|
15789
15889
|
if (remaining2 < 5) {
|
|
15790
15890
|
return;
|
|
15791
15891
|
}
|
|
@@ -15801,7 +15901,7 @@ var Mediabunny = (() => {
|
|
|
15801
15901
|
const numblks = EAC3_NUMBLKS_TABLE[numblkscod];
|
|
15802
15902
|
this.seekTo(possibleSyncPos);
|
|
15803
15903
|
remaining2 = this.ensureBuffered(frameSize);
|
|
15804
|
-
if (remaining2
|
|
15904
|
+
if (isThenable(remaining2)) remaining2 = await remaining2;
|
|
15805
15905
|
const samplesPerFrame = numblks * 256;
|
|
15806
15906
|
const duration = Math.round(
|
|
15807
15907
|
samplesPerFrame * TIMESCALE / elementaryStream.info.sampleRate
|
|
@@ -15814,7 +15914,7 @@ var Mediabunny = (() => {
|
|
|
15814
15914
|
this.skip(-1);
|
|
15815
15915
|
const possibleSyncPos = this.currentPos;
|
|
15816
15916
|
let remaining2 = this.ensureBuffered(DTS_CORE_FRAME_HEADER_SIZE);
|
|
15817
|
-
if (remaining2
|
|
15917
|
+
if (isThenable(remaining2)) remaining2 = await remaining2;
|
|
15818
15918
|
if (remaining2 < DTS_CORE_FRAME_HEADER_SIZE) {
|
|
15819
15919
|
return;
|
|
15820
15920
|
}
|
|
@@ -15829,7 +15929,7 @@ var Mediabunny = (() => {
|
|
|
15829
15929
|
this.seekTo(possibleSyncPos);
|
|
15830
15930
|
const headerBound = Math.min(leadingExss.frameSize, DTS_EXSS_MAX_HEADER_SIZE);
|
|
15831
15931
|
let remaining3 = this.ensureBuffered(headerBound);
|
|
15832
|
-
if (remaining3
|
|
15932
|
+
if (isThenable(remaining3)) remaining3 = await remaining3;
|
|
15833
15933
|
leadingExss = parseDtsExssHeader(this.readBytes(remaining3)) ?? leadingExss;
|
|
15834
15934
|
}
|
|
15835
15935
|
let frameSize = core ? core.frameSize : leadingExss.frameSize;
|
|
@@ -15839,7 +15939,7 @@ var Mediabunny = (() => {
|
|
|
15839
15939
|
this.seekTo(possibleSyncPos);
|
|
15840
15940
|
const neededBytes = nextSubstreamPos + DTS_EXSS_HEADER_PREFIX_SIZE;
|
|
15841
15941
|
let remaining3 = this.ensureBuffered(neededBytes);
|
|
15842
|
-
if (remaining3
|
|
15942
|
+
if (isThenable(remaining3)) remaining3 = await remaining3;
|
|
15843
15943
|
if (remaining3 < neededBytes) {
|
|
15844
15944
|
break;
|
|
15845
15945
|
}
|
|
@@ -15859,7 +15959,7 @@ var Mediabunny = (() => {
|
|
|
15859
15959
|
}
|
|
15860
15960
|
this.seekTo(possibleSyncPos);
|
|
15861
15961
|
remaining2 = this.ensureBuffered(frameSize);
|
|
15862
|
-
if (remaining2
|
|
15962
|
+
if (isThenable(remaining2)) remaining2 = await remaining2;
|
|
15863
15963
|
const duration = Math.round(
|
|
15864
15964
|
sampleCount * TIMESCALE / elementaryStream.info.sampleRate
|
|
15865
15965
|
);
|
|
@@ -16658,7 +16758,7 @@ var Mediabunny = (() => {
|
|
|
16658
16758
|
ref.source._usedForHls ||= this._usedForHls;
|
|
16659
16759
|
return ref;
|
|
16660
16760
|
};
|
|
16661
|
-
if (result
|
|
16761
|
+
if (isThenable(result)) {
|
|
16662
16762
|
return result.then(handle);
|
|
16663
16763
|
} else {
|
|
16664
16764
|
return handle(result);
|
|
@@ -16687,7 +16787,7 @@ var Mediabunny = (() => {
|
|
|
16687
16787
|
this._rootRequest = null;
|
|
16688
16788
|
return ref;
|
|
16689
16789
|
};
|
|
16690
|
-
if (result
|
|
16790
|
+
if (isThenable(result)) {
|
|
16691
16791
|
this._rootRequest = result.then(handle);
|
|
16692
16792
|
} else {
|
|
16693
16793
|
handle(result);
|
|
@@ -16974,7 +17074,7 @@ var Mediabunny = (() => {
|
|
|
16974
17074
|
result2.offset -= this._offset;
|
|
16975
17075
|
return result2;
|
|
16976
17076
|
};
|
|
16977
|
-
if (result
|
|
17077
|
+
if (isThenable(result)) {
|
|
16978
17078
|
return result.then(processResult);
|
|
16979
17079
|
} else {
|
|
16980
17080
|
return processResult(result);
|
|
@@ -17183,7 +17283,7 @@ var Mediabunny = (() => {
|
|
|
17183
17283
|
this._orchestrator.queuedReads.length = 0;
|
|
17184
17284
|
for (const slice of uniqueSlices) {
|
|
17185
17285
|
const result = backing._read(slice.start, slice.start + slice.bytes.length);
|
|
17186
|
-
if (result
|
|
17286
|
+
if (isThenable(result)) {
|
|
17187
17287
|
result.then((readResult) => {
|
|
17188
17288
|
if (readResult) {
|
|
17189
17289
|
assert(readResult.offset === slice.start);
|
|
@@ -17324,7 +17424,7 @@ var Mediabunny = (() => {
|
|
|
17324
17424
|
return this._orchestrator.read(start, end, minReadPosition, maxReadPosition);
|
|
17325
17425
|
}
|
|
17326
17426
|
const result = this._options.getSize();
|
|
17327
|
-
if (result
|
|
17427
|
+
if (isThenable(result)) {
|
|
17328
17428
|
return result.then((size) => {
|
|
17329
17429
|
if (!Number.isInteger(size) || size < 0) {
|
|
17330
17430
|
throw new TypeError("options.getSize must return or resolve to a non-negative integer.");
|
|
@@ -17346,7 +17446,7 @@ var Mediabunny = (() => {
|
|
|
17346
17446
|
const originalCurrentPos = worker.currentPos;
|
|
17347
17447
|
const originalTargetPos = worker.targetPos;
|
|
17348
17448
|
let data = this._options.read(worker.currentPos, originalTargetPos);
|
|
17349
|
-
if (data
|
|
17449
|
+
if (isThenable(data)) data = await data;
|
|
17350
17450
|
if (worker.aborted) {
|
|
17351
17451
|
break;
|
|
17352
17452
|
}
|
|
@@ -18145,7 +18245,7 @@ var Mediabunny = (() => {
|
|
|
18145
18245
|
result2.offset -= this._offset;
|
|
18146
18246
|
return result2;
|
|
18147
18247
|
};
|
|
18148
|
-
if (result
|
|
18248
|
+
if (isThenable(result)) {
|
|
18149
18249
|
return result.then(processResult);
|
|
18150
18250
|
} else {
|
|
18151
18251
|
return processResult(result);
|
|
@@ -19430,7 +19530,7 @@ var Mediabunny = (() => {
|
|
|
19430
19530
|
/** @internal */
|
|
19431
19531
|
async _getMajorBrand(input) {
|
|
19432
19532
|
let slice = input._reader.requestSlice(0, 12);
|
|
19433
|
-
if (slice
|
|
19533
|
+
if (isThenable(slice)) slice = await slice;
|
|
19434
19534
|
if (!slice) return null;
|
|
19435
19535
|
slice.skip(4);
|
|
19436
19536
|
const fourCc = readAscii(slice, 4);
|
|
@@ -19451,11 +19551,33 @@ var Mediabunny = (() => {
|
|
|
19451
19551
|
if (majorBrand !== null) {
|
|
19452
19552
|
return majorBrand !== "qt ";
|
|
19453
19553
|
}
|
|
19454
|
-
let
|
|
19455
|
-
|
|
19456
|
-
|
|
19457
|
-
|
|
19458
|
-
|
|
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;
|
|
19459
19581
|
}
|
|
19460
19582
|
get name() {
|
|
19461
19583
|
return "MP4";
|
|
@@ -19481,7 +19603,7 @@ var Mediabunny = (() => {
|
|
|
19481
19603
|
/** @internal */
|
|
19482
19604
|
async isSupportedEBMLOfDocType(input, desiredDocType) {
|
|
19483
19605
|
let headerSlice = input._reader.requestSlice(0, MAX_HEADER_SIZE);
|
|
19484
|
-
if (headerSlice
|
|
19606
|
+
if (isThenable(headerSlice)) headerSlice = await headerSlice;
|
|
19485
19607
|
if (!headerSlice) return false;
|
|
19486
19608
|
const varIntSize = readVarIntSize(headerSlice);
|
|
19487
19609
|
if (varIntSize === null) {
|
|
@@ -19499,7 +19621,7 @@ var Mediabunny = (() => {
|
|
|
19499
19621
|
return false;
|
|
19500
19622
|
}
|
|
19501
19623
|
let dataSlice = input._reader.requestSlice(headerSlice.filePos, dataSize);
|
|
19502
|
-
if (dataSlice
|
|
19624
|
+
if (isThenable(dataSlice)) dataSlice = await dataSlice;
|
|
19503
19625
|
if (!dataSlice) return false;
|
|
19504
19626
|
const startPos = headerSlice.filePos;
|
|
19505
19627
|
while (dataSlice.filePos <= startPos + dataSize - MIN_HEADER_SIZE) {
|
|
@@ -19583,7 +19705,7 @@ var Mediabunny = (() => {
|
|
|
19583
19705
|
let currentPos = 0;
|
|
19584
19706
|
while (true) {
|
|
19585
19707
|
let slice2 = input._reader.requestSlice(currentPos, ID3_V2_HEADER_SIZE);
|
|
19586
|
-
if (slice2
|
|
19708
|
+
if (isThenable(slice2)) slice2 = await slice2;
|
|
19587
19709
|
if (!slice2) break;
|
|
19588
19710
|
const id3V2Header = readId3V2Header(slice2);
|
|
19589
19711
|
if (!id3V2Header) {
|
|
@@ -19598,7 +19720,7 @@ var Mediabunny = (() => {
|
|
|
19598
19720
|
const firstHeader = firstResult.header;
|
|
19599
19721
|
const xingOffset = getXingOffset(firstHeader.mpegVersionId, firstHeader.channel);
|
|
19600
19722
|
let slice = input._reader.requestSlice(firstResult.startPos + xingOffset, 4);
|
|
19601
|
-
if (slice
|
|
19723
|
+
if (isThenable(slice)) slice = await slice;
|
|
19602
19724
|
if (!slice) return false;
|
|
19603
19725
|
const word = readU32Be(slice);
|
|
19604
19726
|
const isXing = word === XING || word === INFO;
|
|
@@ -19635,7 +19757,7 @@ var Mediabunny = (() => {
|
|
|
19635
19757
|
/** @internal */
|
|
19636
19758
|
async _canReadInput(input) {
|
|
19637
19759
|
let slice = input._reader.requestSlice(0, 12);
|
|
19638
|
-
if (slice
|
|
19760
|
+
if (isThenable(slice)) slice = await slice;
|
|
19639
19761
|
if (!slice) return false;
|
|
19640
19762
|
const riffType = readAscii(slice, 4);
|
|
19641
19763
|
if (riffType !== "RIFF" && riffType !== "RIFX" && riffType !== "RF64") {
|
|
@@ -19660,7 +19782,7 @@ var Mediabunny = (() => {
|
|
|
19660
19782
|
/** @internal */
|
|
19661
19783
|
async _canReadInput(input) {
|
|
19662
19784
|
let slice = input._reader.requestSlice(0, 4);
|
|
19663
|
-
if (slice
|
|
19785
|
+
if (isThenable(slice)) slice = await slice;
|
|
19664
19786
|
if (!slice) return false;
|
|
19665
19787
|
return readAscii(slice, 4) === "OggS";
|
|
19666
19788
|
}
|
|
@@ -19681,7 +19803,7 @@ var Mediabunny = (() => {
|
|
|
19681
19803
|
let currentPos = 0;
|
|
19682
19804
|
while (true) {
|
|
19683
19805
|
let slice2 = input._reader.requestSlice(currentPos, ID3_V2_HEADER_SIZE);
|
|
19684
|
-
if (slice2
|
|
19806
|
+
if (isThenable(slice2)) slice2 = await slice2;
|
|
19685
19807
|
if (!slice2) break;
|
|
19686
19808
|
const id3V2Header = readId3V2Header(slice2);
|
|
19687
19809
|
if (!id3V2Header) {
|
|
@@ -19690,7 +19812,7 @@ var Mediabunny = (() => {
|
|
|
19690
19812
|
currentPos = slice2.filePos + id3V2Header.size;
|
|
19691
19813
|
}
|
|
19692
19814
|
let slice = input._reader.requestSlice(currentPos, 4);
|
|
19693
|
-
if (slice
|
|
19815
|
+
if (isThenable(slice)) slice = await slice;
|
|
19694
19816
|
if (!slice) return false;
|
|
19695
19817
|
return readAscii(slice, 4) === "fLaC";
|
|
19696
19818
|
}
|
|
@@ -19711,7 +19833,7 @@ var Mediabunny = (() => {
|
|
|
19711
19833
|
let currentPos = 0;
|
|
19712
19834
|
while (true) {
|
|
19713
19835
|
let slice2 = input._reader.requestSlice(currentPos, ID3_V2_HEADER_SIZE);
|
|
19714
|
-
if (slice2
|
|
19836
|
+
if (isThenable(slice2)) slice2 = await slice2;
|
|
19715
19837
|
if (!slice2) break;
|
|
19716
19838
|
const id3V2Header = readId3V2Header(slice2);
|
|
19717
19839
|
if (!id3V2Header) {
|
|
@@ -19724,7 +19846,7 @@ var Mediabunny = (() => {
|
|
|
19724
19846
|
MIN_ADTS_FRAME_HEADER_SIZE,
|
|
19725
19847
|
MAX_ADTS_FRAME_HEADER_SIZE
|
|
19726
19848
|
);
|
|
19727
|
-
if (slice
|
|
19849
|
+
if (isThenable(slice)) slice = await slice;
|
|
19728
19850
|
if (!slice) return false;
|
|
19729
19851
|
const firstHeader = readAdtsFrameHeader(slice);
|
|
19730
19852
|
if (!firstHeader) {
|
|
@@ -19736,7 +19858,7 @@ var Mediabunny = (() => {
|
|
|
19736
19858
|
MIN_ADTS_FRAME_HEADER_SIZE,
|
|
19737
19859
|
MAX_ADTS_FRAME_HEADER_SIZE
|
|
19738
19860
|
);
|
|
19739
|
-
if (slice
|
|
19861
|
+
if (isThenable(slice)) slice = await slice;
|
|
19740
19862
|
if (!slice) return false;
|
|
19741
19863
|
const secondHeader = readAdtsFrameHeader(slice);
|
|
19742
19864
|
if (!secondHeader) {
|
|
@@ -19760,7 +19882,7 @@ var Mediabunny = (() => {
|
|
|
19760
19882
|
async _canReadInput(input) {
|
|
19761
19883
|
const lengthToCheck = TS_PACKET_SIZE + 16 + 1;
|
|
19762
19884
|
let slice = input._reader.requestSlice(0, lengthToCheck);
|
|
19763
|
-
if (slice
|
|
19885
|
+
if (isThenable(slice)) slice = await slice;
|
|
19764
19886
|
if (!slice) return false;
|
|
19765
19887
|
const bytes2 = readBytes(slice, lengthToCheck);
|
|
19766
19888
|
if (bytes2[0] === 71 && bytes2[TS_PACKET_SIZE] === 71) {
|
|
@@ -19787,7 +19909,7 @@ var Mediabunny = (() => {
|
|
|
19787
19909
|
/** @internal */
|
|
19788
19910
|
async _canReadInput(input) {
|
|
19789
19911
|
let slice = input._reader.requestSlice(0, 7);
|
|
19790
|
-
if (slice
|
|
19912
|
+
if (isThenable(slice)) slice = await slice;
|
|
19791
19913
|
if (!slice) return false;
|
|
19792
19914
|
const isM3u8 = readAscii(slice, 7) === "#EXTM3U";
|
|
19793
19915
|
if (!isM3u8) {
|
|
@@ -20517,7 +20639,7 @@ var Mediabunny = (() => {
|
|
|
20517
20639
|
let dataPlanes;
|
|
20518
20640
|
if (this._data instanceof VideoSampleResource) {
|
|
20519
20641
|
let result = this._data.getDataPlanes();
|
|
20520
|
-
if (result
|
|
20642
|
+
if (isThenable(result)) result = await result;
|
|
20521
20643
|
if (!Array.isArray(result) || result.some((x) => !(x.data instanceof Uint8Array) || !Number.isInteger(x.stride) || x.stride < 0)) {
|
|
20522
20644
|
throw new TypeError(
|
|
20523
20645
|
'getDataPlanes() must return an array of objects with a Uint8Array "data" property and a non-negative integer "stride" property.'
|
|
@@ -20610,7 +20732,7 @@ var Mediabunny = (() => {
|
|
|
20610
20732
|
);
|
|
20611
20733
|
}
|
|
20612
20734
|
const planes = this._data.getDataPlanes();
|
|
20613
|
-
if (planes
|
|
20735
|
+
if (isThenable(planes)) {
|
|
20614
20736
|
throw new Error(
|
|
20615
20737
|
"Cannot convert a VideoSampleResource-backed VideoSample to VideoFrame if getDataPlanes() returns a promise."
|
|
20616
20738
|
);
|
|
@@ -20990,7 +21112,7 @@ var Mediabunny = (() => {
|
|
|
20990
21112
|
};
|
|
20991
21113
|
for (const transformer of registeredVideoSampleTransformers) {
|
|
20992
21114
|
let result = transformer(this, description);
|
|
20993
|
-
if (result
|
|
21115
|
+
if (isThenable(result)) result = await result;
|
|
20994
21116
|
if (result !== null) {
|
|
20995
21117
|
return result;
|
|
20996
21118
|
}
|
|
@@ -24129,8 +24251,11 @@ var Mediabunny = (() => {
|
|
|
24129
24251
|
/** @internal */
|
|
24130
24252
|
async _createDecoder(onSample, onError) {
|
|
24131
24253
|
if (!await this._track.canDecode()) {
|
|
24254
|
+
if (typeof VideoDecoder === "undefined") {
|
|
24255
|
+
throw new Error(missingWebCodecsClassMessage("VideoDecoder"));
|
|
24256
|
+
}
|
|
24132
24257
|
throw new Error(
|
|
24133
|
-
"This video track cannot be decoded
|
|
24258
|
+
"This video track cannot be decoded in this environment. Make sure to check decodability before using a track."
|
|
24134
24259
|
);
|
|
24135
24260
|
}
|
|
24136
24261
|
const codec = await this._track.getCodec();
|
|
@@ -24662,8 +24787,11 @@ var Mediabunny = (() => {
|
|
|
24662
24787
|
/** @internal */
|
|
24663
24788
|
async _createDecoder(onSample, onError) {
|
|
24664
24789
|
if (!await this._track.canDecode()) {
|
|
24790
|
+
if (typeof AudioDecoder === "undefined") {
|
|
24791
|
+
throw new Error(missingWebCodecsClassMessage("AudioDecoder"));
|
|
24792
|
+
}
|
|
24665
24793
|
throw new Error(
|
|
24666
|
-
"This audio track cannot be decoded
|
|
24794
|
+
"This audio track cannot be decoded in this environment. Make sure to check decodability before using a track."
|
|
24667
24795
|
);
|
|
24668
24796
|
}
|
|
24669
24797
|
const codec = await this._track.getCodec();
|
|
@@ -25093,7 +25221,7 @@ var Mediabunny = (() => {
|
|
|
25093
25221
|
}
|
|
25094
25222
|
};
|
|
25095
25223
|
var requireSync = (value, getterName, asyncName) => {
|
|
25096
|
-
if (value
|
|
25224
|
+
if (isThenable(value)) {
|
|
25097
25225
|
throw new Error(
|
|
25098
25226
|
`'${getterName}' is deprecated and not available synchronously for this track. Use the preferred '${asyncName}()' instead.`
|
|
25099
25227
|
);
|
|
@@ -25112,7 +25240,7 @@ var Mediabunny = (() => {
|
|
|
25112
25240
|
return result2;
|
|
25113
25241
|
};
|
|
25114
25242
|
const result = predicate(track);
|
|
25115
|
-
if (result
|
|
25243
|
+
if (isThenable(result)) {
|
|
25116
25244
|
return result.then(handle);
|
|
25117
25245
|
}
|
|
25118
25246
|
return handle(result);
|
|
@@ -25557,7 +25685,7 @@ var Mediabunny = (() => {
|
|
|
25557
25685
|
return bool;
|
|
25558
25686
|
};
|
|
25559
25687
|
const result = query.filter(track);
|
|
25560
|
-
if (result
|
|
25688
|
+
if (isThenable(result)) {
|
|
25561
25689
|
return result.then(handle);
|
|
25562
25690
|
} else {
|
|
25563
25691
|
return handle(result);
|
|
@@ -25573,7 +25701,7 @@ var Mediabunny = (() => {
|
|
|
25573
25701
|
return value;
|
|
25574
25702
|
};
|
|
25575
25703
|
const result = query.sortBy(track);
|
|
25576
|
-
if (result
|
|
25704
|
+
if (isThenable(result)) {
|
|
25577
25705
|
return result.then(handle);
|
|
25578
25706
|
} else {
|
|
25579
25707
|
return handle(result);
|
|
@@ -25591,7 +25719,7 @@ var Mediabunny = (() => {
|
|
|
25591
25719
|
}
|
|
25592
25720
|
return queryB?.filter?.(track) ?? true;
|
|
25593
25721
|
};
|
|
25594
|
-
if (resultA
|
|
25722
|
+
if (isThenable(resultA)) {
|
|
25595
25723
|
return resultA.then(handleResultA);
|
|
25596
25724
|
} else {
|
|
25597
25725
|
return handleResultA(resultA);
|
|
@@ -25606,7 +25734,7 @@ var Mediabunny = (() => {
|
|
|
25606
25734
|
...Array.isArray(resultB2) ? resultB2 : [resultB2]
|
|
25607
25735
|
];
|
|
25608
25736
|
};
|
|
25609
|
-
if (resultA
|
|
25737
|
+
if (isThenable(resultA) || isThenable(resultB)) {
|
|
25610
25738
|
return Promise.all([resultA, resultB]).then(([resultA2, resultB2]) => {
|
|
25611
25739
|
return join(resultA2, resultB2);
|
|
25612
25740
|
});
|
|
@@ -25620,7 +25748,7 @@ var Mediabunny = (() => {
|
|
|
25620
25748
|
let matched = tracks;
|
|
25621
25749
|
if (query?.filter) {
|
|
25622
25750
|
const filterMatches = tracks.map((t) => query.filter(t));
|
|
25623
|
-
const hasAsyncFilter = filterMatches.some((x) => x
|
|
25751
|
+
const hasAsyncFilter = filterMatches.some((x) => isThenable(x));
|
|
25624
25752
|
if (hasAsyncFilter) {
|
|
25625
25753
|
const resolvedFilterMatches = await Promise.all(filterMatches);
|
|
25626
25754
|
matched = tracks.filter((_, i) => resolvedFilterMatches[i]);
|
|
@@ -25632,7 +25760,7 @@ var Mediabunny = (() => {
|
|
|
25632
25760
|
return matched;
|
|
25633
25761
|
}
|
|
25634
25762
|
const sortValues = matched.map((t) => query.sortBy(t));
|
|
25635
|
-
const hasAsyncSort = sortValues.some((x) => x
|
|
25763
|
+
const hasAsyncSort = sortValues.some((x) => isThenable(x));
|
|
25636
25764
|
const resolvedSortValues = hasAsyncSort ? await Promise.all(sortValues) : sortValues;
|
|
25637
25765
|
return matched.map((track, i) => ({ track, sortValue: resolvedSortValues[i] })).sort((a, b) => {
|
|
25638
25766
|
const aValues = Array.isArray(a.sortValue) ? a.sortValue : [a.sortValue];
|
|
@@ -26232,7 +26360,7 @@ var Mediabunny = (() => {
|
|
|
26232
26360
|
}
|
|
26233
26361
|
const end = start + length;
|
|
26234
26362
|
const result = this.source._read(start, end, DEFAULT_MIN_READ_POSITION, DEFAULT_MAX_READ_POSITION);
|
|
26235
|
-
if (result
|
|
26363
|
+
if (isThenable(result)) {
|
|
26236
26364
|
return result.then((x) => {
|
|
26237
26365
|
if (!x) {
|
|
26238
26366
|
return null;
|
|
@@ -26270,7 +26398,7 @@ var Mediabunny = (() => {
|
|
|
26270
26398
|
clamp(this.fileSizeNonStrict - start, minLength, maxLength)
|
|
26271
26399
|
);
|
|
26272
26400
|
};
|
|
26273
|
-
if (promisedAttempt
|
|
26401
|
+
if (isThenable(promisedAttempt)) {
|
|
26274
26402
|
return promisedAttempt.then(handleAttempt);
|
|
26275
26403
|
} else {
|
|
26276
26404
|
return handleAttempt(promisedAttempt);
|
|
@@ -26290,7 +26418,7 @@ var Mediabunny = (() => {
|
|
|
26290
26418
|
return this.requestSlice(0, this.fileSizeNonStrict);
|
|
26291
26419
|
}
|
|
26292
26420
|
let slice = this.requestSliceRange(currentSize, 0, CHUNK_SIZE);
|
|
26293
|
-
if (slice
|
|
26421
|
+
if (isThenable(slice)) slice = await slice;
|
|
26294
26422
|
if (!slice || slice.length === 0) {
|
|
26295
26423
|
break;
|
|
26296
26424
|
}
|
|
@@ -30547,8 +30675,8 @@ var Mediabunny = (() => {
|
|
|
30547
30675
|
}
|
|
30548
30676
|
decoderConfig.description = buildAacAudioSpecificConfig({
|
|
30549
30677
|
objectType: adtsFrame.objectType,
|
|
30550
|
-
sampleRate,
|
|
30551
|
-
numberOfChannels
|
|
30678
|
+
outputSampleRate: sampleRate,
|
|
30679
|
+
outputNumberOfChannels: numberOfChannels
|
|
30552
30680
|
});
|
|
30553
30681
|
requiresAdtsStripping = true;
|
|
30554
30682
|
}
|
|
@@ -31984,8 +32112,8 @@ var Mediabunny = (() => {
|
|
|
31984
32112
|
}
|
|
31985
32113
|
decoderConfig.description = buildAacAudioSpecificConfig({
|
|
31986
32114
|
objectType: adtsFrame.objectType,
|
|
31987
|
-
sampleRate,
|
|
31988
|
-
numberOfChannels
|
|
32115
|
+
outputSampleRate: sampleRate,
|
|
32116
|
+
outputNumberOfChannels: numberOfChannels
|
|
31989
32117
|
});
|
|
31990
32118
|
requiresAdtsStripping = true;
|
|
31991
32119
|
}
|
|
@@ -34319,7 +34447,7 @@ ${cue.notes ?? ""}`;
|
|
|
34319
34447
|
let samplesToEncode;
|
|
34320
34448
|
if (config.transform?.process) {
|
|
34321
34449
|
let processed = config.transform.process(videoSample);
|
|
34322
|
-
if (processed
|
|
34450
|
+
if (isThenable(processed)) {
|
|
34323
34451
|
processed = await processed;
|
|
34324
34452
|
}
|
|
34325
34453
|
if (processed === null) {
|
|
@@ -34539,14 +34667,14 @@ ${cue.notes ?? ""}`;
|
|
|
34539
34667
|
}
|
|
34540
34668
|
if (!selected) {
|
|
34541
34669
|
if (typeof VideoEncoder === "undefined") {
|
|
34542
|
-
throw new Error("VideoEncoder
|
|
34670
|
+
throw new Error(missingWebCodecsClassMessage("VideoEncoder"));
|
|
34543
34671
|
}
|
|
34544
34672
|
const firstConfig = candidates[0].config;
|
|
34545
34673
|
const rateControls = candidates.map(
|
|
34546
34674
|
({ config, quantizer }) => quantizer !== null ? `quantizer ${quantizer}` : `${config.bitrate} bps`
|
|
34547
34675
|
);
|
|
34548
34676
|
throw new Error(
|
|
34549
|
-
`This specific encoder configuration (${firstConfig.codec}, ${rateControls.join(" / ")}, ${firstConfig.width}x${firstConfig.height}, hardware acceleration: ${firstConfig.hardwareAcceleration ?? "no-preference"}) is not supported
|
|
34677
|
+
`This specific encoder configuration (${firstConfig.codec}, ${rateControls.join(" / ")}, ${firstConfig.width}x${firstConfig.height}, hardware acceleration: ${firstConfig.hardwareAcceleration ?? "no-preference"}) is not supported in this environment. Consider using another codec or changing your video parameters.`
|
|
34550
34678
|
);
|
|
34551
34679
|
}
|
|
34552
34680
|
const encoderConfig = selected.config;
|
|
@@ -35207,7 +35335,7 @@ ${cue.notes ?? ""}`;
|
|
|
35207
35335
|
});
|
|
35208
35336
|
} else {
|
|
35209
35337
|
throw new Error(
|
|
35210
|
-
"When no explicit frame rate is set, MediaStreamTrackProcessor is required; but it's not
|
|
35338
|
+
"When no explicit frame rate is set, MediaStreamTrackProcessor is required; but it's not available in this environment."
|
|
35211
35339
|
);
|
|
35212
35340
|
}
|
|
35213
35341
|
}
|
|
@@ -35386,7 +35514,7 @@ ${cue.notes ?? ""}`;
|
|
|
35386
35514
|
if (config.transform?.process) {
|
|
35387
35515
|
try {
|
|
35388
35516
|
let processed = config.transform.process(audioSample);
|
|
35389
|
-
if (processed
|
|
35517
|
+
if (isThenable(processed)) {
|
|
35390
35518
|
processed = await processed;
|
|
35391
35519
|
}
|
|
35392
35520
|
if (processed === null) {
|
|
@@ -35588,7 +35716,7 @@ ${cue.notes ?? ""}`;
|
|
|
35588
35716
|
this.initPcmEncoder();
|
|
35589
35717
|
} else {
|
|
35590
35718
|
if (typeof AudioEncoder === "undefined") {
|
|
35591
|
-
throw new Error("AudioEncoder
|
|
35719
|
+
throw new Error(missingWebCodecsClassMessage("AudioEncoder"));
|
|
35592
35720
|
}
|
|
35593
35721
|
let supported;
|
|
35594
35722
|
try {
|
|
@@ -35599,7 +35727,7 @@ ${cue.notes ?? ""}`;
|
|
|
35599
35727
|
}
|
|
35600
35728
|
if (!supported) {
|
|
35601
35729
|
throw new Error(
|
|
35602
|
-
`This specific encoder configuration (${encoderConfig.codec}, ${encoderConfig.bitrate} bps, ${encoderConfig.numberOfChannels} channels, ${encoderConfig.sampleRate} Hz) is not supported
|
|
35730
|
+
`This specific encoder configuration (${encoderConfig.codec}, ${encoderConfig.bitrate} bps, ${encoderConfig.numberOfChannels} channels, ${encoderConfig.sampleRate} Hz) is not supported in this environment. Consider using another codec or changing your audio parameters.`
|
|
35603
35731
|
);
|
|
35604
35732
|
}
|
|
35605
35733
|
const stack = new Error("Encoding error").stack;
|
|
@@ -35619,8 +35747,8 @@ ${cue.notes ?? ""}`;
|
|
|
35619
35747
|
const objectType = Number(last(encoderConfig.codec.split(".")));
|
|
35620
35748
|
meta.decoderConfig.description = buildAacAudioSpecificConfig({
|
|
35621
35749
|
objectType,
|
|
35622
|
-
|
|
35623
|
-
|
|
35750
|
+
outputNumberOfChannels: meta.decoderConfig.numberOfChannels,
|
|
35751
|
+
outputSampleRate: meta.decoderConfig.sampleRate
|
|
35624
35752
|
});
|
|
35625
35753
|
}
|
|
35626
35754
|
}
|
|
@@ -38200,7 +38328,7 @@ ${cue.notes ?? ""}`;
|
|
|
38200
38328
|
throw new TypeError(errorMessage);
|
|
38201
38329
|
}
|
|
38202
38330
|
const rootTargetResult = this._getRootTarget();
|
|
38203
|
-
if (rootTargetResult
|
|
38331
|
+
if (isThenable(rootTargetResult)) {
|
|
38204
38332
|
throw new TypeError(errorMessage);
|
|
38205
38333
|
}
|
|
38206
38334
|
return rootTargetResult;
|
|
@@ -38215,7 +38343,7 @@ ${cue.notes ?? ""}`;
|
|
|
38215
38343
|
}
|
|
38216
38344
|
return result2;
|
|
38217
38345
|
};
|
|
38218
|
-
if (result
|
|
38346
|
+
if (isThenable(result)) {
|
|
38219
38347
|
return result.then(handleResult);
|
|
38220
38348
|
} else {
|
|
38221
38349
|
return handleResult(result);
|
|
@@ -38285,7 +38413,7 @@ ${cue.notes ?? ""}`;
|
|
|
38285
38413
|
this._rootTarget = target;
|
|
38286
38414
|
return target;
|
|
38287
38415
|
};
|
|
38288
|
-
if (result
|
|
38416
|
+
if (isThenable(result)) {
|
|
38289
38417
|
return this._rootTargetPromise = result.then(handleResult);
|
|
38290
38418
|
} else {
|
|
38291
38419
|
return handleResult(result);
|