@siteed/expo-audio-studio 2.18.5 → 3.0.0

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 (329) hide show
  1. package/README.md +13 -297
  2. package/index.d.ts +1 -0
  3. package/index.js +1 -0
  4. package/package.json +6 -135
  5. package/CHANGELOG.md +0 -493
  6. package/LICENSE +0 -21
  7. package/android/build.gradle +0 -129
  8. package/android/src/androidTest/assets/chorus.wav +0 -0
  9. package/android/src/androidTest/assets/jfk.wav +0 -0
  10. package/android/src/androidTest/assets/osr_us_000_0010_8k.wav +0 -0
  11. package/android/src/androidTest/assets/recorder_hello_world.wav +0 -0
  12. package/android/src/androidTest/java/net/siteed/audiostream/AudioProcessorInstrumentedTest.kt +0 -197
  13. package/android/src/androidTest/java/net/siteed/audiostream/AudioRecorderInstrumentedTest.kt +0 -541
  14. package/android/src/androidTest/java/net/siteed/audiostream/AudioRecorderPerformanceInstrumentedTest.kt +0 -234
  15. package/android/src/androidTest/java/net/siteed/audiostream/integration/AudioFocusStrategyIntegrationTest.kt +0 -332
  16. package/android/src/androidTest/java/net/siteed/audiostream/integration/BufferDurationIntegrationTest.kt +0 -324
  17. package/android/src/androidTest/java/net/siteed/audiostream/integration/CompressedOnlyOutputTest.kt +0 -253
  18. package/android/src/androidTest/java/net/siteed/audiostream/integration/DeviceDisconnectionFallbackTest.kt +0 -218
  19. package/android/src/androidTest/java/net/siteed/audiostream/integration/EventEmissionIntervalTest.kt +0 -120
  20. package/android/src/androidTest/java/net/siteed/audiostream/integration/M4aFormatTest.kt +0 -345
  21. package/android/src/androidTest/java/net/siteed/audiostream/integration/OutputControlIntegrationTest.kt +0 -340
  22. package/android/src/androidTest/java/net/siteed/audiostream/integration/PcmStreamingDurationTest.kt +0 -252
  23. package/android/src/androidTest/java/net/siteed/audiostream/integration/README.md +0 -95
  24. package/android/src/androidTest/java/net/siteed/audiostream/integration/run_integration_tests.sh +0 -43
  25. package/android/src/main/AndroidManifest.xml +0 -30
  26. package/android/src/main/java/net/siteed/audiostream/AudioAnalysisData.kt +0 -188
  27. package/android/src/main/java/net/siteed/audiostream/AudioDataEncoder.kt +0 -9
  28. package/android/src/main/java/net/siteed/audiostream/AudioDeviceManager.kt +0 -1741
  29. package/android/src/main/java/net/siteed/audiostream/AudioFileHandler.kt +0 -136
  30. package/android/src/main/java/net/siteed/audiostream/AudioFormatUtils.kt +0 -354
  31. package/android/src/main/java/net/siteed/audiostream/AudioNotificationsManager.kt +0 -439
  32. package/android/src/main/java/net/siteed/audiostream/AudioProcessor.kt +0 -2237
  33. package/android/src/main/java/net/siteed/audiostream/AudioRecorderManager.kt +0 -2141
  34. package/android/src/main/java/net/siteed/audiostream/AudioRecordingService.kt +0 -167
  35. package/android/src/main/java/net/siteed/audiostream/AudioTrimmer.kt +0 -1099
  36. package/android/src/main/java/net/siteed/audiostream/Constants.kt +0 -37
  37. package/android/src/main/java/net/siteed/audiostream/EventSender.kt +0 -7
  38. package/android/src/main/java/net/siteed/audiostream/ExpoAudioStreamModule.kt +0 -1113
  39. package/android/src/main/java/net/siteed/audiostream/FFT.kt +0 -99
  40. package/android/src/main/java/net/siteed/audiostream/Features.kt +0 -98
  41. package/android/src/main/java/net/siteed/audiostream/LogUtils.kt +0 -93
  42. package/android/src/main/java/net/siteed/audiostream/NotificationConfig.kt +0 -72
  43. package/android/src/main/java/net/siteed/audiostream/PermissionUtils.kt +0 -68
  44. package/android/src/main/java/net/siteed/audiostream/RecordingActionReceiver.kt +0 -59
  45. package/android/src/main/java/net/siteed/audiostream/RecordingConfig.kt +0 -257
  46. package/android/src/main/java/net/siteed/audiostream/WaveformConfig.kt +0 -19
  47. package/android/src/main/java/net/siteed/audiostream/WaveformRenderer.kt +0 -159
  48. package/android/src/main/res/drawable/ic_default_action_icon.xml +0 -16
  49. package/android/src/main/res/drawable/ic_microphone.xml +0 -13
  50. package/android/src/main/res/drawable/ic_pause.xml +0 -10
  51. package/android/src/main/res/drawable/ic_play.xml +0 -10
  52. package/android/src/main/res/drawable/ic_stop.xml +0 -10
  53. package/android/src/main/res/layout/notification_recording.xml +0 -37
  54. package/android/src/test/java/net/siteed/audiostream/AudioFileHandlerTest.kt +0 -279
  55. package/android/src/test/java/net/siteed/audiostream/AudioFocusStrategyTest.kt +0 -249
  56. package/android/src/test/java/net/siteed/audiostream/AudioFormatTest.kt +0 -151
  57. package/android/src/test/java/net/siteed/audiostream/AudioFormatUtilsTest.kt +0 -273
  58. package/android/src/test/java/net/siteed/audiostream/DeviceDisconnectionFallbackUnitTest.kt +0 -140
  59. package/android/src/test/resources/chorus.wav +0 -0
  60. package/android/src/test/resources/generate_test_audio.py +0 -94
  61. package/android/src/test/resources/jfk.wav +0 -0
  62. package/android/src/test/resources/osr_us_000_0010_8k.wav +0 -0
  63. package/android/src/test/resources/recorder_hello_world.wav +0 -0
  64. package/app.plugin.js +0 -3
  65. package/build/cjs/AudioAnalysis/AudioAnalysis.types.js +0 -4
  66. package/build/cjs/AudioAnalysis/AudioAnalysis.types.js.map +0 -1
  67. package/build/cjs/AudioAnalysis/extractAudioAnalysis.js +0 -210
  68. package/build/cjs/AudioAnalysis/extractAudioAnalysis.js.map +0 -1
  69. package/build/cjs/AudioAnalysis/extractAudioData.js +0 -21
  70. package/build/cjs/AudioAnalysis/extractAudioData.js.map +0 -1
  71. package/build/cjs/AudioAnalysis/extractMelSpectrogram.js +0 -92
  72. package/build/cjs/AudioAnalysis/extractMelSpectrogram.js.map +0 -1
  73. package/build/cjs/AudioAnalysis/extractPreview.js +0 -28
  74. package/build/cjs/AudioAnalysis/extractPreview.js.map +0 -1
  75. package/build/cjs/AudioAnalysis/extractWaveform.js +0 -18
  76. package/build/cjs/AudioAnalysis/extractWaveform.js.map +0 -1
  77. package/build/cjs/AudioDeviceManager.js +0 -689
  78. package/build/cjs/AudioDeviceManager.js.map +0 -1
  79. package/build/cjs/AudioRecorder.provider.js +0 -78
  80. package/build/cjs/AudioRecorder.provider.js.map +0 -1
  81. package/build/cjs/ExpoAudioStream.native.js +0 -8
  82. package/build/cjs/ExpoAudioStream.native.js.map +0 -1
  83. package/build/cjs/ExpoAudioStream.types.js +0 -11
  84. package/build/cjs/ExpoAudioStream.types.js.map +0 -1
  85. package/build/cjs/ExpoAudioStream.web.js +0 -708
  86. package/build/cjs/ExpoAudioStream.web.js.map +0 -1
  87. package/build/cjs/ExpoAudioStreamModule.js +0 -718
  88. package/build/cjs/ExpoAudioStreamModule.js.map +0 -1
  89. package/build/cjs/WebRecorder.web.js +0 -777
  90. package/build/cjs/WebRecorder.web.js.map +0 -1
  91. package/build/cjs/constants/platformLimitations.js +0 -99
  92. package/build/cjs/constants/platformLimitations.js.map +0 -1
  93. package/build/cjs/constants.js +0 -17
  94. package/build/cjs/constants.js.map +0 -1
  95. package/build/cjs/events.js +0 -29
  96. package/build/cjs/events.js.map +0 -1
  97. package/build/cjs/hooks/useAudioDevices.js +0 -179
  98. package/build/cjs/hooks/useAudioDevices.js.map +0 -1
  99. package/build/cjs/index.js +0 -58
  100. package/build/cjs/index.js.map +0 -1
  101. package/build/cjs/trimAudio.js +0 -76
  102. package/build/cjs/trimAudio.js.map +0 -1
  103. package/build/cjs/useAudioRecorder.js +0 -518
  104. package/build/cjs/useAudioRecorder.js.map +0 -1
  105. package/build/cjs/utils/BlobFix.js +0 -502
  106. package/build/cjs/utils/BlobFix.js.map +0 -1
  107. package/build/cjs/utils/audioProcessing.js +0 -136
  108. package/build/cjs/utils/audioProcessing.js.map +0 -1
  109. package/build/cjs/utils/cleanNativeOptions.js +0 -22
  110. package/build/cjs/utils/cleanNativeOptions.js.map +0 -1
  111. package/build/cjs/utils/concatenateBuffers.js +0 -25
  112. package/build/cjs/utils/concatenateBuffers.js.map +0 -1
  113. package/build/cjs/utils/convertPCMToFloat32.js +0 -124
  114. package/build/cjs/utils/convertPCMToFloat32.js.map +0 -1
  115. package/build/cjs/utils/crc32.js +0 -52
  116. package/build/cjs/utils/crc32.js.map +0 -1
  117. package/build/cjs/utils/encodingToBitDepth.js +0 -17
  118. package/build/cjs/utils/encodingToBitDepth.js.map +0 -1
  119. package/build/cjs/utils/getWavFileInfo.js +0 -96
  120. package/build/cjs/utils/getWavFileInfo.js.map +0 -1
  121. package/build/cjs/utils/writeWavHeader.js +0 -88
  122. package/build/cjs/utils/writeWavHeader.js.map +0 -1
  123. package/build/cjs/workers/InlineFeaturesExtractor.web.js +0 -859
  124. package/build/cjs/workers/InlineFeaturesExtractor.web.js.map +0 -1
  125. package/build/cjs/workers/inlineAudioWebWorker.web.js +0 -184
  126. package/build/cjs/workers/inlineAudioWebWorker.web.js.map +0 -1
  127. package/build/esm/AudioAnalysis/AudioAnalysis.types.js +0 -3
  128. package/build/esm/AudioAnalysis/AudioAnalysis.types.js.map +0 -1
  129. package/build/esm/AudioAnalysis/extractAudioAnalysis.js +0 -202
  130. package/build/esm/AudioAnalysis/extractAudioAnalysis.js.map +0 -1
  131. package/build/esm/AudioAnalysis/extractAudioData.js +0 -14
  132. package/build/esm/AudioAnalysis/extractAudioData.js.map +0 -1
  133. package/build/esm/AudioAnalysis/extractMelSpectrogram.js +0 -89
  134. package/build/esm/AudioAnalysis/extractMelSpectrogram.js.map +0 -1
  135. package/build/esm/AudioAnalysis/extractPreview.js +0 -25
  136. package/build/esm/AudioAnalysis/extractPreview.js.map +0 -1
  137. package/build/esm/AudioAnalysis/extractWaveform.js +0 -11
  138. package/build/esm/AudioAnalysis/extractWaveform.js.map +0 -1
  139. package/build/esm/AudioDeviceManager.js +0 -682
  140. package/build/esm/AudioDeviceManager.js.map +0 -1
  141. package/build/esm/AudioRecorder.provider.js +0 -40
  142. package/build/esm/AudioRecorder.provider.js.map +0 -1
  143. package/build/esm/ExpoAudioStream.native.js +0 -6
  144. package/build/esm/ExpoAudioStream.native.js.map +0 -1
  145. package/build/esm/ExpoAudioStream.types.js +0 -8
  146. package/build/esm/ExpoAudioStream.types.js.map +0 -1
  147. package/build/esm/ExpoAudioStream.web.js +0 -704
  148. package/build/esm/ExpoAudioStream.web.js.map +0 -1
  149. package/build/esm/ExpoAudioStreamModule.js +0 -713
  150. package/build/esm/ExpoAudioStreamModule.js.map +0 -1
  151. package/build/esm/WebRecorder.web.js +0 -773
  152. package/build/esm/WebRecorder.web.js.map +0 -1
  153. package/build/esm/constants/platformLimitations.js +0 -90
  154. package/build/esm/constants/platformLimitations.js.map +0 -1
  155. package/build/esm/constants.js +0 -14
  156. package/build/esm/constants.js.map +0 -1
  157. package/build/esm/events.js +0 -21
  158. package/build/esm/events.js.map +0 -1
  159. package/build/esm/hooks/useAudioDevices.js +0 -176
  160. package/build/esm/hooks/useAudioDevices.js.map +0 -1
  161. package/build/esm/index.js +0 -20
  162. package/build/esm/index.js.map +0 -1
  163. package/build/esm/trimAudio.js +0 -69
  164. package/build/esm/trimAudio.js.map +0 -1
  165. package/build/esm/useAudioRecorder.js +0 -512
  166. package/build/esm/useAudioRecorder.js.map +0 -1
  167. package/build/esm/utils/BlobFix.js +0 -498
  168. package/build/esm/utils/BlobFix.js.map +0 -1
  169. package/build/esm/utils/audioProcessing.js +0 -133
  170. package/build/esm/utils/audioProcessing.js.map +0 -1
  171. package/build/esm/utils/cleanNativeOptions.js +0 -19
  172. package/build/esm/utils/cleanNativeOptions.js.map +0 -1
  173. package/build/esm/utils/concatenateBuffers.js +0 -21
  174. package/build/esm/utils/concatenateBuffers.js.map +0 -1
  175. package/build/esm/utils/convertPCMToFloat32.js +0 -120
  176. package/build/esm/utils/convertPCMToFloat32.js.map +0 -1
  177. package/build/esm/utils/crc32.js +0 -50
  178. package/build/esm/utils/crc32.js.map +0 -1
  179. package/build/esm/utils/encodingToBitDepth.js +0 -13
  180. package/build/esm/utils/encodingToBitDepth.js.map +0 -1
  181. package/build/esm/utils/getWavFileInfo.js +0 -92
  182. package/build/esm/utils/getWavFileInfo.js.map +0 -1
  183. package/build/esm/utils/writeWavHeader.js +0 -84
  184. package/build/esm/utils/writeWavHeader.js.map +0 -1
  185. package/build/esm/workers/InlineFeaturesExtractor.web.js +0 -856
  186. package/build/esm/workers/InlineFeaturesExtractor.web.js.map +0 -1
  187. package/build/esm/workers/inlineAudioWebWorker.web.js +0 -181
  188. package/build/esm/workers/inlineAudioWebWorker.web.js.map +0 -1
  189. package/build/types/AudioAnalysis/AudioAnalysis.types.d.ts +0 -196
  190. package/build/types/AudioAnalysis/AudioAnalysis.types.d.ts.map +0 -1
  191. package/build/types/AudioAnalysis/extractAudioAnalysis.d.ts +0 -74
  192. package/build/types/AudioAnalysis/extractAudioAnalysis.d.ts.map +0 -1
  193. package/build/types/AudioAnalysis/extractAudioData.d.ts +0 -3
  194. package/build/types/AudioAnalysis/extractAudioData.d.ts.map +0 -1
  195. package/build/types/AudioAnalysis/extractMelSpectrogram.d.ts +0 -14
  196. package/build/types/AudioAnalysis/extractMelSpectrogram.d.ts.map +0 -1
  197. package/build/types/AudioAnalysis/extractPreview.d.ts +0 -11
  198. package/build/types/AudioAnalysis/extractPreview.d.ts.map +0 -1
  199. package/build/types/AudioAnalysis/extractWaveform.d.ts +0 -8
  200. package/build/types/AudioAnalysis/extractWaveform.d.ts.map +0 -1
  201. package/build/types/AudioDeviceManager.d.ts +0 -187
  202. package/build/types/AudioDeviceManager.d.ts.map +0 -1
  203. package/build/types/AudioRecorder.provider.d.ts +0 -11
  204. package/build/types/AudioRecorder.provider.d.ts.map +0 -1
  205. package/build/types/ExpoAudioStream.native.d.ts +0 -3
  206. package/build/types/ExpoAudioStream.native.d.ts.map +0 -1
  207. package/build/types/ExpoAudioStream.types.d.ts +0 -738
  208. package/build/types/ExpoAudioStream.types.d.ts.map +0 -1
  209. package/build/types/ExpoAudioStream.web.d.ts +0 -96
  210. package/build/types/ExpoAudioStream.web.d.ts.map +0 -1
  211. package/build/types/ExpoAudioStreamModule.d.ts +0 -3
  212. package/build/types/ExpoAudioStreamModule.d.ts.map +0 -1
  213. package/build/types/WebRecorder.web.d.ts +0 -198
  214. package/build/types/WebRecorder.web.d.ts.map +0 -1
  215. package/build/types/constants/platformLimitations.d.ts +0 -40
  216. package/build/types/constants/platformLimitations.d.ts.map +0 -1
  217. package/build/types/constants.d.ts +0 -11
  218. package/build/types/constants.d.ts.map +0 -1
  219. package/build/types/events.d.ts +0 -26
  220. package/build/types/events.d.ts.map +0 -1
  221. package/build/types/hooks/useAudioDevices.d.ts +0 -15
  222. package/build/types/hooks/useAudioDevices.d.ts.map +0 -1
  223. package/build/types/index.d.ts +0 -18
  224. package/build/types/index.d.ts.map +0 -1
  225. package/build/types/trimAudio.d.ts +0 -25
  226. package/build/types/trimAudio.d.ts.map +0 -1
  227. package/build/types/useAudioRecorder.d.ts +0 -22
  228. package/build/types/useAudioRecorder.d.ts.map +0 -1
  229. package/build/types/utils/BlobFix.d.ts +0 -9
  230. package/build/types/utils/BlobFix.d.ts.map +0 -1
  231. package/build/types/utils/audioProcessing.d.ts +0 -24
  232. package/build/types/utils/audioProcessing.d.ts.map +0 -1
  233. package/build/types/utils/cleanNativeOptions.d.ts +0 -15
  234. package/build/types/utils/cleanNativeOptions.d.ts.map +0 -1
  235. package/build/types/utils/concatenateBuffers.d.ts +0 -8
  236. package/build/types/utils/concatenateBuffers.d.ts.map +0 -1
  237. package/build/types/utils/convertPCMToFloat32.d.ts +0 -13
  238. package/build/types/utils/convertPCMToFloat32.d.ts.map +0 -1
  239. package/build/types/utils/crc32.d.ts +0 -7
  240. package/build/types/utils/crc32.d.ts.map +0 -1
  241. package/build/types/utils/encodingToBitDepth.d.ts +0 -5
  242. package/build/types/utils/encodingToBitDepth.d.ts.map +0 -1
  243. package/build/types/utils/getWavFileInfo.d.ts +0 -26
  244. package/build/types/utils/getWavFileInfo.d.ts.map +0 -1
  245. package/build/types/utils/writeWavHeader.d.ts +0 -34
  246. package/build/types/utils/writeWavHeader.d.ts.map +0 -1
  247. package/build/types/workers/InlineFeaturesExtractor.web.d.ts +0 -2
  248. package/build/types/workers/InlineFeaturesExtractor.web.d.ts.map +0 -1
  249. package/build/types/workers/inlineAudioWebWorker.web.d.ts +0 -2
  250. package/build/types/workers/inlineAudioWebWorker.web.d.ts.map +0 -1
  251. package/expo-module.config.json +0 -10
  252. package/ios/AudioAnalysisData.swift +0 -74
  253. package/ios/AudioDeviceManager.swift +0 -666
  254. package/ios/AudioNotificationManager.swift +0 -154
  255. package/ios/AudioProcessingHelpers.swift +0 -743
  256. package/ios/AudioProcessor.swift +0 -1151
  257. package/ios/AudioStreamError.swift +0 -7
  258. package/ios/AudioStreamManager.swift +0 -2352
  259. package/ios/AudioStreamManagerDelegate.swift +0 -16
  260. package/ios/DataPoint.swift +0 -54
  261. package/ios/DecodingConfig.swift +0 -59
  262. package/ios/ExpoAudioStream.podspec +0 -33
  263. package/ios/ExpoAudioStreamModule.swift +0 -1013
  264. package/ios/ExpoAudioStudioTests/AudioFileHandlerTests.swift +0 -338
  265. package/ios/ExpoAudioStudioTests/AudioFormatUtilsTests.swift +0 -331
  266. package/ios/ExpoAudioStudioTests/AudioTestHelpers.swift +0 -130
  267. package/ios/ExpoAudioStudioTests/CompressedOnlyOutputTests.swift +0 -294
  268. package/ios/ExpoAudioStudioTests/EventEmissionIntervalTests.swift +0 -105
  269. package/ios/ExpoAudioStudioTests/Info.plist +0 -22
  270. package/ios/ExpoAudioStudioTests/README.md +0 -39
  271. package/ios/ExpoAudioStudioTests/SimpleAudioTest.swift +0 -98
  272. package/ios/ExpoAudioStudioTests/TestAudioGenerator.swift +0 -75
  273. package/ios/FFT.swift +0 -62
  274. package/ios/Features.swift +0 -95
  275. package/ios/ISSUE_IOS.md +0 -68
  276. package/ios/Logger.swift +0 -39
  277. package/ios/NotificationExtension.swift +0 -15
  278. package/ios/RecordingResult.swift +0 -22
  279. package/ios/RecordingSettings.swift +0 -308
  280. package/ios/WaveformExtractor.swift +0 -105
  281. package/ios/tests/README.md +0 -41
  282. package/ios/tests/integration/buffer_and_fallback_test.swift +0 -178
  283. package/ios/tests/integration/buffer_duration_test.swift +0 -185
  284. package/ios/tests/integration/compressed_only_output_test.swift +0 -271
  285. package/ios/tests/integration/output_control_test.swift +0 -322
  286. package/ios/tests/integration/run_integration_tests.sh +0 -37
  287. package/ios/tests/opus_support_test_macos.swift +0 -154
  288. package/ios/tests/standalone/audio_processing_test.swift +0 -144
  289. package/ios/tests/standalone/audio_recording_test.swift +0 -277
  290. package/ios/tests/standalone/audio_streaming_test.swift +0 -249
  291. package/ios/tests/standalone/standalone_test.swift +0 -144
  292. package/plugin/build/index.cjs +0 -194
  293. package/plugin/build/index.d.cts +0 -22
  294. package/plugin/build/index.js +0 -194
  295. package/plugin/src/index.ts +0 -285
  296. package/plugin/tsconfig.json +0 -10
  297. package/plugin/tsconfig.tsbuildinfo +0 -1
  298. package/src/AudioAnalysis/AudioAnalysis.types.ts +0 -224
  299. package/src/AudioAnalysis/extractAudioAnalysis.ts +0 -344
  300. package/src/AudioAnalysis/extractAudioData.ts +0 -17
  301. package/src/AudioAnalysis/extractMelSpectrogram.ts +0 -154
  302. package/src/AudioAnalysis/extractPreview.ts +0 -34
  303. package/src/AudioAnalysis/extractWaveform.ts +0 -22
  304. package/src/AudioDeviceManager.ts +0 -803
  305. package/src/AudioRecorder.provider.tsx +0 -57
  306. package/src/ExpoAudioStream.native.ts +0 -6
  307. package/src/ExpoAudioStream.types.ts +0 -874
  308. package/src/ExpoAudioStream.web.ts +0 -905
  309. package/src/ExpoAudioStreamModule.ts +0 -990
  310. package/src/WebRecorder.web.ts +0 -1005
  311. package/src/constants/platformLimitations.ts +0 -118
  312. package/src/constants.ts +0 -18
  313. package/src/events.ts +0 -60
  314. package/src/hooks/useAudioDevices.ts +0 -213
  315. package/src/index.ts +0 -54
  316. package/src/trimAudio.ts +0 -94
  317. package/src/types/crc-32.d.ts +0 -9
  318. package/src/useAudioRecorder.tsx +0 -766
  319. package/src/utils/BlobFix.ts +0 -561
  320. package/src/utils/audioProcessing.ts +0 -205
  321. package/src/utils/cleanNativeOptions.ts +0 -18
  322. package/src/utils/concatenateBuffers.ts +0 -24
  323. package/src/utils/convertPCMToFloat32.ts +0 -170
  324. package/src/utils/crc32.ts +0 -59
  325. package/src/utils/encodingToBitDepth.ts +0 -18
  326. package/src/utils/getWavFileInfo.ts +0 -132
  327. package/src/utils/writeWavHeader.ts +0 -115
  328. package/src/workers/InlineFeaturesExtractor.web.tsx +0 -855
  329. package/src/workers/inlineAudioWebWorker.web.tsx +0 -180
