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