@remotion/media-parser 4.0.277 → 4.0.279

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 (365) hide show
  1. package/dist/aac-codecprivate.js +13 -6
  2. package/dist/add-avc-profile-to-track.js +9 -5
  3. package/dist/check-if-done.d.ts +2 -0
  4. package/dist/check-if-done.js +34 -0
  5. package/dist/combine-uint8-arrays.js +5 -1
  6. package/dist/containers/aac/parse-aac.js +27 -18
  7. package/dist/containers/aac/types.js +2 -1
  8. package/dist/containers/avc/codec-string.js +5 -1
  9. package/dist/containers/avc/color.js +9 -3
  10. package/dist/containers/avc/create-sps-pps-data.js +9 -5
  11. package/dist/containers/avc/interpret-sps.js +13 -7
  12. package/dist/containers/avc/key.js +5 -1
  13. package/dist/containers/avc/parse-avc.js +7 -3
  14. package/dist/containers/avc/sps-and-pps.js +5 -1
  15. package/dist/containers/flac/get-block-size.d.ts +1 -1
  16. package/dist/containers/flac/get-block-size.js +5 -1
  17. package/dist/containers/flac/get-channel-count.d.ts +2 -2
  18. package/dist/containers/flac/get-channel-count.js +5 -1
  19. package/dist/containers/flac/get-duration-from-flac.js +5 -1
  20. package/dist/containers/flac/get-metadata-from-flac.js +5 -1
  21. package/dist/containers/flac/get-sample-rate.d.ts +1 -1
  22. package/dist/containers/flac/get-sample-rate.js +5 -1
  23. package/dist/containers/flac/parse-flac-frame.d.ts +1 -1
  24. package/dist/containers/flac/parse-flac-frame.js +33 -23
  25. package/dist/containers/flac/parse-flac.d.ts +1 -1
  26. package/dist/containers/flac/parse-flac.js +19 -15
  27. package/dist/containers/flac/parse-header.d.ts +1 -1
  28. package/dist/containers/flac/parse-header.js +5 -1
  29. package/dist/containers/flac/parse-metadata.d.ts +1 -1
  30. package/dist/containers/flac/parse-metadata.js +5 -1
  31. package/dist/containers/flac/parse-streaminfo.d.ts +1 -1
  32. package/dist/containers/flac/parse-streaminfo.js +7 -3
  33. package/dist/containers/flac/parse-unknown-block.d.ts +1 -1
  34. package/dist/containers/flac/parse-unknown-block.js +5 -1
  35. package/dist/containers/flac/types.js +2 -1
  36. package/dist/containers/iso-base-media/base-media-box.js +2 -1
  37. package/dist/containers/iso-base-media/base-type.js +2 -1
  38. package/dist/containers/iso-base-media/esds/decoder-specific-config.d.ts +1 -1
  39. package/dist/containers/iso-base-media/esds/decoder-specific-config.js +5 -1
  40. package/dist/containers/iso-base-media/esds/esds-descriptors.d.ts +1 -1
  41. package/dist/containers/iso-base-media/esds/esds-descriptors.js +10 -5
  42. package/dist/containers/iso-base-media/esds/esds.d.ts +1 -1
  43. package/dist/containers/iso-base-media/esds/esds.js +7 -3
  44. package/dist/containers/iso-base-media/ftyp.d.ts +1 -1
  45. package/dist/containers/iso-base-media/ftyp.js +5 -1
  46. package/dist/containers/iso-base-media/get-actual-number-of-channels.js +8 -4
  47. package/dist/containers/iso-base-media/get-children.js +7 -3
  48. package/dist/containers/iso-base-media/get-keyframes.js +11 -7
  49. package/dist/containers/iso-base-media/get-moov-atom.js +26 -16
  50. package/dist/containers/iso-base-media/get-sample-positions-from-track.js +24 -20
  51. package/dist/containers/iso-base-media/get-seeking-from-mp4.d.ts +5 -0
  52. package/dist/containers/iso-base-media/get-seeking-from-mp4.js +56 -0
  53. package/dist/containers/iso-base-media/get-video-codec-from-iso-track.js +7 -3
  54. package/dist/containers/iso-base-media/make-track.js +34 -30
  55. package/dist/containers/iso-base-media/mdat/mdat.js +47 -34
  56. package/dist/containers/iso-base-media/mdhd.d.ts +1 -1
  57. package/dist/containers/iso-base-media/mdhd.js +5 -1
  58. package/dist/containers/iso-base-media/meta/hdlr.d.ts +1 -1
  59. package/dist/containers/iso-base-media/meta/hdlr.js +5 -1
  60. package/dist/containers/iso-base-media/meta/ilst.d.ts +1 -1
  61. package/dist/containers/iso-base-media/meta/ilst.js +5 -1
  62. package/dist/containers/iso-base-media/moov/moov.js +7 -3
  63. package/dist/containers/iso-base-media/mvhd.d.ts +1 -1
  64. package/dist/containers/iso-base-media/mvhd.js +11 -7
  65. package/dist/containers/iso-base-media/parse-boxes.js +9 -5
  66. package/dist/containers/iso-base-media/parse-icc-profile.js +8 -4
  67. package/dist/containers/iso-base-media/process-box.js +67 -63
  68. package/dist/containers/iso-base-media/stsd/av1c.d.ts +1 -1
  69. package/dist/containers/iso-base-media/stsd/av1c.js +5 -1
  70. package/dist/containers/iso-base-media/stsd/avcc.d.ts +1 -1
  71. package/dist/containers/iso-base-media/stsd/avcc.js +5 -1
  72. package/dist/containers/iso-base-media/stsd/colr.d.ts +1 -1
  73. package/dist/containers/iso-base-media/stsd/colr.js +7 -3
  74. package/dist/containers/iso-base-media/stsd/ctts.d.ts +1 -1
  75. package/dist/containers/iso-base-media/stsd/ctts.js +5 -1
  76. package/dist/containers/iso-base-media/stsd/hvcc.d.ts +1 -1
  77. package/dist/containers/iso-base-media/stsd/hvcc.js +7 -3
  78. package/dist/containers/iso-base-media/stsd/keys.d.ts +1 -1
  79. package/dist/containers/iso-base-media/stsd/keys.js +5 -1
  80. package/dist/containers/iso-base-media/stsd/mebx.js +7 -3
  81. package/dist/containers/iso-base-media/stsd/pasp.d.ts +1 -1
  82. package/dist/containers/iso-base-media/stsd/pasp.js +5 -1
  83. package/dist/containers/iso-base-media/stsd/samples.js +13 -8
  84. package/dist/containers/iso-base-media/stsd/stco.d.ts +1 -1
  85. package/dist/containers/iso-base-media/stsd/stco.js +5 -1
  86. package/dist/containers/iso-base-media/stsd/stsc.d.ts +1 -1
  87. package/dist/containers/iso-base-media/stsd/stsc.js +5 -1
  88. package/dist/containers/iso-base-media/stsd/stsd.js +7 -3
  89. package/dist/containers/iso-base-media/stsd/stss.d.ts +1 -1
  90. package/dist/containers/iso-base-media/stsd/stss.js +5 -1
  91. package/dist/containers/iso-base-media/stsd/stsz.d.ts +1 -1
  92. package/dist/containers/iso-base-media/stsd/stsz.js +5 -1
  93. package/dist/containers/iso-base-media/stsd/stts.d.ts +1 -1
  94. package/dist/containers/iso-base-media/stsd/stts.js +5 -1
  95. package/dist/containers/iso-base-media/tfdt.d.ts +1 -1
  96. package/dist/containers/iso-base-media/tfdt.js +5 -1
  97. package/dist/containers/iso-base-media/tfhd.d.ts +1 -1
  98. package/dist/containers/iso-base-media/tfhd.js +5 -1
  99. package/dist/containers/iso-base-media/tkhd.d.ts +1 -1
  100. package/dist/containers/iso-base-media/tkhd.js +8 -4
  101. package/dist/containers/iso-base-media/to-date.js +5 -1
  102. package/dist/containers/iso-base-media/trak/trak.js +7 -3
  103. package/dist/containers/iso-base-media/traversal.js +57 -33
  104. package/dist/containers/iso-base-media/trun.d.ts +1 -1
  105. package/dist/containers/iso-base-media/trun.js +5 -1
  106. package/dist/containers/iso-base-media/void-box.js +2 -1
  107. package/dist/containers/m3u/after-manifest-fetch.js +15 -11
  108. package/dist/containers/m3u/fetch-m3u8-stream.js +7 -3
  109. package/dist/containers/m3u/get-chunks.js +5 -1
  110. package/dist/containers/m3u/get-duration-from-m3u.js +8 -4
  111. package/dist/containers/m3u/get-playlist.js +12 -6
  112. package/dist/containers/m3u/get-streams.js +9 -3
  113. package/dist/containers/m3u/iterate-over-segment-files.js +15 -11
  114. package/dist/containers/m3u/parse-directive.js +10 -6
  115. package/dist/containers/m3u/parse-m3u-manifest.d.ts +1 -1
  116. package/dist/containers/m3u/parse-m3u-manifest.js +7 -3
  117. package/dist/containers/m3u/parse-m3u-media-directive.js +10 -5
  118. package/dist/containers/m3u/parse-m3u.js +11 -7
  119. package/dist/containers/m3u/parse-m3u8-text.js +7 -3
  120. package/dist/containers/m3u/parse-stream-inf.js +7 -2
  121. package/dist/containers/m3u/run-over-m3u.js +13 -9
  122. package/dist/containers/m3u/sample-sorter.js +8 -4
  123. package/dist/containers/m3u/select-stream.js +11 -4
  124. package/dist/containers/m3u/types.js +2 -1
  125. package/dist/containers/mp3/get-duration.js +9 -5
  126. package/dist/containers/mp3/get-frame-length.js +7 -2
  127. package/dist/containers/mp3/get-metadata-from-mp3.js +5 -1
  128. package/dist/containers/mp3/id3-v1.d.ts +1 -1
  129. package/dist/containers/mp3/id3-v1.js +5 -1
  130. package/dist/containers/mp3/id3.js +5 -1
  131. package/dist/containers/mp3/parse-mp3.js +11 -7
  132. package/dist/containers/mp3/parse-mpeg-header.js +28 -19
  133. package/dist/containers/mp3/samples-per-mpeg-file.js +5 -1
  134. package/dist/containers/riff/expect-riff-box.js +15 -11
  135. package/dist/containers/riff/get-duration.js +12 -7
  136. package/dist/containers/riff/get-tracks-from-avi.js +28 -20
  137. package/dist/containers/riff/is-movi.d.ts +1 -1
  138. package/dist/containers/riff/is-movi.js +5 -1
  139. package/dist/containers/riff/parse-avih.d.ts +1 -1
  140. package/dist/containers/riff/parse-avih.js +5 -1
  141. package/dist/containers/riff/parse-isft.d.ts +1 -1
  142. package/dist/containers/riff/parse-isft.js +5 -1
  143. package/dist/containers/riff/parse-list-box.js +7 -3
  144. package/dist/containers/riff/parse-movi.js +45 -31
  145. package/dist/containers/riff/parse-riff-body.js +13 -9
  146. package/dist/containers/riff/parse-riff-box.js +13 -9
  147. package/dist/containers/riff/parse-riff-header.js +5 -1
  148. package/dist/containers/riff/parse-riff.js +9 -5
  149. package/dist/containers/riff/parse-strf.d.ts +1 -1
  150. package/dist/containers/riff/parse-strf.js +5 -1
  151. package/dist/containers/riff/parse-strh.d.ts +1 -1
  152. package/dist/containers/riff/parse-strh.js +7 -3
  153. package/dist/containers/riff/parse-video-section.js +11 -7
  154. package/dist/containers/riff/riff-box.js +2 -1
  155. package/dist/containers/riff/timescale.js +4 -1
  156. package/dist/containers/riff/traversal.js +15 -7
  157. package/dist/containers/transport-stream/adts-header.js +10 -6
  158. package/dist/containers/transport-stream/boxes.js +2 -1
  159. package/dist/containers/transport-stream/discard-rest-of-packet.d.ts +1 -1
  160. package/dist/containers/transport-stream/discard-rest-of-packet.js +7 -2
  161. package/dist/containers/transport-stream/find-separator.js +4 -1
  162. package/dist/containers/transport-stream/get-tracks.js +16 -10
  163. package/dist/containers/transport-stream/handle-aac-packet.js +21 -12
  164. package/dist/containers/transport-stream/handle-avc-packet.js +31 -22
  165. package/dist/containers/transport-stream/next-pes-header-store.js +5 -1
  166. package/dist/containers/transport-stream/parse-packet.js +17 -13
  167. package/dist/containers/transport-stream/parse-pat.d.ts +1 -1
  168. package/dist/containers/transport-stream/parse-pat.js +10 -5
  169. package/dist/containers/transport-stream/parse-pes.d.ts +1 -1
  170. package/dist/containers/transport-stream/parse-pes.js +5 -1
  171. package/dist/containers/transport-stream/parse-pmt.d.ts +1 -1
  172. package/dist/containers/transport-stream/parse-pmt.js +7 -3
  173. package/dist/containers/transport-stream/parse-stream-packet.js +17 -13
  174. package/dist/containers/transport-stream/parse-transport-stream.js +9 -5
  175. package/dist/containers/transport-stream/process-stream-buffers.js +17 -12
  176. package/dist/containers/transport-stream/traversal.js +10 -4
  177. package/dist/containers/wav/get-duration-from-wav.js +8 -3
  178. package/dist/containers/wav/get-metadata-from-wav.js +5 -1
  179. package/dist/containers/wav/parse-data.js +9 -5
  180. package/dist/containers/wav/parse-fmt.js +7 -3
  181. package/dist/containers/wav/parse-header.js +5 -1
  182. package/dist/containers/wav/parse-id3.js +5 -1
  183. package/dist/containers/wav/parse-list.js +5 -1
  184. package/dist/containers/wav/parse-video-section.js +21 -12
  185. package/dist/containers/wav/parse-wav.js +19 -15
  186. package/dist/containers/wav/types.js +2 -1
  187. package/dist/containers/webm/allowed-partial-segments.js +4 -1
  188. package/dist/containers/webm/av1-codec-private.js +7 -3
  189. package/dist/containers/webm/color.js +10 -6
  190. package/dist/containers/webm/description.js +10 -6
  191. package/dist/containers/webm/get-ready-tracks.js +18 -13
  192. package/dist/containers/webm/get-sample-from-block.js +16 -12
  193. package/dist/containers/webm/make-track.js +48 -43
  194. package/dist/containers/webm/parse-ebml.js +35 -17
  195. package/dist/containers/webm/parse-webm-header.js +7 -3
  196. package/dist/containers/webm/segments/all-segments.js +173 -168
  197. package/dist/containers/webm/segments/block-simple-block-flags.d.ts +1 -1
  198. package/dist/containers/webm/segments/block-simple-block-flags.js +8 -4
  199. package/dist/containers/webm/segments/track-entry.js +5 -1
  200. package/dist/containers/webm/segments.js +13 -9
  201. package/dist/containers/webm/traversal.js +67 -37
  202. package/dist/convert-audio-or-video-sample.js +5 -1
  203. package/dist/download-and-parse-media.js +14 -10
  204. package/dist/emit-all-info.d.ts +3 -0
  205. package/dist/emit-all-info.js +30 -0
  206. package/dist/emit-audio-sample.d.ts +12 -0
  207. package/dist/emit-audio-sample.js +14 -0
  208. package/dist/emit-available-info.d.ts +2 -7
  209. package/dist/emit-available-info.js +70 -63
  210. package/dist/emitter.js +5 -1
  211. package/dist/errors.js +15 -6
  212. package/dist/esm/index.mjs +1921 -1618
  213. package/dist/esm/worker-server-entry.mjs +840 -537
  214. package/dist/esm/worker-web-entry.mjs +840 -537
  215. package/dist/esm/worker.mjs +4 -5
  216. package/dist/fetch.js +17 -1
  217. package/dist/fields.d.ts +61 -0
  218. package/dist/fields.js +2 -0
  219. package/dist/file-types/bmp.js +7 -3
  220. package/dist/file-types/detect-file-type.js +38 -24
  221. package/dist/file-types/index.js +26 -22
  222. package/dist/file-types/jpeg.js +9 -4
  223. package/dist/file-types/pdf.js +7 -3
  224. package/dist/file-types/png.js +9 -4
  225. package/dist/file-types/webp.js +7 -3
  226. package/dist/forward-controller.js +5 -1
  227. package/dist/get-audio-codec.js +38 -25
  228. package/dist/get-container.js +10 -5
  229. package/dist/get-dimensions.js +13 -8
  230. package/dist/get-duration.js +34 -27
  231. package/dist/get-fields-from-callbacks.d.ts +2 -1
  232. package/dist/get-fields-from-callbacks.js +5 -1
  233. package/dist/get-fps.js +34 -24
  234. package/dist/get-is-hdr.js +10 -5
  235. package/dist/get-keyframes.js +11 -6
  236. package/dist/get-location.js +9 -4
  237. package/dist/get-number-of-audio-channels.js +7 -2
  238. package/dist/get-sample-aspect-ratio.js +30 -17
  239. package/dist/get-sample-positions-from-lpcm.js +9 -5
  240. package/dist/get-sample-positions.js +5 -1
  241. package/dist/get-sample-rate.js +7 -2
  242. package/dist/get-seeking-info.d.ts +4 -0
  243. package/dist/get-seeking-info.js +22 -0
  244. package/dist/get-tracks.js +40 -29
  245. package/dist/get-video-codec.js +34 -26
  246. package/dist/has-all-info.d.ts +3 -5
  247. package/dist/has-all-info.js +39 -35
  248. package/dist/index.d.ts +53 -14
  249. package/dist/index.js +47 -32
  250. package/dist/init-video.d.ts +1 -4
  251. package/dist/init-video.js +29 -24
  252. package/dist/internal-parse-media.js +40 -199
  253. package/dist/is-audio-structure.js +5 -1
  254. package/dist/{buffer-iterator.d.ts → iterator/buffer-iterator.d.ts} +12 -15
  255. package/dist/{buffer-iterator.js → iterator/buffer-iterator.js} +16 -119
  256. package/dist/iterator/buffer-manager.d.ts +18 -0
  257. package/dist/iterator/buffer-manager.js +87 -0
  258. package/dist/iterator/offset-counter.d.ts +10 -0
  259. package/dist/iterator/offset-counter.js +31 -0
  260. package/dist/log.js +12 -8
  261. package/dist/make-hvc1-codec-strings.d.ts +1 -1
  262. package/dist/make-hvc1-codec-strings.js +5 -1
  263. package/dist/make-progress-object.d.ts +6 -0
  264. package/dist/make-progress-object.js +13 -0
  265. package/dist/media-parser-controller.d.ts +3 -0
  266. package/dist/media-parser-controller.js +15 -7
  267. package/dist/metadata/get-metadata.js +22 -17
  268. package/dist/metadata/metadata-from-iso.js +17 -12
  269. package/dist/metadata/metadata-from-matroska.js +7 -3
  270. package/dist/metadata/metadata-from-riff.js +7 -3
  271. package/dist/node-writer.js +17 -1
  272. package/dist/node.js +17 -1
  273. package/dist/options.d.ts +1 -61
  274. package/dist/options.js +2 -1
  275. package/dist/parse-loop.d.ts +8 -0
  276. package/dist/parse-loop.js +93 -0
  277. package/dist/parse-media-on-worker-entry.d.ts +2 -1
  278. package/dist/parse-media-on-worker-entry.js +7 -3
  279. package/dist/parse-media.js +12 -8
  280. package/dist/parse-result.js +2 -1
  281. package/dist/pause-signal.js +5 -1
  282. package/dist/perform-seek.d.ts +2 -7
  283. package/dist/perform-seek.js +29 -26
  284. package/dist/print-timings.d.ts +2 -0
  285. package/dist/print-timings.js +12 -0
  286. package/dist/readers/fetch/get-body-and-reader.js +5 -1
  287. package/dist/readers/fetch/resolve-url.js +5 -1
  288. package/dist/readers/from-fetch.js +21 -14
  289. package/dist/readers/from-node.js +23 -17
  290. package/dist/readers/from-web-file.js +13 -7
  291. package/dist/readers/reader.js +2 -1
  292. package/dist/readers/universal.js +16 -13
  293. package/dist/readers/web.js +12 -9
  294. package/dist/register-track.js +18 -9
  295. package/dist/remotion-license-acknowledge.js +8 -4
  296. package/dist/run-parse-iteration.d.ts +1 -4
  297. package/dist/run-parse-iteration.js +25 -24
  298. package/dist/samples-from-moof.js +10 -6
  299. package/dist/seek-backwards.d.ts +2 -0
  300. package/dist/seek-backwards.js +26 -0
  301. package/dist/seek-forwards.d.ts +2 -0
  302. package/dist/seek-forwards.js +28 -0
  303. package/dist/seek-signal.d.ts +22 -0
  304. package/dist/seek-signal.js +26 -0
  305. package/dist/seeking-info.d.ts +8 -0
  306. package/dist/seeking-info.js +2 -0
  307. package/dist/skip.js +5 -1
  308. package/dist/state/aac-state.js +5 -1
  309. package/dist/state/can-skip-tracks.d.ts +2 -2
  310. package/dist/state/can-skip-tracks.js +12 -4
  311. package/dist/state/emitted-fields.d.ts +1 -1
  312. package/dist/state/emitted-fields.js +5 -1
  313. package/dist/state/flac-state.js +5 -1
  314. package/dist/state/has-tracks-section.d.ts +2 -1
  315. package/dist/state/has-tracks-section.js +7 -3
  316. package/dist/state/images.js +5 -1
  317. package/dist/state/iso-base-media/cached-sample-positions.js +13 -8
  318. package/dist/state/iso-base-media/iso-state.js +9 -5
  319. package/dist/state/iso-base-media/moov-box.js +5 -1
  320. package/dist/state/keyframes.js +5 -1
  321. package/dist/state/m3u-state.js +9 -5
  322. package/dist/state/may-skip-video-data.js +7 -3
  323. package/dist/state/mp3.js +5 -1
  324. package/dist/state/need-samples-for-fields.d.ts +1 -1
  325. package/dist/state/need-samples-for-fields.js +5 -1
  326. package/dist/state/parser-state.d.ts +38 -8
  327. package/dist/state/parser-state.js +59 -35
  328. package/dist/state/riff.js +5 -1
  329. package/dist/state/sample-callbacks.d.ts +8 -3
  330. package/dist/state/sample-callbacks.js +27 -10
  331. package/dist/state/slow-duration-fps.js +5 -1
  332. package/dist/state/structure.js +5 -1
  333. package/dist/state/timings.d.ts +8 -0
  334. package/dist/state/timings.js +13 -0
  335. package/dist/state/transport-stream.js +7 -3
  336. package/dist/state/video-section.d.ts +1 -1
  337. package/dist/state/video-section.js +5 -1
  338. package/dist/state/webm.d.ts +1 -1
  339. package/dist/state/webm.js +9 -5
  340. package/dist/throttled-progress.d.ts +2 -3
  341. package/dist/throttled-progress.js +5 -1
  342. package/dist/truthy.js +4 -1
  343. package/dist/universal.js +5 -1
  344. package/dist/version.d.ts +1 -1
  345. package/dist/version.js +4 -1
  346. package/dist/web.js +5 -1
  347. package/dist/webcodec-sample-types.js +2 -1
  348. package/dist/work-on-seek-request.d.ts +2 -0
  349. package/dist/work-on-seek-request.js +43 -0
  350. package/dist/worker/forward-controller.js +7 -3
  351. package/dist/worker/serialize-error.js +19 -14
  352. package/dist/worker/worker-types.d.ts +2 -1
  353. package/dist/worker/worker-types.js +2 -1
  354. package/dist/worker-server-entry.js +5 -3
  355. package/dist/worker-server.js +16 -12
  356. package/dist/worker-web-entry.js +5 -3
  357. package/dist/worker.d.ts +3 -2
  358. package/dist/worker.js +11 -2
  359. package/dist/writers/node.js +23 -16
  360. package/dist/writers/writer.js +2 -1
  361. package/package.json +10 -10
  362. package/dist/parse-media-on-server-worker.d.ts +0 -2
  363. package/dist/parse-media-on-server-worker.js +0 -4
  364. package/dist/parse-media-on-web-worker.d.ts +0 -2
  365. package/dist/parse-media-on-web-worker.js +0 -4
