@remotion/media-parser 4.0.277 → 4.0.278
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/aac-codecprivate.js +13 -6
- package/dist/add-avc-profile-to-track.js +9 -5
- package/dist/buffer-iterator.js +13 -8
- package/dist/combine-uint8-arrays.js +5 -1
- package/dist/containers/aac/parse-aac.js +13 -9
- package/dist/containers/aac/types.js +2 -1
- package/dist/containers/avc/codec-string.js +5 -1
- package/dist/containers/avc/color.js +9 -3
- package/dist/containers/avc/create-sps-pps-data.js +9 -5
- package/dist/containers/avc/interpret-sps.js +13 -7
- package/dist/containers/avc/key.js +5 -1
- package/dist/containers/avc/parse-avc.js +7 -3
- package/dist/containers/avc/sps-and-pps.js +5 -1
- package/dist/containers/flac/get-block-size.js +5 -1
- package/dist/containers/flac/get-channel-count.js +5 -1
- package/dist/containers/flac/get-duration-from-flac.js +5 -1
- package/dist/containers/flac/get-metadata-from-flac.js +5 -1
- package/dist/containers/flac/get-sample-rate.js +5 -1
- package/dist/containers/flac/parse-flac-frame.js +19 -14
- package/dist/containers/flac/parse-flac.js +19 -15
- package/dist/containers/flac/parse-header.js +5 -1
- package/dist/containers/flac/parse-metadata.js +5 -1
- package/dist/containers/flac/parse-streaminfo.js +7 -3
- package/dist/containers/flac/parse-unknown-block.js +5 -1
- package/dist/containers/flac/types.js +2 -1
- package/dist/containers/iso-base-media/base-media-box.js +2 -1
- package/dist/containers/iso-base-media/base-type.js +2 -1
- package/dist/containers/iso-base-media/esds/decoder-specific-config.js +5 -1
- package/dist/containers/iso-base-media/esds/esds-descriptors.js +10 -5
- package/dist/containers/iso-base-media/esds/esds.js +7 -3
- package/dist/containers/iso-base-media/ftyp.js +5 -1
- package/dist/containers/iso-base-media/get-actual-number-of-channels.js +8 -4
- package/dist/containers/iso-base-media/get-children.js +7 -3
- package/dist/containers/iso-base-media/get-keyframes.js +11 -7
- package/dist/containers/iso-base-media/get-moov-atom.js +17 -13
- package/dist/containers/iso-base-media/get-sample-positions-from-track.js +24 -20
- package/dist/containers/iso-base-media/get-video-codec-from-iso-track.js +7 -3
- package/dist/containers/iso-base-media/make-track.js +34 -30
- package/dist/containers/iso-base-media/mdat/mdat.js +20 -16
- package/dist/containers/iso-base-media/mdhd.js +5 -1
- package/dist/containers/iso-base-media/meta/hdlr.js +5 -1
- package/dist/containers/iso-base-media/meta/ilst.js +5 -1
- package/dist/containers/iso-base-media/moov/moov.js +7 -3
- package/dist/containers/iso-base-media/mvhd.js +11 -7
- package/dist/containers/iso-base-media/parse-boxes.js +9 -5
- package/dist/containers/iso-base-media/parse-icc-profile.js +8 -4
- package/dist/containers/iso-base-media/process-box.js +67 -63
- package/dist/containers/iso-base-media/stsd/av1c.js +5 -1
- package/dist/containers/iso-base-media/stsd/avcc.js +5 -1
- package/dist/containers/iso-base-media/stsd/colr.js +7 -3
- package/dist/containers/iso-base-media/stsd/ctts.js +5 -1
- package/dist/containers/iso-base-media/stsd/hvcc.js +7 -3
- package/dist/containers/iso-base-media/stsd/keys.js +5 -1
- package/dist/containers/iso-base-media/stsd/mebx.js +7 -3
- package/dist/containers/iso-base-media/stsd/pasp.js +5 -1
- package/dist/containers/iso-base-media/stsd/samples.js +13 -8
- package/dist/containers/iso-base-media/stsd/stco.js +5 -1
- package/dist/containers/iso-base-media/stsd/stsc.js +5 -1
- package/dist/containers/iso-base-media/stsd/stsd.js +7 -3
- package/dist/containers/iso-base-media/stsd/stss.js +5 -1
- package/dist/containers/iso-base-media/stsd/stsz.js +5 -1
- package/dist/containers/iso-base-media/stsd/stts.js +5 -1
- package/dist/containers/iso-base-media/tfdt.js +5 -1
- package/dist/containers/iso-base-media/tfhd.js +5 -1
- package/dist/containers/iso-base-media/tkhd.js +8 -4
- package/dist/containers/iso-base-media/to-date.js +5 -1
- package/dist/containers/iso-base-media/trak/trak.js +7 -3
- package/dist/containers/iso-base-media/traversal.js +57 -33
- package/dist/containers/iso-base-media/trun.js +5 -1
- package/dist/containers/iso-base-media/void-box.js +2 -1
- package/dist/containers/m3u/after-manifest-fetch.js +15 -11
- package/dist/containers/m3u/fetch-m3u8-stream.js +7 -3
- package/dist/containers/m3u/get-chunks.js +5 -1
- package/dist/containers/m3u/get-duration-from-m3u.js +8 -4
- package/dist/containers/m3u/get-playlist.js +12 -6
- package/dist/containers/m3u/get-streams.js +9 -3
- package/dist/containers/m3u/iterate-over-segment-files.js +15 -11
- package/dist/containers/m3u/parse-directive.js +10 -6
- package/dist/containers/m3u/parse-m3u-manifest.js +7 -3
- package/dist/containers/m3u/parse-m3u-media-directive.js +10 -5
- package/dist/containers/m3u/parse-m3u.js +11 -7
- package/dist/containers/m3u/parse-m3u8-text.js +7 -3
- package/dist/containers/m3u/parse-stream-inf.js +7 -2
- package/dist/containers/m3u/run-over-m3u.js +13 -9
- package/dist/containers/m3u/sample-sorter.js +8 -4
- package/dist/containers/m3u/select-stream.js +11 -4
- package/dist/containers/m3u/types.js +2 -1
- package/dist/containers/mp3/get-duration.js +9 -5
- package/dist/containers/mp3/get-frame-length.js +7 -2
- package/dist/containers/mp3/get-metadata-from-mp3.js +5 -1
- package/dist/containers/mp3/id3-v1.js +5 -1
- package/dist/containers/mp3/id3.js +5 -1
- package/dist/containers/mp3/parse-mp3.js +11 -7
- package/dist/containers/mp3/parse-mpeg-header.js +14 -10
- package/dist/containers/mp3/samples-per-mpeg-file.js +5 -1
- package/dist/containers/riff/expect-riff-box.js +15 -11
- package/dist/containers/riff/get-duration.js +12 -7
- package/dist/containers/riff/get-tracks-from-avi.js +28 -20
- package/dist/containers/riff/is-movi.js +5 -1
- package/dist/containers/riff/parse-avih.js +5 -1
- package/dist/containers/riff/parse-isft.js +5 -1
- package/dist/containers/riff/parse-list-box.js +7 -3
- package/dist/containers/riff/parse-movi.js +18 -13
- package/dist/containers/riff/parse-riff-body.js +13 -9
- package/dist/containers/riff/parse-riff-box.js +13 -9
- package/dist/containers/riff/parse-riff-header.js +5 -1
- package/dist/containers/riff/parse-riff.js +9 -5
- package/dist/containers/riff/parse-strf.js +5 -1
- package/dist/containers/riff/parse-strh.js +7 -3
- package/dist/containers/riff/parse-video-section.js +11 -7
- package/dist/containers/riff/riff-box.js +2 -1
- package/dist/containers/riff/timescale.js +4 -1
- package/dist/containers/riff/traversal.js +15 -7
- package/dist/containers/transport-stream/adts-header.js +10 -6
- package/dist/containers/transport-stream/boxes.js +2 -1
- package/dist/containers/transport-stream/discard-rest-of-packet.js +7 -2
- package/dist/containers/transport-stream/find-separator.js +4 -1
- package/dist/containers/transport-stream/get-tracks.js +16 -10
- package/dist/containers/transport-stream/handle-aac-packet.js +16 -12
- package/dist/containers/transport-stream/handle-avc-packet.js +26 -22
- package/dist/containers/transport-stream/next-pes-header-store.js +5 -1
- package/dist/containers/transport-stream/parse-packet.js +17 -13
- package/dist/containers/transport-stream/parse-pat.js +10 -5
- package/dist/containers/transport-stream/parse-pes.js +5 -1
- package/dist/containers/transport-stream/parse-pmt.js +7 -3
- package/dist/containers/transport-stream/parse-stream-packet.js +17 -13
- package/dist/containers/transport-stream/parse-transport-stream.js +9 -5
- package/dist/containers/transport-stream/process-stream-buffers.js +17 -12
- package/dist/containers/transport-stream/traversal.js +10 -4
- package/dist/containers/wav/get-duration-from-wav.js +8 -3
- package/dist/containers/wav/get-metadata-from-wav.js +5 -1
- package/dist/containers/wav/parse-data.js +9 -5
- package/dist/containers/wav/parse-fmt.js +7 -3
- package/dist/containers/wav/parse-header.js +5 -1
- package/dist/containers/wav/parse-id3.js +5 -1
- package/dist/containers/wav/parse-list.js +5 -1
- package/dist/containers/wav/parse-video-section.js +7 -3
- package/dist/containers/wav/parse-wav.js +19 -15
- package/dist/containers/wav/types.js +2 -1
- package/dist/containers/webm/allowed-partial-segments.js +4 -1
- package/dist/containers/webm/av1-codec-private.js +7 -3
- package/dist/containers/webm/color.js +10 -6
- package/dist/containers/webm/description.js +10 -6
- package/dist/containers/webm/get-ready-tracks.js +18 -13
- package/dist/containers/webm/get-sample-from-block.js +16 -12
- package/dist/containers/webm/make-track.js +48 -43
- package/dist/containers/webm/parse-ebml.js +19 -14
- package/dist/containers/webm/parse-webm-header.js +7 -3
- package/dist/containers/webm/segments/all-segments.js +173 -168
- package/dist/containers/webm/segments/block-simple-block-flags.js +8 -4
- package/dist/containers/webm/segments/track-entry.js +5 -1
- package/dist/containers/webm/segments.js +13 -9
- package/dist/containers/webm/traversal.js +67 -37
- package/dist/convert-audio-or-video-sample.js +5 -1
- package/dist/download-and-parse-media.js +14 -10
- package/dist/emit-available-info.js +38 -34
- package/dist/emitter.js +5 -1
- package/dist/errors.js +15 -6
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/worker.mjs +4 -5
- package/dist/fetch.js +17 -1
- package/dist/file-types/bmp.js +7 -3
- package/dist/file-types/detect-file-type.js +38 -24
- package/dist/file-types/index.js +26 -22
- package/dist/file-types/jpeg.js +9 -4
- package/dist/file-types/pdf.js +7 -3
- package/dist/file-types/png.js +9 -4
- package/dist/file-types/webp.js +7 -3
- package/dist/forward-controller.js +5 -1
- package/dist/get-audio-codec.js +38 -25
- package/dist/get-container.js +10 -5
- package/dist/get-dimensions.js +13 -8
- package/dist/get-duration.js +34 -27
- package/dist/get-fields-from-callbacks.js +5 -1
- package/dist/get-fps.js +34 -24
- package/dist/get-is-hdr.js +10 -5
- package/dist/get-keyframes.js +11 -6
- package/dist/get-location.js +9 -4
- package/dist/get-number-of-audio-channels.js +7 -2
- package/dist/get-sample-aspect-ratio.js +30 -17
- package/dist/get-sample-positions-from-lpcm.js +9 -5
- package/dist/get-sample-positions.js +5 -1
- package/dist/get-sample-rate.js +7 -2
- package/dist/get-tracks.js +40 -29
- package/dist/get-video-codec.js +34 -26
- package/dist/has-all-info.js +38 -33
- package/dist/index.js +47 -32
- package/dist/init-video.js +28 -24
- package/dist/internal-parse-media.js +39 -35
- package/dist/is-audio-structure.js +5 -1
- package/dist/log.js +12 -8
- package/dist/make-hvc1-codec-strings.js +5 -1
- package/dist/media-parser-controller.js +11 -7
- package/dist/metadata/get-metadata.js +22 -17
- package/dist/metadata/metadata-from-iso.js +17 -12
- package/dist/metadata/metadata-from-matroska.js +7 -3
- package/dist/metadata/metadata-from-riff.js +7 -3
- package/dist/node-writer.js +17 -1
- package/dist/node.js +17 -1
- package/dist/options.js +2 -1
- package/dist/parse-media-on-worker-entry.js +7 -3
- package/dist/parse-media.js +12 -8
- package/dist/parse-result.js +2 -1
- package/dist/pause-signal.js +5 -1
- package/dist/perform-seek.js +10 -6
- package/dist/readers/fetch/get-body-and-reader.js +5 -1
- package/dist/readers/fetch/resolve-url.js +5 -1
- package/dist/readers/from-fetch.js +21 -14
- package/dist/readers/from-node.js +23 -17
- package/dist/readers/from-web-file.js +13 -7
- package/dist/readers/reader.js +2 -1
- package/dist/readers/universal.js +16 -13
- package/dist/readers/web.js +12 -9
- package/dist/register-track.js +15 -9
- package/dist/remotion-license-acknowledge.js +8 -4
- package/dist/run-parse-iteration.js +25 -21
- package/dist/samples-from-moof.js +10 -6
- package/dist/skip.js +5 -1
- package/dist/state/aac-state.js +5 -1
- package/dist/state/can-skip-tracks.js +8 -3
- package/dist/state/emitted-fields.js +5 -1
- package/dist/state/flac-state.js +5 -1
- package/dist/state/has-tracks-section.js +7 -3
- package/dist/state/images.js +5 -1
- package/dist/state/iso-base-media/cached-sample-positions.js +13 -8
- package/dist/state/iso-base-media/iso-state.js +9 -5
- package/dist/state/iso-base-media/moov-box.js +5 -1
- package/dist/state/keyframes.js +5 -1
- package/dist/state/m3u-state.js +9 -5
- package/dist/state/may-skip-video-data.js +7 -3
- package/dist/state/mp3.js +5 -1
- package/dist/state/need-samples-for-fields.js +5 -1
- package/dist/state/parser-state.js +39 -35
- package/dist/state/riff.js +5 -1
- package/dist/state/sample-callbacks.js +12 -8
- package/dist/state/slow-duration-fps.js +5 -1
- package/dist/state/structure.js +5 -1
- package/dist/state/transport-stream.js +7 -3
- package/dist/state/video-section.js +5 -1
- package/dist/state/webm.js +9 -5
- package/dist/throttled-progress.js +5 -1
- package/dist/truthy.js +4 -1
- package/dist/universal.js +5 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +4 -1
- package/dist/web.js +5 -1
- package/dist/webcodec-sample-types.js +2 -1
- package/dist/worker/forward-controller.js +7 -3
- package/dist/worker/serialize-error.js +19 -14
- package/dist/worker/worker-types.js +2 -1
- package/dist/worker-server-entry.js +5 -3
- package/dist/worker-server.js +16 -12
- package/dist/worker-web-entry.js +5 -3
- package/dist/worker.d.ts +3 -2
- package/dist/worker.js +11 -2
- package/dist/worker.module.d.ts +4 -0
- package/dist/worker.module.js +16 -0
- package/dist/writers/node.js +23 -16
- package/dist/writers/writer.js +2 -1
- package/package.json +3 -3
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hasAllTracksFromTransportStream = exports.getTracksFromTransportStream = exports.filterStreamsBySupportedTypes = void 0;
|
|
4
|
+
const truthy_1 = require("../../truthy");
|
|
5
|
+
const traversal_1 = require("./traversal");
|
|
6
|
+
const filterStreamsBySupportedTypes = (streams) => {
|
|
4
7
|
return streams.filter((stream) => stream.streamType === 27 || stream.streamType === 15);
|
|
5
8
|
};
|
|
6
|
-
|
|
9
|
+
exports.filterStreamsBySupportedTypes = filterStreamsBySupportedTypes;
|
|
10
|
+
const getTracksFromTransportStream = (parserState) => {
|
|
7
11
|
const structure = parserState.getTsStructure();
|
|
8
|
-
const programMapTable = findProgramMapTableOrThrow(structure);
|
|
12
|
+
const programMapTable = (0, traversal_1.findProgramMapTableOrThrow)(structure);
|
|
9
13
|
const parserTracks = parserState.callbacks.tracks.getTracks();
|
|
10
|
-
const mapped = filterStreamsBySupportedTypes(programMapTable.streams)
|
|
14
|
+
const mapped = (0, exports.filterStreamsBySupportedTypes)(programMapTable.streams)
|
|
11
15
|
.map((stream) => {
|
|
12
16
|
return parserTracks.find((track) => track.trackId === stream.pid);
|
|
13
17
|
})
|
|
14
|
-
.filter(truthy);
|
|
18
|
+
.filter(truthy_1.truthy);
|
|
15
19
|
if (mapped.length !==
|
|
16
|
-
filterStreamsBySupportedTypes(programMapTable.streams).length) {
|
|
20
|
+
(0, exports.filterStreamsBySupportedTypes)(programMapTable.streams).length) {
|
|
17
21
|
throw new Error('Not all tracks found');
|
|
18
22
|
}
|
|
19
23
|
return {
|
|
@@ -22,12 +26,14 @@ export const getTracksFromTransportStream = (parserState) => {
|
|
|
22
26
|
otherTracks: [],
|
|
23
27
|
};
|
|
24
28
|
};
|
|
25
|
-
|
|
29
|
+
exports.getTracksFromTransportStream = getTracksFromTransportStream;
|
|
30
|
+
const hasAllTracksFromTransportStream = (parserState) => {
|
|
26
31
|
try {
|
|
27
|
-
getTracksFromTransportStream(parserState);
|
|
32
|
+
(0, exports.getTracksFromTransportStream)(parserState);
|
|
28
33
|
return true;
|
|
29
34
|
}
|
|
30
35
|
catch (_a) {
|
|
31
36
|
return false;
|
|
32
37
|
}
|
|
33
38
|
};
|
|
39
|
+
exports.hasAllTracksFromTransportStream = hasAllTracksFromTransportStream;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleAacPacket = void 0;
|
|
4
|
+
const aac_codecprivate_1 = require("../../aac-codecprivate");
|
|
5
|
+
const convert_audio_or_video_sample_1 = require("../../convert-audio-or-video-sample");
|
|
6
|
+
const register_track_1 = require("../../register-track");
|
|
7
|
+
const adts_header_1 = require("./adts-header");
|
|
8
|
+
const handle_avc_packet_1 = require("./handle-avc-packet");
|
|
9
|
+
const handleAacPacket = async ({ streamBuffer, state, programId, offset, }) => {
|
|
7
10
|
var _a;
|
|
8
|
-
const adtsHeader = readAdtsHeader(streamBuffer.buffer);
|
|
11
|
+
const adtsHeader = (0, adts_header_1.readAdtsHeader)(streamBuffer.buffer);
|
|
9
12
|
if (!adtsHeader) {
|
|
10
13
|
throw new Error('Invalid ADTS header - too short');
|
|
11
14
|
}
|
|
@@ -19,15 +22,15 @@ export const handleAacPacket = async ({ streamBuffer, state, programId, offset,
|
|
|
19
22
|
codecPrivate,
|
|
20
23
|
trackId: programId,
|
|
21
24
|
trakBox: null,
|
|
22
|
-
timescale: MPEG_TIMESCALE,
|
|
25
|
+
timescale: handle_avc_packet_1.MPEG_TIMESCALE,
|
|
23
26
|
codecWithoutConfig: 'aac',
|
|
24
|
-
codec: mapAudioObjectTypeToCodecString(audioObjectType),
|
|
27
|
+
codec: (0, aac_codecprivate_1.mapAudioObjectTypeToCodecString)(audioObjectType),
|
|
25
28
|
// https://www.w3.org/TR/webcodecs-aac-codec-registration/
|
|
26
29
|
description: undefined,
|
|
27
30
|
numberOfChannels: channelConfiguration,
|
|
28
31
|
sampleRate,
|
|
29
32
|
};
|
|
30
|
-
await registerAudioTrack({
|
|
33
|
+
await (0, register_track_1.registerAudioTrack)({
|
|
31
34
|
track,
|
|
32
35
|
state,
|
|
33
36
|
container: 'transport-stream',
|
|
@@ -42,7 +45,8 @@ export const handleAacPacket = async ({ streamBuffer, state, programId, offset,
|
|
|
42
45
|
trackId: programId,
|
|
43
46
|
type: 'key',
|
|
44
47
|
offset,
|
|
45
|
-
timescale: MPEG_TIMESCALE,
|
|
48
|
+
timescale: handle_avc_packet_1.MPEG_TIMESCALE,
|
|
46
49
|
};
|
|
47
|
-
await state.callbacks.onAudioSample(programId, convertAudioOrVideoSampleToWebCodecsTimestamps(sample, MPEG_TIMESCALE));
|
|
50
|
+
await state.callbacks.onAudioSample(programId, (0, convert_audio_or_video_sample_1.convertAudioOrVideoSampleToWebCodecsTimestamps)(sample, handle_avc_packet_1.MPEG_TIMESCALE));
|
|
48
51
|
};
|
|
52
|
+
exports.handleAacPacket = handleAacPacket;
|
|
@@ -1,30 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleAvcPacket = exports.MPEG_TIMESCALE = void 0;
|
|
4
|
+
const convert_audio_or_video_sample_1 = require("../../convert-audio-or-video-sample");
|
|
5
|
+
const register_track_1 = require("../../register-track");
|
|
6
|
+
const codec_string_1 = require("../avc/codec-string");
|
|
7
|
+
const create_sps_pps_data_1 = require("../avc/create-sps-pps-data");
|
|
8
|
+
const interpret_sps_1 = require("../avc/interpret-sps");
|
|
9
|
+
const key_1 = require("../avc/key");
|
|
10
|
+
const parse_avc_1 = require("../avc/parse-avc");
|
|
11
|
+
const sps_and_pps_1 = require("../avc/sps-and-pps");
|
|
12
|
+
exports.MPEG_TIMESCALE = 90000;
|
|
13
|
+
const handleAvcPacket = async ({ streamBuffer, programId, state, offset, }) => {
|
|
11
14
|
var _a;
|
|
12
|
-
const avc = parseAvc(streamBuffer.buffer);
|
|
15
|
+
const avc = (0, parse_avc_1.parseAvc)(streamBuffer.buffer);
|
|
13
16
|
const isTrackRegistered = state.callbacks.tracks.getTracks().find((t) => {
|
|
14
17
|
return t.trackId === programId;
|
|
15
18
|
});
|
|
16
19
|
if (!isTrackRegistered) {
|
|
17
|
-
const spsAndPps = getSpsAndPps(avc);
|
|
18
|
-
const dimensions = getDimensionsFromSps(spsAndPps.sps.spsData);
|
|
19
|
-
const sampleAspectRatio = getSampleAspectRatioFromSps(spsAndPps.sps.spsData);
|
|
20
|
+
const spsAndPps = (0, sps_and_pps_1.getSpsAndPps)(avc);
|
|
21
|
+
const dimensions = (0, interpret_sps_1.getDimensionsFromSps)(spsAndPps.sps.spsData);
|
|
22
|
+
const sampleAspectRatio = (0, interpret_sps_1.getSampleAspectRatioFromSps)(spsAndPps.sps.spsData);
|
|
20
23
|
const track = {
|
|
21
24
|
m3uStreamFormat: null,
|
|
22
25
|
rotation: 0,
|
|
23
26
|
trackId: programId,
|
|
24
27
|
type: 'video',
|
|
25
|
-
timescale: MPEG_TIMESCALE,
|
|
26
|
-
codec: getCodecStringFromSpsAndPps(spsAndPps.sps),
|
|
27
|
-
codecPrivate: createSpsPpsData(spsAndPps),
|
|
28
|
+
timescale: exports.MPEG_TIMESCALE,
|
|
29
|
+
codec: (0, codec_string_1.getCodecStringFromSpsAndPps)(spsAndPps.sps),
|
|
30
|
+
codecPrivate: (0, create_sps_pps_data_1.createSpsPpsData)(spsAndPps),
|
|
28
31
|
fps: null,
|
|
29
32
|
codedWidth: dimensions.width,
|
|
30
33
|
codedHeight: dimensions.height,
|
|
@@ -39,9 +42,9 @@ export const handleAvcPacket = async ({ streamBuffer, programId, state, offset,
|
|
|
39
42
|
denominator: sampleAspectRatio.height,
|
|
40
43
|
numerator: sampleAspectRatio.width,
|
|
41
44
|
},
|
|
42
|
-
color: getVideoColorFromSps(spsAndPps.sps.spsData),
|
|
45
|
+
color: (0, interpret_sps_1.getVideoColorFromSps)(spsAndPps.sps.spsData),
|
|
43
46
|
};
|
|
44
|
-
await registerVideoTrack({ track, state, container: 'transport-stream' });
|
|
47
|
+
await (0, register_track_1.registerVideoTrack)({ track, state, container: 'transport-stream' });
|
|
45
48
|
}
|
|
46
49
|
// sample for webcodecs needs to be in nano seconds
|
|
47
50
|
const sample = {
|
|
@@ -51,9 +54,10 @@ export const handleAvcPacket = async ({ streamBuffer, programId, state, offset,
|
|
|
51
54
|
duration: undefined,
|
|
52
55
|
data: new Uint8Array(streamBuffer.buffer),
|
|
53
56
|
trackId: programId,
|
|
54
|
-
type: getKeyFrameOrDeltaFromAvcInfo(avc),
|
|
57
|
+
type: (0, key_1.getKeyFrameOrDeltaFromAvcInfo)(avc),
|
|
55
58
|
offset,
|
|
56
|
-
timescale: MPEG_TIMESCALE,
|
|
59
|
+
timescale: exports.MPEG_TIMESCALE,
|
|
57
60
|
};
|
|
58
|
-
await state.callbacks.onVideoSample(programId, convertAudioOrVideoSampleToWebCodecsTimestamps(sample, MPEG_TIMESCALE));
|
|
61
|
+
await state.callbacks.onVideoSample(programId, (0, convert_audio_or_video_sample_1.convertAudioOrVideoSampleToWebCodecsTimestamps)(sample, exports.MPEG_TIMESCALE));
|
|
59
62
|
};
|
|
63
|
+
exports.handleAvcPacket = handleAvcPacket;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeNextPesHeaderStore = void 0;
|
|
4
|
+
const makeNextPesHeaderStore = () => {
|
|
2
5
|
let nextPesHeader = null;
|
|
3
6
|
return {
|
|
4
7
|
setNextPesHeader: (pesHeader) => {
|
|
@@ -12,3 +15,4 @@ export const makeNextPesHeaderStore = () => {
|
|
|
12
15
|
},
|
|
13
16
|
};
|
|
14
17
|
};
|
|
18
|
+
exports.makeNextPesHeaderStore = makeNextPesHeaderStore;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parsePacket = void 0;
|
|
4
|
+
const parse_pat_1 = require("./parse-pat");
|
|
5
|
+
const parse_pes_1 = require("./parse-pes");
|
|
6
|
+
const parse_pmt_1 = require("./parse-pmt");
|
|
7
|
+
const parse_stream_packet_1 = require("./parse-stream-packet");
|
|
8
|
+
const traversal_1 = require("./traversal");
|
|
9
|
+
const parsePacket = async ({ parserState, }) => {
|
|
7
10
|
const { iterator } = parserState;
|
|
8
11
|
const offset = iterator.counter.getOffset();
|
|
9
12
|
const syncByte = iterator.getUint8();
|
|
@@ -47,29 +50,29 @@ export const parsePacket = async ({ parserState, }) => {
|
|
|
47
50
|
const pat = structure.boxes.find((b) => b.type === 'transport-stream-pmt-box');
|
|
48
51
|
const isPes = payloadUnitStartIndicator && (pat === null || pat === void 0 ? void 0 : pat.streams.find((e) => e.pid === programId));
|
|
49
52
|
if (isPes) {
|
|
50
|
-
const packetPes = parsePes(iterator);
|
|
53
|
+
const packetPes = (0, parse_pes_1.parsePes)(iterator);
|
|
51
54
|
parserState.transportStream.nextPesHeaderStore.setNextPesHeader(packetPes);
|
|
52
55
|
}
|
|
53
56
|
else if (payloadUnitStartIndicator === 1) {
|
|
54
57
|
iterator.getUint8(); // pointerField
|
|
55
58
|
}
|
|
56
59
|
if (programId === 0) {
|
|
57
|
-
return Promise.resolve(parsePat(iterator));
|
|
60
|
+
return Promise.resolve((0, parse_pat_1.parsePat)(iterator));
|
|
58
61
|
}
|
|
59
62
|
if (programId === 17) {
|
|
60
|
-
return Promise.resolve(parseSdt(iterator));
|
|
63
|
+
return Promise.resolve((0, parse_pat_1.parseSdt)(iterator));
|
|
61
64
|
}
|
|
62
65
|
// PID 17 is SDT
|
|
63
66
|
// https://de.wikipedia.org/wiki/MPEG-Transportstrom
|
|
64
67
|
// Die Service Description Table nennt den Programmnamen (z. B. „ZDF“) und gibt weitere Informationen der einzelnen Programme (Services); sie wird auf PID 17 übertragen.
|
|
65
|
-
const program = programId === 17 ? null : getProgramForId(structure, programId);
|
|
68
|
+
const program = programId === 17 ? null : (0, traversal_1.getProgramForId)(structure, programId);
|
|
66
69
|
if (program) {
|
|
67
|
-
const pmt = parsePmt(iterator);
|
|
70
|
+
const pmt = (0, parse_pmt_1.parsePmt)(iterator);
|
|
68
71
|
return Promise.resolve(pmt);
|
|
69
72
|
}
|
|
70
|
-
const stream = getStreamForId(structure, programId);
|
|
73
|
+
const stream = (0, traversal_1.getStreamForId)(structure, programId);
|
|
71
74
|
if (stream) {
|
|
72
|
-
await parseStream({
|
|
75
|
+
await (0, parse_stream_packet_1.parseStream)({
|
|
73
76
|
transportStreamEntry: stream,
|
|
74
77
|
state: parserState,
|
|
75
78
|
programId,
|
|
@@ -79,3 +82,4 @@ export const parsePacket = async ({ parserState, }) => {
|
|
|
79
82
|
}
|
|
80
83
|
throw new Error('Unknown packet identifier');
|
|
81
84
|
};
|
|
85
|
+
exports.parsePacket = parsePacket;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// https://en.wikipedia.org/wiki/Program-specific_information
|
|
2
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.parseSdt = exports.parsePat = void 0;
|
|
5
|
+
const discard_rest_of_packet_1 = require("./discard-rest-of-packet");
|
|
3
6
|
const parsePatTable = (iterator, tableId) => {
|
|
4
7
|
iterator.getUint16(); // table ID extension
|
|
5
8
|
iterator.startReadingBits();
|
|
@@ -28,7 +31,7 @@ const parsePatTable = (iterator, tableId) => {
|
|
|
28
31
|
pat: tables,
|
|
29
32
|
};
|
|
30
33
|
};
|
|
31
|
-
|
|
34
|
+
const parsePat = (iterator) => {
|
|
32
35
|
iterator.startReadingBits();
|
|
33
36
|
const tableId = iterator.getBits(8);
|
|
34
37
|
iterator.getBits(1); // syntax indicator
|
|
@@ -40,10 +43,11 @@ export const parsePat = (iterator) => {
|
|
|
40
43
|
}
|
|
41
44
|
iterator.stopReadingBits();
|
|
42
45
|
const tables = parsePatTable(iterator, tableId);
|
|
43
|
-
discardRestOfPacket(iterator);
|
|
46
|
+
(0, discard_rest_of_packet_1.discardRestOfPacket)(iterator);
|
|
44
47
|
return tables;
|
|
45
48
|
};
|
|
46
|
-
|
|
49
|
+
exports.parsePat = parsePat;
|
|
50
|
+
const parseSdt = (iterator) => {
|
|
47
51
|
iterator.startReadingBits();
|
|
48
52
|
iterator.getBits(8); // table ID
|
|
49
53
|
iterator.getBits(1); // section syntax indicator
|
|
@@ -52,8 +56,9 @@ export const parseSdt = (iterator) => {
|
|
|
52
56
|
const sectionLength = iterator.getBits(12);
|
|
53
57
|
iterator.stopReadingBits();
|
|
54
58
|
iterator.discard(sectionLength);
|
|
55
|
-
discardRestOfPacket(iterator);
|
|
59
|
+
(0, discard_rest_of_packet_1.discardRestOfPacket)(iterator);
|
|
56
60
|
return {
|
|
57
61
|
type: 'transport-stream-sdt-box',
|
|
58
62
|
};
|
|
59
63
|
};
|
|
64
|
+
exports.parseSdt = parseSdt;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parsePes = void 0;
|
|
4
|
+
const parsePes = (iterator) => {
|
|
2
5
|
const ident = iterator.getUint24();
|
|
3
6
|
if (ident !== 0x000001) {
|
|
4
7
|
throw new Error(`Unexpected PES packet start code: ${ident.toString(16)}`);
|
|
@@ -70,3 +73,4 @@ export const parsePes = (iterator) => {
|
|
|
70
73
|
};
|
|
71
74
|
return packet;
|
|
72
75
|
};
|
|
76
|
+
exports.parsePes = parsePes;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parsePmt = void 0;
|
|
4
|
+
const discard_rest_of_packet_1 = require("./discard-rest-of-packet");
|
|
2
5
|
const parsePmtTable = ({ iterator, tableId, sectionLength, }) => {
|
|
3
6
|
const start = iterator.counter.getOffset();
|
|
4
7
|
iterator.getUint16(); // table ID extension
|
|
@@ -43,7 +46,7 @@ const parsePmtTable = ({ iterator, tableId, sectionLength, }) => {
|
|
|
43
46
|
streams: tables[0].streams,
|
|
44
47
|
};
|
|
45
48
|
};
|
|
46
|
-
|
|
49
|
+
const parsePmt = (iterator) => {
|
|
47
50
|
iterator.startReadingBits();
|
|
48
51
|
const tableId = iterator.getBits(8);
|
|
49
52
|
iterator.getBits(1); // syntax indicator
|
|
@@ -55,6 +58,7 @@ export const parsePmt = (iterator) => {
|
|
|
55
58
|
}
|
|
56
59
|
iterator.stopReadingBits();
|
|
57
60
|
const tables = parsePmtTable({ iterator, tableId, sectionLength });
|
|
58
|
-
discardRestOfPacket(iterator);
|
|
61
|
+
(0, discard_rest_of_packet_1.discardRestOfPacket)(iterator);
|
|
59
62
|
return tables;
|
|
60
63
|
};
|
|
64
|
+
exports.parsePmt = parsePmt;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseStream = void 0;
|
|
4
|
+
const combine_uint8_arrays_1 = require("../../combine-uint8-arrays");
|
|
5
|
+
const adts_header_1 = require("./adts-header");
|
|
6
|
+
const discard_rest_of_packet_1 = require("./discard-rest-of-packet");
|
|
7
|
+
const find_separator_1 = require("./find-separator");
|
|
8
|
+
const process_stream_buffers_1 = require("./process-stream-buffers");
|
|
6
9
|
const parseAdtsStream = async ({ transportStreamEntry, state, structure, offset, }) => {
|
|
7
10
|
var _a, _b;
|
|
8
11
|
const { streamBuffers, nextPesHeaderStore: nextPesHeader } = state.transportStream;
|
|
@@ -11,14 +14,14 @@ const parseAdtsStream = async ({ transportStreamEntry, state, structure, offset,
|
|
|
11
14
|
if (!streamBuffer) {
|
|
12
15
|
throw new Error('Stream buffer not found');
|
|
13
16
|
}
|
|
14
|
-
const expectedLength = (_b = (_a = readAdtsHeader(streamBuffer.buffer)) === null || _a === void 0 ? void 0 : _a.frameLength) !== null && _b !== void 0 ? _b : null;
|
|
17
|
+
const expectedLength = (_b = (_a = (0, adts_header_1.readAdtsHeader)(streamBuffer.buffer)) === null || _a === void 0 ? void 0 : _a.frameLength) !== null && _b !== void 0 ? _b : null;
|
|
15
18
|
if (expectedLength === null) {
|
|
16
19
|
break;
|
|
17
20
|
}
|
|
18
21
|
if (expectedLength > streamBuffer.buffer.length) {
|
|
19
22
|
break;
|
|
20
23
|
}
|
|
21
|
-
await processStreamBuffer({
|
|
24
|
+
await (0, process_stream_buffers_1.processStreamBuffer)({
|
|
22
25
|
streamBuffer: {
|
|
23
26
|
buffer: streamBuffer.buffer.slice(0, expectedLength),
|
|
24
27
|
offset,
|
|
@@ -37,13 +40,13 @@ const parseAdtsStream = async ({ transportStreamEntry, state, structure, offset,
|
|
|
37
40
|
}
|
|
38
41
|
};
|
|
39
42
|
const parseAvcStream = async ({ programId, state, structure, streamBuffer, }) => {
|
|
40
|
-
const indexOfSeparator = findNthSubarrayIndex(streamBuffer.buffer, new Uint8Array([0, 0, 1, 9]), 2);
|
|
43
|
+
const indexOfSeparator = (0, find_separator_1.findNthSubarrayIndex)(streamBuffer.buffer, new Uint8Array([0, 0, 1, 9]), 2);
|
|
41
44
|
if (indexOfSeparator === -1 || indexOfSeparator === 0) {
|
|
42
45
|
return null;
|
|
43
46
|
}
|
|
44
47
|
const packet = streamBuffer.buffer.slice(0, indexOfSeparator);
|
|
45
48
|
const rest = streamBuffer.buffer.slice(indexOfSeparator);
|
|
46
|
-
await processStreamBuffer({
|
|
49
|
+
await (0, process_stream_buffers_1.processStreamBuffer)({
|
|
47
50
|
state,
|
|
48
51
|
streamBuffer: {
|
|
49
52
|
offset: streamBuffer.offset,
|
|
@@ -56,9 +59,9 @@ const parseAvcStream = async ({ programId, state, structure, streamBuffer, }) =>
|
|
|
56
59
|
});
|
|
57
60
|
return rest;
|
|
58
61
|
};
|
|
59
|
-
|
|
62
|
+
const parseStream = async ({ transportStreamEntry, state, programId, structure, }) => {
|
|
60
63
|
const { iterator } = state;
|
|
61
|
-
let restOfPacket = getRestOfPacket(iterator);
|
|
64
|
+
let restOfPacket = (0, discard_rest_of_packet_1.getRestOfPacket)(iterator);
|
|
62
65
|
const offset = iterator.counter.getOffset();
|
|
63
66
|
if (transportStreamEntry.streamType === 27) {
|
|
64
67
|
const { streamBuffers, nextPesHeaderStore: nextPesHeader } = state.transportStream;
|
|
@@ -71,7 +74,7 @@ export const parseStream = async ({ transportStreamEntry, state, programId, stru
|
|
|
71
74
|
});
|
|
72
75
|
}
|
|
73
76
|
const streamBuffer = streamBuffers.get(transportStreamEntry.pid);
|
|
74
|
-
streamBuffer.buffer = combineUint8Arrays([
|
|
77
|
+
streamBuffer.buffer = (0, combine_uint8_arrays_1.combineUint8Arrays)([
|
|
75
78
|
streamBuffer.buffer,
|
|
76
79
|
restOfPacket,
|
|
77
80
|
]);
|
|
@@ -105,7 +108,7 @@ export const parseStream = async ({ transportStreamEntry, state, programId, stru
|
|
|
105
108
|
});
|
|
106
109
|
}
|
|
107
110
|
else {
|
|
108
|
-
streamBuffer.buffer = combineUint8Arrays([
|
|
111
|
+
streamBuffer.buffer = (0, combine_uint8_arrays_1.combineUint8Arrays)([
|
|
109
112
|
streamBuffer.buffer,
|
|
110
113
|
restOfPacket,
|
|
111
114
|
]);
|
|
@@ -119,3 +122,4 @@ export const parseStream = async ({ transportStreamEntry, state, programId, stru
|
|
|
119
122
|
}
|
|
120
123
|
throw new Error(`Unsupported stream type ${transportStreamEntry.streamType}`);
|
|
121
124
|
};
|
|
125
|
+
exports.parseStream = parseStream;
|
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseTransportStream = void 0;
|
|
4
|
+
const parse_packet_1 = require("./parse-packet");
|
|
5
|
+
const process_stream_buffers_1 = require("./process-stream-buffers");
|
|
6
|
+
const parseTransportStream = async (state) => {
|
|
4
7
|
const structure = state.getTsStructure();
|
|
5
8
|
const { iterator } = state;
|
|
6
9
|
if (iterator.bytesRemaining() < 188) {
|
|
7
10
|
return Promise.resolve(null);
|
|
8
11
|
}
|
|
9
|
-
const packet = await parsePacket({
|
|
12
|
+
const packet = await (0, parse_packet_1.parsePacket)({
|
|
10
13
|
parserState: state,
|
|
11
14
|
});
|
|
12
15
|
if (packet) {
|
|
13
16
|
structure.boxes.push(packet);
|
|
14
17
|
}
|
|
15
18
|
if (iterator.bytesRemaining() === 0) {
|
|
16
|
-
await processFinalStreamBuffers({
|
|
19
|
+
await (0, process_stream_buffers_1.processFinalStreamBuffers)({
|
|
17
20
|
state,
|
|
18
21
|
structure,
|
|
19
22
|
});
|
|
20
23
|
}
|
|
21
24
|
return Promise.resolve(null);
|
|
22
25
|
};
|
|
26
|
+
exports.parseTransportStream = parseTransportStream;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processFinalStreamBuffers = exports.processStreamBuffer = void 0;
|
|
4
|
+
const get_tracks_1 = require("./get-tracks");
|
|
5
|
+
const handle_aac_packet_1 = require("./handle-aac-packet");
|
|
6
|
+
const handle_avc_packet_1 = require("./handle-avc-packet");
|
|
7
|
+
const traversal_1 = require("./traversal");
|
|
8
|
+
const processStreamBuffer = async ({ streamBuffer, state, programId, structure, }) => {
|
|
9
|
+
const stream = (0, traversal_1.getStreamForId)(structure, programId);
|
|
7
10
|
if (!stream) {
|
|
8
11
|
throw new Error('No stream found');
|
|
9
12
|
}
|
|
10
13
|
// 27 = AVC / H.264 Video
|
|
11
14
|
if (stream.streamType === 27) {
|
|
12
|
-
await handleAvcPacket({
|
|
15
|
+
await (0, handle_avc_packet_1.handleAvcPacket)({
|
|
13
16
|
programId,
|
|
14
17
|
streamBuffer,
|
|
15
18
|
state,
|
|
@@ -18,7 +21,7 @@ export const processStreamBuffer = async ({ streamBuffer, state, programId, stru
|
|
|
18
21
|
}
|
|
19
22
|
// 15 = AAC / ADTS
|
|
20
23
|
else if (stream.streamType === 15) {
|
|
21
|
-
await handleAacPacket({
|
|
24
|
+
await (0, handle_aac_packet_1.handleAacPacket)({
|
|
22
25
|
streamBuffer,
|
|
23
26
|
state,
|
|
24
27
|
programId,
|
|
@@ -27,16 +30,17 @@ export const processStreamBuffer = async ({ streamBuffer, state, programId, stru
|
|
|
27
30
|
}
|
|
28
31
|
if (!state.callbacks.tracks.hasAllTracks()) {
|
|
29
32
|
const tracksRegistered = state.callbacks.tracks.getTracks().length;
|
|
30
|
-
const { streams } = findProgramMapTableOrThrow(structure);
|
|
31
|
-
if (filterStreamsBySupportedTypes(streams).length === tracksRegistered) {
|
|
33
|
+
const { streams } = (0, traversal_1.findProgramMapTableOrThrow)(structure);
|
|
34
|
+
if ((0, get_tracks_1.filterStreamsBySupportedTypes)(streams).length === tracksRegistered) {
|
|
32
35
|
state.callbacks.tracks.setIsDone(state.logLevel);
|
|
33
36
|
}
|
|
34
37
|
}
|
|
35
38
|
};
|
|
36
|
-
|
|
39
|
+
exports.processStreamBuffer = processStreamBuffer;
|
|
40
|
+
const processFinalStreamBuffers = async ({ state, structure, }) => {
|
|
37
41
|
for (const [programId, buffer] of state.transportStream.streamBuffers) {
|
|
38
42
|
if (buffer.buffer.byteLength > 0) {
|
|
39
|
-
await processStreamBuffer({
|
|
43
|
+
await (0, exports.processStreamBuffer)({
|
|
40
44
|
streamBuffer: buffer,
|
|
41
45
|
state,
|
|
42
46
|
programId,
|
|
@@ -46,3 +50,4 @@ export const processFinalStreamBuffers = async ({ state, structure, }) => {
|
|
|
46
50
|
}
|
|
47
51
|
}
|
|
48
52
|
};
|
|
53
|
+
exports.processFinalStreamBuffers = processFinalStreamBuffers;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getStreamForId = exports.getProgramForId = exports.findProgramMapTableOrThrow = void 0;
|
|
1
4
|
const findProgramAssociationTableOrThrow = (structure) => {
|
|
2
5
|
const box = structure.boxes.find((b) => b.type === 'transport-stream-pat-box');
|
|
3
6
|
if (!box) {
|
|
@@ -5,20 +8,23 @@ const findProgramAssociationTableOrThrow = (structure) => {
|
|
|
5
8
|
}
|
|
6
9
|
return box;
|
|
7
10
|
};
|
|
8
|
-
|
|
11
|
+
const findProgramMapTableOrThrow = (structure) => {
|
|
9
12
|
const box = structure.boxes.find((b) => b.type === 'transport-stream-pmt-box');
|
|
10
13
|
if (!box) {
|
|
11
14
|
throw new Error('No PMT box found');
|
|
12
15
|
}
|
|
13
16
|
return box;
|
|
14
17
|
};
|
|
15
|
-
|
|
18
|
+
exports.findProgramMapTableOrThrow = findProgramMapTableOrThrow;
|
|
19
|
+
const getProgramForId = (structure, packetIdentifier) => {
|
|
16
20
|
const box = findProgramAssociationTableOrThrow(structure);
|
|
17
21
|
const entry = box.pat.find((e) => e.programMapIdentifier === packetIdentifier);
|
|
18
22
|
return entry !== null && entry !== void 0 ? entry : null;
|
|
19
23
|
};
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
exports.getProgramForId = getProgramForId;
|
|
25
|
+
const getStreamForId = (structure, packetIdentifier) => {
|
|
26
|
+
const box = (0, exports.findProgramMapTableOrThrow)(structure);
|
|
22
27
|
const entry = box.streams.find((e) => e.pid === packetIdentifier);
|
|
23
28
|
return entry !== null && entry !== void 0 ? entry : null;
|
|
24
29
|
};
|
|
30
|
+
exports.getStreamForId = getStreamForId;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hasDurationFromWav = exports.getDurationFromWav = void 0;
|
|
4
|
+
const getDurationFromWav = (state) => {
|
|
2
5
|
const structure = state.getWavStructure();
|
|
3
6
|
const fmt = structure.boxes.find((b) => b.type === 'wav-fmt');
|
|
4
7
|
if (!fmt) {
|
|
@@ -11,11 +14,13 @@ export const getDurationFromWav = (state) => {
|
|
|
11
14
|
const durationInSeconds = dataBox.dataSize / (fmt.sampleRate * fmt.blockAlign);
|
|
12
15
|
return durationInSeconds;
|
|
13
16
|
};
|
|
14
|
-
|
|
17
|
+
exports.getDurationFromWav = getDurationFromWav;
|
|
18
|
+
const hasDurationFromWav = (state) => {
|
|
15
19
|
try {
|
|
16
|
-
return getDurationFromWav(state);
|
|
20
|
+
return (0, exports.getDurationFromWav)(state);
|
|
17
21
|
}
|
|
18
22
|
catch (_a) {
|
|
19
23
|
return false;
|
|
20
24
|
}
|
|
21
25
|
};
|
|
26
|
+
exports.hasDurationFromWav = hasDurationFromWav;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMetadataFromWav = void 0;
|
|
4
|
+
const getMetadataFromWav = (structure) => {
|
|
2
5
|
const list = structure.boxes.find((b) => b.type === 'wav-list');
|
|
3
6
|
if (!list) {
|
|
4
7
|
return null;
|
|
5
8
|
}
|
|
6
9
|
return list.metadata;
|
|
7
10
|
};
|
|
11
|
+
exports.getMetadataFromWav = getMetadataFromWav;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseData = void 0;
|
|
4
|
+
const skip_1 = require("../../skip");
|
|
5
|
+
const may_skip_video_data_1 = require("../../state/may-skip-video-data");
|
|
6
|
+
const parseData = ({ state, }) => {
|
|
4
7
|
const { iterator } = state;
|
|
5
8
|
const ckSize = iterator.getUint32Le(); // chunkSize
|
|
6
9
|
const box = {
|
|
@@ -13,9 +16,10 @@ export const parseData = ({ state, }) => {
|
|
|
13
16
|
size: ckSize,
|
|
14
17
|
start: iterator.counter.getOffset(),
|
|
15
18
|
});
|
|
16
|
-
if (maySkipVideoData({ state })) {
|
|
19
|
+
if ((0, may_skip_video_data_1.maySkipVideoData)({ state })) {
|
|
17
20
|
// Skipping only in query mode
|
|
18
|
-
return Promise.resolve(makeSkip(iterator.counter.getOffset() + ckSize));
|
|
21
|
+
return Promise.resolve((0, skip_1.makeSkip)(iterator.counter.getOffset() + ckSize));
|
|
19
22
|
}
|
|
20
23
|
return Promise.resolve(null);
|
|
21
24
|
};
|
|
25
|
+
exports.parseData = parseData;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseFmt = void 0;
|
|
4
|
+
const register_track_1 = require("../../register-track");
|
|
5
|
+
const parseFmt = async ({ state, }) => {
|
|
3
6
|
const { iterator } = state;
|
|
4
7
|
const ckSize = iterator.getUint32Le(); // chunkSize
|
|
5
8
|
const box = iterator.startBox(ckSize);
|
|
@@ -31,7 +34,7 @@ export const parseFmt = async ({ state, }) => {
|
|
|
31
34
|
type: 'wav-fmt',
|
|
32
35
|
};
|
|
33
36
|
state.getWavStructure().boxes.push(wavHeader);
|
|
34
|
-
await registerAudioTrack({
|
|
37
|
+
await (0, register_track_1.registerAudioTrack)({
|
|
35
38
|
state,
|
|
36
39
|
track: {
|
|
37
40
|
type: 'audio',
|
|
@@ -50,3 +53,4 @@ export const parseFmt = async ({ state, }) => {
|
|
|
50
53
|
box.expectNoMoreBytes();
|
|
51
54
|
return Promise.resolve(null);
|
|
52
55
|
};
|
|
56
|
+
exports.parseFmt = parseFmt;
|