@siteed/expo-audio-stream 1.0.2 → 1.0.5

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 (139) hide show
  1. package/.size-limit.json +6 -0
  2. package/README.md +18 -176
  3. package/android/src/main/java/net/siteed/audiostream/AudioRecorderManager.kt +1 -0
  4. package/app.plugin.js +1 -1
  5. package/build/AudioAnalysis/AudioAnalysis.types.d.ts +74 -0
  6. package/build/AudioAnalysis/AudioAnalysis.types.d.ts.map +1 -0
  7. package/build/AudioAnalysis/AudioAnalysis.types.js +3 -0
  8. package/build/AudioAnalysis/AudioAnalysis.types.js.map +1 -0
  9. package/build/AudioAnalysis/extractAudioAnalysis.d.ts +20 -0
  10. package/build/AudioAnalysis/extractAudioAnalysis.d.ts.map +1 -0
  11. package/build/AudioAnalysis/extractAudioAnalysis.js +88 -0
  12. package/build/AudioAnalysis/extractAudioAnalysis.js.map +1 -0
  13. package/build/AudioAnalysis/extractWaveform.d.ts +8 -0
  14. package/build/AudioAnalysis/extractWaveform.d.ts.map +1 -0
  15. package/build/AudioAnalysis/extractWaveform.js +14 -0
  16. package/build/AudioAnalysis/extractWaveform.js.map +1 -0
  17. package/build/AudioRecorder.provider.d.ts +15 -2
  18. package/build/AudioRecorder.provider.d.ts.map +1 -1
  19. package/build/AudioRecorder.provider.js +21 -8
  20. package/build/AudioRecorder.provider.js.map +1 -1
  21. package/build/ExpoAudioStream.native.d.ts.map +1 -1
  22. package/build/ExpoAudioStream.native.js +2 -2
  23. package/build/ExpoAudioStream.native.js.map +1 -1
  24. package/build/ExpoAudioStream.types.d.ts +33 -89
  25. package/build/ExpoAudioStream.types.d.ts.map +1 -1
  26. package/build/ExpoAudioStream.types.js.map +1 -1
  27. package/build/ExpoAudioStream.web.d.ts +10 -9
  28. package/build/ExpoAudioStream.web.d.ts.map +1 -1
  29. package/build/ExpoAudioStream.web.js +44 -25
  30. package/build/ExpoAudioStream.web.js.map +1 -1
  31. package/build/ExpoAudioStreamModule.d.ts.map +1 -1
  32. package/build/ExpoAudioStreamModule.js +13 -8
  33. package/build/ExpoAudioStreamModule.js.map +1 -1
  34. package/build/{WebRecorder.d.ts → WebRecorder.web.d.ts} +13 -9
  35. package/build/WebRecorder.web.d.ts.map +1 -0
  36. package/build/{WebRecorder.js → WebRecorder.web.js} +118 -63
  37. package/build/WebRecorder.web.js.map +1 -0
  38. package/build/constants.d.ts +11 -0
  39. package/build/constants.d.ts.map +1 -0
  40. package/build/constants.js +14 -0
  41. package/build/constants.js.map +1 -0
  42. package/build/events.d.ts +18 -0
  43. package/build/events.d.ts.map +1 -0
  44. package/build/events.js +15 -0
  45. package/build/events.js.map +1 -0
  46. package/build/index.d.ts +9 -17
  47. package/build/index.d.ts.map +1 -1
  48. package/build/index.js +7 -113
  49. package/build/index.js.map +1 -1
  50. package/build/logger.d.ts +9 -0
  51. package/build/logger.d.ts.map +1 -0
  52. package/build/logger.js +13 -0
  53. package/build/logger.js.map +1 -0
  54. package/build/useAudioRecorder.d.ts +20 -0
  55. package/build/useAudioRecorder.d.ts.map +1 -0
  56. package/build/{useAudioRecording.js → useAudioRecorder.js} +90 -86
  57. package/build/useAudioRecorder.js.map +1 -0
  58. package/build/utils/BlobFix.d.ts +9 -0
  59. package/build/utils/BlobFix.d.ts.map +1 -0
  60. package/build/utils/BlobFix.js +494 -0
  61. package/build/utils/BlobFix.js.map +1 -0
  62. package/build/utils/concatenateBuffers.d.ts +8 -0
  63. package/build/utils/concatenateBuffers.d.ts.map +1 -0
  64. package/build/utils/concatenateBuffers.js +21 -0
  65. package/build/utils/concatenateBuffers.js.map +1 -0
  66. package/build/utils/convertPCMToFloat32.d.ts +11 -0
  67. package/build/utils/convertPCMToFloat32.d.ts.map +1 -0
  68. package/build/utils/convertPCMToFloat32.js +54 -0
  69. package/build/utils/convertPCMToFloat32.js.map +1 -0
  70. package/build/utils/encodingToBitDepth.d.ts +5 -0
  71. package/build/utils/encodingToBitDepth.d.ts.map +1 -0
  72. package/build/utils/encodingToBitDepth.js +13 -0
  73. package/build/utils/encodingToBitDepth.js.map +1 -0
  74. package/build/utils/getWavFileInfo.d.ts +26 -0
  75. package/build/utils/getWavFileInfo.d.ts.map +1 -0
  76. package/build/utils/getWavFileInfo.js +92 -0
  77. package/build/utils/getWavFileInfo.js.map +1 -0
  78. package/build/utils/writeWavHeader.d.ts +9 -0
  79. package/build/utils/writeWavHeader.d.ts.map +1 -0
  80. package/build/utils/writeWavHeader.js +41 -0
  81. package/build/utils/writeWavHeader.js.map +1 -0
  82. package/build/workers/InlineFeaturesExtractor.web.d.ts +2 -0
  83. package/build/workers/InlineFeaturesExtractor.web.d.ts.map +1 -0
  84. package/build/workers/InlineFeaturesExtractor.web.js +303 -0
  85. package/build/workers/InlineFeaturesExtractor.web.js.map +1 -0
  86. package/build/workers/inlineAudioWebWorker.web.d.ts +2 -0
  87. package/build/workers/inlineAudioWebWorker.web.d.ts.map +1 -0
  88. package/build/workers/inlineAudioWebWorker.web.js +243 -0
  89. package/build/workers/inlineAudioWebWorker.web.js.map +1 -0
  90. package/expo-module.config.json +8 -17
  91. package/ios/AudioStreamManager.swift +40 -2
  92. package/ios/ExpoAudioStreamModule.swift +11 -0
  93. package/ios/RecordingResult.swift +1 -0
  94. package/package.json +72 -64
  95. package/plugin/build/index.d.ts +1 -1
  96. package/plugin/build/index.js +7 -7
  97. package/plugin/src/index.ts +47 -47
  98. package/plugin/tsconfig.json +8 -13
  99. package/publish.sh +0 -0
  100. package/src/AudioAnalysis/AudioAnalysis.types.ts +84 -0
  101. package/src/AudioAnalysis/extractAudioAnalysis.ts +147 -0
  102. package/src/AudioAnalysis/extractWaveform.ts +25 -0
  103. package/src/AudioRecorder.provider.tsx +59 -31
  104. package/src/ExpoAudioStream.native.ts +2 -2
  105. package/src/ExpoAudioStream.types.ts +58 -116
  106. package/src/ExpoAudioStream.web.ts +233 -205
  107. package/src/ExpoAudioStreamModule.ts +18 -12
  108. package/src/WebRecorder.web.ts +433 -0
  109. package/src/constants.ts +18 -0
  110. package/src/events.ts +39 -0
  111. package/src/index.ts +15 -176
  112. package/src/logger.ts +23 -0
  113. package/src/useAudioRecorder.tsx +420 -0
  114. package/src/utils/BlobFix.ts +550 -0
  115. package/src/utils/concatenateBuffers.ts +24 -0
  116. package/src/utils/convertPCMToFloat32.ts +75 -0
  117. package/src/utils/encodingToBitDepth.ts +18 -0
  118. package/src/utils/getWavFileInfo.ts +132 -0
  119. package/src/utils/writeWavHeader.ts +56 -0
  120. package/src/workers/InlineFeaturesExtractor.web.tsx +302 -0
  121. package/src/workers/inlineAudioWebWorker.web.tsx +242 -0
  122. package/tsconfig.json +12 -7
  123. package/build/WebRecorder.d.ts.map +0 -1
  124. package/build/WebRecorder.js.map +0 -1
  125. package/build/inlineAudioWebWorker.d.ts +0 -3
  126. package/build/inlineAudioWebWorker.d.ts.map +0 -1
  127. package/build/inlineAudioWebWorker.js +0 -340
  128. package/build/inlineAudioWebWorker.js.map +0 -1
  129. package/build/useAudioRecording.d.ts +0 -38
  130. package/build/useAudioRecording.d.ts.map +0 -1
  131. package/build/useAudioRecording.js.map +0 -1
  132. package/build/utils.d.ts +0 -31
  133. package/build/utils.d.ts.map +0 -1
  134. package/build/utils.js +0 -143
  135. package/build/utils.js.map +0 -1
  136. package/src/WebRecorder.ts +0 -364
  137. package/src/inlineAudioWebWorker.tsx +0 -340
  138. package/src/useAudioRecording.tsx +0 -410
  139. package/src/utils.ts +0 -189
