@remotion/media-parser 4.0.241 → 4.0.242
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/add-avc-profile-to-track.js +2 -2
- package/dist/boxes/avc/codec-private.js +2 -2
- package/dist/boxes/avc/create-sps-pps-data.d.ts +2 -0
- package/dist/boxes/avc/create-sps-pps-data.js +28 -0
- package/dist/boxes/iso-base-media/get-keyframes.d.ts +3 -0
- package/dist/boxes/iso-base-media/get-keyframes.js +30 -0
- package/dist/boxes/iso-base-media/mdat/mdat.d.ts +3 -3
- package/dist/boxes/iso-base-media/mdat/mdat.js +9 -5
- package/dist/boxes/iso-base-media/moov/moov.d.ts +3 -3
- package/dist/boxes/iso-base-media/moov/moov.js +5 -4
- package/dist/boxes/iso-base-media/process-box.d.ts +9 -9
- package/dist/boxes/iso-base-media/process-box.js +48 -56
- package/dist/boxes/iso-base-media/stsd/mebx.d.ts +3 -3
- package/dist/boxes/iso-base-media/stsd/mebx.js +5 -4
- package/dist/boxes/iso-base-media/stsd/samples.d.ts +5 -5
- package/dist/boxes/iso-base-media/stsd/samples.js +19 -16
- package/dist/boxes/iso-base-media/stsd/stsd.d.ts +3 -3
- package/dist/boxes/iso-base-media/stsd/stsd.js +2 -2
- package/dist/boxes/iso-base-media/trak/trak.d.ts +3 -3
- package/dist/boxes/iso-base-media/trak/trak.js +7 -6
- package/dist/boxes/riff/expect-riff-box.d.ts +3 -3
- package/dist/boxes/riff/expect-riff-box.js +5 -5
- package/dist/boxes/riff/get-tracks-from-avi.js +1 -1
- package/dist/boxes/riff/parse-box.d.ts +7 -7
- package/dist/boxes/riff/parse-box.js +29 -24
- package/dist/boxes/riff/parse-list-box.d.ts +3 -3
- package/dist/boxes/riff/parse-list-box.js +2 -2
- package/dist/boxes/riff/parse-movi.d.ts +5 -5
- package/dist/boxes/riff/parse-movi.js +35 -20
- package/dist/boxes/riff/parse-riff-box.d.ts +3 -3
- package/dist/boxes/riff/parse-riff-box.js +2 -2
- package/dist/boxes/transport-stream/get-tracks.js +1 -1
- package/dist/boxes/transport-stream/handle-aac-packet.d.ts +4 -3
- package/dist/boxes/transport-stream/handle-aac-packet.js +6 -4
- package/dist/boxes/transport-stream/handle-avc-packet.d.ts +4 -3
- package/dist/boxes/transport-stream/handle-avc-packet.js +8 -6
- package/dist/boxes/transport-stream/parse-packet.d.ts +3 -3
- package/dist/boxes/transport-stream/parse-packet.js +2 -2
- package/dist/boxes/transport-stream/parse-stream-packet.d.ts +3 -3
- package/dist/boxes/transport-stream/parse-stream-packet.js +14 -7
- package/dist/boxes/transport-stream/parse-transport-stream.d.ts +5 -6
- package/dist/boxes/transport-stream/parse-transport-stream.js +10 -9
- package/dist/boxes/transport-stream/process-stream-buffers.d.ts +6 -5
- package/dist/boxes/transport-stream/process-stream-buffers.js +18 -8
- package/dist/boxes/webm/ebml.d.ts +1 -1
- package/dist/boxes/webm/get-sample-from-block.d.ts +2 -2
- package/dist/boxes/webm/get-sample-from-block.js +8 -4
- package/dist/boxes/webm/parse-ebml.d.ts +4 -4
- package/dist/boxes/webm/parse-ebml.js +18 -18
- package/dist/boxes/webm/parse-webm-header.d.ts +5 -5
- package/dist/boxes/webm/parse-webm-header.js +6 -5
- package/dist/boxes/webm/segments/parse-children.d.ts +5 -5
- package/dist/boxes/webm/segments/parse-children.js +12 -13
- package/dist/boxes/webm/segments.d.ts +3 -3
- package/dist/boxes/webm/segments.js +13 -13
- package/dist/convert-audio-or-video-sample.js +2 -0
- package/dist/emit-available-info.d.ts +4 -5
- package/dist/emit-available-info.js +171 -57
- package/dist/esm/index.mjs +881 -490
- package/dist/get-duration.d.ts +1 -0
- package/dist/get-duration.js +14 -1
- package/dist/get-fields-from-callbacks.js +5 -0
- package/dist/get-fps.d.ts +1 -0
- package/dist/get-fps.js +17 -12
- package/dist/get-keyframes.d.ts +5 -0
- package/dist/get-keyframes.js +20 -0
- package/dist/get-tracks.d.ts +7 -1
- package/dist/get-tracks.js +15 -10
- package/dist/has-all-info.d.ts +2 -5
- package/dist/has-all-info.js +23 -4
- package/dist/index.d.ts +2 -1
- package/dist/may-skip-video-data/may-skip-video-data.d.ts +4 -0
- package/dist/may-skip-video-data/may-skip-video-data.js +14 -0
- package/dist/may-skip-video-data/need-samples-for-fields.d.ts +5 -0
- package/dist/may-skip-video-data/need-samples-for-fields.js +33 -0
- package/dist/options.d.ts +32 -0
- package/dist/parse-media.js +12 -40
- package/dist/parse-result.d.ts +2 -4
- package/dist/parse-video.d.ts +5 -5
- package/dist/parse-video.js +24 -10
- package/dist/register-track.d.ts +5 -5
- package/dist/register-track.js +12 -12
- package/dist/state/can-skip-tracks.js +5 -0
- package/dist/state/emitted-fields.d.ts +2 -0
- package/dist/state/emitted-fields.js +31 -0
- package/dist/state/has-tracks-section.d.ts +1 -0
- package/dist/state/keyframes.d.ts +6 -0
- package/dist/state/keyframes.js +15 -0
- package/dist/state/parser-state.d.ts +60 -29
- package/dist/state/parser-state.js +32 -150
- package/dist/state/riff.d.ts +10 -0
- package/dist/state/riff.js +32 -0
- package/dist/state/sample-callbacks.d.ts +31 -0
- package/dist/state/sample-callbacks.js +96 -0
- package/dist/state/slow-duration-fps.d.ts +8 -0
- package/dist/state/slow-duration-fps.js +36 -0
- package/dist/state/structure.d.ts +7 -0
- package/dist/state/structure.js +21 -0
- package/dist/state/tracks-and-samples.d.ts +0 -0
- package/dist/state/tracks-and-samples.js +1 -0
- package/dist/state/webm.d.ts +11 -0
- package/dist/state/webm.js +67 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/webcodec-sample-types.d.ts +2 -0
- package/package.json +3 -3
|
@@ -4,7 +4,7 @@ exports.getSampleFromBlock = void 0;
|
|
|
4
4
|
const buffer_iterator_1 = require("../../buffer-iterator");
|
|
5
5
|
const all_segments_1 = require("./segments/all-segments");
|
|
6
6
|
const block_simple_block_flags_1 = require("./segments/block-simple-block-flags");
|
|
7
|
-
const getSampleFromBlock = (ebml,
|
|
7
|
+
const getSampleFromBlock = (ebml, state, offset) => {
|
|
8
8
|
const iterator = (0, buffer_iterator_1.getArrayBufferIterator)(ebml.value, ebml.value.length);
|
|
9
9
|
const trackNumber = iterator.getVint();
|
|
10
10
|
if (trackNumber === null) {
|
|
@@ -14,9 +14,9 @@ const getSampleFromBlock = (ebml, parserContext, offset) => {
|
|
|
14
14
|
const { keyframe } = (0, block_simple_block_flags_1.parseBlockFlags)(iterator, ebml.type === 'SimpleBlock'
|
|
15
15
|
? all_segments_1.matroskaElements.SimpleBlock
|
|
16
16
|
: all_segments_1.matroskaElements.Block);
|
|
17
|
-
const { codec, trackTimescale } =
|
|
18
|
-
const clusterOffset =
|
|
19
|
-
const timescale =
|
|
17
|
+
const { codec, trackTimescale } = state.webm.getTrackInfoByNumber(trackNumber);
|
|
18
|
+
const clusterOffset = state.webm.getTimestampOffsetForByteOffset(offset);
|
|
19
|
+
const timescale = state.webm.getTimescale();
|
|
20
20
|
if (clusterOffset === undefined) {
|
|
21
21
|
throw new Error('Could not find offset for byte offset ' + offset);
|
|
22
22
|
}
|
|
@@ -39,6 +39,8 @@ const getSampleFromBlock = (ebml, parserContext, offset) => {
|
|
|
39
39
|
duration: undefined,
|
|
40
40
|
trackId: trackNumber,
|
|
41
41
|
timestamp: timecodeInMicroseconds,
|
|
42
|
+
offset,
|
|
43
|
+
timescale,
|
|
42
44
|
};
|
|
43
45
|
if (keyframe === null) {
|
|
44
46
|
iterator.destroy();
|
|
@@ -66,6 +68,8 @@ const getSampleFromBlock = (ebml, parserContext, offset) => {
|
|
|
66
68
|
duration: undefined,
|
|
67
69
|
cts: timecodeInMicroseconds,
|
|
68
70
|
dts: timecodeInMicroseconds,
|
|
71
|
+
offset,
|
|
72
|
+
timescale,
|
|
69
73
|
};
|
|
70
74
|
iterator.destroy();
|
|
71
75
|
return {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { type BufferIterator } from '../../buffer-iterator';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ParserState } from '../../state/parser-state';
|
|
3
3
|
import type { PossibleEbml } from './segments/all-segments';
|
|
4
4
|
export type Prettify<T> = {
|
|
5
5
|
[K in keyof T]: T[K];
|
|
6
6
|
} & {};
|
|
7
|
-
export declare const parseEbml: (iterator: BufferIterator,
|
|
8
|
-
export declare const postprocessEbml: ({ offset, ebml,
|
|
7
|
+
export declare const parseEbml: (iterator: BufferIterator, state: ParserState) => Promise<Prettify<PossibleEbml>>;
|
|
8
|
+
export declare const postprocessEbml: ({ offset, ebml, state, }: {
|
|
9
9
|
offset: number;
|
|
10
10
|
ebml: Prettify<PossibleEbml>;
|
|
11
|
-
|
|
11
|
+
state: ParserState;
|
|
12
12
|
}) => Promise<Prettify<PossibleEbml>>;
|
|
@@ -5,7 +5,7 @@ const register_track_1 = require("../../register-track");
|
|
|
5
5
|
const get_sample_from_block_1 = require("./get-sample-from-block");
|
|
6
6
|
const make_track_1 = require("./make-track");
|
|
7
7
|
const all_segments_1 = require("./segments/all-segments");
|
|
8
|
-
const parseEbml = async (iterator,
|
|
8
|
+
const parseEbml = async (iterator, state) => {
|
|
9
9
|
const hex = iterator.getMatroskaSegmentId();
|
|
10
10
|
if (hex === null) {
|
|
11
11
|
throw new Error('Not enough bytes left to parse EBML - this should not happen');
|
|
@@ -83,12 +83,12 @@ const parseEbml = async (iterator, parserContext) => {
|
|
|
83
83
|
break;
|
|
84
84
|
}
|
|
85
85
|
const offset = iterator.counter.getOffset();
|
|
86
|
-
const value = await (0, exports.parseEbml)(iterator,
|
|
86
|
+
const value = await (0, exports.parseEbml)(iterator, state);
|
|
87
87
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
88
88
|
const remapped = await (0, exports.postprocessEbml)({
|
|
89
89
|
offset,
|
|
90
90
|
ebml: value,
|
|
91
|
-
|
|
91
|
+
state,
|
|
92
92
|
});
|
|
93
93
|
children.push(remapped);
|
|
94
94
|
const offsetNow = iterator.counter.getOffset();
|
|
@@ -105,46 +105,46 @@ const parseEbml = async (iterator, parserContext) => {
|
|
|
105
105
|
throw new Error(`Unknown segment type ${hasInMap.type}`);
|
|
106
106
|
};
|
|
107
107
|
exports.parseEbml = parseEbml;
|
|
108
|
-
const postprocessEbml = async ({ offset, ebml,
|
|
108
|
+
const postprocessEbml = async ({ offset, ebml, state, }) => {
|
|
109
109
|
if (ebml.type === 'TimestampScale') {
|
|
110
|
-
|
|
110
|
+
state.webm.setTimescale(ebml.value.value);
|
|
111
111
|
}
|
|
112
112
|
if (ebml.type === 'TrackEntry') {
|
|
113
|
-
|
|
113
|
+
state.webm.onTrackEntrySegment(ebml);
|
|
114
114
|
const track = (0, make_track_1.getTrack)({
|
|
115
115
|
track: ebml,
|
|
116
|
-
timescale:
|
|
116
|
+
timescale: state.webm.getTimescale(),
|
|
117
117
|
});
|
|
118
118
|
if (track) {
|
|
119
119
|
await (0, register_track_1.registerTrack)({
|
|
120
|
-
|
|
120
|
+
state,
|
|
121
121
|
track,
|
|
122
122
|
container: 'webm',
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
if (ebml.type === 'Timestamp') {
|
|
127
|
-
|
|
127
|
+
state.webm.setTimestampOffset(offset, ebml.value.value);
|
|
128
128
|
}
|
|
129
129
|
if (ebml.type === 'Block' || ebml.type === 'SimpleBlock') {
|
|
130
|
-
const sample = (0, get_sample_from_block_1.getSampleFromBlock)(ebml,
|
|
131
|
-
if (sample.type === 'video-sample' &&
|
|
132
|
-
await
|
|
130
|
+
const sample = (0, get_sample_from_block_1.getSampleFromBlock)(ebml, state, offset);
|
|
131
|
+
if (sample.type === 'video-sample' && state.nullifySamples) {
|
|
132
|
+
await state.callbacks.onVideoSample(sample.videoSample.trackId, sample.videoSample);
|
|
133
133
|
return {
|
|
134
134
|
type: 'Block',
|
|
135
135
|
value: new Uint8Array([]),
|
|
136
136
|
minVintWidth: ebml.minVintWidth,
|
|
137
137
|
};
|
|
138
138
|
}
|
|
139
|
-
if (sample.type === 'audio-sample' &&
|
|
140
|
-
await
|
|
139
|
+
if (sample.type === 'audio-sample' && state.nullifySamples) {
|
|
140
|
+
await state.callbacks.onAudioSample(sample.audioSample.trackId, sample.audioSample);
|
|
141
141
|
return {
|
|
142
142
|
type: 'Block',
|
|
143
143
|
value: new Uint8Array([]),
|
|
144
144
|
minVintWidth: ebml.minVintWidth,
|
|
145
145
|
};
|
|
146
146
|
}
|
|
147
|
-
if (sample.type === 'no-sample' &&
|
|
147
|
+
if (sample.type === 'no-sample' && state.nullifySamples) {
|
|
148
148
|
return {
|
|
149
149
|
type: 'Block',
|
|
150
150
|
value: new Uint8Array([]),
|
|
@@ -164,15 +164,15 @@ const postprocessEbml = async ({ offset, ebml, parserContext, }) => {
|
|
|
164
164
|
const hasReferenceBlock = ebml.value.find((c) => c.type === 'ReferenceBlock');
|
|
165
165
|
const sample = block.value.length === 0
|
|
166
166
|
? null
|
|
167
|
-
: (0, get_sample_from_block_1.getSampleFromBlock)(block,
|
|
167
|
+
: (0, get_sample_from_block_1.getSampleFromBlock)(block, state, offset);
|
|
168
168
|
if (sample && sample.type === 'partial-video-sample') {
|
|
169
169
|
const completeFrame = {
|
|
170
170
|
...sample.partialVideoSample,
|
|
171
171
|
type: hasReferenceBlock ? 'delta' : 'key',
|
|
172
172
|
};
|
|
173
|
-
await
|
|
173
|
+
await state.callbacks.onVideoSample(sample.partialVideoSample.trackId, completeFrame);
|
|
174
174
|
}
|
|
175
|
-
if (
|
|
175
|
+
if (state.nullifySamples) {
|
|
176
176
|
return {
|
|
177
177
|
type: 'BlockGroup',
|
|
178
178
|
value: [],
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { BufferIterator } from '../../buffer-iterator';
|
|
2
2
|
import type { Options, ParseMediaFields } from '../../options';
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
export declare const parseWebm: ({ counter,
|
|
3
|
+
import type { ParseResult } from '../../parse-result';
|
|
4
|
+
import type { ParserState } from '../../state/parser-state';
|
|
5
|
+
export declare const parseWebm: ({ counter, state, fields, }: {
|
|
6
6
|
counter: BufferIterator;
|
|
7
|
-
|
|
7
|
+
state: ParserState;
|
|
8
8
|
fields: Options<ParseMediaFields>;
|
|
9
|
-
}) => Promise<ParseResult
|
|
9
|
+
}) => Promise<ParseResult>;
|
|
@@ -6,12 +6,10 @@ const continueAfterMatroskaResult = (result, structure) => {
|
|
|
6
6
|
if (result.status === 'done') {
|
|
7
7
|
return {
|
|
8
8
|
status: 'done',
|
|
9
|
-
segments: structure,
|
|
10
9
|
};
|
|
11
10
|
}
|
|
12
11
|
return {
|
|
13
12
|
status: 'incomplete',
|
|
14
|
-
segments: structure,
|
|
15
13
|
continueParsing: async () => {
|
|
16
14
|
const newResult = await result.continueParsing();
|
|
17
15
|
return continueAfterMatroskaResult(newResult, structure);
|
|
@@ -20,13 +18,16 @@ const continueAfterMatroskaResult = (result, structure) => {
|
|
|
20
18
|
};
|
|
21
19
|
};
|
|
22
20
|
// Parsing according to https://darkcoding.net/software/reading-mediarecorders-webm-opus-output/
|
|
23
|
-
const parseWebm = async ({ counter,
|
|
24
|
-
const structure =
|
|
21
|
+
const parseWebm = async ({ counter, state, fields, }) => {
|
|
22
|
+
const structure = state.structure.getStructure();
|
|
23
|
+
if (structure.type !== 'matroska') {
|
|
24
|
+
throw new Error('Invalid structure type');
|
|
25
|
+
}
|
|
25
26
|
const results = await (0, parse_children_1.expectChildren)({
|
|
26
27
|
iterator: counter,
|
|
27
28
|
length: Infinity,
|
|
28
29
|
children: structure.boxes,
|
|
29
|
-
|
|
30
|
+
state,
|
|
30
31
|
startOffset: counter.counter.getOffset(),
|
|
31
32
|
fields,
|
|
32
33
|
topLevelStructure: structure,
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import type { BufferIterator } from '../../../buffer-iterator';
|
|
2
2
|
import type { Options, ParseMediaFields } from '../../../options';
|
|
3
3
|
import type { ExpectSegmentParseResult, MatroskaParseResult, MatroskaStructure } from '../../../parse-result';
|
|
4
|
-
import type {
|
|
4
|
+
import type { ParserState } from '../../../state/parser-state';
|
|
5
5
|
import type { MatroskaSegment } from '../segments';
|
|
6
6
|
import type { PossibleEbml } from './all-segments';
|
|
7
|
-
export declare const expectAndProcessSegment: ({ iterator,
|
|
7
|
+
export declare const expectAndProcessSegment: ({ iterator, state, offset, children, fields, topLevelStructure, }: {
|
|
8
8
|
iterator: BufferIterator;
|
|
9
|
-
|
|
9
|
+
state: ParserState;
|
|
10
10
|
offset: number;
|
|
11
11
|
children: PossibleEbml[];
|
|
12
12
|
fields: Options<ParseMediaFields>;
|
|
13
13
|
topLevelStructure: MatroskaStructure;
|
|
14
14
|
}) => Promise<ExpectSegmentParseResult>;
|
|
15
|
-
export declare const expectChildren: ({ iterator, length, children,
|
|
15
|
+
export declare const expectChildren: ({ iterator, length, children, state, startOffset, fields, topLevelStructure, }: {
|
|
16
16
|
iterator: BufferIterator;
|
|
17
17
|
length: number;
|
|
18
18
|
children: MatroskaSegment[];
|
|
19
|
-
|
|
19
|
+
state: ParserState;
|
|
20
20
|
startOffset: number;
|
|
21
21
|
fields: Options<ParseMediaFields>;
|
|
22
22
|
topLevelStructure: MatroskaStructure;
|
|
@@ -6,14 +6,14 @@ const segments_1 = require("../segments");
|
|
|
6
6
|
const processParseResult = ({ parseResult, children, state, fields, topLevelStructure, }) => {
|
|
7
7
|
if (parseResult.segment && !children.includes(parseResult.segment)) {
|
|
8
8
|
children.push(parseResult.segment);
|
|
9
|
-
if ((0, has_all_info_1.hasAllInfo)({ fields, state
|
|
9
|
+
if ((0, has_all_info_1.hasAllInfo)({ fields, state })) {
|
|
10
10
|
return {
|
|
11
11
|
status: 'done',
|
|
12
12
|
segment: parseResult.segment,
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
if (parseResult.segment.type === 'Tracks') {
|
|
16
|
-
state.tracks.setIsDone();
|
|
16
|
+
state.callbacks.tracks.setIsDone();
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
if (parseResult.status === 'incomplete') {
|
|
@@ -38,10 +38,10 @@ const processParseResult = ({ parseResult, children, state, fields, topLevelStru
|
|
|
38
38
|
segment: parseResult.segment,
|
|
39
39
|
};
|
|
40
40
|
};
|
|
41
|
-
const expectAndProcessSegment = async ({ iterator,
|
|
41
|
+
const expectAndProcessSegment = async ({ iterator, state, offset, children, fields, topLevelStructure, }) => {
|
|
42
42
|
const segment = await (0, segments_1.expectSegment)({
|
|
43
43
|
iterator,
|
|
44
|
-
|
|
44
|
+
state,
|
|
45
45
|
offset,
|
|
46
46
|
children,
|
|
47
47
|
fields,
|
|
@@ -50,13 +50,13 @@ const expectAndProcessSegment = async ({ iterator, parserContext, offset, childr
|
|
|
50
50
|
return processParseResult({
|
|
51
51
|
children,
|
|
52
52
|
parseResult: segment,
|
|
53
|
-
state
|
|
53
|
+
state,
|
|
54
54
|
fields,
|
|
55
55
|
topLevelStructure,
|
|
56
56
|
});
|
|
57
57
|
};
|
|
58
58
|
exports.expectAndProcessSegment = expectAndProcessSegment;
|
|
59
|
-
const continueAfterSegmentResult = async ({ result, length, children,
|
|
59
|
+
const continueAfterSegmentResult = async ({ result, length, children, state, iterator, startOffset, fields, topLevelStructure, }) => {
|
|
60
60
|
if (result.status === 'done') {
|
|
61
61
|
throw new Error('Should not continue after done');
|
|
62
62
|
}
|
|
@@ -70,7 +70,7 @@ const continueAfterSegmentResult = async ({ result, length, children, parserCont
|
|
|
70
70
|
children,
|
|
71
71
|
iterator,
|
|
72
72
|
length,
|
|
73
|
-
|
|
73
|
+
state,
|
|
74
74
|
startOffset,
|
|
75
75
|
fields,
|
|
76
76
|
topLevelStructure,
|
|
@@ -87,7 +87,7 @@ const continueAfterSegmentResult = async ({ result, length, children, parserCont
|
|
|
87
87
|
children,
|
|
88
88
|
iterator,
|
|
89
89
|
length,
|
|
90
|
-
|
|
90
|
+
state,
|
|
91
91
|
startOffset,
|
|
92
92
|
fields,
|
|
93
93
|
topLevelStructure,
|
|
@@ -96,7 +96,7 @@ const continueAfterSegmentResult = async ({ result, length, children, parserCont
|
|
|
96
96
|
skipTo: null,
|
|
97
97
|
};
|
|
98
98
|
};
|
|
99
|
-
const expectChildren = async ({ iterator, length, children,
|
|
99
|
+
const expectChildren = async ({ iterator, length, children, state, startOffset, fields, topLevelStructure, }) => {
|
|
100
100
|
while (iterator.counter.getOffset() < startOffset + length) {
|
|
101
101
|
if (iterator.bytesRemaining() === 0) {
|
|
102
102
|
break;
|
|
@@ -104,7 +104,7 @@ const expectChildren = async ({ iterator, length, children, parserContext, start
|
|
|
104
104
|
const currentOffset = iterator.counter.getOffset();
|
|
105
105
|
const child = await (0, exports.expectAndProcessSegment)({
|
|
106
106
|
iterator,
|
|
107
|
-
|
|
107
|
+
state,
|
|
108
108
|
offset: currentOffset,
|
|
109
109
|
children,
|
|
110
110
|
fields,
|
|
@@ -112,8 +112,7 @@ const expectChildren = async ({ iterator, length, children, parserContext, start
|
|
|
112
112
|
});
|
|
113
113
|
if ((0, has_all_info_1.hasAllInfo)({
|
|
114
114
|
fields,
|
|
115
|
-
state
|
|
116
|
-
structure: topLevelStructure,
|
|
115
|
+
state,
|
|
117
116
|
})) {
|
|
118
117
|
return {
|
|
119
118
|
status: 'done',
|
|
@@ -128,7 +127,7 @@ const expectChildren = async ({ iterator, length, children, parserContext, start
|
|
|
128
127
|
children,
|
|
129
128
|
iterator,
|
|
130
129
|
length: length - (currentOffset - startOffset),
|
|
131
|
-
|
|
130
|
+
state,
|
|
132
131
|
startOffset: currentOffset,
|
|
133
132
|
fields,
|
|
134
133
|
topLevelStructure,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { BufferIterator } from '../../buffer-iterator';
|
|
2
2
|
import type { Options, ParseMediaFields } from '../../options';
|
|
3
3
|
import type { ExpectSegmentParseResult, MatroskaStructure } from '../../parse-result';
|
|
4
|
-
import type {
|
|
4
|
+
import type { ParserState } from '../../state/parser-state';
|
|
5
5
|
import { type PossibleEbml, type TrackEntry } from './segments/all-segments';
|
|
6
6
|
export type MatroskaSegment = PossibleEbml;
|
|
7
7
|
export type OnTrackEntrySegment = (trackEntry: TrackEntry) => void;
|
|
8
|
-
export declare const expectSegment: ({ iterator,
|
|
8
|
+
export declare const expectSegment: ({ iterator, state, offset, children, fields, topLevelStructure, }: {
|
|
9
9
|
iterator: BufferIterator;
|
|
10
|
-
|
|
10
|
+
state: ParserState;
|
|
11
11
|
offset: number;
|
|
12
12
|
children: PossibleEbml[];
|
|
13
13
|
fields: Options<ParseMediaFields>;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.expectSegment = void 0;
|
|
4
4
|
const parse_ebml_1 = require("./parse-ebml");
|
|
5
5
|
const parse_children_1 = require("./segments/parse-children");
|
|
6
|
-
const continueAfterMatroskaParseResult = async ({ result, iterator,
|
|
6
|
+
const continueAfterMatroskaParseResult = async ({ result, iterator, state, segment, }) => {
|
|
7
7
|
if (result.status === 'done') {
|
|
8
8
|
throw new Error('Should not continue after done');
|
|
9
9
|
}
|
|
@@ -19,7 +19,7 @@ const continueAfterMatroskaParseResult = async ({ result, iterator, parserContex
|
|
|
19
19
|
return continueAfterMatroskaParseResult({
|
|
20
20
|
result: proceeded,
|
|
21
21
|
iterator,
|
|
22
|
-
|
|
22
|
+
state,
|
|
23
23
|
segment,
|
|
24
24
|
});
|
|
25
25
|
},
|
|
@@ -27,7 +27,7 @@ const continueAfterMatroskaParseResult = async ({ result, iterator, parserContex
|
|
|
27
27
|
status: 'incomplete',
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
|
-
const expectSegment = async ({ iterator,
|
|
30
|
+
const expectSegment = async ({ iterator, state, offset, children, fields, topLevelStructure, }) => {
|
|
31
31
|
iterator.counter.decrement(iterator.counter.getOffset() - offset);
|
|
32
32
|
if (iterator.bytesRemaining() === 0) {
|
|
33
33
|
return {
|
|
@@ -35,7 +35,7 @@ const expectSegment = async ({ iterator, parserContext, offset, children, fields
|
|
|
35
35
|
continueParsing: () => {
|
|
36
36
|
return (0, parse_children_1.expectAndProcessSegment)({
|
|
37
37
|
iterator,
|
|
38
|
-
|
|
38
|
+
state,
|
|
39
39
|
offset,
|
|
40
40
|
children,
|
|
41
41
|
fields,
|
|
@@ -53,7 +53,7 @@ const expectSegment = async ({ iterator, parserContext, offset, children, fields
|
|
|
53
53
|
continueParsing: () => {
|
|
54
54
|
return (0, parse_children_1.expectAndProcessSegment)({
|
|
55
55
|
iterator,
|
|
56
|
-
|
|
56
|
+
state,
|
|
57
57
|
offset,
|
|
58
58
|
children,
|
|
59
59
|
fields,
|
|
@@ -73,7 +73,7 @@ const expectSegment = async ({ iterator, parserContext, offset, children, fields
|
|
|
73
73
|
continueParsing: () => {
|
|
74
74
|
return (0, exports.expectSegment)({
|
|
75
75
|
iterator,
|
|
76
|
-
|
|
76
|
+
state,
|
|
77
77
|
offset,
|
|
78
78
|
children,
|
|
79
79
|
fields,
|
|
@@ -94,7 +94,7 @@ const expectSegment = async ({ iterator, parserContext, offset, children, fields
|
|
|
94
94
|
iterator,
|
|
95
95
|
length,
|
|
96
96
|
children: newSegment.value,
|
|
97
|
-
|
|
97
|
+
state,
|
|
98
98
|
startOffset: iterator.counter.getOffset(),
|
|
99
99
|
fields,
|
|
100
100
|
topLevelStructure,
|
|
@@ -105,7 +105,7 @@ const expectSegment = async ({ iterator, parserContext, offset, children, fields
|
|
|
105
105
|
continueParsing: () => {
|
|
106
106
|
return continueAfterMatroskaParseResult({
|
|
107
107
|
iterator,
|
|
108
|
-
|
|
108
|
+
state,
|
|
109
109
|
result: main,
|
|
110
110
|
segment: newSegment,
|
|
111
111
|
});
|
|
@@ -127,7 +127,7 @@ const expectSegment = async ({ iterator, parserContext, offset, children, fields
|
|
|
127
127
|
continueParsing: () => {
|
|
128
128
|
return (0, exports.expectSegment)({
|
|
129
129
|
iterator,
|
|
130
|
-
|
|
130
|
+
state,
|
|
131
131
|
offset,
|
|
132
132
|
children,
|
|
133
133
|
fields,
|
|
@@ -140,7 +140,7 @@ const expectSegment = async ({ iterator, parserContext, offset, children, fields
|
|
|
140
140
|
segmentId,
|
|
141
141
|
iterator,
|
|
142
142
|
length,
|
|
143
|
-
|
|
143
|
+
state,
|
|
144
144
|
headerReadSoFar: iterator.counter.getOffset() - offset,
|
|
145
145
|
});
|
|
146
146
|
return {
|
|
@@ -149,13 +149,13 @@ const expectSegment = async ({ iterator, parserContext, offset, children, fields
|
|
|
149
149
|
};
|
|
150
150
|
};
|
|
151
151
|
exports.expectSegment = expectSegment;
|
|
152
|
-
const parseSegment = async ({ segmentId, iterator, length,
|
|
152
|
+
const parseSegment = async ({ segmentId, iterator, length, state, headerReadSoFar, }) => {
|
|
153
153
|
if (length < 0) {
|
|
154
154
|
throw new Error(`Expected length of ${segmentId} to be greater or equal 0`);
|
|
155
155
|
}
|
|
156
156
|
iterator.counter.decrement(headerReadSoFar);
|
|
157
157
|
const offset = iterator.counter.getOffset();
|
|
158
|
-
const ebml = await (0, parse_ebml_1.parseEbml)(iterator,
|
|
159
|
-
const remapped = await (0, parse_ebml_1.postprocessEbml)({ offset, ebml,
|
|
158
|
+
const ebml = await (0, parse_ebml_1.parseEbml)(iterator, state);
|
|
159
|
+
const remapped = await (0, parse_ebml_1.postprocessEbml)({ offset, ebml, state });
|
|
160
160
|
return remapped;
|
|
161
161
|
};
|
|
@@ -12,6 +12,8 @@ const convertAudioOrVideoSampleToWebCodecsTimestamps = (sample, timescale) => {
|
|
|
12
12
|
data: sample.data,
|
|
13
13
|
trackId: sample.trackId,
|
|
14
14
|
type: sample.type,
|
|
15
|
+
offset: sample.offset,
|
|
16
|
+
timescale: 1000000,
|
|
15
17
|
};
|
|
16
18
|
};
|
|
17
19
|
exports.convertAudioOrVideoSampleToWebCodecsTimestamps = convertAudioOrVideoSampleToWebCodecsTimestamps;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ParseResult
|
|
1
|
+
import type { AllParseMediaFields, Options, ParseMediaCallbacks, ParseMediaFields, ParseMediaResult } from './options';
|
|
2
|
+
import type { ParseResult } from './parse-result';
|
|
3
3
|
import type { ParserState } from './state/parser-state';
|
|
4
|
-
export declare const emitAvailableInfo: ({ hasInfo, parseResult, callbacks, state, returnValue, contentLength, name, mimeType, fieldsInReturnValue,
|
|
4
|
+
export declare const emitAvailableInfo: ({ hasInfo, parseResult, callbacks, state, returnValue, contentLength, name, mimeType, fieldsInReturnValue, }: {
|
|
5
5
|
hasInfo: Record<keyof Options<ParseMediaFields>, boolean>;
|
|
6
|
-
parseResult: ParseResult
|
|
6
|
+
parseResult: ParseResult | null;
|
|
7
7
|
callbacks: ParseMediaCallbacks;
|
|
8
8
|
fieldsInReturnValue: Options<ParseMediaFields>;
|
|
9
|
-
emittedFields: AllOptions<ParseMediaFields>;
|
|
10
9
|
state: ParserState;
|
|
11
10
|
returnValue: ParseMediaResult<AllParseMediaFields>;
|
|
12
11
|
contentLength: number | null;
|