@remotion/media-parser 4.0.276 → 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.
Files changed (260) hide show
  1. package/dist/aac-codecprivate.js +13 -6
  2. package/dist/add-avc-profile-to-track.js +9 -5
  3. package/dist/buffer-iterator.js +13 -8
  4. package/dist/combine-uint8-arrays.js +5 -1
  5. package/dist/containers/aac/parse-aac.js +13 -9
  6. package/dist/containers/aac/types.js +2 -1
  7. package/dist/containers/avc/codec-string.js +5 -1
  8. package/dist/containers/avc/color.js +9 -3
  9. package/dist/containers/avc/create-sps-pps-data.js +9 -5
  10. package/dist/containers/avc/interpret-sps.js +13 -7
  11. package/dist/containers/avc/key.js +5 -1
  12. package/dist/containers/avc/parse-avc.js +7 -3
  13. package/dist/containers/avc/sps-and-pps.js +5 -1
  14. package/dist/containers/flac/get-block-size.js +5 -1
  15. package/dist/containers/flac/get-channel-count.js +5 -1
  16. package/dist/containers/flac/get-duration-from-flac.js +5 -1
  17. package/dist/containers/flac/get-metadata-from-flac.js +5 -1
  18. package/dist/containers/flac/get-sample-rate.js +5 -1
  19. package/dist/containers/flac/parse-flac-frame.js +19 -14
  20. package/dist/containers/flac/parse-flac.js +19 -15
  21. package/dist/containers/flac/parse-header.js +5 -1
  22. package/dist/containers/flac/parse-metadata.js +5 -1
  23. package/dist/containers/flac/parse-streaminfo.js +7 -3
  24. package/dist/containers/flac/parse-unknown-block.js +5 -1
  25. package/dist/containers/flac/types.js +2 -1
  26. package/dist/containers/iso-base-media/base-media-box.js +2 -1
  27. package/dist/containers/iso-base-media/base-type.js +2 -1
  28. package/dist/containers/iso-base-media/esds/decoder-specific-config.js +5 -1
  29. package/dist/containers/iso-base-media/esds/esds-descriptors.js +10 -5
  30. package/dist/containers/iso-base-media/esds/esds.js +7 -3
  31. package/dist/containers/iso-base-media/ftyp.js +5 -1
  32. package/dist/containers/iso-base-media/get-actual-number-of-channels.js +8 -4
  33. package/dist/containers/iso-base-media/get-children.js +7 -3
  34. package/dist/containers/iso-base-media/get-keyframes.js +11 -7
  35. package/dist/containers/iso-base-media/get-moov-atom.js +17 -13
  36. package/dist/containers/iso-base-media/get-sample-positions-from-track.js +24 -20
  37. package/dist/containers/iso-base-media/get-video-codec-from-iso-track.js +7 -3
  38. package/dist/containers/iso-base-media/make-track.js +34 -30
  39. package/dist/containers/iso-base-media/mdat/mdat.js +20 -16
  40. package/dist/containers/iso-base-media/mdhd.js +5 -1
  41. package/dist/containers/iso-base-media/meta/hdlr.js +5 -1
  42. package/dist/containers/iso-base-media/meta/ilst.js +5 -1
  43. package/dist/containers/iso-base-media/moov/moov.js +7 -3
  44. package/dist/containers/iso-base-media/mvhd.js +11 -7
  45. package/dist/containers/iso-base-media/parse-boxes.js +9 -5
  46. package/dist/containers/iso-base-media/parse-icc-profile.js +8 -4
  47. package/dist/containers/iso-base-media/process-box.js +67 -63
  48. package/dist/containers/iso-base-media/stsd/av1c.js +5 -1
  49. package/dist/containers/iso-base-media/stsd/avcc.js +5 -1
  50. package/dist/containers/iso-base-media/stsd/colr.js +7 -3
  51. package/dist/containers/iso-base-media/stsd/ctts.js +5 -1
  52. package/dist/containers/iso-base-media/stsd/hvcc.js +7 -3
  53. package/dist/containers/iso-base-media/stsd/keys.js +5 -1
  54. package/dist/containers/iso-base-media/stsd/mebx.js +7 -3
  55. package/dist/containers/iso-base-media/stsd/pasp.js +5 -1
  56. package/dist/containers/iso-base-media/stsd/samples.js +13 -8
  57. package/dist/containers/iso-base-media/stsd/stco.js +5 -1
  58. package/dist/containers/iso-base-media/stsd/stsc.js +5 -1
  59. package/dist/containers/iso-base-media/stsd/stsd.js +7 -3
  60. package/dist/containers/iso-base-media/stsd/stss.js +5 -1
  61. package/dist/containers/iso-base-media/stsd/stsz.js +5 -1
  62. package/dist/containers/iso-base-media/stsd/stts.js +5 -1
  63. package/dist/containers/iso-base-media/tfdt.js +5 -1
  64. package/dist/containers/iso-base-media/tfhd.js +5 -1
  65. package/dist/containers/iso-base-media/tkhd.js +8 -4
  66. package/dist/containers/iso-base-media/to-date.js +5 -1
  67. package/dist/containers/iso-base-media/trak/trak.js +7 -3
  68. package/dist/containers/iso-base-media/traversal.js +57 -33
  69. package/dist/containers/iso-base-media/trun.js +5 -1
  70. package/dist/containers/iso-base-media/void-box.js +2 -1
  71. package/dist/containers/m3u/after-manifest-fetch.js +15 -11
  72. package/dist/containers/m3u/fetch-m3u8-stream.js +7 -3
  73. package/dist/containers/m3u/get-chunks.js +5 -1
  74. package/dist/containers/m3u/get-duration-from-m3u.js +8 -4
  75. package/dist/containers/m3u/get-playlist.js +12 -6
  76. package/dist/containers/m3u/get-streams.js +9 -3
  77. package/dist/containers/m3u/iterate-over-segment-files.js +15 -11
  78. package/dist/containers/m3u/parse-directive.js +10 -6
  79. package/dist/containers/m3u/parse-m3u-manifest.js +7 -3
  80. package/dist/containers/m3u/parse-m3u-media-directive.js +10 -5
  81. package/dist/containers/m3u/parse-m3u.js +11 -7
  82. package/dist/containers/m3u/parse-m3u8-text.js +7 -3
  83. package/dist/containers/m3u/parse-stream-inf.js +7 -2
  84. package/dist/containers/m3u/run-over-m3u.js +13 -9
  85. package/dist/containers/m3u/sample-sorter.js +8 -4
  86. package/dist/containers/m3u/select-stream.js +11 -4
  87. package/dist/containers/m3u/types.js +2 -1
  88. package/dist/containers/mp3/get-duration.js +9 -5
  89. package/dist/containers/mp3/get-frame-length.js +7 -2
  90. package/dist/containers/mp3/get-metadata-from-mp3.js +5 -1
  91. package/dist/containers/mp3/id3-v1.js +5 -1
  92. package/dist/containers/mp3/id3.js +5 -1
  93. package/dist/containers/mp3/parse-mp3.js +11 -7
  94. package/dist/containers/mp3/parse-mpeg-header.js +14 -10
  95. package/dist/containers/mp3/samples-per-mpeg-file.js +5 -1
  96. package/dist/containers/riff/expect-riff-box.js +15 -11
  97. package/dist/containers/riff/get-duration.js +12 -7
  98. package/dist/containers/riff/get-tracks-from-avi.js +28 -20
  99. package/dist/containers/riff/is-movi.js +5 -1
  100. package/dist/containers/riff/parse-avih.js +5 -1
  101. package/dist/containers/riff/parse-isft.js +5 -1
  102. package/dist/containers/riff/parse-list-box.js +7 -3
  103. package/dist/containers/riff/parse-movi.js +18 -13
  104. package/dist/containers/riff/parse-riff-body.js +13 -9
  105. package/dist/containers/riff/parse-riff-box.js +13 -9
  106. package/dist/containers/riff/parse-riff-header.js +5 -1
  107. package/dist/containers/riff/parse-riff.js +9 -5
  108. package/dist/containers/riff/parse-strf.js +5 -1
  109. package/dist/containers/riff/parse-strh.js +7 -3
  110. package/dist/containers/riff/parse-video-section.js +11 -7
  111. package/dist/containers/riff/riff-box.js +2 -1
  112. package/dist/containers/riff/timescale.js +4 -1
  113. package/dist/containers/riff/traversal.js +15 -7
  114. package/dist/containers/transport-stream/adts-header.js +10 -6
  115. package/dist/containers/transport-stream/boxes.js +2 -1
  116. package/dist/containers/transport-stream/discard-rest-of-packet.js +7 -2
  117. package/dist/containers/transport-stream/find-separator.js +4 -1
  118. package/dist/containers/transport-stream/get-tracks.js +16 -10
  119. package/dist/containers/transport-stream/handle-aac-packet.js +16 -12
  120. package/dist/containers/transport-stream/handle-avc-packet.js +26 -22
  121. package/dist/containers/transport-stream/next-pes-header-store.js +5 -1
  122. package/dist/containers/transport-stream/parse-packet.js +17 -13
  123. package/dist/containers/transport-stream/parse-pat.js +10 -5
  124. package/dist/containers/transport-stream/parse-pes.js +5 -1
  125. package/dist/containers/transport-stream/parse-pmt.js +7 -3
  126. package/dist/containers/transport-stream/parse-stream-packet.js +17 -13
  127. package/dist/containers/transport-stream/parse-transport-stream.js +9 -5
  128. package/dist/containers/transport-stream/process-stream-buffers.js +17 -12
  129. package/dist/containers/transport-stream/traversal.js +10 -4
  130. package/dist/containers/wav/get-duration-from-wav.js +8 -3
  131. package/dist/containers/wav/get-metadata-from-wav.js +5 -1
  132. package/dist/containers/wav/parse-data.js +9 -5
  133. package/dist/containers/wav/parse-fmt.js +7 -3
  134. package/dist/containers/wav/parse-header.js +5 -1
  135. package/dist/containers/wav/parse-id3.js +5 -1
  136. package/dist/containers/wav/parse-list.js +5 -1
  137. package/dist/containers/wav/parse-video-section.js +7 -3
  138. package/dist/containers/wav/parse-wav.js +19 -15
  139. package/dist/containers/wav/types.js +2 -1
  140. package/dist/containers/webm/allowed-partial-segments.js +4 -1
  141. package/dist/containers/webm/av1-codec-private.js +7 -3
  142. package/dist/containers/webm/color.js +10 -6
  143. package/dist/containers/webm/description.js +10 -6
  144. package/dist/containers/webm/get-ready-tracks.js +18 -13
  145. package/dist/containers/webm/get-sample-from-block.js +16 -12
  146. package/dist/containers/webm/make-track.js +48 -43
  147. package/dist/containers/webm/parse-ebml.js +19 -14
  148. package/dist/containers/webm/parse-webm-header.js +7 -3
  149. package/dist/containers/webm/segments/all-segments.js +173 -168
  150. package/dist/containers/webm/segments/block-simple-block-flags.js +8 -4
  151. package/dist/containers/webm/segments/track-entry.js +5 -1
  152. package/dist/containers/webm/segments.js +13 -9
  153. package/dist/containers/webm/traversal.js +67 -37
  154. package/dist/convert-audio-or-video-sample.js +5 -1
  155. package/dist/download-and-parse-media.js +14 -10
  156. package/dist/emit-available-info.js +38 -34
  157. package/dist/emitter.js +5 -1
  158. package/dist/errors.js +15 -6
  159. package/dist/esm/index.mjs +1 -1
  160. package/dist/esm/worker.mjs +4 -5
  161. package/dist/fetch.js +17 -1
  162. package/dist/file-types/bmp.js +7 -3
  163. package/dist/file-types/detect-file-type.js +38 -24
  164. package/dist/file-types/index.js +26 -22
  165. package/dist/file-types/jpeg.js +9 -4
  166. package/dist/file-types/pdf.js +7 -3
  167. package/dist/file-types/png.js +9 -4
  168. package/dist/file-types/webp.js +7 -3
  169. package/dist/forward-controller.js +5 -1
  170. package/dist/get-audio-codec.js +38 -25
  171. package/dist/get-container.js +10 -5
  172. package/dist/get-dimensions.js +13 -8
  173. package/dist/get-duration.js +34 -27
  174. package/dist/get-fields-from-callbacks.js +5 -1
  175. package/dist/get-fps.js +34 -24
  176. package/dist/get-is-hdr.js +10 -5
  177. package/dist/get-keyframes.js +11 -6
  178. package/dist/get-location.js +9 -4
  179. package/dist/get-number-of-audio-channels.js +7 -2
  180. package/dist/get-sample-aspect-ratio.js +30 -17
  181. package/dist/get-sample-positions-from-lpcm.js +9 -5
  182. package/dist/get-sample-positions.js +5 -1
  183. package/dist/get-sample-rate.js +7 -2
  184. package/dist/get-tracks.js +40 -29
  185. package/dist/get-video-codec.js +34 -26
  186. package/dist/has-all-info.js +38 -33
  187. package/dist/index.js +47 -32
  188. package/dist/init-video.js +28 -24
  189. package/dist/internal-parse-media.js +39 -35
  190. package/dist/is-audio-structure.js +5 -1
  191. package/dist/log.js +12 -8
  192. package/dist/make-hvc1-codec-strings.js +5 -1
  193. package/dist/media-parser-controller.js +11 -7
  194. package/dist/metadata/get-metadata.js +22 -17
  195. package/dist/metadata/metadata-from-iso.js +17 -12
  196. package/dist/metadata/metadata-from-matroska.js +7 -3
  197. package/dist/metadata/metadata-from-riff.js +7 -3
  198. package/dist/node-writer.js +17 -1
  199. package/dist/node.js +17 -1
  200. package/dist/options.js +2 -1
  201. package/dist/parse-media-on-worker-entry.js +7 -3
  202. package/dist/parse-media.js +12 -8
  203. package/dist/parse-result.js +2 -1
  204. package/dist/pause-signal.js +5 -1
  205. package/dist/perform-seek.js +10 -6
  206. package/dist/readers/fetch/get-body-and-reader.js +5 -1
  207. package/dist/readers/fetch/resolve-url.js +5 -1
  208. package/dist/readers/from-fetch.js +21 -14
  209. package/dist/readers/from-node.js +23 -17
  210. package/dist/readers/from-web-file.js +13 -7
  211. package/dist/readers/reader.js +2 -1
  212. package/dist/readers/universal.js +16 -13
  213. package/dist/readers/web.js +12 -9
  214. package/dist/register-track.js +15 -9
  215. package/dist/remotion-license-acknowledge.js +8 -4
  216. package/dist/run-parse-iteration.js +25 -21
  217. package/dist/samples-from-moof.js +10 -6
  218. package/dist/skip.js +5 -1
  219. package/dist/state/aac-state.js +5 -1
  220. package/dist/state/can-skip-tracks.js +8 -3
  221. package/dist/state/emitted-fields.js +5 -1
  222. package/dist/state/flac-state.js +5 -1
  223. package/dist/state/has-tracks-section.js +7 -3
  224. package/dist/state/images.js +5 -1
  225. package/dist/state/iso-base-media/cached-sample-positions.js +13 -8
  226. package/dist/state/iso-base-media/iso-state.js +9 -5
  227. package/dist/state/iso-base-media/moov-box.js +5 -1
  228. package/dist/state/keyframes.js +5 -1
  229. package/dist/state/m3u-state.js +9 -5
  230. package/dist/state/may-skip-video-data.js +7 -3
  231. package/dist/state/mp3.js +5 -1
  232. package/dist/state/need-samples-for-fields.js +5 -1
  233. package/dist/state/parser-state.js +39 -35
  234. package/dist/state/riff.js +5 -1
  235. package/dist/state/sample-callbacks.js +12 -8
  236. package/dist/state/slow-duration-fps.js +5 -1
  237. package/dist/state/structure.js +5 -1
  238. package/dist/state/transport-stream.js +7 -3
  239. package/dist/state/video-section.js +5 -1
  240. package/dist/state/webm.js +9 -5
  241. package/dist/throttled-progress.js +5 -1
  242. package/dist/truthy.js +4 -1
  243. package/dist/universal.js +5 -1
  244. package/dist/version.d.ts +1 -1
  245. package/dist/version.js +4 -1
  246. package/dist/web.js +5 -1
  247. package/dist/webcodec-sample-types.js +2 -1
  248. package/dist/worker/forward-controller.js +7 -3
  249. package/dist/worker/serialize-error.js +19 -14
  250. package/dist/worker/worker-types.js +2 -1
  251. package/dist/worker-server-entry.js +5 -3
  252. package/dist/worker-server.js +16 -12
  253. package/dist/worker-web-entry.js +5 -3
  254. package/dist/worker.d.ts +3 -2
  255. package/dist/worker.js +11 -2
  256. package/dist/worker.module.d.ts +4 -0
  257. package/dist/worker.module.js +16 -0
  258. package/dist/writers/node.js +23 -16
  259. package/dist/writers/writer.js +2 -1
  260. package/package.json +3 -3