@@ -0,0 +1,494 @@
1
+ /*
2
+ * There is a bug where `navigator.mediaDevices.getUserMedia` + `MediaRecorder`
3
+ * creates WEBM files without duration metadata. See:
4
+ * - https://bugs.chromium.org/p/chromium/issues/detail?id=642012
5
+ * - https://stackoverflow.com/a/39971175/13989043
6
+ *
7
+ * This file contains a function that fixes the duration metadata of a WEBM file.
8
+ * - Answer found: https://stackoverflow.com/a/75218309/13989043
9
+ * - Code adapted from: https://github.com/mat-sz/webm-fix-duration
10
+ * (forked from https://github.com/yusitnikov/fix-webm-duration)
11
+ */
12
+ const sections = {
13
+ 0xa45dfa3: { name: "EBML", type: "Container" },
14
+ 0x286: { name: "EBMLVersion", type: "Uint" },
15
+ 0x2f7: { name: "EBMLReadVersion", type: "Uint" },
16
+ 0x2f2: { name: "EBMLMaxIDLength", type: "Uint" },
17
+ 0x2f3: { name: "EBMLMaxSizeLength", type: "Uint" },
18
+ 0x282: { name: "DocType", type: "String" },
19
+ 0x287: { name: "DocTypeVersion", type: "Uint" },
20
+ 0x285: { name: "DocTypeReadVersion", type: "Uint" },
21
+ 0x6c: { name: "Void", type: "Binary" },
22
+ 0x3f: { name: "CRC-32", type: "Binary" },
23
+ 0xb538667: { name: "SignatureSlot", type: "Container" },
24
+ 0x3e8a: { name: "SignatureAlgo", type: "Uint" },
25
+ 0x3e9a: { name: "SignatureHash", type: "Uint" },
26
+ 0x3ea5: { name: "SignaturePublicKey", type: "Binary" },
27
+ 0x3eb5: { name: "Signature", type: "Binary" },
28
+ 0x3e5b: { name: "SignatureElements", type: "Container" },
29
+ 0x3e7b: { name: "SignatureElementList", type: "Container" },
30
+ 0x2532: { name: "SignedElement", type: "Binary" },
31
+ 0x8538067: { name: "Segment", type: "Container" },
32
+ 0x14d9b74: { name: "SeekHead", type: "Container" },
33
+ 0xdbb: { name: "Seek", type: "Container" },
34
+ 0x13ab: { name: "SeekID", type: "Binary" },
35
+ 0x13ac: { name: "SeekPosition", type: "Uint" },
36
+ 0x549a966: { name: "Info", type: "Container" },
37
+ 0x33a4: { name: "SegmentUID", type: "Binary" },
38
+ 0x3384: { name: "SegmentFilename", type: "String" },
39
+ 0x1cb923: { name: "PrevUID", type: "Binary" },
40
+ 0x1c83ab: { name: "PrevFilename", type: "String" },
41
+ 0x1eb923: { name: "NextUID", type: "Binary" },
42
+ 0x1e83bb: { name: "NextFilename", type: "String" },
43
+ 0x444: { name: "SegmentFamily", type: "Binary" },
44
+ 0x2924: { name: "ChapterTranslate", type: "Container" },
45
+ 0x29fc: { name: "ChapterTranslateEditionUID", type: "Uint" },
46
+ 0x29bf: { name: "ChapterTranslateCodec", type: "Uint" },
47
+ 0x29a5: { name: "ChapterTranslateID", type: "Binary" },
48
+ 0xad7b1: { name: "TimecodeScale", type: "Uint" },
49
+ 0x489: { name: "Duration", type: "Float" },
50
+ 0x461: { name: "DateUTC", type: "Date" },
51
+ 0x3ba9: { name: "Title", type: "String" },
52
+ 0xd80: { name: "MuxingApp", type: "String" },
53
+ 0x1741: { name: "WritingApp", type: "String" },
54
+ // 0xf43b675: { name: 'Cluster', type: 'Container' },
55
+ 0x67: { name: "Timecode", type: "Uint" },
56
+ 0x1854: { name: "SilentTracks", type: "Container" },
57
+ 0x18d7: { name: "SilentTrackNumber", type: "Uint" },
58
+ 0x27: { name: "Position", type: "Uint" },
59
+ 0x2b: { name: "PrevSize", type: "Uint" },
60
+ 0x23: { name: "SimpleBlock", type: "Binary" },
61
+ 0x20: { name: "BlockGroup", type: "Container" },
62
+ 0x21: { name: "Block", type: "Binary" },
63
+ 0x22: { name: "BlockVirtual", type: "Binary" },
64
+ 0x35a1: { name: "BlockAdditions", type: "Container" },
65
+ 0x26: { name: "BlockMore", type: "Container" },
66
+ 0x6e: { name: "BlockAddID", type: "Uint" },
67
+ 0x25: { name: "BlockAdditional", type: "Binary" },
68
+ 0x1b: { name: "BlockDuration", type: "Uint" },
69
+ 0x7a: { name: "ReferencePriority", type: "Uint" },
70
+ 0x7b: { name: "ReferenceBlock", type: "Int" },
71
+ 0x7d: { name: "ReferenceVirtual", type: "Int" },
72
+ 0x24: { name: "CodecState", type: "Binary" },
73
+ 0x35a2: { name: "DiscardPadding", type: "Int" },
74
+ 0xe: { name: "Slices", type: "Container" },
75
+ 0x68: { name: "TimeSlice", type: "Container" },
76
+ 0x4c: { name: "LaceNumber", type: "Uint" },
77
+ 0x4d: { name: "FrameNumber", type: "Uint" },
78
+ 0x4b: { name: "BlockAdditionID", type: "Uint" },
79
+ 0x4e: { name: "Delay", type: "Uint" },
80
+ 0x4f: { name: "SliceDuration", type: "Uint" },
81
+ 0x48: { name: "ReferenceFrame", type: "Container" },
82
+ 0x49: { name: "ReferenceOffset", type: "Uint" },
83
+ 0x4a: { name: "ReferenceTimeCode", type: "Uint" },
84
+ 0x2f: { name: "EncryptedBlock", type: "Binary" },
85
+ 0x654ae6b: { name: "Tracks", type: "Container" },
86
+ 0x2e: { name: "TrackEntry", type: "Container" },
87
+ 0x57: { name: "TrackNumber", type: "Uint" },
88
+ 0x33c5: { name: "TrackUID", type: "Uint" },
89
+ 0x3: { name: "TrackType", type: "Uint" },
90
+ 0x39: { name: "FlagEnabled", type: "Uint" },
91
+ 0x8: { name: "FlagDefault", type: "Uint" },
92
+ 0x15aa: { name: "FlagForced", type: "Uint" },
93
+ 0x1c: { name: "FlagLacing", type: "Uint" },
94
+ 0x2de7: { name: "MinCache", type: "Uint" },
95
+ 0x2df8: { name: "MaxCache", type: "Uint" },
96
+ 0x3e383: { name: "DefaultDuration", type: "Uint" },
97
+ 0x34e7a: { name: "DefaultDecodedFieldDuration", type: "Uint" },
98
+ 0x3314f: { name: "TrackTimecodeScale", type: "Float" },
99
+ 0x137f: { name: "TrackOffset", type: "Int" },
100
+ 0x15ee: { name: "MaxBlockAdditionID", type: "Uint" },
101
+ 0x136e: { name: "Name", type: "String" },
102
+ 0x2b59c: { name: "Language", type: "String" },
103
+ 0x6: { name: "CodecID", type: "String" },
104
+ 0x23a2: { name: "CodecPrivate", type: "Binary" },
105
+ 0x58688: { name: "CodecName", type: "String" },
106
+ 0x3446: { name: "AttachmentLink", type: "Uint" },
107
+ 0x1a9697: { name: "CodecSettings", type: "String" },
108
+ 0x1b4040: { name: "CodecInfoURL", type: "String" },
109
+ 0x6b240: { name: "CodecDownloadURL", type: "String" },
110
+ 0x2a: { name: "CodecDecodeAll", type: "Uint" },
111
+ 0x2fab: { name: "TrackOverlay", type: "Uint" },
112
+ 0x16aa: { name: "CodecDelay", type: "Uint" },
113
+ 0x16bb: { name: "SeekPreRoll", type: "Uint" },
114
+ 0x2624: { name: "TrackTranslate", type: "Container" },
115
+ 0x26fc: { name: "TrackTranslateEditionUID", type: "Uint" },
116
+ 0x26bf: { name: "TrackTranslateCodec", type: "Uint" },
117
+ 0x26a5: { name: "TrackTranslateTrackID", type: "Binary" },
118
+ 0x60: { name: "Video", type: "Container" },
119
+ 0x1a: { name: "FlagInterlaced", type: "Uint" },
120
+ 0x13b8: { name: "StereoMode", type: "Uint" },
121
+ 0x13c0: { name: "AlphaMode", type: "Uint" },
122
+ 0x13b9: { name: "OldStereoMode", type: "Uint" },
123
+ 0x30: { name: "PixelWidth", type: "Uint" },
124
+ 0x3a: { name: "PixelHeight", type: "Uint" },
125
+ 0x14aa: { name: "PixelCropBottom", type: "Uint" },
126
+ 0x14bb: { name: "PixelCropTop", type: "Uint" },
127
+ 0x14cc: { name: "PixelCropLeft", type: "Uint" },
128
+ 0x14dd: { name: "PixelCropRight", type: "Uint" },
129
+ 0x14b0: { name: "DisplayWidth", type: "Uint" },
130
+ 0x14ba: { name: "DisplayHeight", type: "Uint" },
131
+ 0x14b2: { name: "DisplayUnit", type: "Uint" },
132
+ 0x14b3: { name: "AspectRatioType", type: "Uint" },
133
+ 0xeb524: { name: "ColourSpace", type: "Binary" },
134
+ 0xfb523: { name: "GammaValue", type: "Float" },
135
+ 0x383e3: { name: "FrameRate", type: "Float" },
136
+ 0x61: { name: "Audio", type: "Container" },
137
+ 0x35: { name: "SamplingFrequency", type: "Float" },
138
+ 0x38b5: { name: "OutputSamplingFrequency", type: "Float" },
139
+ 0x1f: { name: "Channels", type: "Uint" },
140
+ 0x3d7b: { name: "ChannelPositions", type: "Binary" },
141
+ 0x2264: { name: "BitDepth", type: "Uint" },
142
+ 0x62: { name: "TrackOperation", type: "Container" },
143
+ 0x63: { name: "TrackCombinePlanes", type: "Container" },
144
+ 0x64: { name: "TrackPlane", type: "Container" },
145
+ 0x65: { name: "TrackPlaneUID", type: "Uint" },
146
+ 0x66: { name: "TrackPlaneType", type: "Uint" },
147
+ 0x69: { name: "TrackJoinBlocks", type: "Container" },
148
+ 0x6d: { name: "TrackJoinUID", type: "Uint" },
149
+ 0x40: { name: "TrickTrackUID", type: "Uint" },
150
+ 0x41: { name: "TrickTrackSegmentUID", type: "Binary" },
151
+ 0x46: { name: "TrickTrackFlag", type: "Uint" },
152
+ 0x47: { name: "TrickMasterTrackUID", type: "Uint" },
153
+ 0x44: { name: "TrickMasterTrackSegmentUID", type: "Binary" },
154
+ 0x2d80: { name: "ContentEncodings", type: "Container" },
155
+ 0x2240: { name: "ContentEncoding", type: "Container" },
156
+ 0x1031: { name: "ContentEncodingOrder", type: "Uint" },
157
+ 0x1032: { name: "ContentEncodingScope", type: "Uint" },
158
+ 0x1033: { name: "ContentEncodingType", type: "Uint" },
159
+ 0x1034: { name: "ContentCompression", type: "Container" },
160
+ 0x254: { name: "ContentCompAlgo", type: "Uint" },
161
+ 0x255: { name: "ContentCompSettings", type: "Binary" },
162
+ 0x1035: { name: "ContentEncryption", type: "Container" },
163
+ 0x7e1: { name: "ContentEncAlgo", type: "Uint" },
164
+ 0x7e2: { name: "ContentEncKeyID", type: "Binary" },
165
+ 0x7e3: { name: "ContentSignature", type: "Binary" },
166
+ 0x7e4: { name: "ContentSigKeyID", type: "Binary" },
167
+ 0x7e5: { name: "ContentSigAlgo", type: "Uint" },
168
+ 0x7e6: { name: "ContentSigHashAlgo", type: "Uint" },
169
+ 0xc53bb6b: { name: "Cues", type: "Container" },
170
+ 0x3b: { name: "CuePoint", type: "Container" },
171
+ 0x33: { name: "CueTime", type: "Uint" },
172
+ 0x37: { name: "CueTrackPositions", type: "Container" },
173
+ 0x77: { name: "CueTrack", type: "Uint" },
174
+ 0x71: { name: "CueClusterPosition", type: "Uint" },
175
+ 0x70: { name: "CueRelativePosition", type: "Uint" },
176
+ 0x32: { name: "CueDuration", type: "Uint" },
177
+ 0x1378: { name: "CueBlockNumber", type: "Uint" },
178
+ 0x6a: { name: "CueCodecState", type: "Uint" },
179
+ 0x5b: { name: "CueReference", type: "Container" },
180
+ 0x16: { name: "CueRefTime", type: "Uint" },
181
+ 0x17: { name: "CueRefCluster", type: "Uint" },
182
+ 0x135f: { name: "CueRefNumber", type: "Uint" },
183
+ 0x6b: { name: "CueRefCodecState", type: "Uint" },
184
+ 0x941a469: { name: "Attachments", type: "Container" },
185
+ 0x21a7: { name: "AttachedFile", type: "Container" },
186
+ 0x67e: { name: "FileDescription", type: "String" },
187
+ 0x66e: { name: "FileName", type: "String" },
188
+ 0x660: { name: "FileMimeType", type: "String" },
189
+ 0x65c: { name: "FileData", type: "Binary" },
190
+ 0x6ae: { name: "FileUID", type: "Uint" },
191
+ 0x675: { name: "FileReferral", type: "Binary" },
192
+ 0x661: { name: "FileUsedStartTime", type: "Uint" },
193
+ 0x662: { name: "FileUsedEndTime", type: "Uint" },
194
+ 0x43a770: { name: "Chapters", type: "Container" },
195
+ 0x5b9: { name: "EditionEntry", type: "Container" },
196
+ 0x5bc: { name: "EditionUID", type: "Uint" },
197
+ 0x5bd: { name: "EditionFlagHidden", type: "Uint" },
198
+ 0x5db: { name: "EditionFlagDefault", type: "Uint" },
199
+ 0x5dd: { name: "EditionFlagOrdered", type: "Uint" },
200
+ 0x36: { name: "ChapterAtom", type: "Container" },
201
+ 0x33c4: { name: "ChapterUID", type: "Uint" },
202
+ 0x1654: { name: "ChapterStringUID", type: "String" },
203
+ 0x11: { name: "ChapterTimeStart", type: "Uint" },
204
+ 0x12: { name: "ChapterTimeEnd", type: "Uint" },
205
+ 0x18: { name: "ChapterFlagHidden", type: "Uint" },
206
+ 0x598: { name: "ChapterFlagEnabled", type: "Uint" },
207
+ 0x2e67: { name: "ChapterSegmentUID", type: "Binary" },
208
+ 0x2ebc: { name: "ChapterSegmentEditionUID", type: "Uint" },
209
+ 0x23c3: { name: "ChapterPhysicalEquiv", type: "Uint" },
210
+ 0xf: { name: "ChapterTrack", type: "Container" },
211
+ 0x9: { name: "ChapterTrackNumber", type: "Uint" },
212
+ 0x0: { name: "ChapterDisplay", type: "Container" },
213
+ 0x5: { name: "ChapString", type: "String" },
214
+ 0x37c: { name: "ChapLanguage", type: "String" },
215
+ 0x37e: { name: "ChapCountry", type: "String" },
216
+ 0x2944: { name: "ChapProcess", type: "Container" },
217
+ 0x2955: { name: "ChapProcessCodecID", type: "Uint" },
218
+ 0x50d: { name: "ChapProcessPrivate", type: "Binary" },
219
+ 0x2911: { name: "ChapProcessCommand", type: "Container" },
220
+ 0x2922: { name: "ChapProcessTime", type: "Uint" },
221
+ 0x2933: { name: "ChapProcessData", type: "Binary" },
222
+ 0x254c367: { name: "Tags", type: "Container" },
223
+ 0x3373: { name: "Tag", type: "Container" },
224
+ 0x23c0: { name: "Targets", type: "Container" },
225
+ 0x28ca: { name: "TargetTypeValue", type: "Uint" },
226
+ 0x23ca: { name: "TargetType", type: "String" },
227
+ 0x23c5: { name: "TagTrackUID", type: "Uint" },
228
+ 0x23c9: { name: "TagEditionUID", type: "Uint" },
229
+ 0x23c4: { name: "TagChapterUID", type: "Uint" },
230
+ 0x23c6: { name: "TagAttachmentUID", type: "Uint" },
231
+ 0x27c8: { name: "SimpleTag", type: "Container" },
232
+ 0x5a3: { name: "TagName", type: "String" },
233
+ 0x47a: { name: "TagLanguage", type: "String" },
234
+ 0x484: { name: "TagDefault", type: "Uint" },
235
+ 0x487: { name: "TagString", type: "String" },
236
+ 0x485: { name: "TagBinary", type: "Binary" },
237
+ };
238
+ class WebmBase {
239
+ name;
240
+ type;
241
+ source;
242
+ data;
243
+ constructor(name = "Unknown", type = "Unknown") {
244
+ this.name = name;
245
+ this.type = type;
246
+ }
247
+ updateBySource() { }
248
+ setSource(source) {
249
+ this.source = source;
250
+ this.updateBySource();
251
+ }
252
+ updateByData() { }
253
+ setData(data) {
254
+ this.data = data;
255
+ this.updateByData();
256
+ }
257
+ }
258
+ class WebmUint extends WebmBase {
259
+ constructor(name, type) {
260
+ super(name, type || "Uint");
261
+ }
262
+ updateBySource() {
263
+ // use hex representation of a number instead of number value
264
+ this.data = "";
265
+ for (let i = 0; i < this.source.length; i++) {
266
+ const hex = this.source[i].toString(16);
267
+ this.data += padHex(hex);
268
+ }
269
+ }
270
+ updateByData() {
271
+ const length = this.data.length / 2;
272
+ this.source = new Uint8Array(length);
273
+ for (let i = 0; i < length; i++) {
274
+ const hex = this.data.substr(i * 2, 2);
275
+ this.source[i] = parseInt(hex, 16);
276
+ }
277
+ }
278
+ getValue() {
279
+ return parseInt(this.data, 16);
280
+ }
281
+ setValue(value) {
282
+ this.setData(padHex(value.toString(16)));
283
+ }
284
+ }
285
+ function padHex(hex) {
286
+ return hex.length % 2 === 1 ? "0" + hex : hex;
287
+ }
288
+ class WebmFloat extends WebmBase {
289
+ constructor(name, type) {
290
+ super(name, type || "Float");
291
+ }
292
+ getFloatArrayType() {
293
+ return this.source && this.source.length === 4
294
+ ? Float32Array
295
+ : Float64Array;
296
+ }
297
+ updateBySource() {
298
+ const byteArray = this.source.reverse();
299
+ const floatArrayType = this.getFloatArrayType();
300
+ const floatArray = new floatArrayType(byteArray.buffer);
301
+ this.data = floatArray[0];
302
+ }
303
+ updateByData() {
304
+ const floatArrayType = this.getFloatArrayType();
305
+ const floatArray = new floatArrayType([this.data]);
306
+ const byteArray = new Uint8Array(floatArray.buffer);
307
+ this.source = byteArray.reverse();
308
+ }
309
+ getValue() {
310
+ return this.data;
311
+ }
312
+ setValue(value) {
313
+ this.setData(value);
314
+ }
315
+ }
316
+ class WebmContainer extends WebmBase {
317
+ offset = 0;
318
+ data = [];
319
+ constructor(name, type) {
320
+ super(name, type || "Container");
321
+ }
322
+ readByte() {
323
+ return this.source[this.offset++];
324
+ }
325
+ readUint() {
326
+ const firstByte = this.readByte();
327
+ const bytes = 8 - firstByte.toString(2).length;
328
+ let value = firstByte - (1 << (7 - bytes));
329
+ for (let i = 0; i < bytes; i++) {
330
+ // don't use bit operators to support x86
331
+ value *= 256;
332
+ value += this.readByte();
333
+ }
334
+ return value;
335
+ }
336
+ updateBySource() {
337
+ let end = undefined;
338
+ this.data = [];
339
+ for (this.offset = 0; this.offset < this.source.length; this.offset = end) {
340
+ const id = this.readUint();
341
+ const len = this.readUint();
342
+ end = Math.min(this.offset + len, this.source.length);
343
+ const data = this.source.slice(this.offset, end);
344
+ const info = sections[id] || { name: "Unknown", type: "Unknown" };
345
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
346
+ let ctr = WebmBase;
347
+ switch (info.type) {
348
+ case "Container":
349
+ ctr = WebmContainer;
350
+ break;
351
+ case "Uint":
352
+ ctr = WebmUint;
353
+ break;
354
+ case "Float":
355
+ ctr = WebmFloat;
356
+ break;
357
+ }
358
+ const section = new ctr(info.name, info.type);
359
+ section.setSource(data);
360
+ this.data.push({
361
+ id: id,
362
+ idHex: id.toString(16),
363
+ data: section,
364
+ });
365
+ }
366
+ }
367
+ writeUint(x, draft = false) {
368
+ let flag = 0x80;
369
+ let bytes = 1;
370
+ // eslint-disable-next-line no-empty
371
+ for (; x >= flag && bytes < 8; bytes++, flag *= 0x80) { }
372
+ if (!draft) {
373
+ let value = flag + x;
374
+ for (let i = bytes - 1; i >= 0; i--) {
375
+ // don't use bit operators to support x86
376
+ const c = value % 256;
377
+ this.source[this.offset + i] = c;
378
+ value = (value - c) / 256;
379
+ }
380
+ }
381
+ this.offset += bytes;
382
+ }
383
+ writeSections(draft = false) {
384
+ this.offset = 0;
385
+ for (let i = 0; i < this.data.length; i++) {
386
+ const section = this.data[i], content = section.data.source, contentLength = content.length;
387
+ this.writeUint(section.id, draft);
388
+ this.writeUint(contentLength, draft);
389
+ if (!draft) {
390
+ this.source.set(content, this.offset);
391
+ }
392
+ this.offset += contentLength;
393
+ }
394
+ return this.offset;
395
+ }
396
+ updateByData() {
397
+ // run without accessing this.source to determine total length - need to know it to create Uint8Array
398
+ const length = this.writeSections(true);
399
+ this.source = new Uint8Array(length);
400
+ // now really write data
401
+ this.writeSections();
402
+ }
403
+ getSectionById(id) {
404
+ for (let i = 0; i < this.data.length; i++) {
405
+ const section = this.data[i];
406
+ if (section.id === id) {
407
+ return section.data;
408
+ }
409
+ }
410
+ return undefined;
411
+ }
412
+ }
413
+ class WebmFile extends WebmContainer {
414
+ constructor(source) {
415
+ super("File", "File");
416
+ this.setSource(source);
417
+ }
418
+ fixDuration(duration) {
419
+ const segmentSection = this.getSectionById(0x8538067);
420
+ if (!segmentSection) {
421
+ return false;
422
+ }
423
+ const infoSection = segmentSection.getSectionById(0x549a966);
424
+ if (!infoSection) {
425
+ return false;
426
+ }
427
+ const timeScaleSection = infoSection.getSectionById(0xad7b1);
428
+ if (!timeScaleSection) {
429
+ return false;
430
+ }
431
+ let durationSection = infoSection.getSectionById(0x489);
432
+ if (durationSection) {
433
+ if (durationSection.getValue() <= 0) {
434
+ durationSection.setValue(duration);
435
+ }
436
+ else {
437
+ return false;
438
+ }
439
+ }
440
+ else {
441
+ // append Duration section
442
+ durationSection = new WebmFloat("Duration", "Float");
443
+ durationSection.setValue(duration);
444
+ infoSection.data.push({
445
+ id: 0x489,
446
+ data: durationSection,
447
+ });
448
+ }
449
+ // set default time scale to 1 millisecond (1000000 nanoseconds)
450
+ timeScaleSection.setValue(1000000);
451
+ infoSection.updateByData();
452
+ segmentSection.updateByData();
453
+ this.updateByData();
454
+ return true;
455
+ }
456
+ toBlob(type = "video/webm") {
457
+ return new Blob([this.source.buffer], { type });
458
+ }
459
+ }
460
+ /**
461
+ * Fixes duration on MediaRecorder output.
462
+ * @param blob Input Blob with incorrect duration.
463
+ * @param duration Correct duration (in milliseconds).
464
+ * @param type Output blob mimetype (default: video/webm).
465
+ * @returns
466
+ */
467
+ export const webmFixDuration = (blob, duration, type = "video/webm") => {
468
+ return new Promise((resolve, reject) => {
469
+ try {
470
+ const reader = new FileReader();
471
+ reader.addEventListener("loadend", () => {
472
+ try {
473
+ const result = reader.result;
474
+ const file = new WebmFile(new Uint8Array(result));
475
+ if (file.fixDuration(duration)) {
476
+ resolve(file.toBlob(type));
477
+ }
478
+ else {
479
+ resolve(blob);
480
+ }
481
+ }
482
+ catch (ex) {
483
+ reject(ex);
484
+ }
485
+ });
486
+ reader.addEventListener("error", () => reject());
487
+ reader.readAsArrayBuffer(blob);
488
+ }
489
+ catch (ex) {
490
+ reject(ex);
491
+ }
492
+ });
493
+ };
494
+ //# sourceMappingURL=BlobFix.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BlobFix.js","sourceRoot":"","sources":["../../src/utils/BlobFix.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAWH,MAAM,QAAQ,GAA4B;IACtC,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE;IAC9C,KAAK,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE;IAC5C,KAAK,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,EAAE;IAChD,KAAK,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,EAAE;IAChD,KAAK,EAAE,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,MAAM,EAAE;IAClD,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC1C,KAAK,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,EAAE;IAC/C,KAAK,EAAE,EAAE,IAAI,EAAE,oBAAoB,EAAE,IAAI,EAAE,MAAM,EAAE;IACnD,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE;IACtC,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE;IACxC,SAAS,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,WAAW,EAAE;IACvD,MAAM,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE;IAC/C,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,CAAC,EAAE,CAAC;wBAC7B,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;oBAC/B,CAAC;yBAAM,CAAC;wBACJ,OAAO,CAAC,IAAI,CAAC,CAAC;oBAClB,CAAC;gBACL,CAAC;gBAAC,OAAO,EAAE,EAAE,CAAC;oBACV,MAAM,CAAC,EAAE,CAAC,CAAC;gBACf,CAAC;YACL,CAAC,CAAC,CAAC;YAEH,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC;YAEjD,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;QACnC,CAAC;QAAC,OAAO,EAAE,EAAE,CAAC;YACV,MAAM,CAAC,EAAE,CAAC,CAAC;QACf,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC,CAAC","sourcesContent":["/*\n * There is a bug where `navigator.mediaDevices.getUserMedia` + `MediaRecorder`\n * creates WEBM files without duration metadata. See:\n * - https://bugs.chromium.org/p/chromium/issues/detail?id=642012\n * - https://stackoverflow.com/a/39971175/13989043\n *\n * This file contains a function that fixes the duration metadata of a WEBM file.\n * - Answer found: https://stackoverflow.com/a/75218309/13989043\n * - Code adapted from: https://github.com/mat-sz/webm-fix-duration\n * (forked from https://github.com/yusitnikov/fix-webm-duration)\n */\n\n/*\n * This is the list of possible WEBM file sections by their IDs.\n * Possible types: Container, Binary, Uint, Int, String, Float, Date\n */\ninterface Section {\n name: string;\n type: string;\n}\n\nconst sections: Record<number, Section> = {\n 0xa45dfa3: { name: \"EBML\", type: \"Container\" },\n 0x286: { name: \"EBMLVersion\", type: \"Uint\" },\n 0x2f7: { name: \"EBMLReadVersion\", type: \"Uint\" },\n 0x2f2: { name: \"EBMLMaxIDLength\", type: \"Uint\" },\n 0x2f3: { name: \"EBMLMaxSizeLength\", type: \"Uint\" },\n 0x282: { name: \"DocType\", type: \"String\" },\n 0x287: { name: \"DocTypeVersion\", type: \"Uint\" },\n 0x285: { name: \"DocTypeReadVersion\", type: \"Uint\" },\n 0x6c: { name: \"Void\", type: \"Binary\" },\n 0x3f: { name: \"CRC-32\", type: \"Binary\" },\n 0xb538667: { name: \"SignatureSlot\", type: \"Container\" },\n 0x3e8a: { name: \"SignatureAlgo\", type: \"Uint\" },\n 0x3e9a: { name: \"SignatureHash\", type: \"Uint\" },\n 0x3ea5: { name: \"SignaturePublicKey\", type: \"Binary\" },\n 0x3eb5: { name: \"Signature\", type: \"Binary\" },\n 0x3e5b: { name: \"SignatureElements\", type: \"Container\" },\n 0x3e7b: { name: \"SignatureElementList\", type: \"Container\" },\n 0x2532: { name: \"SignedElement\", type: \"Binary\" },\n 0x8538067: { name: \"Segment\", type: \"Container\" },\n 0x14d9b74: { name: \"SeekHead\", type: \"Container\" },\n 0xdbb: { name: \"Seek\", type: \"Container\" },\n 0x13ab: { name: \"SeekID\", type: \"Binary\" },\n 0x13ac: { name: \"SeekPosition\", type: \"Uint\" },\n 0x549a966: { name: \"Info\", type: \"Container\" },\n 0x33a4: { name: \"SegmentUID\", type: \"Binary\" },\n 0x3384: { name: \"SegmentFilename\", type: \"String\" },\n 0x1cb923: { name: \"PrevUID\", type: \"Binary\" },\n 0x1c83ab: { name: \"PrevFilename\", type: \"String\" },\n 0x1eb923: { name: \"NextUID\", type: \"Binary\" },\n 0x1e83bb: { name: \"NextFilename\", type: \"String\" },\n 0x444: { name: \"SegmentFamily\", type: \"Binary\" },\n 0x2924: { name: \"ChapterTranslate\", type: \"Container\" },\n 0x29fc: { name: \"ChapterTranslateEditionUID\", type: \"Uint\" },\n 0x29bf: { name: \"ChapterTranslateCodec\", type: \"Uint\" },\n 0x29a5: { name: \"ChapterTranslateID\", type: \"Binary\" },\n 0xad7b1: { name: \"TimecodeScale\", type: \"Uint\" },\n 0x489: { name: \"Duration\", type: \"Float\" },\n 0x461: { name: \"DateUTC\", type: \"Date\" },\n 0x3ba9: { name: \"Title\", type: \"String\" },\n 0xd80: { name: \"MuxingApp\", type: \"String\" },\n 0x1741: { name: \"WritingApp\", type: \"String\" },\n // 0xf43b675: { name: 'Cluster', type: 'Container' },\n 0x67: { name: \"Timecode\", type: \"Uint\" },\n 0x1854: { name: \"SilentTracks\", type: \"Container\" },\n 0x18d7: { name: \"SilentTrackNumber\", type: \"Uint\" },\n 0x27: { name: \"Position\", type: \"Uint\" },\n 0x2b: { name: \"PrevSize\", type: \"Uint\" },\n 0x23: { name: \"SimpleBlock\", type: \"Binary\" },\n 0x20: { name: \"BlockGroup\", type: \"Container\" },\n 0x21: { name: \"Block\", type: \"Binary\" },\n 0x22: { name: \"BlockVirtual\", type: \"Binary\" },\n 0x35a1: { name: \"BlockAdditions\", type: \"Container\" },\n 0x26: { name: \"BlockMore\", type: \"Container\" },\n 0x6e: { name: \"BlockAddID\", type: \"Uint\" },\n 0x25: { name: \"BlockAdditional\", type: \"Binary\" },\n 0x1b: { name: \"BlockDuration\", type: \"Uint\" },\n 0x7a: { name: \"ReferencePriority\", type: \"Uint\" },\n 0x7b: { name: \"ReferenceBlock\", type: \"Int\" },\n 0x7d: { name: \"ReferenceVirtual\", type: \"Int\" },\n 0x24: { name: \"CodecState\", type: \"Binary\" },\n 0x35a2: { name: \"DiscardPadding\", type: \"Int\" },\n 0xe: { name: \"Slices\", type: \"Container\" },\n 0x68: { name: \"TimeSlice\", type: \"Container\" },\n 0x4c: { name: \"LaceNumber\", type: \"Uint\" },\n 0x4d: { name: \"FrameNumber\", type: \"Uint\" },\n 0x4b: { name: \"BlockAdditionID\", type: \"Uint\" },\n 0x4e: { name: \"Delay\", type: \"Uint\" },\n 0x4f: { name: \"SliceDuration\", type: \"Uint\" },\n 0x48: { name: \"ReferenceFrame\", type: \"Container\" },\n 0x49: { name: \"ReferenceOffset\", type: \"Uint\" },\n 0x4a: { name: \"ReferenceTimeCode\", type: \"Uint\" },\n 0x2f: { name: \"EncryptedBlock\", type: \"Binary\" },\n 0x654ae6b: { name: \"Tracks\", type: \"Container\" },\n 0x2e: { name: \"TrackEntry\", type: \"Container\" },\n 0x57: { name: \"TrackNumber\", type: \"Uint\" },\n 0x33c5: { name: \"TrackUID\", type: \"Uint\" },\n 0x3: { name: \"TrackType\", type: \"Uint\" },\n 0x39: { name: \"FlagEnabled\", type: \"Uint\" },\n 0x8: { name: \"FlagDefault\", type: \"Uint\" },\n 0x15aa: { name: \"FlagForced\", type: \"Uint\" },\n 0x1c: { name: \"FlagLacing\", type: \"Uint\" },\n 0x2de7: { name: \"MinCache\", type: \"Uint\" },\n 0x2df8: { name: \"MaxCache\", type: \"Uint\" },\n 0x3e383: { name: \"DefaultDuration\", type: \"Uint\" },\n 0x34e7a: { name: \"DefaultDecodedFieldDuration\", type: \"Uint\" },\n 0x3314f: { name: \"TrackTimecodeScale\", type: \"Float\" },\n 0x137f: { name: \"TrackOffset\", type: \"Int\" },\n 0x15ee: { name: \"MaxBlockAdditionID\", type: \"Uint\" },\n 0x136e: { name: \"Name\", type: \"String\" },\n 0x2b59c: { name: \"Language\", type: \"String\" },\n 0x6: { name: \"CodecID\", type: \"String\" },\n 0x23a2: { name: \"CodecPrivate\", type: \"Binary\" },\n 0x58688: { name: \"CodecName\", type: \"String\" },\n 0x3446: { name: \"AttachmentLink\", type: \"Uint\" },\n 0x1a9697: { name: \"CodecSettings\", type: \"String\" },\n 0x1b4040: { name: \"CodecInfoURL\", type: \"String\" },\n 0x6b240: { name: \"CodecDownloadURL\", type: \"String\" },\n 0x2a: { name: \"CodecDecodeAll\", type: \"Uint\" },\n 0x2fab: { name: \"TrackOverlay\", type: \"Uint\" },\n 0x16aa: { name: \"CodecDelay\", type: \"Uint\" },\n 0x16bb: { name: \"SeekPreRoll\", type: \"Uint\" },\n 0x2624: { name: \"TrackTranslate\", type: \"Container\" },\n 0x26fc: { name: \"TrackTranslateEditionUID\", type: \"Uint\" },\n 0x26bf: { name: \"TrackTranslateCodec\", type: \"Uint\" },\n 0x26a5: { name: \"TrackTranslateTrackID\", type: \"Binary\" },\n 0x60: { name: \"Video\", type: \"Container\" },\n 0x1a: { name: \"FlagInterlaced\", type: \"Uint\" },\n 0x13b8: { name: \"StereoMode\", type: \"Uint\" },\n 0x13c0: { name: \"AlphaMode\", type: \"Uint\" },\n 0x13b9: { name: \"OldStereoMode\", type: \"Uint\" },\n 0x30: { name: \"PixelWidth\", type: \"Uint\" },\n 0x3a: { name: \"PixelHeight\", type: \"Uint\" },\n 0x14aa: { name: \"PixelCropBottom\", type: \"Uint\" },\n 0x14bb: { name: \"PixelCropTop\", type: \"Uint\" },\n 0x14cc: { name: \"PixelCropLeft\", type: \"Uint\" },\n 0x14dd: { name: \"PixelCropRight\", type: \"Uint\" },\n 0x14b0: { name: \"DisplayWidth\", type: \"Uint\" },\n 0x14ba: { name: \"DisplayHeight\", type: \"Uint\" },\n 0x14b2: { name: \"DisplayUnit\", type: \"Uint\" },\n 0x14b3: { name: \"AspectRatioType\", type: \"Uint\" },\n 0xeb524: { name: \"ColourSpace\", type: \"Binary\" },\n 0xfb523: { name: \"GammaValue\", type: \"Float\" },\n 0x383e3: { name: \"FrameRate\", type: \"Float\" },\n 0x61: { name: \"Audio\", type: \"Container\" },\n 0x35: { name: \"SamplingFrequency\", type: \"Float\" },\n 0x38b5: { name: \"OutputSamplingFrequency\", type: \"Float\" },\n 0x1f: { name: \"Channels\", type: \"Uint\" },\n 0x3d7b: { name: \"ChannelPositions\", type: \"Binary\" },\n 0x2264: { name: \"BitDepth\", type: \"Uint\" },\n 0x62: { name: \"TrackOperation\", type: \"Container\" },\n 0x63: { name: \"TrackCombinePlanes\", type: \"Container\" },\n 0x64: { name: \"TrackPlane\", type: \"Container\" },\n 0x65: { name: \"TrackPlaneUID\", type: \"Uint\" },\n 0x66: { name: \"TrackPlaneType\", type: \"Uint\" },\n 0x69: { name: \"TrackJoinBlocks\", type: \"Container\" },\n 0x6d: { name: \"TrackJoinUID\", type: \"Uint\" },\n 0x40: { name: \"TrickTrackUID\", type: \"Uint\" },\n 0x41: { name: \"TrickTrackSegmentUID\", type: \"Binary\" },\n 0x46: { name: \"TrickTrackFlag\", type: \"Uint\" },\n 0x47: { name: \"TrickMasterTrackUID\", type: \"Uint\" },\n 0x44: { name: \"TrickMasterTrackSegmentUID\", type: \"Binary\" },\n 0x2d80: { name: \"ContentEncodings\", type: \"Container\" },\n 0x2240: { name: \"ContentEncoding\", type: \"Container\" },\n 0x1031: { name: \"ContentEncodingOrder\", type: \"Uint\" },\n 0x1032: { name: \"ContentEncodingScope\", type: \"Uint\" },\n 0x1033: { name: \"ContentEncodingType\", type: \"Uint\" },\n 0x1034: { name: \"ContentCompression\", type: \"Container\" },\n 0x254: { name: \"ContentCompAlgo\", type: \"Uint\" },\n 0x255: { name: \"ContentCompSettings\", type: \"Binary\" },\n 0x1035: { name: \"ContentEncryption\", type: \"Container\" },\n 0x7e1: { name: \"ContentEncAlgo\", type: \"Uint\" },\n 0x7e2: { name: \"ContentEncKeyID\", type: \"Binary\" },\n 0x7e3: { name: \"ContentSignature\", type: \"Binary\" },\n 0x7e4: { name: \"ContentSigKeyID\", type: \"Binary\" },\n 0x7e5: { name: \"ContentSigAlgo\", type: \"Uint\" },\n 0x7e6: { name: \"ContentSigHashAlgo\", type: \"Uint\" },\n 0xc53bb6b: { name: \"Cues\", type: \"Container\" },\n 0x3b: { name: \"CuePoint\", type: \"Container\" },\n 0x33: { name: \"CueTime\", type: \"Uint\" },\n 0x37: { name: \"CueTrackPositions\", type: \"Container\" },\n 0x77: { name: \"CueTrack\", type: \"Uint\" },\n 0x71: { name: \"CueClusterPosition\", type: \"Uint\" },\n 0x70: { name: \"CueRelativePosition\", type: \"Uint\" },\n 0x32: { name: \"CueDuration\", type: \"Uint\" },\n 0x1378: { name: \"CueBlockNumber\", type: \"Uint\" },\n 0x6a: { name: \"CueCodecState\", type: \"Uint\" },\n 0x5b: { name: \"CueReference\", type: \"Container\" },\n 0x16: { name: \"CueRefTime\", type: \"Uint\" },\n 0x17: { name: \"CueRefCluster\", type: \"Uint\" },\n 0x135f: { name: \"CueRefNumber\", type: \"Uint\" },\n 0x6b: { name: \"CueRefCodecState\", type: \"Uint\" },\n 0x941a469: { name: \"Attachments\", type: \"Container\" },\n 0x21a7: { name: \"AttachedFile\", type: \"Container\" },\n 0x67e: { name: \"FileDescription\", type: \"String\" },\n 0x66e: { name: \"FileName\", type: \"String\" },\n 0x660: { name: \"FileMimeType\", type: \"String\" },\n 0x65c: { name: \"FileData\", type: \"Binary\" },\n 0x6ae: { name: \"FileUID\", type: \"Uint\" },\n 0x675: { name: \"FileReferral\", type: \"Binary\" },\n 0x661: { name: \"FileUsedStartTime\", type: \"Uint\" },\n 0x662: { name: \"FileUsedEndTime\", type: \"Uint\" },\n 0x43a770: { name: \"Chapters\", type: \"Container\" },\n 0x5b9: { name: \"EditionEntry\", type: \"Container\" },\n 0x5bc: { name: \"EditionUID\", type: \"Uint\" },\n 0x5bd: { name: \"EditionFlagHidden\", type: \"Uint\" },\n 0x5db: { name: \"EditionFlagDefault\", type: \"Uint\" },\n 0x5dd: { name: \"EditionFlagOrdered\", type: \"Uint\" },\n 0x36: { name: \"ChapterAtom\", type: \"Container\" },\n 0x33c4: { name: \"ChapterUID\", type: \"Uint\" },\n 0x1654: { name: \"ChapterStringUID\", type: \"String\" },\n 0x11: { name: \"ChapterTimeStart\", type: \"Uint\" },\n 0x12: { name: \"ChapterTimeEnd\", type: \"Uint\" },\n 0x18: { name: \"ChapterFlagHidden\", type: \"Uint\" },\n 0x598: { name: \"ChapterFlagEnabled\", type: \"Uint\" },\n 0x2e67: { name: \"ChapterSegmentUID\", type: \"Binary\" },\n 0x2ebc: { name: \"ChapterSegmentEditionUID\", type: \"Uint\" },\n 0x23c3: { name: \"ChapterPhysicalEquiv\", type: \"Uint\" },\n 0xf: { name: \"ChapterTrack\", type: \"Container\" },\n 0x9: { name: \"ChapterTrackNumber\", type: \"Uint\" },\n 0x0: { name: \"ChapterDisplay\", type: \"Container\" },\n 0x5: { name: \"ChapString\", type: \"String\" },\n 0x37c: { name: \"ChapLanguage\", type: \"String\" },\n 0x37e: { name: \"ChapCountry\", type: \"String\" },\n 0x2944: { name: \"ChapProcess\", type: \"Container\" },\n 0x2955: { name: \"ChapProcessCodecID\", type: \"Uint\" },\n 0x50d: { name: \"ChapProcessPrivate\", type: \"Binary\" },\n 0x2911: { name: \"ChapProcessCommand\", type: \"Container\" },\n 0x2922: { name: \"ChapProcessTime\", type: \"Uint\" },\n 0x2933: { name: \"ChapProcessData\", type: \"Binary\" },\n 0x254c367: { name: \"Tags\", type: \"Container\" },\n 0x3373: { name: \"Tag\", type: \"Container\" },\n 0x23c0: { name: \"Targets\", type: \"Container\" },\n 0x28ca: { name: \"TargetTypeValue\", type: \"Uint\" },\n 0x23ca: { name: \"TargetType\", type: \"String\" },\n 0x23c5: { name: \"TagTrackUID\", type: \"Uint\" },\n 0x23c9: { name: \"TagEditionUID\", type: \"Uint\" },\n 0x23c4: { name: \"TagChapterUID\", type: \"Uint\" },\n 0x23c6: { name: \"TagAttachmentUID\", type: \"Uint\" },\n 0x27c8: { name: \"SimpleTag\", type: \"Container\" },\n 0x5a3: { name: \"TagName\", type: \"String\" },\n 0x47a: { name: \"TagLanguage\", type: \"String\" },\n 0x484: { name: \"TagDefault\", type: \"Uint\" },\n 0x487: { name: \"TagString\", type: \"String\" },\n 0x485: { name: \"TagBinary\", type: \"Binary\" },\n};\n\nclass WebmBase<T> {\n source?: Uint8Array;\n data?: T;\n\n constructor(private name = \"Unknown\", private type = \"Unknown\") {}\n\n updateBySource() {}\n\n setSource(source: Uint8Array) {\n this.source = source;\n this.updateBySource();\n }\n\n updateByData() {}\n\n setData(data: T) {\n this.data = data;\n this.updateByData();\n }\n}\n\nclass WebmUint extends WebmBase<string> {\n constructor(name: string, type: string) {\n super(name, type || \"Uint\");\n }\n\n updateBySource() {\n // use hex representation of a number instead of number value\n this.data = \"\";\n for (let i = 0; i < this.source!.length; i++) {\n const hex = this.source![i].toString(16);\n this.data += padHex(hex);\n }\n }\n\n updateByData() {\n const length = this.data!.length / 2;\n this.source = new Uint8Array(length);\n for (let i = 0; i < length; i++) {\n const hex = this.data!.substr(i * 2, 2);\n this.source[i] = parseInt(hex, 16);\n }\n }\n\n getValue() {\n return parseInt(this.data!, 16);\n }\n\n setValue(value: number) {\n this.setData(padHex(value.toString(16)));\n }\n}\n\nfunction padHex(hex: string) {\n return hex.length % 2 === 1 ? \"0\" + hex : hex;\n}\n\nclass WebmFloat extends WebmBase<number> {\n constructor(name: string, type: string) {\n super(name, type || \"Float\");\n }\n\n getFloatArrayType() {\n return this.source && this.source.length === 4\n ? Float32Array\n : Float64Array;\n }\n updateBySource() {\n const byteArray = this.source!.reverse();\n const floatArrayType = this.getFloatArrayType();\n const floatArray = new floatArrayType(byteArray.buffer);\n this.data! = floatArray[0];\n }\n updateByData() {\n const floatArrayType = this.getFloatArrayType();\n const floatArray = new floatArrayType([this.data!]);\n const byteArray = new Uint8Array(floatArray.buffer);\n this.source = byteArray.reverse();\n }\n getValue() {\n return this.data;\n }\n setValue(value: number) {\n this.setData(value);\n }\n}\n\ninterface ContainerData {\n id: number;\n idHex?: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: WebmBase<any>;\n}\n\nclass WebmContainer extends WebmBase<ContainerData[]> {\n offset: number = 0;\n data: ContainerData[] = [];\n\n constructor(name: string, type: string) {\n super(name, type || \"Container\");\n }\n\n readByte() {\n return this.source![this.offset++];\n }\n readUint() {\n const firstByte = this.readByte();\n const bytes = 8 - firstByte.toString(2).length;\n let value = firstByte - (1 << (7 - bytes));\n for (let i = 0; i < bytes; i++) {\n // don't use bit operators to support x86\n value *= 256;\n value += this.readByte();\n }\n return value;\n }\n updateBySource() {\n let end: number | undefined = undefined;\n this.data = [];\n for (\n this.offset = 0;\n this.offset < this.source!.length;\n this.offset = end\n ) {\n const id = this.readUint();\n const len = this.readUint();\n end = Math.min(this.offset + len, this.source!.length);\n const data = this.source!.slice(this.offset, end);\n\n const info = sections[id] || { name: \"Unknown\", type: \"Unknown\" };\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let ctr: any = WebmBase;\n switch (info.type) {\n case \"Container\":\n ctr = WebmContainer;\n break;\n case \"Uint\":\n ctr = WebmUint;\n break;\n case \"Float\":\n ctr = WebmFloat;\n break;\n }\n const section = new ctr(info.name, info.type);\n section.setSource(data);\n this.data.push({\n id: id,\n idHex: id.toString(16),\n data: section,\n });\n }\n }\n writeUint(x: number, draft = false) {\n let flag = 0x80;\n let bytes = 1;\n // eslint-disable-next-line no-empty\n for (; x >= flag && bytes < 8; bytes++, flag *= 0x80) {}\n\n if (!draft) {\n let value = flag + x;\n for (let i = bytes - 1; i >= 0; i--) {\n // don't use bit operators to support x86\n const c = value % 256;\n this.source![this.offset! + i] = c;\n value = (value - c) / 256;\n }\n }\n\n this.offset += bytes;\n }\n\n writeSections(draft = false) {\n this.offset = 0;\n for (let i = 0; i < this.data.length; i++) {\n const section = this.data[i],\n content = section.data.source,\n contentLength = content!.length;\n this.writeUint(section.id, draft);\n this.writeUint(contentLength, draft);\n if (!draft) {\n this.source!.set(content!, this.offset);\n }\n this.offset += contentLength;\n }\n return this.offset;\n }\n\n updateByData() {\n // run without accessing this.source to determine total length - need to know it to create Uint8Array\n const length = this.writeSections(true);\n this.source = new Uint8Array(length);\n // now really write data\n this.writeSections();\n }\n\n getSectionById(id: number) {\n for (let i = 0; i < this.data.length; i++) {\n const section = this.data[i];\n if (section.id === id) {\n return section.data;\n }\n }\n\n return undefined;\n }\n}\n\nclass WebmFile extends WebmContainer {\n constructor(source: Uint8Array) {\n super(\"File\", \"File\");\n this.setSource(source);\n }\n\n fixDuration(duration: number) {\n const segmentSection = this.getSectionById(0x8538067) as WebmContainer;\n if (!segmentSection) {\n return false;\n }\n\n const infoSection = segmentSection.getSectionById(\n 0x549a966,\n ) as WebmContainer;\n if (!infoSection) {\n return false;\n }\n\n const timeScaleSection = infoSection.getSectionById(\n 0xad7b1,\n ) as WebmFloat;\n if (!timeScaleSection) {\n return false;\n }\n\n let durationSection = infoSection.getSectionById(0x489) as WebmFloat;\n if (durationSection) {\n if (durationSection.getValue()! <= 0) {\n durationSection.setValue(duration);\n } else {\n return false;\n }\n } else {\n // append Duration section\n durationSection = new WebmFloat(\"Duration\", \"Float\");\n durationSection.setValue(duration);\n infoSection.data.push({\n id: 0x489,\n data: durationSection,\n });\n }\n\n // set default time scale to 1 millisecond (1000000 nanoseconds)\n timeScaleSection.setValue(1000000);\n infoSection.updateByData();\n segmentSection.updateByData();\n this.updateByData();\n\n return true;\n }\n\n toBlob(type = \"video/webm\") {\n return new Blob([this.source!.buffer], { type });\n }\n}\n\n/**\n * Fixes duration on MediaRecorder output.\n * @param blob Input Blob with incorrect duration.\n * @param duration Correct duration (in milliseconds).\n * @param type Output blob mimetype (default: video/webm).\n * @returns\n */\nexport const webmFixDuration = (\n blob: Blob,\n duration: number,\n type = \"video/webm\",\n): Promise<Blob> => {\n return new Promise((resolve, reject) => {\n try {\n const reader = new FileReader();\n\n reader.addEventListener(\"loadend\", () => {\n try {\n const result = reader.result as ArrayBuffer;\n const file = new WebmFile(new Uint8Array(result));\n if (file.fixDuration(duration)) {\n resolve(file.toBlob(type));\n } else {\n resolve(blob);\n }\n } catch (ex) {\n reject(ex);\n }\n });\n\n reader.addEventListener(\"error\", () => reject());\n\n reader.readAsArrayBuffer(blob);\n } catch (ex) {\n reject(ex);\n }\n });\n};\n"]}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Concatenates an array of ArrayBuffers into a single ArrayBuffer.
3
+ *
4
+ * @param buffers - An array of ArrayBuffers to be concatenated.
5
+ * @returns A single ArrayBuffer containing the concatenated data.
6
+ */
7
+ export declare const concatenateBuffers: (buffers: ArrayBuffer[]) => ArrayBuffer;
8
+ //# sourceMappingURL=concatenateBuffers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"concatenateBuffers.d.ts","sourceRoot":"","sources":["../../src/utils/concatenateBuffers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,YAAa,WAAW,EAAE,KAAG,WAiB3D,CAAA"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Concatenates an array of ArrayBuffers into a single ArrayBuffer.
3
+ *
4
+ * @param buffers - An array of ArrayBuffers to be concatenated.
5
+ * @returns A single ArrayBuffer containing the concatenated data.
6
+ */
7
+ export const concatenateBuffers = (buffers) => {
8
+ // Filter out any undefined or null buffers
9
+ const validBuffers = buffers.filter((buffer) => buffer);
10
+ const totalLength = validBuffers.reduce((sum, buffer) => sum + buffer.byteLength, 0);
11
+ // Create a new Uint8Array to hold the concatenated result
12
+ const result = new Uint8Array(totalLength);
13
+ // Offset to keep track of the current position in the result array
14
+ let offset = 0;
15
+ for (const buffer of validBuffers) {
16
+ result.set(new Uint8Array(buffer), offset);
17
+ offset += buffer.byteLength;
18
+ }
19
+ return result.buffer;
20
+ };
21
+ //# sourceMappingURL=concatenateBuffers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"concatenateBuffers.js","sourceRoot":"","sources":["../../src/utils/concatenateBuffers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAAsB,EAAe,EAAE;IACtE,2CAA2C;IAC3C,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,CAAA;IACvD,MAAM,WAAW,GAAG,YAAY,CAAC,MAAM,CACnC,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC,GAAG,GAAG,MAAM,CAAC,UAAU,EACxC,CAAC,CACJ,CAAA;IACD,0DAA0D;IAC1D,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,WAAW,CAAC,CAAA;IAC1C,mEAAmE;IACnE,IAAI,MAAM,GAAG,CAAC,CAAA;IAEd,KAAK,MAAM,MAAM,IAAI,YAAY,EAAE,CAAC;QAChC,MAAM,CAAC,GAAG,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAA;QAC1C,MAAM,IAAI,MAAM,CAAC,UAAU,CAAA;IAC/B,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAA;AACxB,CAAC,CAAA","sourcesContent":["/**\n * Concatenates an array of ArrayBuffers into a single ArrayBuffer.\n *\n * @param buffers - An array of ArrayBuffers to be concatenated.\n * @returns A single ArrayBuffer containing the concatenated data.\n */\nexport const concatenateBuffers = (buffers: ArrayBuffer[]): ArrayBuffer => {\n // Filter out any undefined or null buffers\n const validBuffers = buffers.filter((buffer) => buffer)\n const totalLength = validBuffers.reduce(\n (sum, buffer) => sum + buffer.byteLength,\n 0\n )\n // Create a new Uint8Array to hold the concatenated result\n const result = new Uint8Array(totalLength)\n // Offset to keep track of the current position in the result array\n let offset = 0\n\n for (const buffer of validBuffers) {\n result.set(new Uint8Array(buffer), offset)\n offset += buffer.byteLength\n }\n return result.buffer\n}\n"]}