@@ -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;
@@ -0,0 +1,2 @@
1
+ import type { ParserState } from './state/parser-state';
2
+ export declare const checkIfDone: (state: ParserState) => Promise<boolean>;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkIfDone = void 0;
4
+ const has_all_info_1 = require("./has-all-info");
5
+ const log_1 = require("./log");
6
+ const checkIfDone = async (state) => {
7
+ const startCheck = Date.now();
8
+ const hasAll = (0, has_all_info_1.hasAllInfo)({
9
+ state,
10
+ });
11
+ state.timings.timeCheckingIfDone += Date.now() - startCheck;
12
+ if (hasAll && state.mode === 'query') {
13
+ log_1.Log.verbose(state.logLevel, 'Got all info, skipping to the end.');
14
+ state.increaseSkippedBytes(state.contentLength - state.iterator.counter.getOffset());
15
+ return true;
16
+ }
17
+ if (state.iterator.counter.getOffset() === state.contentLength) {
18
+ if (state.getStructure().type === 'm3u' &&
19
+ !state.m3u.getAllChunksProcessedOverall()) {
20
+ return false;
21
+ }
22
+ log_1.Log.verbose(state.logLevel, 'Reached end of file');
23
+ await state.discardReadBytes(true);
24
+ return true;
25
+ }
26
+ if (state.iterator.counter.getOffset() + state.iterator.bytesRemaining() ===
27
+ state.contentLength &&
28
+ state.errored) {
29
+ log_1.Log.verbose(state.logLevel, 'Reached end of file and errorred');
30
+ return true;
31
+ }
32
+ return false;
33
+ };
34
+ exports.checkIfDone = checkIfDone;
@@ -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,11 @@
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 emit_audio_sample_1 = require("../../emit-audio-sample");
7
+ const register_track_1 = require("../../register-track");
8
+ const parseAac = async (state) => {
5
9
  const { iterator } = state;
6
10
  const startOffset = iterator.counter.getOffset();
7
11
  iterator.startReadingBits();
@@ -20,10 +24,10 @@ export const parseAac = async (state) => {
20
24
  const protectionAbsent = iterator.getBits(1); // protection absent
21
25
  const audioObjectType = iterator.getBits(2); // 1 = 'AAC-LC'
22
26
  const samplingFrequencyIndex = iterator.getBits(4);
23
- const sampleRate = getSampleRateFromSampleFrequencyIndex(samplingFrequencyIndex);
27
+ const sampleRate = (0, aac_codecprivate_1.getSampleRateFromSampleFrequencyIndex)(samplingFrequencyIndex);
24
28
  iterator.getBits(1); // private bit
25
29
  const channelConfiguration = iterator.getBits(3);
26
- const codecPrivate = createAacCodecPrivate({
30
+ const codecPrivate = (0, aac_codecprivate_1.createAacCodecPrivate)({
27
31
  audioObjectType,
28
32
  sampleRate,
29
33
  channelConfiguration,
@@ -43,11 +47,11 @@ export const parseAac = async (state) => {
43
47
  iterator.counter.decrement(iterator.counter.getOffset() - startOffset);
44
48
  const data = iterator.getSlice(frameLength);
45
49
  if (state.callbacks.tracks.getTracks().length === 0) {
46
- await registerAudioTrack({
50
+ await (0, register_track_1.registerAudioTrack)({
47
51
  state,
48
52
  container: 'aac',
49
53
  track: {
50
- codec: mapAudioObjectTypeToCodecString(audioObjectType),
54
+ codec: (0, aac_codecprivate_1.mapAudioObjectTypeToCodecString)(audioObjectType),
51
55
  codecWithoutConfig: 'aac',
52
56
  codecPrivate,
53
57
  description: codecPrivate,
@@ -65,16 +69,21 @@ export const parseAac = async (state) => {
65
69
  const { index } = state.aac.addSample({ offset: startOffset, size: frameLength });
66
70
  const timestamp = (1024 / sampleRate) * index;
67
71
  // One ADTS frame contains 1024 samples
68
- await state.callbacks.onAudioSample(0, convertAudioOrVideoSampleToWebCodecsTimestamps({
69
- duration,
70
- type: 'key',
71
- data,
72
- offset: startOffset,
73
- timescale: 1000000,
72
+ await (0, emit_audio_sample_1.emitAudioSample)({
74
73
  trackId: 0,
75
- cts: timestamp,
76
- dts: timestamp,
77
- timestamp,
78
- }, 1));
74
+ audioSample: (0, convert_audio_or_video_sample_1.convertAudioOrVideoSampleToWebCodecsTimestamps)({
75
+ duration,
76
+ type: 'key',
77
+ data,
78
+ offset: startOffset,
79
+ timescale: 1000000,
80
+ trackId: 0,
81
+ cts: timestamp,
82
+ dts: timestamp,
83
+ timestamp,
84
+ }, 1),
85
+ state,
86
+ });
79
87
  return Promise.resolve(null);
80
88
  };
89
+ 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("../../iterator/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,2 +1,2 @@
1
- import type { BufferIterator } from '../../buffer-iterator';
1
+ import type { BufferIterator } from '../../iterator/buffer-iterator';
2
2
  export declare const getBlockSize: (iterator: BufferIterator) => number | "uncommon-u16" | "uncommon-u8";
@@ -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,2 +1,2 @@
1
- import type { BufferIterator } from '../../buffer-iterator';
2
- export declare const getChannelCount: (iterator: BufferIterator) => 5 | 1 | 2 | 3 | 4 | 6 | 7 | 8;
1
+ import type { BufferIterator } from '../../iterator/buffer-iterator';
2
+ export declare const getChannelCount: (iterator: BufferIterator) => 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
@@ -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,3 +1,3 @@
1
- import type { BufferIterator } from '../../buffer-iterator';
1
+ import type { BufferIterator } from '../../iterator/buffer-iterator';
2
2
  import type { ParserState } from '../../state/parser-state';
3
3
  export declare const getSampleRate: (iterator: BufferIterator, state: ParserState) => number | "uncommon-u8" | "uncommon-u16" | "uncommon-u16-10";
@@ -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,4 +1,4 @@
1
- import { type BufferIterator } from '../../buffer-iterator';
1
+ import { type BufferIterator } from '../../iterator/buffer-iterator';
2
2
  import type { ParseResult } from '../../parse-result';
3
3
  import type { ParserState } from '../../state/parser-state';
4
4
  export declare const parseFrameHeader: ({ iterator, state, }: {
@@ -1,8 +1,12 @@
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 convert_audio_or_video_sample_1 = require("../../convert-audio-or-video-sample");
5
+ const emit_audio_sample_1 = require("../../emit-audio-sample");
6
+ const buffer_iterator_1 = require("../../iterator/buffer-iterator");
7
+ const get_block_size_1 = require("./get-block-size");
8
+ const get_channel_count_1 = require("./get-channel-count");
9
+ const get_sample_rate_1 = require("./get-sample-rate");
6
10
  // https://www.rfc-editor.org/rfc/rfc9639.html#section-9.1.1
7
11
  function calculateCRC8(data) {
8
12
  const polynomial = 0x07; // x^8 + x^2 + x^1 + x^0
@@ -23,16 +27,16 @@ function calculateCRC8(data) {
23
27
  }
24
28
  return crc;
25
29
  }
26
- export const parseFrameHeader = ({ iterator, state, }) => {
30
+ const parseFrameHeader = ({ iterator, state, }) => {
27
31
  if (iterator.bytesRemaining() < 10) {
28
32
  return null;
29
33
  }
30
34
  const startOffset = iterator.counter.getOffset();
31
35
  iterator.discard(2); // sync code
32
36
  iterator.startReadingBits();
33
- const blockSizeBits = getBlockSize(iterator);
34
- const sampleRateBits = getSampleRate(iterator, state);
35
- getChannelCount(iterator); // channel count
37
+ const blockSizeBits = (0, get_block_size_1.getBlockSize)(iterator);
38
+ const sampleRateBits = (0, get_sample_rate_1.getSampleRate)(iterator, state);
39
+ (0, get_channel_count_1.getChannelCount)(iterator); // channel count
36
40
  iterator.getBits(3); // bit depth
37
41
  iterator.getBits(1);
38
42
  const num = iterator.getFlacCodecNumber();
@@ -59,9 +63,10 @@ export const parseFrameHeader = ({ iterator, state, }) => {
59
63
  }
60
64
  return { num, blockSize, sampleRate };
61
65
  };
66
+ exports.parseFrameHeader = parseFrameHeader;
62
67
  const emitSample = async ({ state, data, offset, }) => {
63
- const iterator = getArrayBufferIterator(data, null);
64
- const parsed = parseFrameHeader({ iterator, state });
68
+ const iterator = (0, buffer_iterator_1.getArrayBufferIterator)(data, null);
69
+ const parsed = (0, exports.parseFrameHeader)({ iterator, state });
65
70
  if (!parsed) {
66
71
  throw new Error('Invalid CRC');
67
72
  }
@@ -76,20 +81,24 @@ const emitSample = async ({ state, data, offset, }) => {
76
81
  throw new Error('Cannot determine timestamp');
77
82
  }
78
83
  const timestamp = (num * streamInfo.maximumBlockSize) / streamInfo.sampleRate;
79
- await state.callbacks.onAudioSample(0, convertAudioOrVideoSampleToWebCodecsTimestamps({
80
- data,
81
- duration,
82
- cts: timestamp,
83
- dts: timestamp,
84
- timestamp,
85
- type: 'key',
86
- offset,
87
- timescale: 1000000,
84
+ await (0, emit_audio_sample_1.emitAudioSample)({
88
85
  trackId: 0,
89
- }, 1));
86
+ audioSample: (0, convert_audio_or_video_sample_1.convertAudioOrVideoSampleToWebCodecsTimestamps)({
87
+ data,
88
+ duration,
89
+ cts: timestamp,
90
+ dts: timestamp,
91
+ timestamp,
92
+ type: 'key',
93
+ offset,
94
+ timescale: 1000000,
95
+ trackId: 0,
96
+ }, 1),
97
+ state,
98
+ });
90
99
  iterator.destroy();
91
100
  };
92
- export const parseFlacFrame = async ({ state, iterator, }) => {
101
+ const parseFlacFrame = async ({ state, iterator, }) => {
93
102
  var _a, _b;
94
103
  const blockingBit = state.flac.getBlockingBitStrategy();
95
104
  const offset = iterator.counter.getOffset();
@@ -148,7 +157,7 @@ export const parseFlacFrame = async ({ state, iterator, }) => {
148
157
  continue;
149
158
  }
150
159
  iterator.counter.decrement(2);
151
- const nextIsLegit = parseFrameHeader({ iterator, state });
160
+ const nextIsLegit = (0, exports.parseFrameHeader)({ iterator, state });
152
161
  if (!nextIsLegit) {
153
162
  iterator.discard(1);
154
163
  continue;
@@ -162,3 +171,4 @@ export const parseFlacFrame = async ({ state, iterator, }) => {
162
171
  }
163
172
  return null;
164
173
  };
174
+ exports.parseFlacFrame = parseFlacFrame;
@@ -1,4 +1,4 @@
1
- import type { BufferIterator } from '../../buffer-iterator';
1
+ import type { BufferIterator } from '../../iterator/buffer-iterator';
2
2
  import type { ParseResult } from '../../parse-result';
3
3
  import type { ParserState } from '../../state/parser-state';
4
4
  export declare const parseFlac: ({ iterator, state, }: {