@@ -1,4 +1,7 @@
1
- export const getSampleRateFromSampleFrequencyIndex = (samplingFrequencyIndex) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapAudioObjectTypeToCodecString = exports.parseAacCodecPrivate = exports.createAacCodecPrivate = exports.getSampleRateFromSampleFrequencyIndex = void 0;
4
+ const getSampleRateFromSampleFrequencyIndex = (samplingFrequencyIndex) => {
2
5
  switch (samplingFrequencyIndex) {
3
6
  case 0:
4
7
  return 96000;
@@ -30,6 +33,7 @@ export const getSampleRateFromSampleFrequencyIndex = (samplingFrequencyIndex) =>
30
33
  throw new Error(`Unexpected sampling frequency index ${samplingFrequencyIndex}`);
31
34
  }
32
35
  };
36
+ exports.getSampleRateFromSampleFrequencyIndex = getSampleRateFromSampleFrequencyIndex;
33
37
  // codec private, for example [17, 144]
34
38
  // audioObjectType = 2 = 'AAC LC'
35
39
  // samplingFrequencyIndex = 3 = '48000 Hz'
@@ -86,7 +90,7 @@ const getConfigForSampleRate = (sampleRate) => {
86
90
  }
87
91
  throw new Error(`Unexpected sample rate ${sampleRate}`);
