@remotion/media-parser 4.0.234 → 4.0.236

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.
Files changed (94) hide show
  1. package/dist/aac-codecprivate.d.ts +19 -0
  2. package/dist/aac-codecprivate.js +122 -0
  3. package/dist/add-avc-profile-to-track.d.ts +1 -1
  4. package/dist/boxes/iso-base-media/get-actual-number-of-channels.d.ts +13 -0
  5. package/dist/boxes/iso-base-media/get-actual-number-of-channels.js +22 -0
  6. package/dist/boxes/iso-base-media/make-track.js +16 -7
  7. package/dist/boxes/iso-base-media/meta/hdlr.d.ts +12 -0
  8. package/dist/boxes/iso-base-media/meta/hdlr.js +33 -0
  9. package/dist/boxes/iso-base-media/meta/ilst.d.ts +28 -0
  10. package/dist/boxes/iso-base-media/meta/ilst.js +86 -0
  11. package/dist/boxes/iso-base-media/meta/keys.d.ts +10 -0
  12. package/dist/boxes/iso-base-media/meta/keys.js +17 -0
  13. package/dist/boxes/iso-base-media/meta/list.d.ts +12 -0
  14. package/dist/boxes/iso-base-media/meta/list.js +33 -0
  15. package/dist/boxes/iso-base-media/moov/moov.d.ts +3 -1
  16. package/dist/boxes/iso-base-media/moov/moov.js +2 -1
  17. package/dist/boxes/iso-base-media/process-box.d.ts +5 -2
  18. package/dist/boxes/iso-base-media/process-box.js +66 -8
  19. package/dist/boxes/iso-base-media/stsd/keys.d.ts +15 -1
  20. package/dist/boxes/iso-base-media/stsd/keys.js +25 -12
  21. package/dist/boxes/iso-base-media/stsd/mebx.d.ts +3 -1
  22. package/dist/boxes/iso-base-media/stsd/mebx.js +2 -1
  23. package/dist/boxes/iso-base-media/stsd/samples.d.ts +5 -2
  24. package/dist/boxes/iso-base-media/stsd/samples.js +7 -2
  25. package/dist/boxes/iso-base-media/stsd/stsd.d.ts +3 -1
  26. package/dist/boxes/iso-base-media/stsd/stsd.js +2 -1
  27. package/dist/boxes/iso-base-media/trak/trak.d.ts +3 -1
  28. package/dist/boxes/iso-base-media/trak/trak.js +2 -1
  29. package/dist/boxes/riff/expect-riff-box.d.ts +1 -0
  30. package/dist/boxes/riff/expect-riff-box.js +1 -1
  31. package/dist/boxes/riff/get-tracks-from-avi.d.ts +2 -1
  32. package/dist/boxes/riff/get-tracks-from-avi.js +14 -8
  33. package/dist/boxes/riff/parse-box.d.ts +3 -1
  34. package/dist/boxes/riff/parse-box.js +38 -5
  35. package/dist/boxes/riff/parse-isft.d.ts +6 -0
  36. package/dist/boxes/riff/parse-isft.js +17 -0
  37. package/dist/boxes/riff/parse-movi.js +31 -20
  38. package/dist/boxes/riff/parse-riff-box.js +4 -0
  39. package/dist/boxes/riff/riff-box.d.ts +5 -1
  40. package/dist/boxes/webm/parse-ebml.js +2 -1
  41. package/dist/boxes/webm/parse-webm-header.d.ts +6 -1
  42. package/dist/boxes/webm/parse-webm-header.js +3 -1
  43. package/dist/boxes/webm/segments/all-segments.d.ts +42 -2
  44. package/dist/boxes/webm/segments/all-segments.js +28 -3
  45. package/dist/boxes/webm/segments/parse-children.d.ts +8 -3
  46. package/dist/boxes/webm/segments/parse-children.js +39 -4
  47. package/dist/boxes/webm/segments.d.ts +5 -2
  48. package/dist/boxes/webm/segments.js +23 -3
  49. package/dist/boxes/webm/traversal.d.ts +1 -0
  50. package/dist/boxes/webm/traversal.js +18 -2
  51. package/dist/buffer-iterator.d.ts +3 -0
  52. package/dist/buffer-iterator.js +23 -0
  53. package/dist/create/iso-base-media/codec-specific/mp4a.js +1 -17
  54. package/dist/create/iso-base-media/mp4-header.js +2 -1
  55. package/dist/emit-available-info.d.ts +1 -1
  56. package/dist/emit-available-info.js +17 -6
  57. package/dist/esm/index.mjs +992 -162
  58. package/dist/get-audio-codec.d.ts +1 -1
  59. package/dist/get-dimensions.d.ts +1 -1
  60. package/dist/get-duration.d.ts +1 -1
  61. package/dist/get-is-hdr.d.ts +1 -1
  62. package/dist/get-metadata.d.ts +7 -0
  63. package/dist/get-metadata.js +63 -0
  64. package/dist/get-tracks.d.ts +1 -1
  65. package/dist/get-tracks.js +1 -1
  66. package/dist/get-video-codec.d.ts +1 -1
  67. package/dist/has-all-info.d.ts +8 -3
  68. package/dist/has-all-info.js +21 -12
  69. package/dist/index.d.ts +6 -0
  70. package/dist/index.js +2 -0
  71. package/dist/metadata/get-metadata.d.ts +7 -0
  72. package/dist/metadata/get-metadata.js +16 -0
  73. package/dist/metadata/metadata-from-iso.d.ts +4 -0
  74. package/dist/metadata/metadata-from-iso.js +148 -0
  75. package/dist/metadata/metadata-from-matroska.d.ts +3 -0
  76. package/dist/metadata/metadata-from-matroska.js +53 -0
  77. package/dist/metadata/metadata-from-riff.d.ts +3 -0
  78. package/dist/metadata/metadata-from-riff.js +24 -0
  79. package/dist/options.d.ts +9 -3
  80. package/dist/parse-media.js +32 -29
  81. package/dist/parse-result.d.ts +3 -1
  82. package/dist/parse-video.d.ts +3 -1
  83. package/dist/parse-video.js +5 -3
  84. package/dist/parser-context.d.ts +1 -2
  85. package/dist/register-track.d.ts +1 -1
  86. package/dist/state/can-skip-tracks.d.ts +9 -0
  87. package/dist/state/can-skip-tracks.js +33 -0
  88. package/dist/state/has-tracks-section.d.ts +6 -0
  89. package/dist/state/has-tracks-section.js +21 -0
  90. package/dist/state/parser-state.d.ts +51 -0
  91. package/dist/state/parser-state.js +170 -0
  92. package/dist/version.d.ts +1 -1
  93. package/dist/version.js +1 -1
  94. package/package.json +9 -9
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseRiff = exports.parseRiffBody = void 0;
4
+ const get_tracks_1 = require("../../get-tracks");
5
+ const has_all_info_1 = require("../../has-all-info");
4
6
  const register_track_1 = require("../../register-track");