@@ -1 +0,0 @@
1
- {"version":3,"file":"useAudioRecorder.js","sourceRoot":"","sources":["../../src/useAudioRecorder.tsx"],"names":[],"mappings":";;;;;AA8JA,4CA+lBC;AA7vBD,0BAA0B;AAC1B,yDAA+D;AAC/D,iCAAyE;AAGzE,6DAAyD;AAUzD,oFAA2D;AAC3D,yEAAyE;AACzE,qCAKiB;AACjB,mEAA+D;AAkD/D,MAAM,eAAe,GAAkB;IACnC,iBAAiB,EAAE,GAAG;IACtB,QAAQ,EAAE,EAAE;IACZ,gBAAgB,EAAE,CAAC;IACnB,UAAU,EAAE,CAAC;IACb,UAAU,EAAE,KAAK;IACjB,OAAO,EAAE,CAAC;IACV,UAAU,EAAE,EAAE;IACd,QAAQ,EAAE;QACN,GAAG,EAAE,MAAM,CAAC,iBAAiB;QAC7B,GAAG,EAAE,MAAM,CAAC,iBAAiB;KAChC;IACD,cAAc,EAAE;QACZ,GAAG,EAAE,MAAM,CAAC,iBAAiB;QAC7B,GAAG,EAAE,MAAM,CAAC,iBAAiB;KAChC;IACD,gBAAgB,EAAE,CAAC;CACtB,CAAA;AAED,SAAS,oBAAoB,CACzB,KAA2B,EAC3B,MAAsB;IAEtB,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,OAAO;YACR,OAAO;gBACH,GAAG,KAAK;gBACR,WAAW,EAAE,IAAI;gBACjB,QAAQ,EAAE,KAAK;gBACf,UAAU,EAAE,CAAC;gBACb,IAAI,EAAE,CAAC;gBACP,WAAW,EAAE,SAAS;gBACtB,YAAY,EAAE,eAAe;aAChC,CAAA;QACL,KAAK,MAAM;YACP,OAAO;gBACH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AC9B,YAAY,EAAE,KAAK,CAAC,YAAY;KACnC,CAAA;AACL,CAAC","sourcesContent":["// src/useAudioRecorder.ts\nimport { EventSubscription, Platform } from 'expo-modules-core'\nimport { useCallback, useEffect, useReducer, useRef, useId } from 'react'\n\nimport { AudioAnalysis } from './AudioAnalysis/AudioAnalysis.types'\nimport { audioDeviceManager } from './AudioDeviceManager'\nimport {\n AudioDataEvent,\n AudioRecording,\n AudioStreamStatus,\n CompressionInfo,\n ConsoleLike,\n RecordingConfig,\n StartRecordingResult,\n} from './ExpoAudioStream.types'\nimport ExpoAudioStreamModule from './ExpoAudioStreamModule'\nimport { validateRecordingConfig } from './constants/platformLimitations'\nimport {\n addAudioAnalysisListener,\n addAudioEventListener,\n AudioEventPayload,\n addRecordingInterruptionListener,\n} from './events'\nimport { cleanNativeOptions } from './utils/cleanNativeOptions'\n\nexport interface UseAudioRecorderProps {\n logger?: ConsoleLike\n audioWorkletUrl?: string\n featuresExtratorUrl?: string\n}\n\nexport interface UseAudioRecorderState {\n prepareRecording: (_: RecordingConfig) => Promise<void>\n startRecording: (_: RecordingConfig) => Promise<StartRecordingResult>\n stopRecording: () => Promise<AudioRecording>\n pauseRecording: () => Promise<void>\n resumeRecording: () => Promise<void>\n isRecording: boolean\n isPaused: boolean\n durationMs: number\n size: number\n compression?: CompressionInfo\n analysisData?: AudioAnalysis\n}\n\ninterface RecorderReducerState {\n isRecording: boolean\n isPaused: boolean\n durationMs: number\n size: number\n compression?: CompressionInfo\n analysisData?: AudioAnalysis\n}\n\ntype RecorderAction =\n | { type: 'START' | 'STOP' | 'PAUSE' | 'RESUME' }\n | {\n type: 'UPDATE_RECORDING_STATE'\n payload: {\n isRecording: boolean\n isPaused: boolean\n }\n }\n | {\n type: 'UPDATE_STATUS'\n payload: {\n durationMs: number\n size: number\n compression?: CompressionInfo\n }\n }\n | { type: 'UPDATE_ANALYSIS'; payload: AudioAnalysis }\n\nconst defaultAnalysis: AudioAnalysis = {\n segmentDurationMs: 100,\n bitDepth: 32,\n numberOfChannels: 1,\n durationMs: 0,\n sampleRate: 44100,\n samples: 0,\n dataPoints: [],\n rmsRange: {\n min: Number.POSITIVE_INFINITY,\n max: Number.NEGATIVE_INFINITY,\n },\n amplitudeRange: {\n min: Number.POSITIVE_INFINITY,\n max: Number.NEGATIVE_INFINITY,\n },\n extractionTimeMs: 0,\n}\n\nfunction audioRecorderReducer(\n state: RecorderReducerState,\n action: RecorderAction\n): RecorderReducerState {\n switch (action.type) {\n case 'START':\n return {\n ...state,\n isRecording: true,\n isPaused: false,\n durationMs: 0,\n size: 0,\n compression: undefined,\n analysisData: defaultAnalysis,\n }\n case 'STOP':\n return {\n ...state,\n isRecording: false,\n isPaused: false,\n durationMs: 0,\n size: 0,\n compression: undefined,\n analysisData: undefined,\n }\n case 'PAUSE':\n return { ...state, isPaused: true, isRecording: false }\n case 'RESUME':\n return { ...state, isPaused: false, isRecording: true }\n case 'UPDATE_RECORDING_STATE':\n return {\n ...state,\n isPaused: action.payload.isPaused,\n isRecording: action.payload.isRecording,\n }\n case 'UPDATE_STATUS': {\n const newState = {\n ...state,\n durationMs: action.payload.durationMs,\n size: action.payload.size,\n compression: action.payload.compression\n ? {\n size: action.payload.compression.size,\n mimeType: action.payload.compression.mimeType,\n bitrate: action.payload.compression.bitrate,\n format: action.payload.compression.format,\n }\n : undefined,\n }\n return newState\n }\n case 'UPDATE_ANALYSIS':\n return {\n ...state,\n analysisData: action.payload,\n }\n default:\n return state\n }\n}\n\ninterface HandleAudioAnalysisProps {\n analysis: AudioAnalysis\n visualizationDuration: number\n}\n\nexport function useAudioRecorder({\n logger,\n audioWorkletUrl,\n featuresExtratorUrl,\n}: UseAudioRecorderProps = {}): UseAudioRecorderState {\n // Initialize AudioDeviceManager with logger (once)\n if (logger) {\n audioDeviceManager.setLogger(logger)\n }\n const [state, dispatch] = useReducer(audioRecorderReducer, {\n isRecording: false,\n isPaused: false,\n durationMs: 0,\n size: 0,\n compression: undefined,\n analysisData: undefined,\n })\n\n const startResultRef = useRef<StartRecordingResult | null>(null)\n\n const analysisListenerRef = useRef<EventSubscription | null>(null)\n // analysisRef is the current analysis data (last 10 seconds by default)\n const analysisRef = useRef<AudioAnalysis>({ ...defaultAnalysis })\n // fullAnalysisRef is the full analysis data (all data points)\n const fullAnalysisRef = useRef<AudioAnalysis>({\n ...defaultAnalysis,\n })\n\n // Instantiate the module for web with URLs\n const ExpoAudioStream =\n Platform.OS === 'web'\n ? ExpoAudioStreamModule({\n audioWorkletUrl,\n featuresExtratorUrl,\n logger,\n })\n : ExpoAudioStreamModule\n\n const onAudioStreamRef = useRef<\n ((_: AudioDataEvent) => Promise<void>) | null\n >(null)\n\n const stateRef = useRef({\n isRecording: false,\n isPaused: false,\n durationMs: 0,\n size: 0,\n compression: undefined as CompressionInfo | undefined,\n })\n\n const recordingConfigRef = useRef<RecordingConfig | null>(null)\n\n // Generate unique instance ID for debugging\n const instanceId = useId().replace(/:/g, '').slice(0, 5)\n\n const handleAudioAnalysis = useCallback(\n async ({\n analysis,\n visualizationDuration,\n }: HandleAudioAnalysisProps) => {\n const savedAnalysisData = analysisRef.current || {\n ...defaultAnalysis,\n }\n\n const maxDuration = visualizationDuration\n\n logger?.debug(\n `[handleAudioAnalysis] Received audio analysis: maxDuration=${maxDuration} analysis.dataPoints=${analysis.dataPoints.length} analysisData.dataPoints=${savedAnalysisData.dataPoints.length}`\n )\n\n // Combine data points\n const combinedDataPoints = [\n ...savedAnalysisData.dataPoints,\n ...analysis.dataPoints,\n ]\n\n const fullCombinedDataPoints = [\n ...(fullAnalysisRef.current?.dataPoints ?? []),\n ...analysis.dataPoints,\n ]\n\n // Calculate the new duration\n // The number of segments is based on how many segments of segmentDurationMs can fit in visualizationDuration\n const numberOfSegments = Math.ceil(\n visualizationDuration / analysis.segmentDurationMs\n )\n // maxDataPoints should be the number of data points, not milliseconds\n const maxDataPoints = numberOfSegments\n\n logger?.debug(\n `[handleAudioAnalysis] Combined data points before trimming: numberOfSegments=${numberOfSegments} visualizationDuration=${visualizationDuration} combinedDataPointsLength=${combinedDataPoints.length} vs maxDataPoints=${maxDataPoints}`\n )\n\n // Trim data points to keep within the maximum number of data points\n if (combinedDataPoints.length > maxDataPoints) {\n combinedDataPoints.splice(\n 0,\n combinedDataPoints.length - maxDataPoints\n )\n }\n\n // Keep the full data points\n fullAnalysisRef.current = {\n ...fullAnalysisRef.current,\n dataPoints: fullCombinedDataPoints,\n }\n fullAnalysisRef.current.durationMs =\n fullCombinedDataPoints.length * analysis.segmentDurationMs\n savedAnalysisData.dataPoints = combinedDataPoints\n savedAnalysisData.bitDepth =\n analysis.bitDepth || savedAnalysisData.bitDepth\n savedAnalysisData.durationMs =\n combinedDataPoints.length * analysis.segmentDurationMs\n\n // Update amplitude range\n const newMin = Math.min(\n savedAnalysisData.amplitudeRange.min,\n analysis.amplitudeRange.min\n )\n const newMax = Math.max(\n savedAnalysisData.amplitudeRange.max,\n analysis.amplitudeRange.max\n )\n\n savedAnalysisData.amplitudeRange = {\n min: newMin,\n max: newMax,\n }\n fullAnalysisRef.current.amplitudeRange = {\n min: newMin,\n max: newMax,\n }\n\n logger?.debug(\n `[handleAudioAnalysis] Updated analysis data: durationMs=${savedAnalysisData.durationMs}`,\n { dataPoints: savedAnalysisData.dataPoints.length }\n )\n\n // Call the onAudioAnalysis callback if it exists in the recording config\n if (recordingConfigRef.current?.onAudioAnalysis) {\n recordingConfigRef.current\n .onAudioAnalysis(analysis)\n .catch((error) => {\n logger?.warn(`Error processing audio analysis:`, error)\n })\n }\n\n // Update the ref\n analysisRef.current = savedAnalysisData\n\n // Dispatch the updated analysis data to state to trigger re-render\n dispatch({\n type: 'UPDATE_ANALYSIS',\n payload: { ...savedAnalysisData },\n })\n },\n [dispatch]\n )\n\n const handleAudioEvent = useCallback(\n async (eventData: AudioEventPayload) => {\n const {\n fileUri,\n deltaSize,\n totalSize,\n lastEmittedSize,\n position,\n streamUuid,\n encoded,\n mimeType,\n buffer,\n compression,\n } = eventData\n logger?.debug(`[handleAudioEvent] Received audio event:`, {\n fileUri,\n deltaSize,\n totalSize,\n position,\n mimeType,\n lastEmittedSize,\n streamUuid,\n encodedLength: encoded?.length,\n compression,\n })\n if (deltaSize === 0) {\n // Ignore packet with no data\n return\n }\n try {\n // Coming from native ( ios / android ) otherwise buffer is set\n if (Platform.OS !== 'web') {\n // Read the audio file as a base64 string for comparison\n if (!encoded) {\n logger?.error(`Encoded audio data is missing`)\n throw new Error('Encoded audio data is missing')\n }\n onAudioStreamRef.current?.({\n data: encoded,\n position,\n fileUri,\n eventDataSize: deltaSize,\n totalSize,\n compression:\n compression && startResultRef.current?.compression\n ? {\n data: compression.data,\n size: compression.totalSize,\n mimeType:\n startResultRef.current.compression\n ?.mimeType,\n bitrate:\n startResultRef.current.compression\n ?.bitrate,\n format: startResultRef.current.compression\n ?.format,\n }\n : undefined,\n })\n } else if (buffer) {\n // Coming from web\n const webEvent: AudioDataEvent = {\n data: buffer,\n position,\n fileUri,\n eventDataSize: deltaSize,\n totalSize,\n compression:\n compression && startResultRef.current?.compression\n ? {\n data: compression.data,\n size: compression.totalSize,\n mimeType:\n startResultRef.current.compression\n ?.mimeType,\n bitrate:\n startResultRef.current.compression\n ?.bitrate,\n format: startResultRef.current.compression\n ?.format,\n }\n : undefined,\n }\n onAudioStreamRef.current?.(webEvent)\n logger?.debug(\n `[handleAudioEvent] Audio data sent to onAudioStream`,\n webEvent\n )\n }\n } catch (error) {\n logger?.error(`Error processing audio event:`, error)\n }\n },\n []\n )\n\n const checkStatus = useCallback(async () => {\n try {\n const status: AudioStreamStatus = ExpoAudioStream.status()\n logger?.debug(\n `Status: paused: ${status.isPaused} isRecording: ${status.isRecording} durationMs: ${status.durationMs} size: ${status.size}`,\n status.compression\n )\n\n // Only dispatch if values actually changed\n if (\n status.isRecording !== stateRef.current.isRecording ||\n status.isPaused !== stateRef.current.isPaused\n ) {\n stateRef.current.isRecording = status.isRecording\n stateRef.current.isPaused = status.isPaused\n dispatch({\n type: 'UPDATE_RECORDING_STATE',\n payload: {\n isRecording: status.isRecording,\n isPaused: status.isPaused,\n },\n })\n }\n\n if (\n status.durationMs !== stateRef.current.durationMs ||\n status.size !== stateRef.current.size\n ) {\n stateRef.current.durationMs = status.durationMs\n stateRef.current.size = status.size\n stateRef.current.compression = status.compression\n dispatch({\n type: 'UPDATE_STATUS',\n payload: {\n durationMs: status.durationMs,\n size: status.size,\n compression: status.compression,\n },\n })\n }\n } catch (error) {\n logger?.error(`Error getting status:`, error)\n }\n }, [ExpoAudioStream, logger]) // Only depend on ExpoAudioStream and logger\n\n // Update ref when state changes\n useEffect(() => {\n stateRef.current = {\n isRecording: state.isRecording,\n isPaused: state.isPaused,\n durationMs: state.durationMs,\n size: state.size,\n compression: state.compression,\n }\n }, [\n state.isRecording,\n state.isPaused,\n state.durationMs,\n state.size,\n state.compression,\n ])\n\n const startRecording = useCallback(\n async (recordingOptions: RecordingConfig) => {\n // Validate the encoding configuration\n const validationResult = validateRecordingConfig({\n encoding: recordingOptions.encoding,\n })\n\n // Log warnings if any\n if (validationResult.warnings.length > 0) {\n validationResult.warnings.forEach((warning) => {\n logger?.warn(warning)\n })\n }\n\n // Update recording options with validated values\n const validatedOptions = {\n ...recordingOptions,\n encoding: validationResult.encoding,\n }\n\n recordingConfigRef.current = validatedOptions\n logger?.debug(\n `start recording with validated config`,\n validatedOptions\n )\n\n analysisRef.current = { ...defaultAnalysis } // Reset analysis data\n fullAnalysisRef.current = { ...defaultAnalysis }\n const {\n onAudioStream,\n onRecordingInterrupted,\n onAudioAnalysis,\n ...options\n } = validatedOptions\n const { enableProcessing } = options\n\n const maxRecentDataDuration = 10000 // TODO compute maxRecentDataDuration based on screen dimensions\n if (typeof onAudioStream === 'function') {\n onAudioStreamRef.current = onAudioStream\n } else {\n logger?.warn(`onAudioStream is not a function`, onAudioStream)\n onAudioStreamRef.current = null\n }\n // Strip undefined values and functions that can't cross the native bridge\n const cleanOptions = cleanNativeOptions(options)\n const startResult: StartRecordingResult =\n await ExpoAudioStream.startRecording(cleanOptions)\n dispatch({ type: 'START' })\n\n startResultRef.current = startResult\n\n if (enableProcessing) {\n logger?.debug(`Enabling audio analysis listener`)\n const listener = addAudioAnalysisListener(\n async (analysisData) => {\n try {\n await handleAudioAnalysis({\n analysis: analysisData,\n visualizationDuration: maxRecentDataDuration,\n })\n } catch (error) {\n logger?.warn(\n `Error processing audio analysis:`,\n error\n )\n }\n }\n )\n\n analysisListenerRef.current = listener\n }\n\n return startResult\n },\n [handleAudioAnalysis, dispatch]\n )\n\n const prepareRecording = useCallback(\n async (recordingOptions: RecordingConfig) => {\n recordingConfigRef.current = recordingOptions\n logger?.debug(`preparing recording`, recordingOptions)\n\n analysisRef.current = { ...defaultAnalysis } // Reset analysis data\n fullAnalysisRef.current = { ...defaultAnalysis }\n const {\n onAudioStream,\n onRecordingInterrupted,\n onAudioAnalysis,\n ...options\n } = recordingOptions\n\n // Store onAudioStream for later use when recording starts\n if (typeof onAudioStream === 'function') {\n onAudioStreamRef.current = onAudioStream\n } else {\n logger?.warn(`onAudioStream is not a function`, onAudioStream)\n onAudioStreamRef.current = null\n }\n\n // Strip undefined values and functions that can't cross the native bridge\n const cleanOptions = cleanNativeOptions(options)\n // Call the native prepareRecording method\n await ExpoAudioStream.prepareRecording(cleanOptions)\n logger?.debug(`recording prepared successfully`)\n },\n []\n )\n\n const stopRecording = useCallback(async () => {\n logger?.debug(`stoping recording`)\n\n const stopResult: AudioRecording = await ExpoAudioStream.stopRecording()\n stopResult.analysisData = fullAnalysisRef.current\n\n if (analysisListenerRef.current) {\n analysisListenerRef.current.remove()\n analysisListenerRef.current = null\n }\n onAudioStreamRef.current = null\n\n // Note: We deliberately DON'T clear recordingConfigRef here to preserve interruption callback\n logger?.debug(`recording stopped`, stopResult)\n dispatch({ type: 'STOP' })\n return stopResult\n }, [dispatch])\n\n const pauseRecording = useCallback(async () => {\n logger?.debug(`pause recording`)\n const pauseResult = await ExpoAudioStream.pauseRecording()\n dispatch({ type: 'PAUSE' })\n return pauseResult\n }, [dispatch])\n\n const resumeRecording = useCallback(async () => {\n logger?.debug(`resume recording`)\n const resumeResult = await ExpoAudioStream.resumeRecording()\n dispatch({ type: 'RESUME' })\n return resumeResult\n }, [dispatch])\n\n useEffect(() => {\n let intervalId: ReturnType<typeof setInterval> | undefined\n\n if (state.isRecording || state.isPaused) {\n // Immediately check status when starting\n checkStatus()\n\n // Start interval\n intervalId = setInterval(checkStatus, 1000)\n }\n\n return () => {\n if (intervalId) {\n clearInterval(intervalId)\n intervalId = undefined\n }\n }\n }, [checkStatus, state.isRecording, state.isPaused])\n\n useEffect(() => {\n logger?.debug(`Registering audio event listener`)\n const subscribeAudio = addAudioEventListener(handleAudioEvent)\n\n logger?.debug(\n `Subscribed to audio event listener and analysis listener`,\n {\n subscribeAudio,\n }\n )\n\n return () => {\n logger?.debug(`Removing audio event listener`)\n subscribeAudio.remove()\n }\n }, [handleAudioEvent, handleAudioAnalysis])\n\n useEffect(() => {\n // Add event subscription for recording interruptions\n logger?.debug(\n `Setting up recording interruption listener [${instanceId}]`\n )\n\n const subscription = addRecordingInterruptionListener((event) => {\n logger?.debug(\n `[${instanceId}] Received recording interruption event:`,\n event\n )\n\n // Handle device disconnection for UI updates\n if (event.reason === 'deviceDisconnected') {\n logger?.debug(\n `[${instanceId}] Device disconnected - temporarily hiding last device from UI`\n )\n\n // Get current device list before the native layer updates\n const currentDevices = audioDeviceManager.getRawDevices()\n\n // Wait a moment for native layer to update, then compare\n setTimeout(async () => {\n try {\n // Get updated devices without notifying yet\n const updatedDevices =\n await audioDeviceManager.getAvailableDevices({\n refresh: true,\n })\n\n // Find missing devices by comparing lists\n const missingDevices = currentDevices.filter(\n (oldDevice) =>\n !updatedDevices.some(\n (newDevice) => newDevice.id === oldDevice.id\n )\n )\n\n if (missingDevices.length > 0) {\n // Mark all missing devices as disconnected (silently)\n missingDevices.forEach((missingDevice) => {\n logger?.debug(\n `[${instanceId}] Confirmed disconnected device: ${missingDevice.name} (${missingDevice.id})`\n )\n audioDeviceManager.markDeviceAsDisconnected(\n missingDevice.id,\n false\n )\n })\n }\n\n // Notify listeners once with the final filtered state\n audioDeviceManager.notifyListeners()\n } catch (error) {\n logger?.warn(\n `[${instanceId}] Error in delayed device disconnection handling:`,\n error\n )\n }\n }, 500) // 500ms delay to let native layer update\n } else if (event.reason === 'deviceConnected') {\n // Device reconnected - force refresh to show it immediately\n logger?.debug(\n `[${instanceId}] Device connected, forcing refresh`\n )\n audioDeviceManager.forceRefreshDevices()\n }\n\n // Check if we have a callback configured\n logger?.debug(\n `[${instanceId}] recordingConfigRef.current exists:`,\n !!recordingConfigRef.current\n )\n\n if (recordingConfigRef.current?.onRecordingInterrupted) {\n try {\n logger?.debug(\n `[${instanceId}] Calling recording interruption callback`\n )\n recordingConfigRef.current.onRecordingInterrupted(event)\n } catch (error) {\n logger?.error(\n `[${instanceId}] Error in recording interruption callback:`,\n error\n )\n }\n } else {\n logger?.debug(\n `[${instanceId}] No recording interruption callback configured`\n )\n }\n })\n\n return () => {\n logger?.debug(\n `[${instanceId}] Removing recording interruption listener`\n )\n subscription.remove()\n }\n }, [instanceId, logger]) // Include instanceId and logger in dependencies\n\n return {\n prepareRecording,\n startRecording,\n stopRecording,\n pauseRecording,\n resumeRecording,\n isPaused: state.isPaused,\n isRecording: state.isRecording,\n durationMs: state.durationMs,\n size: state.size,\n compression: state.compression,\n analysisData: state.analysisData,\n }\n}\n"]}
@@ -1,502 +0,0 @@
1
- "use strict";
2
- /*
3
- * There is a bug where `navigator.mediaDevices.getUserMedia` + `MediaRecorder`
4
- * creates WEBM files without duration metadata. See:
5
- * - https://bugs.chromium.org/p/chromium/issues/detail?id=642012
6
- * - https://stackoverflow.com/a/39971175/13989043
7
- *
8
- * This file contains a function that fixes the duration metadata of a WEBM file.
9
- * - Answer found: https://stackoverflow.com/a/75218309/13989043
10
- * - Code adapted from: https://github.com/mat-sz/webm-fix-duration
11
- * (forked from https://github.com/yusitnikov/fix-webm-duration)
12
- */
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.webmFixDuration = void 0;
15
- const sections = {
16
- 0xa45dfa3: { name: 'EBML', type: 'Container' },
17
- 0x286: { name: 'EBMLVersion', type: 'Uint' },
18
- 0x2f7: { name: 'EBMLReadVersion', type: 'Uint' },
19
- 0x2f2: { name: 'EBMLMaxIDLength', type: 'Uint' },
20
- 0x2f3: { name: 'EBMLMaxSizeLength', type: 'Uint' },
21
- 0x282: { name: 'DocType', type: 'String' },
22
- 0x287: { name: 'DocTypeVersion', type: 'Uint' },
23
- 0x285: { name: 'DocTypeReadVersion', type: 'Uint' },
24
- 0x6c: { name: 'Void', type: 'Binary' },
25
- 0x3f: { name: 'CRC-32', type: 'Binary' },
26
- 0xb538667: { name: 'SignatureSlot', type: 'Container' },
27
- 0x3e8a: { name: 'SignatureAlgo', type: 'Uint' },
28
- 0x3e9a: { name: 'SignatureHash', type: 'Uint' },
29
- 0x3ea5: { name: 'SignaturePublicKey', type: 'Binary' },
30
- 0x3eb5: { name: 'Signature', type: 'Binary' },
31
- 0x3e5b: { name: 'SignatureElements', type: 'Container' },
32
- 0x3e7b: { name: 'SignatureElementList', type: 'Container' },
33
- 0x2532: { name: 'SignedElement', type: 'Binary' },
34
- 0x8538067: { name: 'Segment', type: 'Container' },
35
- 0x14d9b74: { name: 'SeekHead', type: 'Container' },
36
- 0xdbb: { name: 'Seek', type: 'Container' },
37
- 0x13ab: { name: 'SeekID', type: 'Binary' },
38
- 0x13ac: { name: 'SeekPosition', type: 'Uint' },
39
- 0x549a966: { name: 'Info', type: 'Container' },
40
- 0x33a4: { name: 'SegmentUID', type: 'Binary' },
41
- 0x3384: { name: 'SegmentFilename', type: 'String' },
42
- 0x1cb923: { name: 'PrevUID', type: 'Binary' },
43
- 0x1c83ab: { name: 'PrevFilename', type: 'String' },
44
- 0x1eb923: { name: 'NextUID', type: 'Binary' },
45
- 0x1e83bb: { name: 'NextFilename', type: 'String' },
46
- 0x444: { name: 'SegmentFamily', type: 'Binary' },
47
- 0x2924: { name: 'ChapterTranslate', type: 'Container' },
48
- 0x29fc: { name: 'ChapterTranslateEditionUID', type: 'Uint' },
49
- 0x29bf: { name: 'ChapterTranslateCodec', type: 'Uint' },
50
- 0x29a5: { name: 'ChapterTranslateID', type: 'Binary' },
51
- 0xad7b1: { name: 'TimecodeScale', type: 'Uint' },
52
- 0x489: { name: 'Duration', type: 'Float' },
53
- 0x461: { name: 'DateUTC', type: 'Date' },
54
- 0x3ba9: { name: 'Title', type: 'String' },
55
- 0xd80: { name: 'MuxingApp', type: 'String' },
56
- 0x1741: { name: 'WritingApp', type: 'String' },
57
- // 0xf43b675: { name: 'Cluster', type: 'Container' },
58
- 0x67: { name: 'Timecode', type: 'Uint' },
59
- 0x1854: { name: 'SilentTracks', type: 'Container' },
60
- 0x18d7: { name: 'SilentTrackNumber', type: 'Uint' },
61
- 0x27: { name: 'Position', type: 'Uint' },
62
- 0x2b: { name: 'PrevSize', type: 'Uint' },
63
- 0x23: { name: 'SimpleBlock', type: 'Binary' },
64
- 0x20: { name: 'BlockGroup', type: 'Container' },
65
- 0x21: { name: 'Block', type: 'Binary' },
66
- 0x22: { name: 'BlockVirtual', type: 'Binary' },
67
- 0x35a1: { name: 'BlockAdditions', type: 'Container' },
68
- 0x26: { name: 'BlockMore', type: 'Container' },
69
- 0x6e: { name: 'BlockAddID', type: 'Uint' },
70
- 0x25: { name: 'BlockAdditional', type: 'Binary' },
71
- 0x1b: { name: 'BlockDuration', type: 'Uint' },
72
- 0x7a: { name: 'ReferencePriority', type: 'Uint' },
73
- 0x7b: { name: 'ReferenceBlock', type: 'Int' },
74
- 0x7d: { name: 'ReferenceVirtual', type: 'Int' },
75
- 0x24: { name: 'CodecState', type: 'Binary' },
76
- 0x35a2: { name: 'DiscardPadding', type: 'Int' },
77
- 0xe: { name: 'Slices', type: 'Container' },
78
- 0x68: { name: 'TimeSlice', type: 'Container' },
79
- 0x4c: { name: 'LaceNumber', type: 'Uint' },
80
- 0x4d: { name: 'FrameNumber', type: 'Uint' },
81
- 0x4b: { name: 'BlockAdditionID', type: 'Uint' },
82
- 0x4e: { name: 'Delay', type: 'Uint' },
83
- 0x4f: { name: 'SliceDuration', type: 'Uint' },
84
- 0x48: { name: 'ReferenceFrame', type: 'Container' },
85
- 0x49: { name: 'ReferenceOffset', type: 'Uint' },
86
- 0x4a: { name: 'ReferenceTimeCode', type: 'Uint' },
87
- 0x2f: { name: 'EncryptedBlock', type: 'Binary' },
88
- 0x654ae6b: { name: 'Tracks', type: 'Container' },
89
- 0x2e: { name: 'TrackEntry', type: 'Container' },
90
- 0x57: { name: 'TrackNumber', type: 'Uint' },
91
- 0x33c5: { name: 'TrackUID', type: 'Uint' },
92
- 0x3: { name: 'TrackType', type: 'Uint' },
93
- 0x39: { name: 'FlagEnabled', type: 'Uint' },
94
- 0x8: { name: 'FlagDefault', type: 'Uint' },
95
- 0x15aa: { name: 'FlagForced', type: 'Uint' },
96
- 0x1c: { name: 'FlagLacing', type: 'Uint' },
97
- 0x2de7: { name: 'MinCache', type: 'Uint' },
98
- 0x2df8: { name: 'MaxCache', type: 'Uint' },
99
- 0x3e383: { name: 'DefaultDuration', type: 'Uint' },
100
- 0x34e7a: { name: 'DefaultDecodedFieldDuration', type: 'Uint' },
101
- 0x3314f: { name: 'TrackTimecodeScale', type: 'Float' },
102
- 0x137f: { name: 'TrackOffset', type: 'Int' },
103
- 0x15ee: { name: 'MaxBlockAdditionID', type: 'Uint' },
104
- 0x136e: { name: 'Name', type: 'String' },
105
- 0x2b59c: { name: 'Language', type: 'String' },
106
- 0x6: { name: 'CodecID', type: 'String' },
107
- 0x23a2: { name: 'CodecPrivate', type: 'Binary' },
108
- 0x58688: { name: 'CodecName', type: 'String' },
109
- 0x3446: { name: 'AttachmentLink', type: 'Uint' },
110
- 0x1a9697: { name: 'CodecSettings', type: 'String' },
111
- 0x1b4040: { name: 'CodecInfoURL', type: 'String' },
112
- 0x6b240: { name: 'CodecDownloadURL', type: 'String' },
113
- 0x2a: { name: 'CodecDecodeAll', type: 'Uint' },
114
- 0x2fab: { name: 'TrackOverlay', type: 'Uint' },
115
- 0x16aa: { name: 'CodecDelay', type: 'Uint' },
116
- 0x16bb: { name: 'SeekPreRoll', type: 'Uint' },
117
- 0x2624: { name: 'TrackTranslate', type: 'Container' },
118
- 0x26fc: { name: 'TrackTranslateEditionUID', type: 'Uint' },
119
- 0x26bf: { name: 'TrackTranslateCodec', type: 'Uint' },
120
- 0x26a5: { name: 'TrackTranslateTrackID', type: 'Binary' },
121
- 0x60: { name: 'Video', type: 'Container' },
122
- 0x1a: { name: 'FlagInterlaced', type: 'Uint' },
123
- 0x13b8: { name: 'StereoMode', type: 'Uint' },
124
- 0x13c0: { name: 'AlphaMode', type: 'Uint' },
125
- 0x13b9: { name: 'OldStereoMode', type: 'Uint' },
126
- 0x30: { name: 'PixelWidth', type: 'Uint' },
127
- 0x3a: { name: 'PixelHeight', type: 'Uint' },
128
- 0x14aa: { name: 'PixelCropBottom', type: 'Uint' },
129
- 0x14bb: { name: 'PixelCropTop', type: 'Uint' },
130
- 0x14cc: { name: 'PixelCropLeft', type: 'Uint' },
131
- 0x14dd: { name: 'PixelCropRight', type: 'Uint' },
132
- 0x14b0: { name: 'DisplayWidth', type: 'Uint' },
133
- 0x14ba: { name: 'DisplayHeight', type: 'Uint' },
134
- 0x14b2: { name: 'DisplayUnit', type: 'Uint' },
135
- 0x14b3: { name: 'AspectRatioType', type: 'Uint' },
136
- 0xeb524: { name: 'ColourSpace', type: 'Binary' },
137
- 0xfb523: { name: 'GammaValue', type: 'Float' },
138
- 0x383e3: { name: 'FrameRate', type: 'Float' },
139
- 0x61: { name: 'Audio', type: 'Container' },
140
- 0x35: { name: 'SamplingFrequency', type: 'Float' },
141
- 0x38b5: { name: 'OutputSamplingFrequency', type: 'Float' },
142
- 0x1f: { name: 'Channels', type: 'Uint' },
143
- 0x3d7b: { name: 'ChannelPositions', type: 'Binary' },
144
- 0x2264: { name: 'BitDepth', type: 'Uint' },
145
- 0x62: { name: 'TrackOperation', type: 'Container' },
146
- 0x63: { name: 'TrackCombinePlanes', type: 'Container' },
147
- 0x64: { name: 'TrackPlane', type: 'Container' },
148
- 0x65: { name: 'TrackPlaneUID', type: 'Uint' },
149
- 0x66: { name: 'TrackPlaneType', type: 'Uint' },
150
- 0x69: { name: 'TrackJoinBlocks', type: 'Container' },
151
- 0x6d: { name: 'TrackJoinUID', type: 'Uint' },
152
- 0x40: { name: 'TrickTrackUID', type: 'Uint' },
153
- 0x41: { name: 'TrickTrackSegmentUID', type: 'Binary' },
154
- 0x46: { name: 'TrickTrackFlag', type: 'Uint' },
155
- 0x47: { name: 'TrickMasterTrackUID', type: 'Uint' },
156
- 0x44: { name: 'TrickMasterTrackSegmentUID', type: 'Binary' },
157
- 0x2d80: { name: 'ContentEncodings', type: 'Container' },
158
- 0x2240: { name: 'ContentEncoding', type: 'Container' },
159
- 0x1031: { name: 'ContentEncodingOrder', type: 'Uint' },
160
- 0x1032: { name: 'ContentEncodingScope', type: 'Uint' },
161
- 0x1033: { name: 'ContentEncodingType', type: 'Uint' },
162
- 0x1034: { name: 'ContentCompression', type: 'Container' },
163
- 0x254: { name: 'ContentCompAlgo', type: 'Uint' },
164
- 0x255: { name: 'ContentCompSettings', type: 'Binary' },
165
- 0x1035: { name: 'ContentEncryption', type: 'Container' },
166
- 0x7e1: { name: 'ContentEncAlgo', type: 'Uint' },
167
- 0x7e2: { name: 'ContentEncKeyID', type: 'Binary' },
168
- 0x7e3: { name: 'ContentSignature', type: 'Binary' },
169
- 0x7e4: { name: 'ContentSigKeyID', type: 'Binary' },
170
- 0x7e5: { name: 'ContentSigAlgo', type: 'Uint' },
171
- 0x7e6: { name: 'ContentSigHashAlgo', type: 'Uint' },
172
- 0xc53bb6b: { name: 'Cues', type: 'Container' },
173
- 0x3b: { name: 'CuePoint', type: 'Container' },
174
- 0x33: { name: 'CueTime', type: 'Uint' },
175
- 0x37: { name: 'CueTrackPositions', type: 'Container' },
176
- 0x77: { name: 'CueTrack', type: 'Uint' },
177
- 0x71: { name: 'CueClusterPosition', type: 'Uint' },
178
- 0x70: { name: 'CueRelativePosition', type: 'Uint' },
179
- 0x32: { name: 'CueDuration', type: 'Uint' },
180
- 0x1378: { name: 'CueBlockNumber', type: 'Uint' },
181
- 0x6a: { name: 'CueCodecState', type: 'Uint' },
182
- 0x5b: { name: 'CueReference', type: 'Container' },
183
- 0x16: { name: 'CueRefTime', type: 'Uint' },
184
- 0x17: { name: 'CueRefCluster', type: 'Uint' },
185
- 0x135f: { name: 'CueRefNumber', type: 'Uint' },
186
- 0x6b: { name: 'CueRefCodecState', type: 'Uint' },
187
- 0x941a469: { name: 'Attachments', type: 'Container' },
188
- 0x21a7: { name: 'AttachedFile', type: 'Container' },
189
- 0x67e: { name: 'FileDescription', type: 'String' },
190
- 0x66e: { name: 'FileName', type: 'String' },
191
- 0x660: { name: 'FileMimeType', type: 'String' },
192
- 0x65c: { name: 'FileData', type: 'Binary' },
193
- 0x6ae: { name: 'FileUID', type: 'Uint' },
194
- 0x675: { name: 'FileReferral', type: 'Binary' },
195
- 0x661: { name: 'FileUsedStartTime', type: 'Uint' },
196
- 0x662: { name: 'FileUsedEndTime', type: 'Uint' },
197
- 0x43a770: { name: 'Chapters', type: 'Container' },
198
- 0x5b9: { name: 'EditionEntry', type: 'Container' },
199
- 0x5bc: { name: 'EditionUID', type: 'Uint' },
200
- 0x5bd: { name: 'EditionFlagHidden', type: 'Uint' },
201
- 0x5db: { name: 'EditionFlagDefault', type: 'Uint' },
202
- 0x5dd: { name: 'EditionFlagOrdered', type: 'Uint' },
203
- 0x36: { name: 'ChapterAtom', type: 'Container' },
204
- 0x33c4: { name: 'ChapterUID', type: 'Uint' },
205
- 0x1654: { name: 'ChapterStringUID', type: 'String' },
206
- 0x11: { name: 'ChapterTimeStart', type: 'Uint' },
207
- 0x12: { name: 'ChapterTimeEnd', type: 'Uint' },
208
- 0x18: { name: 'ChapterFlagHidden', type: 'Uint' },
209
- 0x598: { name: 'ChapterFlagEnabled', type: 'Uint' },
210
- 0x2e67: { name: 'ChapterSegmentUID', type: 'Binary' },
211
- 0x2ebc: { name: 'ChapterSegmentEditionUID', type: 'Uint' },
212
- 0x23c3: { name: 'ChapterPhysicalEquiv', type: 'Uint' },
213
- 0xf: { name: 'ChapterTrack', type: 'Container' },
214
- 0x9: { name: 'ChapterTrackNumber', type: 'Uint' },
215
- 0x0: { name: 'ChapterDisplay', type: 'Container' },
216
- 0x5: { name: 'ChapString', type: 'String' },
217
- 0x37c: { name: 'ChapLanguage', type: 'String' },
218
- 0x37e: { name: 'ChapCountry', type: 'String' },
219
- 0x2944: { name: 'ChapProcess', type: 'Container' },
220
- 0x2955: { name: 'ChapProcessCodecID', type: 'Uint' },
221
- 0x50d: { name: 'ChapProcessPrivate', type: 'Binary' },
222
- 0x2911: { name: 'ChapProcessCommand', type: 'Container' },
223
- 0x2922: { name: 'ChapProcessTime', type: 'Uint' },
224
- 0x2933: { name: 'ChapProcessData', type: 'Binary' },
225
- 0x254c367: { name: 'Tags', type: 'Container' },
226
- 0x3373: { name: 'Tag', type: 'Container' },
227
- 0x23c0: { name: 'Targets', type: 'Container' },
228
- 0x28ca: { name: 'TargetTypeValue', type: 'Uint' },
229
- 0x23ca: { name: 'TargetType', type: 'String' },
230
- 0x23c5: { name: 'TagTrackUID', type: 'Uint' },
231
- 0x23c9: { name: 'TagEditionUID', type: 'Uint' },
232
- 0x23c4: { name: 'TagChapterUID', type: 'Uint' },
233
- 0x23c6: { name: 'TagAttachmentUID', type: 'Uint' },
234
- 0x27c8: { name: 'SimpleTag', type: 'Container' },
235
- 0x5a3: { name: 'TagName', type: 'String' },
236
- 0x47a: { name: 'TagLanguage', type: 'String' },
237
- 0x484: { name: 'TagDefault', type: 'Uint' },
238
- 0x487: { name: 'TagString', type: 'String' },
239
- 0x485: { name: 'TagBinary', type: 'Binary' },
240
- };
241
- class WebmBase {
242
- source;
243
- data;
244
- name;
245
- type;
246
- constructor(name = 'Unknown', type = 'Unknown') {
247
- this.name = name;
248
- this.type = type;
249
- }
250
- updateBySource() { }
251
- setSource(source) {
252
- this.source = source;
253
- this.updateBySource();
254
- }
255
- updateByData() { }
256
- setData(data) {
257
- this.data = data;
258
- this.updateByData();
259
- }
260
- }
261
- class WebmUint extends WebmBase {
262
- constructor(name, type) {
263
- super(name, type || 'Uint');
264
- }
265
- updateBySource() {
266
- // use hex representation of a number instead of number value
267
- this.data = '';
268
- for (let i = 0; i < this.source.length; i++) {
269
- const hex = this.source[i].toString(16);
270
- this.data += padHex(hex);
271
- }
272
- }
273
- updateByData() {
274
- const length = this.data.length / 2;
275
- this.source = new Uint8Array(length);
276
- for (let i = 0; i < length; i++) {
277
- const hex = this.data.substr(i * 2, 2);
278
- this.source[i] = parseInt(hex, 16);
279
- }
280
- }
281
- getValue() {
282
- return parseInt(this.data, 16);
283
- }
284
- setValue(value) {
285
- this.setData(padHex(value.toString(16)));
286
- }
287
- }
288
- function padHex(hex) {
289
- return hex.length % 2 === 1 ? '0' + hex : hex;
290
- }
291
- class WebmFloat extends WebmBase {
292
- constructor(name, type) {
293
- super(name, type || 'Float');
294
- }
295
- getFloatArrayType() {
296
- return this.source && this.source.length === 4
297
- ? Float32Array
298
- : Float64Array;
299
- }
300
- updateBySource() {
301
- const byteArray = this.source.reverse();
302
- const floatArrayType = this.getFloatArrayType();
303
- const buffer = new ArrayBuffer(byteArray.buffer.byteLength);
304
- new Uint8Array(buffer).set(new Uint8Array(byteArray.buffer));
305
- const floatArray = new floatArrayType(buffer);
306
- this.data = floatArray[0];
307
- }
308
- updateByData() {
309
- const floatArrayType = this.getFloatArrayType();
310
- const floatArray = new floatArrayType([this.data]);
311
- const byteArray = new Uint8Array(floatArray.buffer);
312
- this.source = byteArray.reverse();
313
- }
314
- getValue() {
315
- return this.data;
316
- }
317
- setValue(value) {
318
- this.setData(value);
319
- }
320
- }
321
- class WebmContainer extends WebmBase {
322
- offset = 0;
323
- data = [];
324
- constructor(name, type) {
325
- super(name, type || 'Container');
326
- }
327
- readByte() {
328
- return this.source[this.offset++];
329
- }
330
- readUint() {
331
- const firstByte = this.readByte();
332
- const bytes = 8 - firstByte.toString(2).length;
333
- let value = firstByte - (1 << (7 - bytes));
334
- for (let i = 0; i < bytes; i++) {
335
- // don't use bit operators to support x86
336
- value *= 256;
337
- value += this.readByte();
338
- }
339
- return value;
340
- }
341
- updateBySource() {
342
- let end = undefined;
343
- this.data = [];
344
- for (this.offset = 0; this.offset < this.source.length; this.offset = end) {
345
- const id = this.readUint();
346
- const len = this.readUint();
347
- end = Math.min(this.offset + len, this.source.length);
348
- const data = this.source.slice(this.offset, end);
349
- const info = sections[id] || { name: 'Unknown', type: 'Unknown' };
350
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
351
- let ctr = WebmBase;
352
- switch (info.type) {
353
- case 'Container':
354
- ctr = WebmContainer;
355
- break;
356
- case 'Uint':
357
- ctr = WebmUint;
358
- break;
359
- case 'Float':
360
- ctr = WebmFloat;
361
- break;
362
- }
363
- const section = new ctr(info.name, info.type);
364
- section.setSource(data);
365
- this.data.push({
366
- id,
367
- idHex: id.toString(16),
368
- data: section,
369
- });
370
- }
371
- }
372
- writeUint(x, draft = false) {
373
- let flag = 0x80;
374
- let bytes = 1;
375
- // eslint-disable-next-line no-empty
376
- for (; x >= flag && bytes < 8; bytes++, flag *= 0x80) { }
377
- if (!draft) {
378
- let value = flag + x;
379
- for (let i = bytes - 1; i >= 0; i--) {
380
- // don't use bit operators to support x86
381
- const c = value % 256;
382
- this.source[this.offset + i] = c;
383
- value = (value - c) / 256;
384
- }
385
- }
386
- this.offset += bytes;
387
- }
388
- writeSections(draft = false) {
389
- this.offset = 0;
390
- for (let i = 0; i < this.data.length; i++) {
391
- const section = this.data[i], content = section.data.source, contentLength = content.length;
392
- this.writeUint(section.id, draft);
393
- this.writeUint(contentLength, draft);
394
- if (!draft) {
395
- this.source.set(content, this.offset);
396
- }
397
- this.offset += contentLength;
398
- }
399
- return this.offset;
400
- }
401
- updateByData() {
402
- // run without accessing this.source to determine total length - need to know it to create Uint8Array
403
- const length = this.writeSections(true);
404
- this.source = new Uint8Array(length);
405
- // now really write data
406
- this.writeSections();
407
- }
408
- getSectionById(id) {
409
- for (let i = 0; i < this.data.length; i++) {
410
- const section = this.data[i];
411
- if (section.id === id) {
412
- return section.data;
413
- }
414
- }
415
- return undefined;
416
- }
417
- }
418
- class WebmFile extends WebmContainer {
419
- constructor(source) {
420
- super('File', 'File');
421
- this.setSource(source);
422
- }
423
- fixDuration(duration) {
424
- const segmentSection = this.getSectionById(0x8538067);
425
- if (!segmentSection) {
426
- return false;
427
- }
428
- const infoSection = segmentSection.getSectionById(0x549a966);
429
- if (!infoSection) {
430
- return false;
431
- }
432
- const timeScaleSection = infoSection.getSectionById(0xad7b1);
433
- if (!timeScaleSection) {
434
- return false;
435
- }
436
- let durationSection = infoSection.getSectionById(0x489);
437
- if (durationSection) {
438
- if (durationSection.getValue() <= 0) {
439
- durationSection.setValue(duration);
440
- }
441
- else {
442
- return false;
443
- }
444
- }
445
- else {
446
- // append Duration section
447
- durationSection = new WebmFloat('Duration', 'Float');
448
- durationSection.setValue(duration);
449
- infoSection.data.push({
450
- id: 0x489,
451
- data: durationSection,
452
- });
453
- }
454
- // set default time scale to 1 millisecond (1000000 nanoseconds)
455
- timeScaleSection.setValue(1000000);
456
- infoSection.updateByData();
457
- segmentSection.updateByData();
458
- this.updateByData();
459
- return true;
460
- }
461
- toBlob(type = 'video/webm') {
462
- const buffer = new ArrayBuffer(this.source.buffer.byteLength);
463
- new Uint8Array(buffer).set(new Uint8Array(this.source.buffer));
464
- return new Blob([buffer], { type });
465
- }
466
- }
467
- /**
468
- * Fixes duration on MediaRecorder output.
469
- * @param blob Input Blob with incorrect duration.
470
- * @param duration Correct duration (in milliseconds).
471
- * @param type Output blob mimetype (default: video/webm).
472
- * @returns
473
- */
474
- const webmFixDuration = (blob, duration, type = 'video/webm') => {
475
- return new Promise((resolve, reject) => {
476
- try {
477
- const reader = new FileReader();
478
- reader.addEventListener('loadend', () => {
479
- try {
480
- const result = reader.result;
481
- const file = new WebmFile(new Uint8Array(result));
482
- if (file.fixDuration(duration)) {
483
- resolve(file.toBlob(type));
484
- }
485
- else {
486
- resolve(blob);
487
- }
488
- }
489
- catch (ex) {
490
- reject(ex);
491
- }
492
- });
493
- reader.addEventListener('error', () => reject(new Error('FileReader error')));
494
- reader.readAsArrayBuffer(blob);
495
- }
496
- catch (ex) {
497
- reject(ex);
498
- }
499
- });
500
- };
501
- exports.webmFixDuration = webmFixDuration;
502
- //# sourceMappingURL=BlobFix.js.map