@svta/cml-iso-bmff 1.0.0-alpha.9 → 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -361,7 +361,7 @@ var IsoBoxReadableStream = class extends ReadableStream {
361
361
  * @param boxes - The boxes to stream.
362
362
  * @param config - The configuration for the stream.
363
363
  */
364
- constructor(boxes, config = {}) {
364
+ constructor(boxes, config) {
365
365
  const iterator = boxes[Symbol.iterator]();
366
366
  const cfg = createWriterConfig(config);
367
367
  function pull(controller) {
@@ -394,7 +394,7 @@ var IsoBoxReadableStream = class extends ReadableStream {
394
394
  *
395
395
  * @public
396
396
  */
397
- function createIsoBoxReadableStream(boxes, config = {}) {
397
+ function createIsoBoxReadableStream(boxes, config) {
398
398
  return new IsoBoxReadableStream(boxes, config);
399
399
  }
400
400
 
@@ -2288,6 +2288,80 @@ function readVtte(_) {
2288
2288
  return { type: "vtte" };
2289
2289
  }
2290
2290
 
2291
+ //#endregion
2292
+ //#region src/readers/defaultReaderConfig.ts
2293
+ /**
2294
+ * Create a default reader configuration with all available readers pre-configured.
2295
+ *
2296
+ * @returns An `IsoBoxReadViewConfig` with all available readers pre-configured
2297
+ *
2298
+ * @public
2299
+ */
2300
+ function defaultReaderConfig() {
2301
+ return { readers: {
2302
+ ardi: readArdi,
2303
+ avc1: readAvc1,
2304
+ avc2: readAvc2,
2305
+ avc3: readAvc3,
2306
+ avc4: readAvc4,
2307
+ ctts: readCtts,
2308
+ dref: readDref,
2309
+ elng: readElng,
2310
+ elst: readElst,
2311
+ emsg: readEmsg,
2312
+ enca: readEnca,
2313
+ encv: readEncv,
2314
+ free: readFree,
2315
+ frma: readFrma,
2316
+ ftyp: readFtyp,
2317
+ hdlr: readHdlr,
2318
+ hev1: readHev1,
2319
+ hvc1: readHvc1,
2320
+ iden: readIden,
2321
+ imda: readImda,
2322
+ kind: readKind,
2323
+ labl: readLabl,
2324
+ mdat: readMdat,
2325
+ mdhd: readMdhd,
2326
+ mehd: readMehd,
2327
+ meta: readMeta,
2328
+ mfhd: readMfhd,
2329
+ mfro: readMfro,
2330
+ mp4a: readMp4a,
2331
+ mvhd: readMvhd,
2332
+ payl: readPayl,
2333
+ prft: readPrft,
2334
+ prsl: readPrsl,
2335
+ pssh: readPssh,
2336
+ schm: readSchm,
2337
+ sdtp: readSdtp,
2338
+ sidx: readSidx,
2339
+ skip: readSkip,
2340
+ smhd: readSmhd,
2341
+ ssix: readSsix,
2342
+ sthd: readSthd,
2343
+ stsd: readStsd,
2344
+ stss: readStss,
2345
+ sttg: readSttg,
2346
+ stts: readStts,
2347
+ styp: readStyp,
2348
+ subs: readSubs,
2349
+ tenc: readTenc,
2350
+ tfdt: readTfdt,
2351
+ tfhd: readTfhd,
2352
+ tfra: readTfra,
2353
+ tkhd: readTkhd,
2354
+ trex: readTrex,
2355
+ trun: readTrun,
2356
+ "url ": readUrl,
2357
+ "urn ": readUrn,
2358
+ vlab: readVlab,
2359
+ vmhd: readVmhd,
2360
+ vttC: readVttC,
2361
+ vtte: readVtte
2362
+ } };
2363
+ }
2364
+
2291
2365
  //#endregion
2292
2366
  //#region src/utils/fourCcToUint32.ts
2293
2367
  /**
@@ -2339,45 +2413,6 @@ function writeArdi(box) {
2339
2413
  return writer;
2340
2414
  }
2341
2415
 
2342
- //#endregion
2343
- //#region src/writers/writeAudioSampleEntryBox.ts
2344
- /**
2345
- * Write an `AudioSampleEntryBox` to an `IsoBoxWriteView`.
2346
- *
2347
- * ISO/IEC 14496-12:2012 - 12.2.3 Audio Sample Entry
2348
- *
2349
- * @param box - The `AudioSampleEntryBox` fields to write
2350
- * @param config - The `IsoBoxWriteViewConfig` to use
2351
- *
2352
- * @returns An `IsoBoxWriteView` containing the encoded box
2353
- *
2354
- * @public
2355
- */
2356
- function writeAudioSampleEntryBox(box, config) {
2357
- const headerSize = 8;
2358
- const reserved1Size = 6;
2359
- const dataReferenceIndexSize = 2;
2360
- const reserved2Size = 8;
2361
- const channelcountSize = 2;
2362
- const samplesizeSize = 2;
2363
- const preDefinedSize = 2;
2364
- const reserved3Size = 2;
2365
- const samplerateSize = 4;
2366
- const { bytes, size } = writeChildBoxes(box.boxes, config);
2367
- const totalSize = headerSize + reserved1Size + dataReferenceIndexSize + reserved2Size + channelcountSize + samplesizeSize + preDefinedSize + reserved3Size + samplerateSize + size;
2368
- const writer = new IsoBoxWriteView(box.type, totalSize);
2369
- writer.writeArray(box.reserved1, UINT, 1, 6);
2370
- writer.writeUint(box.dataReferenceIndex, 2);
2371
- writer.writeArray(box.reserved2, UINT, 4, 2);
2372
- writer.writeUint(box.channelcount, 2);
2373
- writer.writeUint(box.samplesize, 2);
2374
- writer.writeUint(box.preDefined, 2);
2375
- writer.writeUint(box.reserved3, 2);
2376
- writer.writeTemplate(box.samplerate, 4);
2377
- writer.writeBytes(bytes);
2378
- return writer;
2379
- }
2380
-
2381
2416
  //#endregion
2382
2417
  //#region src/writers/writeVisualSampleEntryBox.ts
2383
2418
  /**
@@ -2644,6 +2679,45 @@ function writeEmsg(box) {
2644
2679
  return writer;
2645
2680
  }
2646
2681
 
2682
+ //#endregion
2683
+ //#region src/writers/writeAudioSampleEntryBox.ts
2684
+ /**
2685
+ * Write an `AudioSampleEntryBox` to an `IsoBoxWriteView`.
2686
+ *
2687
+ * ISO/IEC 14496-12:2012 - 12.2.3 Audio Sample Entry
2688
+ *
2689
+ * @param box - The `AudioSampleEntryBox` fields to write
2690
+ * @param config - The `IsoBoxWriteViewConfig` to use
2691
+ *
2692
+ * @returns An `IsoBoxWriteView` containing the encoded box
2693
+ *
2694
+ * @public
2695
+ */
2696
+ function writeAudioSampleEntryBox(box, config) {
2697
+ const headerSize = 8;
2698
+ const reserved1Size = 6;
2699
+ const dataReferenceIndexSize = 2;
2700
+ const reserved2Size = 8;
2701
+ const channelcountSize = 2;
2702
+ const samplesizeSize = 2;
2703
+ const preDefinedSize = 2;
2704
+ const reserved3Size = 2;
2705
+ const samplerateSize = 4;
2706
+ const { bytes, size } = writeChildBoxes(box.boxes, config);
2707
+ const totalSize = headerSize + reserved1Size + dataReferenceIndexSize + reserved2Size + channelcountSize + samplesizeSize + preDefinedSize + reserved3Size + samplerateSize + size;
2708
+ const writer = new IsoBoxWriteView(box.type, totalSize);
2709
+ writer.writeArray(box.reserved1, UINT, 1, 6);
2710
+ writer.writeUint(box.dataReferenceIndex, 2);
2711
+ writer.writeArray(box.reserved2, UINT, 4, 2);
2712
+ writer.writeUint(box.channelcount, 2);
2713
+ writer.writeUint(box.samplesize, 2);
2714
+ writer.writeUint(box.preDefined, 2);
2715
+ writer.writeUint(box.reserved3, 2);
2716
+ writer.writeTemplate(box.samplerate, 4);
2717
+ writer.writeBytes(bytes);
2718
+ return writer;
2719
+ }
2720
+
2647
2721
  //#endregion
2648
2722
  //#region src/writers/writeEnca.ts
2649
2723
  /**
@@ -3355,6 +3429,31 @@ function writeSsix(box) {
3355
3429
  return writer;
3356
3430
  }
3357
3431
 
3432
+ //#endregion
3433
+ //#region src/writers/writeStco.ts
3434
+ /**
3435
+ * Write a `ChunkOffsetBox` to an `IsoBoxWriteView`.
3436
+ *
3437
+ * ISO/IEC 14496-12:2012 - 8.7.5 Chunk Offset Box
3438
+ *
3439
+ * @param box - The `ChunkOffsetBox` fields to write
3440
+ *
3441
+ * @returns An `IsoBoxWriteView` containing the encoded box
3442
+ *
3443
+ * @public
3444
+ */
3445
+ function writeStco(box) {
3446
+ const headerSize = 8;
3447
+ const fullBoxSize = 4;
3448
+ const entryCountSize = 4;
3449
+ const entriesSize = box.entryCount * 4;
3450
+ const writer = new IsoBoxWriteView("stco", headerSize + fullBoxSize + entryCountSize + entriesSize);
3451
+ writer.writeFullBox(box.version, box.flags);
3452
+ writer.writeUint(box.entryCount, 4);
3453
+ for (const offset of box.chunkOffset) writer.writeUint(offset, 4);
3454
+ return writer;
3455
+ }
3456
+
3358
3457
  //#endregion
3359
3458
  //#region src/writers/writeSthd.ts
3360
3459
  /**
@@ -3374,6 +3473,35 @@ function writeSthd(box) {
3374
3473
  return writer;
3375
3474
  }
3376
3475
 
3476
+ //#endregion
3477
+ //#region src/writers/writeStsc.ts
3478
+ /**
3479
+ * Write a `SampleToChunkBox` to an `IsoBoxWriteView`.
3480
+ *
3481
+ * ISO/IEC 14496-12:2012 - 8.7.4 Sample to Chunk Box
3482
+ *
3483
+ * @param box - The `SampleToChunkBox` fields to write
3484
+ *
3485
+ * @returns An `IsoBoxWriteView` containing the encoded box
3486
+ *
3487
+ * @public
3488
+ */
3489
+ function writeStsc(box) {
3490
+ const headerSize = 8;
3491
+ const fullBoxSize = 4;
3492
+ const entryCountSize = 4;
3493
+ const entriesSize = box.entryCount * 12;
3494
+ const writer = new IsoBoxWriteView("stsc", headerSize + fullBoxSize + entryCountSize + entriesSize);
3495
+ writer.writeFullBox(box.version, box.flags);
3496
+ writer.writeUint(box.entryCount, 4);
3497
+ for (const entry of box.entries) {
3498
+ writer.writeUint(entry.firstChunk, 4);
3499
+ writer.writeUint(entry.samplesPerChunk, 4);
3500
+ writer.writeUint(entry.sampleDescriptionIndex, 4);
3501
+ }
3502
+ return writer;
3503
+ }
3504
+
3377
3505
  //#endregion
3378
3506
  //#region src/writers/writeStsd.ts
3379
3507
  /**
@@ -3424,6 +3552,33 @@ function writeStss(box) {
3424
3552
  return writer;
3425
3553
  }
3426
3554
 
3555
+ //#endregion
3556
+ //#region src/writers/writeStsz.ts
3557
+ /**
3558
+ * Write a `SampleSizeBox` to an `IsoBoxWriteView`.
3559
+ *
3560
+ * ISO/IEC 14496-12:2012 - 8.7.3 Sample Size Box
3561
+ *
3562
+ * @param box - The `SampleSizeBox` fields to write
3563
+ *
3564
+ * @returns An `IsoBoxWriteView` containing the encoded box
3565
+ *
3566
+ * @public
3567
+ */
3568
+ function writeStsz(box) {
3569
+ const headerSize = 8;
3570
+ const fullBoxSize = 4;
3571
+ const sampleSizeFieldSize = 4;
3572
+ const sampleCountFieldSize = 4;
3573
+ const entrySizeSize = box.sampleSize === 0 ? box.sampleCount * 4 : 0;
3574
+ const writer = new IsoBoxWriteView("stsz", headerSize + fullBoxSize + sampleSizeFieldSize + sampleCountFieldSize + entrySizeSize);
3575
+ writer.writeFullBox(box.version, box.flags);
3576
+ writer.writeUint(box.sampleSize, 4);
3577
+ writer.writeUint(box.sampleCount, 4);
3578
+ if (box.sampleSize === 0 && box.entrySize) for (const size of box.entrySize) writer.writeUint(size, 4);
3579
+ return writer;
3580
+ }
3581
+
3427
3582
  //#endregion
3428
3583
  //#region src/writers/writeSttg.ts
3429
3584
  /**
@@ -3865,5 +4020,82 @@ function writeVtte(_) {
3865
4020
  }
3866
4021
 
3867
4022
  //#endregion
3868
- export { CONTAINERS, DATA, INT, IsoBoxFields, IsoBoxReadView, IsoBoxReadableStream, IsoBoxWriteView, STRING, TEMPLATE, UINT, UTF8, createAudioSampleEntryReader, createIsoBoxReadableStream, createVisualSampleEntryReader, filterIsoBoxes, findIsoBox, fourCcToUint32, isContainer, isFullBox, isIsoBoxType, readArdi, readAudioSampleEntryBox, readAvc1, readAvc2, readAvc3, readAvc4, readCtts, readDref, readElng, readElst, readEmsg, readEnca, readEncv, readFree, readFrma, readFtyp, readHdlr, readHev1, readHvc1, readIden, readImda, readIsoBoxes, readKind, readLabl, readMdat, readMdhd, readMehd, readMeta, readMfhd, readMfro, readMp4a, readMvhd, readPayl, readPrft, readPrsl, readPssh, readSchm, readSdtp, readSidx, readSkip, readSmhd, readSsix, readSthd, readStsd, readStss, readSttg, readStts, readStyp, readSubs, readTenc, readTfdt, readTfhd, readTfra, readTkhd, readTrex, readTrun, readUrl, readUrn, readVisualSampleEntryBox, readVlab, readVmhd, readVttC, readVtte, traverseIsoBoxes, writeArdi, writeAudioSampleEntryBox, writeAvc1, writeAvc2, writeAvc3, writeAvc4, writeCtts, writeDref, writeElng, writeElst, writeEmsg, writeEnca, writeEncv, writeFree, writeFrma, writeFtyp, writeHdlr, writeHev1, writeHvc1, writeIden, writeImda, writeIsoBox, writeIsoBoxes, writeKind, writeLabl, writeMdat, writeMdhd, writeMehd, writeMeta, writeMfhd, writeMfro, writeMp4a, writeMvhd, writePayl, writePrft, writePrsl, writePssh, writeSchm, writeSdtp, writeSidx, writeSkip, writeSmhd, writeSsix, writeSthd, writeStsd, writeStss, writeSttg, writeStts, writeStyp, writeSubs, writeTenc, writeTfdt, writeTfhd, writeTfra, writeTkhd, writeTrex, writeTrun, writeUrl, writeUrn, writeVisualSampleEntryBox, writeVlab, writeVmhd, writeVttC, writeVtte };
4023
+ //#region src/writers/defaultWriterConfig.ts
4024
+ /**
4025
+ * Create a default writer configuration with all available writers pre-configured.
4026
+ *
4027
+ * @returns An `IsoBoxWriteViewConfig` with all available writers pre-configured
4028
+ *
4029
+ * @public
4030
+ */
4031
+ function defaultWriterConfig() {
4032
+ return { writers: {
4033
+ ardi: writeArdi,
4034
+ avc1: writeAvc1,
4035
+ avc2: writeAvc2,
4036
+ avc3: writeAvc3,
4037
+ avc4: writeAvc4,
4038
+ ctts: writeCtts,
4039
+ dref: writeDref,
4040
+ elng: writeElng,
4041
+ elst: writeElst,
4042
+ emsg: writeEmsg,
4043
+ enca: writeEnca,
4044
+ encv: writeEncv,
4045
+ free: writeFree,
4046
+ frma: writeFrma,
4047
+ ftyp: writeFtyp,
4048
+ hdlr: writeHdlr,
4049
+ hev1: writeHev1,
4050
+ hvc1: writeHvc1,
4051
+ iden: writeIden,
4052
+ imda: writeImda,
4053
+ kind: writeKind,
4054
+ labl: writeLabl,
4055
+ mdat: writeMdat,
4056
+ mdhd: writeMdhd,
4057
+ mehd: writeMehd,
4058
+ meta: writeMeta,
4059
+ mfhd: writeMfhd,
4060
+ mfro: writeMfro,
4061
+ mp4a: writeMp4a,
4062
+ mvhd: writeMvhd,
4063
+ payl: writePayl,
4064
+ prft: writePrft,
4065
+ prsl: writePrsl,
4066
+ pssh: writePssh,
4067
+ schm: writeSchm,
4068
+ sdtp: writeSdtp,
4069
+ sidx: writeSidx,
4070
+ skip: writeSkip,
4071
+ smhd: writeSmhd,
4072
+ ssix: writeSsix,
4073
+ stco: writeStco,
4074
+ sthd: writeSthd,
4075
+ stsc: writeStsc,
4076
+ stsd: writeStsd,
4077
+ stss: writeStss,
4078
+ stsz: writeStsz,
4079
+ sttg: writeSttg,
4080
+ stts: writeStts,
4081
+ styp: writeStyp,
4082
+ subs: writeSubs,
4083
+ tenc: writeTenc,
4084
+ tfdt: writeTfdt,
4085
+ tfhd: writeTfhd,
4086
+ tfra: writeTfra,
4087
+ tkhd: writeTkhd,
4088
+ trex: writeTrex,
4089
+ trun: writeTrun,
4090
+ "url ": writeUrl,
4091
+ "urn ": writeUrn,
4092
+ vlab: writeVlab,
4093
+ vmhd: writeVmhd,
4094
+ vttC: writeVttC,
4095
+ vtte: writeVtte
4096
+ } };
4097
+ }
4098
+
4099
+ //#endregion
4100
+ export { CONTAINERS, DATA, INT, IsoBoxFields, IsoBoxReadView, IsoBoxReadableStream, IsoBoxWriteView, STRING, TEMPLATE, UINT, UTF8, createAudioSampleEntryReader, createIsoBoxReadableStream, createVisualSampleEntryReader, defaultReaderConfig, defaultWriterConfig, filterIsoBoxes, findIsoBox, fourCcToUint32, isContainer, isFullBox, isIsoBoxType, readArdi, readAudioSampleEntryBox, readAvc1, readAvc2, readAvc3, readAvc4, readCtts, readDref, readElng, readElst, readEmsg, readEnca, readEncv, readFree, readFrma, readFtyp, readHdlr, readHev1, readHvc1, readIden, readImda, readIsoBoxes, readKind, readLabl, readMdat, readMdhd, readMehd, readMeta, readMfhd, readMfro, readMp4a, readMvhd, readPayl, readPrft, readPrsl, readPssh, readSchm, readSdtp, readSidx, readSkip, readSmhd, readSsix, readSthd, readStsd, readStss, readSttg, readStts, readStyp, readSubs, readTenc, readTfdt, readTfhd, readTfra, readTkhd, readTrex, readTrun, readUrl, readUrn, readVisualSampleEntryBox, readVlab, readVmhd, readVttC, readVtte, traverseIsoBoxes, writeArdi, writeAudioSampleEntryBox, writeAvc1, writeAvc2, writeAvc3, writeAvc4, writeCtts, writeDref, writeElng, writeElst, writeEmsg, writeEnca, writeEncv, writeFree, writeFrma, writeFtyp, writeHdlr, writeHev1, writeHvc1, writeIden, writeImda, writeIsoBox, writeIsoBoxes, writeKind, writeLabl, writeMdat, writeMdhd, writeMehd, writeMeta, writeMfhd, writeMfro, writeMp4a, writeMvhd, writePayl, writePrft, writePrsl, writePssh, writeSchm, writeSdtp, writeSidx, writeSkip, writeSmhd, writeSsix, writeStco, writeSthd, writeStsc, writeStsd, writeStss, writeStsz, writeSttg, writeStts, writeStyp, writeSubs, writeTenc, writeTfdt, writeTfhd, writeTfra, writeTkhd, writeTrex, writeTrun, writeUrl, writeUrn, writeVisualSampleEntryBox, writeVlab, writeVmhd, writeVttC, writeVtte };
3869
4101
  //# sourceMappingURL=index.js.map