5
7
  const expect_riff_box_1 = require("./expect-riff-box");
6
8
  const get_tracks_from_avi_1 = require("./get-tracks-from-avi");
@@ -22,10 +24,8 @@ const continueAfterRiffBoxResult = ({ result, structure, iterator, maxOffset, op
22
24
  skipTo: null,
23
25
  });
24
26
  }
25
- if (result.type === 'complete') {
26
- if (result.box) {
27
- structure.boxes.push(result.box);
28
- }
27
+ if (result.type === 'complete' && result.box) {
28
+ structure.boxes.push(result.box);
29
29
  }
30
30
  return (0, exports.parseRiffBody)({ iterator, maxOffset, options, structure });
31
31
  };
@@ -37,6 +37,22 @@ const parseRiffBody = async ({ iterator, structure, maxOffset, options, }) => {
37
37
  options,
38
38
  structure,
39
39
  });
40
+ if (result.type === 'complete' && result.skipTo !== null) {
41
+ return {
42
+ status: 'incomplete',
43
+ skipTo: result.skipTo,
44
+ segments: structure,
45
+ continueParsing() {
46
+ return Promise.resolve(continueAfterRiffBoxResult({
47
+ iterator,
48
+ maxOffset,
49
+ options,
50
+ result,
51
+ structure,
52
+ }));
53
+ },
54
+ };
55
+ }
40
56
  if (result.type === 'incomplete') {
41
57
  return {
42
58
  status: 'incomplete',
@@ -57,6 +73,17 @@ const parseRiffBody = async ({ iterator, structure, maxOffset, options, }) => {
57
73
  continue;
58
74
  }
59
75
  structure.boxes.push(result.box);
76
+ // When parsing an AVI
77
+ if (result.box.type === 'list-box' && result.box.listType === 'hdrl') {
78
+ const tracks = (0, get_tracks_1.getTracks)(structure, options.parserState);
79
+ if (!tracks.videoTracks.some((t) => t.codec === get_tracks_from_avi_1.TO_BE_OVERRIDDEN_LATER)) {
80
+ options.parserState.tracks.setIsDone();
81
+ }
82
+ }
83
+ // When parsing a WAV
84
+ if (result.box.type === 'wave-format-box') {
85
+ options.parserState.tracks.setIsDone();
86
+ }
60
87
  if (result.box.type === 'strf-box-video' ||
61
88
  result.box.type === 'strf-box-audio') {
62
89
  const strh = (0, traversal_1.getStrhBox)(structure.boxes);
@@ -96,7 +123,7 @@ const parseRiffBody = async ({ iterator, structure, maxOffset, options, }) => {
96
123
  };
97
124
  };
98
125
  exports.parseRiffBody = parseRiffBody;
99
- const parseRiff = ({ iterator, options, }) => {
126
+ const parseRiff = ({ iterator, options, fields, }) => {
100
127
  const structure = { type: 'riff', boxes: [] };
101
128
  const riff = iterator.getByteString(4);
102
129
  if (riff !== 'RIFF') {
@@ -108,6 +135,12 @@ const parseRiff = ({ iterator, options, }) => {
108
135
  throw new Error(`File type ${fileType} not supported`);
109
136
  }
110
137
  structure.boxes.push({ type: 'riff-header', fileSize: size, fileType });
138
+ if ((0, has_all_info_1.hasAllInfo)({ fields, structure, state: options.parserState })) {
139
+ return Promise.resolve({
140
+ status: 'done',
141
+ segments: structure,
142
+ });
143
+ }
111
144
  return (0, exports.parseRiffBody)({ iterator, structure, maxOffset: Infinity, options });
112
145
  };
113
146
  exports.parseRiff = parseRiff;
@@ -0,0 +1,6 @@
1
+ import type { BufferIterator } from '../../buffer-iterator';
2
+ import type { IsftBox } from './riff-box';
3
+ export declare const parseIsft: ({ iterator, size, }: {
4
+ iterator: BufferIterator;
5
+ size: number;
6
+ }) => IsftBox;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseIsft = void 0;
4
+ const parseIsft = ({ iterator, size, }) => {
5
+ const { expectNoMoreBytes } = iterator.startBox(size);
6
+ const software = iterator.getByteString(size - 1);
7
+ const last = iterator.getUint8();
8
+ if (last !== 0) {
9
+ throw new Error(`Expected 0 byte, got ${last}`);
10
+ }
11
+ expectNoMoreBytes();
12
+ return {
13
+ type: 'isft-box',
14
+ software,
15
+ };
16
+ };
17
+ exports.parseIsft = parseIsft;
@@ -36,6 +36,7 @@ const handleChunk = async ({ iterator, options, structure, ckId, ckSize, }) => {
36
36
  const ppsProfile = infos.find((i) => i.type === 'avc-pps');
37
37
  if (avcProfile && ppsProfile) {
38
38
  await options.parserState.onProfile({ pps: ppsProfile, sps: avcProfile });
39
+ options.parserState.tracks.setIsDone();
39
40
  }
40
41
  await options.parserState.onVideoSample(trackId, {
41
42
  cts: timestamp,
@@ -46,27 +47,26 @@ const handleChunk = async ({ iterator, options, structure, ckId, ckSize, }) => {
46
47
  trackId,
47
48
  type: keyOrDelta.type === 'keyframe' ? 'key' : 'delta',
48
49
  });
50
+ return;
49
51
  }
50
- else {
51
- const audioChunk = ckId.match(/^([0-9]{2})wb$/);
52
- if (audioChunk) {
53
- const trackId = parseInt(audioChunk[1], 10);
54
- const strh = getStrhForIndex(structure, trackId);
55
- const samplesPerSecond = strh.rate / strh.scale;
56
- const nthSample = options.parserState.getSamplesForTrack(trackId);
57
- const timeInSec = nthSample / samplesPerSecond;
58
- const timestamp = timeInSec * timescale_1.MEDIA_PARSER_RIFF_TIMESCALE;
59
- const duration = (1 / samplesPerSecond) * timescale_1.MEDIA_PARSER_RIFF_TIMESCALE;
60
- await options.parserState.onAudioSample(trackId, {
61
- cts: timestamp,
62
- dts: timestamp,
63
- data: iterator.getSlice(ckSize),
64
- duration,
65
- timestamp,
66
- trackId,
67
- type: 'key',
68
- });
69
- }
52
+ const audioChunk = ckId.match(/^([0-9]{2})wb$/);
53
+ if (audioChunk) {
54
+ const trackId = parseInt(audioChunk[1], 10);
55
+ const strh = getStrhForIndex(structure, trackId);
56
+ const samplesPerSecond = strh.rate / strh.scale;
57
+ const nthSample = options.parserState.getSamplesForTrack(trackId);
58
+ const timeInSec = nthSample / samplesPerSecond;
59
+ const timestamp = timeInSec * timescale_1.MEDIA_PARSER_RIFF_TIMESCALE;
60
+ const duration = (1 / samplesPerSecond) * timescale_1.MEDIA_PARSER_RIFF_TIMESCALE;
61
+ await options.parserState.onAudioSample(trackId, {
62
+ cts: timestamp,
63
+ dts: timestamp,
64
+ data: iterator.getSlice(ckSize),
65
+ duration,
66
+ timestamp,
67
+ trackId,
68
+ type: 'key',
69
+ });
70
70
  }
71
71
  };
72
72
  exports.handleChunk = handleChunk;
@@ -82,6 +82,16 @@ const parseMovi = async ({ iterator, maxOffset, options, structure, }) => {
82
82
  }
83
83
  const ckId = iterator.getByteString(4);
84
84
  const ckSize = iterator.getUint32Le();
85
+ if (options.parserState.maySkipVideoData() &&
86
+ options.parserState.getAvcProfile()) {
87
+ return {
88
+ type: 'complete',
89
+ box: {
90
+ type: 'movi-box',
91
+ },
92
+ skipTo: maxOffset,
93
+ };
94
+ }
85
95
  if (iterator.bytesRemaining() < ckSize) {
86
96
  iterator.counter.decrement(8);
87
97
  return {
@@ -107,6 +117,7 @@ const parseMovi = async ({ iterator, maxOffset, options, structure, }) => {
107
117
  box: {
108
118
  type: 'movi-box',
109
119
  },
120
+ skipTo: null,
110
121
  };
111
122
  }
112
123
  if (iterator.counter.getOffset() > maxOffset) {
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseRiffBox = void 0;
4
4
  const parse_avih_1 = require("./parse-avih");
5
5
  const parse_fmt_box_1 = require("./parse-fmt-box");
6
+ const parse_isft_1 = require("./parse-isft");
6
7
  const parse_list_box_1 = require("./parse-list-box");
7
8
  const parse_strf_1 = require("./parse-strf");
8
9
  const parse_strh_1 = require("./parse-strh");
@@ -13,6 +14,9 @@ const parseRiffBox = ({ iterator, size, id, boxes, options, }) => {
13
14
  if (id === 'LIST') {
14
15
  return (0, parse_list_box_1.parseListBox)({ iterator, size, options });
15
16
  }
17
+ if (id === 'ISFT') {
18
+ return Promise.resolve((0, parse_isft_1.parseIsft)({ iterator, size }));
19
+ }
16
20
  if (id === 'avih') {
17
21
  return Promise.resolve((0, parse_avih_1.parseAvih)({ iterator, size }));
18
22
  }
@@ -78,4 +78,8 @@ export type RiffHeader = {
78
78
  export type MoviBox = {
79
79
  type: 'movi-box';
80
80
  };
81
- export type RiffBox = RiffRegularBox | WaveFormatBox | RiffHeader | ListBox | AvihBox | StrhBox | StrfBoxVideo | StrfBoxAudio | MoviBox;
81
+ export type IsftBox = {
82
+ type: 'isft-box';
83
+ software: string;
84
+ };
85
+ export type RiffBox = RiffRegularBox | WaveFormatBox | RiffHeader | ListBox | AvihBox | StrhBox | StrfBoxVideo | StrfBoxAudio | MoviBox | IsftBox;
@@ -63,7 +63,8 @@ const parseEbml = async (iterator, parserContext) => {
63
63
  value: '0x' +
64
64
  [...iterator.getSlice(size)]
65
65
  .map((b) => b.toString(16).padStart(2, '0'))
66
- .join(''),
66
+ .join('')
67
+ .replace(new RegExp('^' + hex), ''),
67
68
  minVintWidth,
68
69
  };
69
70
  }
@@ -1,4 +1,9 @@
1
1
  import type { BufferIterator } from '../../buffer-iterator';
2
+ import type { Options, ParseMediaFields } from '../../options';
2
3
  import type { MatroskaStructure, ParseResult } from '../../parse-result';
3
4
  import type { ParserContext } from '../../parser-context';
4
- export declare const parseWebm: (counter: BufferIterator, parserContext: ParserContext) => Promise<ParseResult<MatroskaStructure>>;
5
+ export declare const parseWebm: ({ counter, parserContext, fields, }: {
6
+ counter: BufferIterator;
7
+ parserContext: ParserContext;
8
+ fields: Options<ParseMediaFields>;
9
+ }) => Promise<ParseResult<MatroskaStructure>>;
@@ -20,7 +20,7 @@ const continueAfterMatroskaResult = (result, structure) => {
20
20
  };
21
21
  };
22
22
  // Parsing according to https://darkcoding.net/software/reading-mediarecorders-webm-opus-output/
23
- const parseWebm = async (counter, parserContext) => {
23
+ const parseWebm = async ({ counter, parserContext, fields, }) => {
24
24
  const structure = { type: 'matroska', boxes: [] };
25
25
  const results = await (0, parse_children_1.expectChildren)({
26
26
  iterator: counter,
@@ -28,6 +28,8 @@ const parseWebm = async (counter, parserContext) => {
28
28
  children: structure.boxes,
29
29
  parserContext,
30
30
  startOffset: counter.counter.getOffset(),
31
+ fields,
32
+ topLevelStructure: structure,
31
33
  });
32
34
  return continueAfterMatroskaResult(results, structure);
33
35
  };
@@ -404,6 +404,10 @@ export declare const titleType: {
404
404
  readonly name: "Title";
405
405
  readonly type: "string";
406
406
  };
407
+ export declare const tagTrackUidType: {
408
+ readonly name: "TagTrackUID";
409
+ readonly type: "hex-string";
410
+ };
407
411
  export declare const samplingFrequency: {
408
412
  readonly name: "SamplingFrequency";
409
413
  readonly type: "float";
@@ -438,7 +442,7 @@ export declare const flagLacing: {
438
442
  };
439
443
  export declare const tagSegment: {
440
444
  readonly name: "Tag";
441
- readonly type: "uint8array";
445
+ readonly type: "children";
442
446
  };
443
447
  export declare const tags: {
444
448
  readonly name: "Tags";
@@ -560,6 +564,22 @@ export declare const cluster: {
560
564
  readonly name: "Cluster";
561
565
  readonly type: "children";
562
566
  };
567
+ export declare const targetsType: {
568
+ readonly name: "Targets";
569
+ readonly type: "children";
570
+ };
571
+ export declare const simpleTagType: {
572
+ readonly name: "SimpleTag";
573
+ readonly type: "children";
574
+ };
575
+ export declare const tagNameType: {
576
+ readonly name: "TagName";
577
+ readonly type: "string";
578
+ };
579
+ export declare const tagStringType: {
580
+ readonly name: "TagString";
581
+ readonly type: "string";
582
+ };
563
583
  export type CodecIdSegment = EbmlParsed<typeof codecID>;
564
584
  export type ColourSegment = EbmlParsed<typeof color>;
565
585
  export type TransferCharacteristicsSegment = EbmlParsed<typeof transferCharacteristics>;
@@ -611,6 +631,22 @@ export declare const ebmlMap: {
611
631
  name: "DocType";
612
632
  type: "string";
613
633
  };
634
+ readonly "0x63c0": {
635
+ readonly name: "Targets";
636
+ readonly type: "children";
637
+ };
638
+ readonly "0x67c8": {
639
+ readonly name: "SimpleTag";
640
+ readonly type: "children";
641
+ };
642
+ readonly "0x45a3": {
643
+ readonly name: "TagName";
644
+ readonly type: "string";
645
+ };
646
+ readonly "0x4487": {
647
+ readonly name: "TagString";
648
+ readonly type: "string";
649
+ };
614
650
  readonly "0x4287": {
615
651
  name: "DocTypeVersion";
616
652
  type: "uint";
@@ -707,6 +743,10 @@ export declare const ebmlMap: {
707
743
  readonly name: "SliceDuration";
708
744
  readonly type: "uint8array";
709
745
  };
746
+ readonly "0x63c5": {
747
+ readonly name: "TagTrackUID";
748
+ readonly type: "hex-string";
749
+ };
710
750
  readonly "0x114d9b74": {
711
751
  readonly name: "SeekHead";
712
752
  readonly type: "children";
@@ -809,7 +849,7 @@ export declare const ebmlMap: {
809
849
  };
810
850
  readonly "0x7373": {
811
851
  readonly name: "Tag";
812
- readonly type: "uint8array";
852
+ readonly type: "children";
813
853
  };
814
854
  readonly "0xd7": {
815
855
  readonly name: "TrackNumber";
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defaultDuration = exports.language = exports.ChromaSitingVert = exports.ChromaSitingHorz = exports.range = exports.primaries = exports.matrixCoefficients = exports.transferCharacteristics = exports.color = exports.trackUID = exports.trackNumber = exports.tags = exports.tagSegment = exports.flagLacing = exports.displayHeight = exports.displayWidth = exports.bitDepth = exports.interlaced = exports.alphaMode = exports.channels = exports.samplingFrequency = exports.titleType = exports.infoType = exports.writingApp = exports.timestampScale = exports.duration = exports.muxingApp = exports.heightType = exports.widthType = exports.trackType = exports.codecID = exports.voidHeader = exports.seekHead = exports.seek = exports.seekPosition = exports.seekId = exports.matroskaHeader = exports.docTypeReadVersion = exports.docTypeVersion = exports.docType = exports.ebmlMaxSizeLength = exports.ebmlMaxIdLength = exports.ebmlReadVersion = exports.ebmlVersion = exports.getIdForName = exports.getSegmentName = exports.knownIdsWithThreeLength = exports.knownIdsWithTwoLength = exports.knownIdsWithOneLength = exports.matroskaElements = void 0;
4
- exports.incrementOffsetAndChildren = exports.ebmlMap = exports.cluster = exports.segment = exports.blockGroup = exports.simpleBlock = exports.block = exports.timestampEntry = exports.tracks = exports.trackEntry = exports.trackTimestampScale = exports.codecName = exports.blockElement = exports.referenceBlock = exports.flagDefault = exports.videoSegment = exports.audioSegment = exports.maxBlockAdditionIdSegment = exports.blockAdditionsSegment = exports.codecPrivate = void 0;
3
+ exports.language = exports.ChromaSitingVert = exports.ChromaSitingHorz = exports.range = exports.primaries = exports.matrixCoefficients = exports.transferCharacteristics = exports.color = exports.trackUID = exports.trackNumber = exports.tags = exports.tagSegment = exports.flagLacing = exports.displayHeight = exports.displayWidth = exports.bitDepth = exports.interlaced = exports.alphaMode = exports.channels = exports.samplingFrequency = exports.tagTrackUidType = exports.titleType = exports.infoType = exports.writingApp = exports.timestampScale = exports.duration = exports.muxingApp = exports.heightType = exports.widthType = exports.trackType = exports.codecID = exports.voidHeader = exports.seekHead = exports.seek = exports.seekPosition = exports.seekId = exports.matroskaHeader = exports.docTypeReadVersion = exports.docTypeVersion = exports.docType = exports.ebmlMaxSizeLength = exports.ebmlMaxIdLength = exports.ebmlReadVersion = exports.ebmlVersion = exports.getIdForName = exports.getSegmentName = exports.knownIdsWithThreeLength = exports.knownIdsWithTwoLength = exports.knownIdsWithOneLength = exports.matroskaElements = void 0;
4
+ exports.incrementOffsetAndChildren = exports.ebmlMap = exports.tagStringType = exports.tagNameType = exports.simpleTagType = exports.targetsType = exports.cluster = exports.segment = exports.blockGroup = exports.simpleBlock = exports.block = exports.timestampEntry = exports.tracks = exports.trackEntry = exports.trackTimestampScale = exports.codecName = exports.blockElement = exports.referenceBlock = exports.flagDefault = exports.videoSegment = exports.audioSegment = exports.maxBlockAdditionIdSegment = exports.blockAdditionsSegment = exports.codecPrivate = exports.defaultDuration = void 0;
5
5
  exports.matroskaElements = {
6
6
  Header: '0x1a45dfa3',
7
7
  EBMLMaxIDLength: '0x42f2',
@@ -387,6 +387,10 @@ exports.titleType = {
387
387
  name: 'Title',
388
388
  type: 'string',
389
389
  };
390
+ exports.tagTrackUidType = {
391
+ name: 'TagTrackUID',
392
+ type: 'hex-string',
393
+ };
390
394
  exports.samplingFrequency = {
391
395
  name: 'SamplingFrequency',
392
396
  type: 'float',
@@ -421,7 +425,7 @@ exports.flagLacing = {
421
425
  };
422
426
  exports.tagSegment = {
423
427
  name: 'Tag',
424
- type: 'uint8array',
428
+ type: 'children',
425
429
  };
426
430
  exports.tags = {
427
431
  name: 'Tags',
@@ -543,9 +547,29 @@ exports.cluster = {
543
547
  name: 'Cluster',
544
548
  type: 'children',
545
549
  };
550
+ exports.targetsType = {
551
+ name: 'Targets',
552
+ type: 'children',
553
+ };
554
+ exports.simpleTagType = {
555
+ name: 'SimpleTag',
556
+ type: 'children',
557
+ };
558
+ exports.tagNameType = {
559
+ name: 'TagName',
560
+ type: 'string',
561
+ };
562
+ exports.tagStringType = {
563
+ name: 'TagString',
564
+ type: 'string',
565
+ };
546
566
  exports.ebmlMap = {
547
567
  [exports.matroskaElements.Header]: exports.matroskaHeader,
548
568
  [exports.matroskaElements.DocType]: exports.docType,
569
+ [exports.matroskaElements.Targets]: exports.targetsType,
570
+ [exports.matroskaElements.SimpleTag]: exports.simpleTagType,
571
+ [exports.matroskaElements.TagName]: exports.tagNameType,
572
+ [exports.matroskaElements.TagString]: exports.tagStringType,
549
573
  [exports.matroskaElements.DocTypeVersion]: exports.docTypeVersion,
550
574
  [exports.matroskaElements.DocTypeReadVersion]: exports.docTypeReadVersion,
551
575
  [exports.matroskaElements.EBMLVersion]: exports.ebmlVersion,
@@ -615,6 +639,7 @@ exports.ebmlMap = {
615
639
  name: 'SliceDuration',
616
640
  type: 'uint8array',
617
641
  },
642
+ [exports.matroskaElements.TagTrackUID]: exports.tagTrackUidType,
618
643
  [exports.matroskaElements.SeekHead]: exports.seekHead,
619
644
  [exports.matroskaElements.Seek]: exports.seek,
620
645
  [exports.matroskaElements.SeekID]: exports.seekId,
@@ -1,18 +1,23 @@
1
1
  import type { BufferIterator } from '../../../buffer-iterator';
2
- import type { ExpectSegmentParseResult, MatroskaParseResult } from '../../../parse-result';
2
+ import type { Options, ParseMediaFields } from '../../../options';
3
+ import type { ExpectSegmentParseResult, MatroskaParseResult, MatroskaStructure } from '../../../parse-result';
3
4
  import type { ParserContext } from '../../../parser-context';
4
5
  import type { MatroskaSegment } from '../segments';
5
6
  import type { PossibleEbml } from './all-segments';
6
- export declare const expectAndProcessSegment: ({ iterator, parserContext, offset, children, }: {
7
+ export declare const expectAndProcessSegment: ({ iterator, parserContext, offset, children, fields, topLevelStructure, }: {
7
8
  iterator: BufferIterator;
8
9
  parserContext: ParserContext;
9
10
  offset: number;
10
11
  children: PossibleEbml[];
12
+ fields: Options<ParseMediaFields>;
13
+ topLevelStructure: MatroskaStructure;
11
14
  }) => Promise<ExpectSegmentParseResult>;
12
- export declare const expectChildren: ({ iterator, length, children, parserContext, startOffset, }: {
15
+ export declare const expectChildren: ({ iterator, length, children, parserContext, startOffset, fields, topLevelStructure, }: {
13
16
  iterator: BufferIterator;
14
17
  length: number;
15
18
  children: MatroskaSegment[];
16
19
  parserContext: ParserContext;
17
20
  startOffset: number;
21
+ fields: Options<ParseMediaFields>;
22
+ topLevelStructure: MatroskaStructure;
18
23
  }) => Promise<MatroskaParseResult>;
@@ -1,10 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.expectChildren = exports.expectAndProcessSegment = void 0;
4
+ const has_all_info_1 = require("../../../has-all-info");
4
5
  const segments_1 = require("../segments");
5
- const processParseResult = ({ parseResult, children, }) => {
6
+ const processParseResult = ({ parseResult, children, state, fields, topLevelStructure, }) => {
6
7
  if (parseResult.segment && !children.includes(parseResult.segment)) {
7
8
  children.push(parseResult.segment);
9
+ if ((0, has_all_info_1.hasAllInfo)({ fields, state, structure: topLevelStructure })) {
10
+ return {
11
+ status: 'done',
12
+ segment: parseResult.segment,
13
+ };
14
+ }
15
+ if (parseResult.segment.type === 'Tracks') {
16
+ state.tracks.setIsDone();
17
+ }
8
18
  }
9
19
  if (parseResult.status === 'incomplete') {
10
20
  // No need to decrement because expectSegment already does it
@@ -16,6 +26,9 @@ const processParseResult = ({ parseResult, children, }) => {
16
26
  return processParseResult({
17
27
  children,
18
28
  parseResult: newParseResult,
29
+ state,
30
+ fields,
31
+ topLevelStructure,
19
32
  });
20
33
  },
21
34
  };
@@ -25,20 +38,25 @@ const processParseResult = ({ parseResult, children, }) => {
25
38
  segment: parseResult.segment,
26
39
  };
27
40
  };
28
- const expectAndProcessSegment = async ({ iterator, parserContext, offset, children, }) => {
41
+ const expectAndProcessSegment = async ({ iterator, parserContext, offset, children, fields, topLevelStructure, }) => {
29
42
  const segment = await (0, segments_1.expectSegment)({
30
43
  iterator,
31
44
  parserContext,
32
45
  offset,
33
46
  children,
47
+ fields,
48
+ topLevelStructure,
34
49
  });
35
50
  return processParseResult({
36
51
  children,
37
52
  parseResult: segment,
53
+ state: parserContext.parserState,
54
+ fields,
55
+ topLevelStructure,
38
56
  });
39
57
  };
40
58
  exports.expectAndProcessSegment = expectAndProcessSegment;
41
- const continueAfterSegmentResult = async ({ result, length, children, parserContext, iterator, startOffset, }) => {
59
+ const continueAfterSegmentResult = async ({ result, length, children, parserContext, iterator, startOffset, fields, topLevelStructure, }) => {
42
60
  if (result.status === 'done') {
43
61
  throw new Error('Should not continue after done');
44
62
  }
@@ -54,6 +72,8 @@ const continueAfterSegmentResult = async ({ result, length, children, parserCont
54
72
  length,
55
73
  parserContext,
56
74
  startOffset,
75
+ fields,
76
+ topLevelStructure,
57
77
  });
58
78
  },
59
79
  skipTo: null,
@@ -69,12 +89,14 @@ const continueAfterSegmentResult = async ({ result, length, children, parserCont
69
89
  length,
70
90
  parserContext,
71
91
  startOffset,
92
+ fields,
93
+ topLevelStructure,
72
94
  });
73
95
  },
74
96
  skipTo: null,
75
97
  };
76
98
  };
77
- const expectChildren = async ({ iterator, length, children, parserContext, startOffset, }) => {
99
+ const expectChildren = async ({ iterator, length, children, parserContext, startOffset, fields, topLevelStructure, }) => {
78
100
  while (iterator.counter.getOffset() < startOffset + length) {
79
101
  if (iterator.bytesRemaining() === 0) {
80
102
  break;
@@ -85,7 +107,18 @@ const expectChildren = async ({ iterator, length, children, parserContext, start
85
107
  parserContext,
86
108
  offset: currentOffset,
87
109
  children,
110
+ fields,
111
+ topLevelStructure,
88
112
  });
113
+ if ((0, has_all_info_1.hasAllInfo)({
114
+ fields,
115
+ state: parserContext.parserState,
116
+ structure: topLevelStructure,
117
+ })) {
118
+ return {
119
+ status: 'done',
120
+ };
121
+ }
89
122
  if (child.status === 'incomplete') {
90
123
  return {
91
124
  status: 'incomplete',
@@ -97,6 +130,8 @@ const expectChildren = async ({ iterator, length, children, parserContext, start
97
130
  length: length - (currentOffset - startOffset),
98
131
  parserContext,
99
132
  startOffset: currentOffset,
133
+ fields,
134
+ topLevelStructure,
100
135
  });
101
136
  },
102
137
  skipTo: null,
@@ -1,12 +1,15 @@
1
1
  import type { BufferIterator } from '../../buffer-iterator';
2
- import type { ExpectSegmentParseResult } from '../../parse-result';
2
+ import type { Options, ParseMediaFields } from '../../options';
3
+ import type { ExpectSegmentParseResult, MatroskaStructure } from '../../parse-result';
3
4
  import type { ParserContext } from '../../parser-context';
4
5
  import { type PossibleEbml, type TrackEntry } from './segments/all-segments';
5
6
  export type MatroskaSegment = PossibleEbml;
6
7
  export type OnTrackEntrySegment = (trackEntry: TrackEntry) => void;
7
- export declare const expectSegment: ({ iterator, parserContext, offset, children, }: {
8
+ export declare const expectSegment: ({ iterator, parserContext, offset, children, fields, topLevelStructure, }: {
8
9
  iterator: BufferIterator;
9
10
  parserContext: ParserContext;
10
11
  offset: number;
11
12
  children: PossibleEbml[];
13
+ fields: Options<ParseMediaFields>;
14
+ topLevelStructure: MatroskaStructure;
12
15
  }) => Promise<ExpectSegmentParseResult>;
@@ -27,7 +27,7 @@ const continueAfterMatroskaParseResult = async ({ result, iterator, parserContex
27
27
  status: 'incomplete',
28
28
  };
29
29
  };
30
- const expectSegment = async ({ iterator, parserContext, offset, children, }) => {
30
+ const expectSegment = async ({ iterator, parserContext, offset, children, fields, topLevelStructure, }) => {
31
31
  iterator.counter.decrement(iterator.counter.getOffset() - offset);
32
32
  if (iterator.bytesRemaining() === 0) {
33
33
  return {
@@ -38,6 +38,8 @@ const expectSegment = async ({ iterator, parserContext, offset, children, }) =>
38
38
  parserContext,
39
39
  offset,
40
40
  children,
41
+ fields,
42
+ topLevelStructure,
41
43
  });
42
44
  },
43
45
  segment: null,
@@ -54,6 +56,8 @@ const expectSegment = async ({ iterator, parserContext, offset, children, }) =>
54
56
  parserContext,
55
57
  offset,
56
58
  children,
59
+ fields,
60
+ topLevelStructure,
57
61
  });
58
62
  },
59
63
  segment: null,
@@ -67,7 +71,14 @@ const expectSegment = async ({ iterator, parserContext, offset, children, }) =>
67
71
  return {
68
72
  status: 'incomplete',
69
73
  continueParsing: () => {
70
- return (0, exports.expectSegment)({ iterator, parserContext, offset, children });
74
+ return (0, exports.expectSegment)({
75
+ iterator,
76
+ parserContext,
77
+ offset,
78
+ children,
79
+ fields,
80
+ topLevelStructure,
81
+ });
71
82
  },
72
83
  segment: null,
73
84
  };
@@ -85,6 +96,8 @@ const expectSegment = async ({ iterator, parserContext, offset, children, }) =>
85
96
  children: newSegment.value,
86
97
  parserContext,
87
98
  startOffset: iterator.counter.getOffset(),
99
+ fields,
100
+ topLevelStructure,
88
101
  });
89
102
  if (main.status === 'incomplete') {
90
103
  return {
@@ -112,7 +125,14 @@ const expectSegment = async ({ iterator, parserContext, offset, children, }) =>
112
125
  status: 'incomplete',
113
126
  segment: null,
114
127
  continueParsing: () => {
115
- return (0, exports.expectSegment)({ iterator, parserContext, offset, children });
128
+ return (0, exports.expectSegment)({
129
+ iterator,
130
+ parserContext,
131
+ offset,
132
+ children,
133
+ fields,
134
+ topLevelStructure,
135
+ });
116
136
  },
117
137
  };
118
138
  }
@@ -22,6 +22,7 @@ export declare const getTracksSegment: (segment: MainSegment) => {
22
22
  value: import("./segments/all-segments").PossibleEbml[];
23
23
  minVintWidth: number | null;
24
24
  } | null;
25
+ export declare const getTrackWithUid: (segment: MainSegment, trackUid: string) => number | null;
25
26
  export declare const getTimescaleSegment: (segment: MainSegment) => TimestampScaleSegment | null;
26
27
  export declare const getVideoSegment: (track: TrackEntry) => VideoSegment | null;
27
28
  export declare const getAudioSegment: (track: TrackEntry) => AudioSegment | null;