88
92
  };
89
- export const createAacCodecPrivate = ({ audioObjectType, sampleRate, channelConfiguration, codecPrivate, }) => {
93
+ const createAacCodecPrivate = ({ audioObjectType, sampleRate, channelConfiguration, codecPrivate, }) => {
90
94
  if (codecPrivate !== null && codecPrivate.length > 2) {
91
95
  // Video submitted
92
96
  // submitted by Yossi Elkrief
@@ -104,7 +108,8 @@ export const createAacCodecPrivate = ({ audioObjectType, sampleRate, channelConf
104
108
  const secondByte = parseInt(bits.slice(8, 16), 2);
105
109
  return new Uint8Array([firstByte, secondByte]);
106
110
  };
107
- export const parseAacCodecPrivate = (bytes) => {
111
+ exports.createAacCodecPrivate = createAacCodecPrivate;
112
+ const parseAacCodecPrivate = (bytes) => {
108
113
  if (bytes.length < 2) {
109
114
  throw new Error('Invalid AAC codec private length');
110
115
  }
@@ -126,18 +131,19 @@ export const parseAacCodecPrivate = (bytes) => {
126
131
  offset += 5;
127
132
  return {
128
133
  audioObjectType: newAudioObjectType,
129
- sampleRate: getSampleRateFromSampleFrequencyIndex(extensionSamplingFrequencyIndex),
134
+ sampleRate: (0, exports.getSampleRateFromSampleFrequencyIndex)(extensionSamplingFrequencyIndex),
130
135
  channelConfiguration,
131
136
  };
132
137
  }
133
- const sampleRate = getSampleRateFromSampleFrequencyIndex(samplingFrequencyIndex);
138
+ const sampleRate = (0, exports.getSampleRateFromSampleFrequencyIndex)(samplingFrequencyIndex);
134
139
  return {
135
140
  audioObjectType,
136
141
  sampleRate,
137
142
  channelConfiguration,
138
143
  };
139
144
  };
140
- export const mapAudioObjectTypeToCodecString = (audioObjectType) => {
145
+ exports.parseAacCodecPrivate = parseAacCodecPrivate;
146
+ const mapAudioObjectTypeToCodecString = (audioObjectType) => {
141
147
  /**
142
148
  * 1. 1 - mp4a.40.2: MPEG-4 AAC LC (Low Complexity)
143
149
  2. 2 - mp4a.40.5: MPEG-4 AAC HE (High Efficiency)
@@ -169,3 +175,4 @@ export const mapAudioObjectTypeToCodecString = (audioObjectType) => {
169
175
  throw new Error(`Unexpected audio object type ${audioObjectType}`);
170
176
  }
171
177
  };
178
+ exports.mapAudioObjectTypeToCodecString = mapAudioObjectTypeToCodecString;
@@ -1,12 +1,16 @@
1
- import { getCodecStringFromSpsAndPps } from './containers/avc/codec-string';
2
- import { createSpsPpsData } from './containers/avc/create-sps-pps-data';
3
- export const addAvcProfileToTrack = (track, avc1Profile) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addAvcProfileToTrack = void 0;
4
+ const codec_string_1 = require("./containers/avc/codec-string");
5
+ const create_sps_pps_data_1 = require("./containers/avc/create-sps-pps-data");
6
+ const addAvcProfileToTrack = (track, avc1Profile) => {
4
7
  if (avc1Profile === null) {
5
8
  return track;
6
9
  }
7
10
  return {
8
11
  ...track,
9
- codec: getCodecStringFromSpsAndPps(avc1Profile.sps),
10
- codecPrivate: createSpsPpsData(avc1Profile),
12
+ codec: (0, codec_string_1.getCodecStringFromSpsAndPps)(avc1Profile.sps),
13
+ codecPrivate: (0, create_sps_pps_data_1.createSpsPpsData)(avc1Profile),
11
14
  };
12
15
  };
16
+ exports.addAvcProfileToTrack = addAvcProfileToTrack;
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
3
  if (kind === "m") throw new TypeError("Private method is not writable");
3
4
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
@@ -10,10 +11,12 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
11
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
12
  };
12
13
  var _OffsetCounter_offset, _OffsetCounter_discardedBytes;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.getArrayBufferIterator = exports.OffsetCounter = void 0;
13
16
  /* eslint-disable @typescript-eslint/no-use-before-define */
14
- import { knownIdsWithOneLength, knownIdsWithThreeLength, knownIdsWithTwoLength, } from './containers/webm/segments/all-segments';
15
- import { detectFileType } from './file-types';
16
- export class OffsetCounter {
17
+ const all_segments_1 = require("./containers/webm/segments/all-segments");
18
+ const file_types_1 = require("./file-types");
19
+ class OffsetCounter {
17
20
  constructor(initial) {
18
21
  _OffsetCounter_offset.set(this, void 0);
19
22
  _OffsetCounter_discardedBytes.set(this, void 0);
@@ -48,11 +51,12 @@ export class OffsetCounter {
48
51
  __classPrivateFieldSet(this, _OffsetCounter_offset, __classPrivateFieldGet(this, _OffsetCounter_offset, "f") - amount, "f");
49
52
  }
50
53
  }
54
+ exports.OffsetCounter = OffsetCounter;
51
55
  _OffsetCounter_offset = new WeakMap(), _OffsetCounter_discardedBytes = new WeakMap();
52
56
  const makeOffsetCounter = () => {
53
57
  return new OffsetCounter(0);
54
58
  };
55
- export const getArrayBufferIterator = (initialData, maxBytes) => {
59
+ const getArrayBufferIterator = (initialData, maxBytes) => {
56
60
  const buf = new ArrayBuffer(initialData.byteLength, {
57
61
  maxByteLength: maxBytes === null
58
62
  ? initialData.byteLength
@@ -381,7 +385,7 @@ export const getArrayBufferIterator = (initialData, maxBytes) => {
381
385
  return new TextDecoder().decode(atom);
382
386
  },
383
387
  detectFileType: () => {
384
- return detectFileType(uintArray);
388
+ return (0, file_types_1.detectFileType)(uintArray);
385
389
  },
386
390
  getPaddedFourByteNumber,
387
391
  getMatroskaSegmentId: () => {
@@ -396,7 +400,7 @@ export const getArrayBufferIterator = (initialData, maxBytes) => {
396
400
  .join('')}`;
397
401
  // Catch void block
398
402
  // https://www.matroska.org/technical/elements.html
399
- if (knownIdsWithOneLength.includes(firstOneString)) {
403
+ if (all_segments_1.knownIdsWithOneLength.includes(firstOneString)) {
400
404
  return firstOneString;
401
405
  }
402
406
  if (bytesRemaining() === 0) {
@@ -408,7 +412,7 @@ export const getArrayBufferIterator = (initialData, maxBytes) => {
408
412
  return b.toString(16).padStart(2, '0');
409
413
  })
410
414
  .join('')}`;
411
- if (knownIdsWithTwoLength.includes(firstTwoString)) {
415
+ if (all_segments_1.knownIdsWithTwoLength.includes(firstTwoString)) {
412
416
  return firstTwoString;
413
417
  }
414
418
  if (bytesRemaining() === 0) {
@@ -420,7 +424,7 @@ export const getArrayBufferIterator = (initialData, maxBytes) => {
420
424
  return b.toString(16).padStart(2, '0');
421
425
  })
422
426
  .join('')}`;
423
- if (knownIdsWithThreeLength.includes(firstThreeString)) {
427
+ if (all_segments_1.knownIdsWithThreeLength.includes(firstThreeString)) {
424
428
  return firstThreeString;
425
429
  }
426
430
  if (bytesRemaining() === 0) {
@@ -581,3 +585,4 @@ export const getArrayBufferIterator = (initialData, maxBytes) => {
581
585
  getSyncSafeInt32,
582
586
  };
583
587
  };
588
+ exports.getArrayBufferIterator = getArrayBufferIterator;
@@ -1,4 +1,7 @@
1
- export const combineUint8Arrays = (arrays) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.combineUint8Arrays = void 0;
4
+ const combineUint8Arrays = (arrays) => {
2
5
  if (arrays.length === 0) {
3
6
  return new Uint8Array([]);
4
7
  }
@@ -17,3 +20,4 @@ export const combineUint8Arrays = (arrays) => {
17
20
  }
18
21
  return result;
19
22
  };
23
+ exports.combineUint8Arrays = combineUint8Arrays;
@@ -1,7 +1,10 @@
1
- import { createAacCodecPrivate, getSampleRateFromSampleFrequencyIndex, mapAudioObjectTypeToCodecString, } from '../../aac-codecprivate';
2
- import { convertAudioOrVideoSampleToWebCodecsTimestamps } from '../../convert-audio-or-video-sample';
3
- import { registerAudioTrack } from '../../register-track';
4
- export const parseAac = async (state) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseAac = 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 parseAac = async (state) => {
5
8
  const { iterator } = state;
6
9
  const startOffset = iterator.counter.getOffset();
7
10
  iterator.startReadingBits();
@@ -20,10 +23,10 @@ export const parseAac = async (state) => {
20
23
  const protectionAbsent = iterator.getBits(1); // protection absent
21
24
  const audioObjectType = iterator.getBits(2); // 1 = 'AAC-LC'
22
25
  const samplingFrequencyIndex = iterator.getBits(4);
23
- const sampleRate = getSampleRateFromSampleFrequencyIndex(samplingFrequencyIndex);
26
+ const sampleRate = (0, aac_codecprivate_1.getSampleRateFromSampleFrequencyIndex)(samplingFrequencyIndex);
24
27
  iterator.getBits(1); // private bit
25
28
  const channelConfiguration = iterator.getBits(3);
26
- const codecPrivate = createAacCodecPrivate({
29
+ const codecPrivate = (0, aac_codecprivate_1.createAacCodecPrivate)({
27
30
  audioObjectType,
28
31
  sampleRate,
29
32
  channelConfiguration,
@@ -43,11 +46,11 @@ export const parseAac = async (state) => {
43
46
  iterator.counter.decrement(iterator.counter.getOffset() - startOffset);
44
47
  const data = iterator.getSlice(frameLength);
45
48
  if (state.callbacks.tracks.getTracks().length === 0) {
46
- await registerAudioTrack({
49
+ await (0, register_track_1.registerAudioTrack)({
47
50
  state,
48
51
  container: 'aac',
49
52
  track: {
50
- codec: mapAudioObjectTypeToCodecString(audioObjectType),
53
+ codec: (0, aac_codecprivate_1.mapAudioObjectTypeToCodecString)(audioObjectType),
51
54
  codecWithoutConfig: 'aac',
52
55
  codecPrivate,
53
56
  description: codecPrivate,
@@ -65,7 +68,7 @@ export const parseAac = async (state) => {
65
68
  const { index } = state.aac.addSample({ offset: startOffset, size: frameLength });
66
69
  const timestamp = (1024 / sampleRate) * index;
67
70
  // One ADTS frame contains 1024 samples
68
- await state.callbacks.onAudioSample(0, convertAudioOrVideoSampleToWebCodecsTimestamps({
71
+ await state.callbacks.onAudioSample(0, (0, convert_audio_or_video_sample_1.convertAudioOrVideoSampleToWebCodecsTimestamps)({
69
72
  duration,
70
73
  type: 'key',
71
74
  data,
@@ -78,3 +81,4 @@ export const parseAac = async (state) => {
78
81
  }, 1));
79
82
  return Promise.resolve(null);
80
83
  };
84
+ exports.parseAac = parseAac;
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +1,7 @@
1
- export const getCodecStringFromSpsAndPps = (sps) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCodecStringFromSpsAndPps = void 0;
4
+ const getCodecStringFromSpsAndPps = (sps) => {
2
5
  return `avc1.${sps.spsData.profile.toString(16).padStart(2, '0')}${sps.spsData.compatibility.toString(16).padStart(2, '0')}${sps.spsData.level.toString(16).padStart(2, '0')}`;
3
6
  };
7
+ exports.getCodecStringFromSpsAndPps = getCodecStringFromSpsAndPps;
@@ -1,4 +1,7 @@
1
- export const getMatrixCoefficientsFromIndex = (index) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPrimariesFromIndex = exports.getTransferCharacteristicsFromIndex = exports.getMatrixCoefficientsFromIndex = void 0;
4
+ const getMatrixCoefficientsFromIndex = (index) => {
2
5
  return index === 1
3
6
  ? 'bt709'
4
7
  : index === 5
@@ -9,7 +12,8 @@ export const getMatrixCoefficientsFromIndex = (index) => {
9
12
  ? 'bt2020'
10
13
  : null;
11
14
  };
12
- export const getTransferCharacteristicsFromIndex = (index) => {
15
+ exports.getMatrixCoefficientsFromIndex = getMatrixCoefficientsFromIndex;
16
+ const getTransferCharacteristicsFromIndex = (index) => {
13
17
  return index === 1
14
18
  ? 'bt709'
15
19
  : index === 6
@@ -20,7 +24,8 @@ export const getTransferCharacteristicsFromIndex = (index) => {
20
24
  ? 'arib-std-b67'
21
25
  : null;
22
26
  };
23
- export const getPrimariesFromIndex = (index) => {
27
+ exports.getTransferCharacteristicsFromIndex = getTransferCharacteristicsFromIndex;
28
+ const getPrimariesFromIndex = (index) => {
24
29
  return index === 1
25
30
  ? 'bt709'
26
31
  : index === 5
@@ -31,3 +36,4 @@ export const getPrimariesFromIndex = (index) => {
31
36
  ? 'bt2020'
32
37
  : null;
33
38
  };
39
+ exports.getPrimariesFromIndex = getPrimariesFromIndex;
@@ -1,13 +1,16 @@
1
- import { combineUint8Arrays } from '../../combine-uint8-arrays';
2
- import { truthy } from '../../truthy';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createSpsPpsData = void 0;
4
+ const combine_uint8_arrays_1 = require("../../combine-uint8-arrays");
5
+ const truthy_1 = require("../../truthy");
3
6
  function serializeUint16(value) {
4
7
  const buffer = new ArrayBuffer(2);
5
8
  const view = new DataView(buffer);
6
9
  view.setUint16(0, value);
7
10
  return new Uint8Array(buffer);
8
11
  }
9
- export const createSpsPpsData = (avc1Profile) => {
10
- return combineUint8Arrays([
12
+ const createSpsPpsData = (avc1Profile) => {
13
+ return (0, combine_uint8_arrays_1.combineUint8Arrays)([
11
14
  new Uint8Array([
12
15
  // https://gist.github.com/uupaa/8493378ec15f644a3d2b
13
16
  1, // version
@@ -40,5 +43,6 @@ export const createSpsPpsData = (avc1Profile) => {
40
43
  numOfSequenceParameterSetExt 0
41
44
  */
42
45
  new Uint8Array([0xfd, 0xf8, 0xf8, 0]),
43
- ].filter(truthy));
46
+ ].filter(truthy_1.truthy));
44
47
  };
48
+ exports.createSpsPpsData = createSpsPpsData;
@@ -1,5 +1,8 @@
1
- import { getMatrixCoefficientsFromIndex, getPrimariesFromIndex, getTransferCharacteristicsFromIndex, } from './color';
2
- export const getDimensionsFromSps = (sps) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getVideoColorFromSps = exports.getSampleAspectRatioFromSps = exports.getDimensionsFromSps = void 0;
4
+ const color_1 = require("./color");
5
+ const getDimensionsFromSps = (sps) => {
3
6
  var _a, _b, _c, _d;
4
7
  const height = sps.pic_height_in_map_units_minus1;
5
8
  const width = sps.pic_width_in_mbs_minus1;
@@ -13,7 +16,8 @@ export const getDimensionsFromSps = (sps) => {
13
16
  ((_d = sps.frame_crop_left_offset) !== null && _d !== void 0 ? _d : 0) * 2,
14
17
  };
15
18
  };
16
- export const getSampleAspectRatioFromSps = (sps) => {
19
+ exports.getDimensionsFromSps = getDimensionsFromSps;
20
+ const getSampleAspectRatioFromSps = (sps) => {
17
21
  var _a;
18
22
  if (((_a = sps.vui_parameters) === null || _a === void 0 ? void 0 : _a.sar_height) && sps.vui_parameters.sar_width) {
19
23
  return {
@@ -26,19 +30,21 @@ export const getSampleAspectRatioFromSps = (sps) => {
26
30
  height: 1,
27
31
  };
28
32
  };
29
- export const getVideoColorFromSps = (sps) => {
33
+ exports.getSampleAspectRatioFromSps = getSampleAspectRatioFromSps;
34
+ const getVideoColorFromSps = (sps) => {
30
35
  var _a, _b, _c, _d, _e;
31
36
  const matrixCoefficients = (_a = sps.vui_parameters) === null || _a === void 0 ? void 0 : _a.matrix_coefficients;
32
37
  const transferCharacteristics = (_b = sps.vui_parameters) === null || _b === void 0 ? void 0 : _b.transfer_characteristics;
33
38
  const colorPrimaries = (_c = sps.vui_parameters) === null || _c === void 0 ? void 0 : _c.colour_primaries;
34
39
  return {
35
40
  matrixCoefficients: matrixCoefficients
36
- ? getMatrixCoefficientsFromIndex(matrixCoefficients)
41
+ ? (0, color_1.getMatrixCoefficientsFromIndex)(matrixCoefficients)
37
42
  : null,
38
43
  transferCharacteristics: transferCharacteristics
39
- ? getTransferCharacteristicsFromIndex(transferCharacteristics)
44
+ ? (0, color_1.getTransferCharacteristicsFromIndex)(transferCharacteristics)
40
45
  : null,
41
- primaries: colorPrimaries ? getPrimariesFromIndex(colorPrimaries) : null,
46
+ primaries: colorPrimaries ? (0, color_1.getPrimariesFromIndex)(colorPrimaries) : null,
42
47
  fullRange: (_e = (_d = sps.vui_parameters) === null || _d === void 0 ? void 0 : _d.video_full_range_flag) !== null && _e !== void 0 ? _e : null,
43
48
  };
44
49
  };
50
+ exports.getVideoColorFromSps = getVideoColorFromSps;
@@ -1,7 +1,11 @@
1
- export const getKeyFrameOrDeltaFromAvcInfo = (infos) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getKeyFrameOrDeltaFromAvcInfo = void 0;
4
+ const getKeyFrameOrDeltaFromAvcInfo = (infos) => {
2
5
  const keyOrDelta = infos.find((i) => i.type === 'keyframe' || i.type === 'delta-frame');
3
6
  if (!keyOrDelta) {
4
7
  throw new Error('expected avc to contain info about key or delta');
5
8
  }
6
9
  return keyOrDelta.type === 'keyframe' ? 'key' : 'delta';
7
10
  };
11
+ exports.getKeyFrameOrDeltaFromAvcInfo = getKeyFrameOrDeltaFromAvcInfo;
@@ -1,6 +1,9 @@
1
+ "use strict";
1
2
  // https://www.itu.int/rec/T-REC-H.264-202408-I/en
2
3
  // Page 455
3
- import { getArrayBufferIterator } from '../../buffer-iterator';
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.parseAvc = void 0;
6
+ const buffer_iterator_1 = require("../../buffer-iterator");
4
7
  const Extended_SAR = 255;
5
8
  const readVuiParameters = (iterator) => {
6
9
  let sar_width = null;
@@ -183,7 +186,7 @@ const findEnd = (buffer) => {
183
186
  return null;
184
187
  };
185
188
  const inspect = (buffer) => {
186
- const iterator = getArrayBufferIterator(buffer, buffer.byteLength);
189
+ const iterator = (0, buffer_iterator_1.getArrayBufferIterator)(buffer, buffer.byteLength);
187
190
  iterator.startReadingBits();
188
191
  iterator.getBits(1);
189
192
  iterator.getBits(2);
@@ -221,7 +224,7 @@ const inspect = (buffer) => {
221
224
  return null;
222
225
  };
223
226
  // https://stackoverflow.com/questions/24884827/possible-locations-for-sequence-picture-parameter-sets-for-h-264-stream
224
- export const parseAvc = (buffer) => {
227
+ const parseAvc = (buffer) => {
225
228
  let zeroesInARow = 0;
226
229
  const infos = [];
227
230
  for (let i = 0; i < buffer.length; i++) {
@@ -246,3 +249,4 @@ export const parseAvc = (buffer) => {
246
249
  }
247
250
  return infos;
248
251
  };
252
+ exports.parseAvc = parseAvc;
@@ -1,4 +1,7 @@
1
- export const getSpsAndPps = (infos) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSpsAndPps = void 0;
4
+ const getSpsAndPps = (infos) => {
2
5
  const avcProfile = infos.find((i) => i.type === 'avc-profile');
3
6
  const ppsProfile = infos.find((i) => i.type === 'avc-pps');
4
7
  if (!avcProfile || !ppsProfile) {
@@ -6,3 +9,4 @@ export const getSpsAndPps = (infos) => {
6
9
  }
7
10
  return { pps: ppsProfile, sps: avcProfile };
8
11
  };
12
+ exports.getSpsAndPps = getSpsAndPps;
@@ -1,4 +1,7 @@
1
- export const getBlockSize = (iterator) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getBlockSize = void 0;
4
+ const getBlockSize = (iterator) => {
2
5
  const bits = iterator.getBits(4);
3
6
  if (bits === 0b0000) {
4
7
  throw new Error('Reserved block size');
@@ -20,3 +23,4 @@ export const getBlockSize = (iterator) => {
20
23
  }
21
24
  throw new Error('Invalid block size');
22
25
  };
26
+ exports.getBlockSize = getBlockSize;
@@ -1,5 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getChannelCount = void 0;
1
4
  // https://www.rfc-editor.org/rfc/rfc9639.html#name-channels-bits
2
- export const getChannelCount = (iterator) => {
5
+ const getChannelCount = (iterator) => {
3
6
  const bits = iterator.getBits(4);
4
7
  if (bits === 0b0000) {
5
8
  return 1;
@@ -30,3 +33,4 @@ export const getChannelCount = (iterator) => {
30
33
  }
31
34
  throw new Error(`Invalid channel count: ${bits.toString(2)}`);
32
35
  };
36
+ exports.getChannelCount = getChannelCount;
@@ -1,4 +1,7 @@
1
- export const getDurationFromFlac = (parserState) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDurationFromFlac = void 0;
4
+ const getDurationFromFlac = (parserState) => {
2
5
  const structure = parserState.getFlacStructure();
3
6
  const streaminfo = structure.boxes.find((b) => b.type === 'flac-streaminfo');
4
7
  if (!streaminfo) {
@@ -6,3 +9,4 @@ export const getDurationFromFlac = (parserState) => {
6
9
  }
7
10
  return streaminfo.totalSamples / streaminfo.sampleRate;
8
11
  };
12
+ exports.getDurationFromFlac = getDurationFromFlac;
@@ -1,7 +1,11 @@
1
- export const getMetadataFromFlac = (structure) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getMetadataFromFlac = void 0;
4
+ const getMetadataFromFlac = (structure) => {
2
5
  const box = structure.boxes.find((b) => b.type === 'flac-vorbis-comment');
3
6
  if (!box) {
4
7
  return null;
5
8
  }
6
9
  return box.fields;
7
10
  };
11
+ exports.getMetadataFromFlac = getMetadataFromFlac;
@@ -1,5 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSampleRate = void 0;
1
4
  // https://www.rfc-editor.org/rfc/rfc9639.html#name-sample-rate-bits
2
- export const getSampleRate = (iterator, state) => {
5
+ const getSampleRate = (iterator, state) => {
3
6
  var _a, _b;
4
7
  const mode = iterator.getBits(4);
5
8
  if (mode === 0b0000) {
@@ -54,3 +57,4 @@ export const getSampleRate = (iterator, state) => {
54
57
  }
55
58
  throw new Error(`Invalid sample rate mode: ${mode.toString(2)}`);
56
59
  };
60
+ exports.getSampleRate = getSampleRate;
@@ -1,8 +1,11 @@
1
- import { getArrayBufferIterator, } from '../../buffer-iterator';
2
- import { convertAudioOrVideoSampleToWebCodecsTimestamps } from '../../convert-audio-or-video-sample';
3
- import { getBlockSize } from './get-block-size';
4
- import { getChannelCount } from './get-channel-count';
5
- import { getSampleRate } from './get-sample-rate';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseFlacFrame = exports.parseFrameHeader = void 0;
4
+ const buffer_iterator_1 = require("../../buffer-iterator");
5
+ const convert_audio_or_video_sample_1 = require("../../convert-audio-or-video-sample");
6
+ const get_block_size_1 = require("./get-block-size");
7
+ const get_channel_count_1 = require("./get-channel-count");
8
+ const get_sample_rate_1 = require("./get-sample-rate");
6
9
  // https://www.rfc-editor.org/rfc/rfc9639.html#section-9.1.1
7
10
  function calculateCRC8(data) {
8
11
  const polynomial = 0x07; // x^8 + x^2 + x^1 + x^0
@@ -23,16 +26,16 @@ function calculateCRC8(data) {
23
26
  }
24
27
  return crc;
25
28
  }
26
- export const parseFrameHeader = ({ iterator, state, }) => {
29
+ const parseFrameHeader = ({ iterator, state, }) => {
27
30
  if (iterator.bytesRemaining() < 10) {
28
31
  return null;
29
32
  }
30
33
  const startOffset = iterator.counter.getOffset();
31
34
  iterator.discard(2); // sync code
32
35
  iterator.startReadingBits();
33
- const blockSizeBits = getBlockSize(iterator);
34
- const sampleRateBits = getSampleRate(iterator, state);
35
- getChannelCount(iterator); // channel count
36
+ const blockSizeBits = (0, get_block_size_1.getBlockSize)(iterator);
37
+ const sampleRateBits = (0, get_sample_rate_1.getSampleRate)(iterator, state);
38
+ (0, get_channel_count_1.getChannelCount)(iterator); // channel count
36
39
  iterator.getBits(3); // bit depth
37
40
  iterator.getBits(1);
38
41
  const num = iterator.getFlacCodecNumber();
@@ -59,9 +62,10 @@ export const parseFrameHeader = ({ iterator, state, }) => {
59
62
  }
60
63
  return { num, blockSize, sampleRate };
61
64
  };
65
+ exports.parseFrameHeader = parseFrameHeader;
62
66
  const emitSample = async ({ state, data, offset, }) => {
63
- const iterator = getArrayBufferIterator(data, null);
64
- const parsed = parseFrameHeader({ iterator, state });
67
+ const iterator = (0, buffer_iterator_1.getArrayBufferIterator)(data, null);
68
+ const parsed = (0, exports.parseFrameHeader)({ iterator, state });
65
69
  if (!parsed) {
66
70
  throw new Error('Invalid CRC');
67
71
  }
@@ -76,7 +80,7 @@ const emitSample = async ({ state, data, offset, }) => {
76
80
  throw new Error('Cannot determine timestamp');
77
81
  }
78
82
  const timestamp = (num * streamInfo.maximumBlockSize) / streamInfo.sampleRate;
79
- await state.callbacks.onAudioSample(0, convertAudioOrVideoSampleToWebCodecsTimestamps({
83
+ await state.callbacks.onAudioSample(0, (0, convert_audio_or_video_sample_1.convertAudioOrVideoSampleToWebCodecsTimestamps)({
80
84
  data,
81
85
  duration,
82
86
  cts: timestamp,
@@ -89,7 +93,7 @@ const emitSample = async ({ state, data, offset, }) => {
89
93
  }, 1));
90
94
  iterator.destroy();
91
95
  };
92
- export const parseFlacFrame = async ({ state, iterator, }) => {
96
+ const parseFlacFrame = async ({ state, iterator, }) => {
93
97
  var _a, _b;
94
98
  const blockingBit = state.flac.getBlockingBitStrategy();
95
99
  const offset = iterator.counter.getOffset();
@@ -148,7 +152,7 @@ export const parseFlacFrame = async ({ state, iterator, }) => {
148
152
  continue;
149
153
  }
150
154
  iterator.counter.decrement(2);
151
- const nextIsLegit = parseFrameHeader({ iterator, state });
155
+ const nextIsLegit = (0, exports.parseFrameHeader)({ iterator, state });
152
156
  if (!nextIsLegit) {
153
157
  iterator.discard(1);
154
158
  continue;
@@ -162,3 +166,4 @@ export const parseFlacFrame = async ({ state, iterator, }) => {
162
166
  }
163
167
  return null;
164
168
  };
169
+ exports.parseFlacFrame = parseFlacFrame;
@@ -1,25 +1,28 @@
1
- import { makeSkip } from '../../skip';
2
- import { maySkipVideoData } from '../../state/may-skip-video-data';
3
- import { parseFlacFrame } from './parse-flac-frame';
4
- import { parseFlacHeader } from './parse-header';
5
- import { parseVorbisComment } from './parse-metadata';
6
- import { parseStreamInfo } from './parse-streaminfo';
7
- import { parseFlacUnkownBlock } from './parse-unknown-block';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseFlac = void 0;
4
+ const skip_1 = require("../../skip");
5
+ const may_skip_video_data_1 = require("../../state/may-skip-video-data");
6
+ const parse_flac_frame_1 = require("./parse-flac-frame");
7
+ const parse_header_1 = require("./parse-header");
8
+ const parse_metadata_1 = require("./parse-metadata");
9
+ const parse_streaminfo_1 = require("./parse-streaminfo");
10
+ const parse_unknown_block_1 = require("./parse-unknown-block");
8
11
  const flacTypes = {
9
12
  streaminfo: 0,
10
13
  vorbisComment: 4,
11
14
  };
12
- export const parseFlac = ({ iterator, state, }) => {
15
+ const parseFlac = ({ iterator, state, }) => {
13
16
  const videoSectionState = state.videoSection.isInVideoSectionState(iterator);
14
17
  if (videoSectionState === 'in-section') {
15
- if (maySkipVideoData({ state })) {
16
- return Promise.resolve(makeSkip(state.contentLength));
18
+ if ((0, may_skip_video_data_1.maySkipVideoData)({ state })) {
19
+ return Promise.resolve((0, skip_1.makeSkip)(state.contentLength));
17
20
  }
18
- return parseFlacFrame({ state, iterator });
21
+ return (0, parse_flac_frame_1.parseFlacFrame)({ state, iterator });
19
22
  }
20
23
  const bytes = iterator.getByteString(4, true);
21
24
  if (bytes === 'fLaC') {
22
- return parseFlacHeader({ state, iterator });
25
+ return (0, parse_header_1.parseFlacHeader)({ state, iterator });
23
26
  }
24
27
  iterator.counter.decrement(4);
25
28
  // https://www.rfc-editor.org/rfc/rfc9639.html#name-streaminfo
@@ -36,10 +39,11 @@ export const parseFlac = ({ iterator, state, }) => {
36
39
  });
37
40
  }
38
41
  if (metaBlockType === flacTypes.streaminfo) {
39
- return parseStreamInfo({ iterator, state });
42
+ return (0, parse_streaminfo_1.parseStreamInfo)({ iterator, state });
40
43
  }
41
44
  if (metaBlockType === flacTypes.vorbisComment) {
42
- return parseVorbisComment({ iterator, state, size });
45
+ return (0, parse_metadata_1.parseVorbisComment)({ iterator, state, size });
43
46
  }
44
- return parseFlacUnkownBlock({ iterator, state, size });
47
+ return (0, parse_unknown_block_1.parseFlacUnkownBlock)({ iterator, state, size });
45
48
  };
49
+ exports.parseFlac = parseFlac;
@@ -1,6 +1,10 @@
1
- export const parseFlacHeader = ({ state, }) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseFlacHeader = void 0;
4
+ const parseFlacHeader = ({ state, }) => {
2
5
  state.getFlacStructure().boxes.push({
3
6
  type: 'flac-header',
4
7
  });
5
8
  return Promise.resolve(null);
6
9
  };
10
+ exports.parseFlacHeader = parseFlacHeader;