neoagent 2.1.18-beta.59 → 2.1.18-beta.60

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 (33) hide show
  1. package/package.json +1 -1
  2. package/server/public/.last_build_id +1 -1
  3. package/server/public/assets/AssetManifest.bin +1 -1
  4. package/server/public/assets/AssetManifest.bin.json +1 -1
  5. package/server/public/assets/NOTICES +66 -0
  6. package/server/public/assets/fonts/MaterialIcons-Regular.otf +0 -0
  7. package/server/public/assets/packages/record_web/assets/js/record.fixwebmduration.js +507 -0
  8. package/server/public/assets/packages/record_web/assets/js/record.worklet.js +407 -0
  9. package/server/public/flutter_bootstrap.js +2 -2
  10. package/server/public/main.dart.js +67499 -66781
  11. package/server/routes/settings.js +12 -0
  12. package/server/services/ai/capabilityHealth.js +34 -21
  13. package/server/services/ai/engine.js +14 -0
  14. package/server/services/ai/settings.js +21 -29
  15. package/server/services/ai/tools.js +1 -1
  16. package/server/services/manager.js +25 -1
  17. package/server/services/messaging/manager.js +5 -1
  18. package/server/services/messaging/telnyx.js +98 -2
  19. package/server/services/runtime/manager.js +15 -3
  20. package/server/services/runtime/settings.js +12 -0
  21. package/server/services/voice/agentBridge.js +62 -0
  22. package/server/services/voice/bufferedLiveRelayAdapter.js +118 -0
  23. package/server/services/voice/geminiLiveRelayAdapter.js +16 -0
  24. package/server/services/voice/liveAudio.js +98 -0
  25. package/server/services/voice/liveSession.js +125 -0
  26. package/server/services/voice/liveSettings.js +105 -0
  27. package/server/services/voice/message.js +4 -1
  28. package/server/services/voice/openaiClient.js +11 -1
  29. package/server/services/voice/openaiLiveRelayAdapter.js +16 -0
  30. package/server/services/voice/providers.js +22 -12
  31. package/server/services/voice/runtimeManager.js +316 -0
  32. package/server/services/voice/turnRunner.js +38 -4
  33. package/server/services/websocket.js +85 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neoagent",
3
- "version": "2.1.18-beta.59",
3
+ "version": "2.1.18-beta.60",
4
4
  "description": "Proactive personal AI agent with no limits",
5
5
  "license": "MIT",
6
6
  "main": "server/index.js",
@@ -1 +1 @@
1
- 1364c60312b13e5d80c77b1708e33bfb
1
+ dc2ac3821de37958afef0c20433c5630
@@ -1 +1 @@
1
-
1
+
@@ -1 +1 @@
1
- "DQIHMnBhY2thZ2VzL2N1cGVydGlub19pY29ucy9hc3NldHMvQ3VwZXJ0aW5vSWNvbnMudHRmDAENAQcFYXNzZXQHMnBhY2thZ2VzL2N1cGVydGlub19pY29ucy9hc3NldHMvQ3VwZXJ0aW5vSWNvbnMudHRmBxZ3ZWIvaWNvbnMvSWNvbi0xOTIucG5nDAENAQcFYXNzZXQHFndlYi9pY29ucy9JY29uLTE5Mi5wbmc="
1
+ "DQQHMnBhY2thZ2VzL2N1cGVydGlub19pY29ucy9hc3NldHMvQ3VwZXJ0aW5vSWNvbnMudHRmDAENAQcFYXNzZXQHMnBhY2thZ2VzL2N1cGVydGlub19pY29ucy9hc3NldHMvQ3VwZXJ0aW5vSWNvbnMudHRmBzdwYWNrYWdlcy9yZWNvcmRfd2ViL2Fzc2V0cy9qcy9yZWNvcmQuZml4d2VibWR1cmF0aW9uLmpzDAENAQcFYXNzZXQHN3BhY2thZ2VzL3JlY29yZF93ZWIvYXNzZXRzL2pzL3JlY29yZC5maXh3ZWJtZHVyYXRpb24uanMHL3BhY2thZ2VzL3JlY29yZF93ZWIvYXNzZXRzL2pzL3JlY29yZC53b3JrbGV0LmpzDAENAQcFYXNzZXQHL3BhY2thZ2VzL3JlY29yZF93ZWIvYXNzZXRzL2pzL3JlY29yZC53b3JrbGV0LmpzBxZ3ZWIvaWNvbnMvSWNvbi0xOTIucG5nDAENAQcFYXNzZXQHFndlYi9pY29ucy9JY29uLTE5Mi5wbmc="
@@ -25233,6 +25233,72 @@ WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY
25233
25233
  REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
25234
25234
  OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
25235
25235
  --------------------------------------------------------------------------------
25236
+ record
25237
+ record_android
25238
+ record_ios
25239
+ record_linux
25240
+ record_macos
25241
+ record_platform_interface
25242
+ record_web
25243
+
25244
+ // Copyright 2022 openapi4j authors. All rights reserved.
25245
+ //
25246
+ // Redistribution and use in source and binary forms, with or without
25247
+ // modification, are permitted provided that the following conditions are
25248
+ // met:
25249
+ //
25250
+ // * Redistributions of source code must retain the above copyright
25251
+ // notice, this list of conditions and the following disclaimer.
25252
+ // * Redistributions in binary form must reproduce the above
25253
+ // copyright notice, this list of conditions and the following disclaimer
25254
+ // in the documentation and/or other materials provided with the
25255
+ // distribution.
25256
+ // * Neither the name of openapi4j nor the names of its
25257
+ // contributors may be used to endorse or promote products derived from
25258
+ // this software without specific prior written permission.
25259
+ //
25260
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25261
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25262
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25263
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25264
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25265
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25266
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25267
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25268
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25269
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25270
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25271
+ --------------------------------------------------------------------------------
25272
+ record_windows
25273
+
25274
+ // Copyright 2022 openapi4j authors. All rights reserved.
25275
+ //
25276
+ // Redistribution and use in source and binary forms, with or without
25277
+ // modification, are permitted provided that the following conditions are
25278
+ // met:
25279
+ //
25280
+ // * Redistributions of source code must retain the above copyright
25281
+ // notice, this list of conditions and the following disclaimer.
25282
+ // * Redistributions in binary form must reproduce the above
25283
+ // copyright notice, this list of conditions and the following disclaimer
25284
+ // in the documentation and/or other materials provided with the
25285
+ // distribution.
25286
+ // * Neither the name of openapi4j nor the names of its
25287
+ // contributors may be used to endorse or promote products derived from
25288
+ // this software without specific prior written permission.
25289
+ //
25290
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25291
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25292
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25293
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25294
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25295
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25296
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25297
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25298
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25299
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25300
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25301
+ --------------------------------------------------------------------------------
25236
25302
  shaderc
25237
25303
 
25238
25304
  Apache License
@@ -0,0 +1,507 @@
1
+ (function (name, definition) {
2
+ window.jsFixWebmDuration = definition();
3
+ })('fix-webm-duration', function () {
4
+ /*
5
+ * This is the list of possible WEBM file sections by their IDs.
6
+ * Possible types: Container, Binary, Uint, Int, String, Float, Date
7
+ */
8
+ var sections = {
9
+ 0xa45dfa3: { name: 'EBML', type: 'Container' },
10
+ 0x286: { name: 'EBMLVersion', type: 'Uint' },
11
+ 0x2f7: { name: 'EBMLReadVersion', type: 'Uint' },
12
+ 0x2f2: { name: 'EBMLMaxIDLength', type: 'Uint' },
13
+ 0x2f3: { name: 'EBMLMaxSizeLength', type: 'Uint' },
14
+ 0x282: { name: 'DocType', type: 'String' },
15
+ 0x287: { name: 'DocTypeVersion', type: 'Uint' },
16
+ 0x285: { name: 'DocTypeReadVersion', type: 'Uint' },
17
+ 0x6c: { name: 'Void', type: 'Binary' },
18
+ 0x3f: { name: 'CRC-32', type: 'Binary' },
19
+ 0xb538667: { name: 'SignatureSlot', type: 'Container' },
20
+ 0x3e8a: { name: 'SignatureAlgo', type: 'Uint' },
21
+ 0x3e9a: { name: 'SignatureHash', type: 'Uint' },
22
+ 0x3ea5: { name: 'SignaturePublicKey', type: 'Binary' },
23
+ 0x3eb5: { name: 'Signature', type: 'Binary' },
24
+ 0x3e5b: { name: 'SignatureElements', type: 'Container' },
25
+ 0x3e7b: { name: 'SignatureElementList', type: 'Container' },
26
+ 0x2532: { name: 'SignedElement', type: 'Binary' },
27
+ 0x8538067: { name: 'Segment', type: 'Container' },
28
+ 0x14d9b74: { name: 'SeekHead', type: 'Container' },
29
+ 0xdbb: { name: 'Seek', type: 'Container' },
30
+ 0x13ab: { name: 'SeekID', type: 'Binary' },
31
+ 0x13ac: { name: 'SeekPosition', type: 'Uint' },
32
+ 0x549a966: { name: 'Info', type: 'Container' },
33
+ 0x33a4: { name: 'SegmentUID', type: 'Binary' },
34
+ 0x3384: { name: 'SegmentFilename', type: 'String' },
35
+ 0x1cb923: { name: 'PrevUID', type: 'Binary' },
36
+ 0x1c83ab: { name: 'PrevFilename', type: 'String' },
37
+ 0x1eb923: { name: 'NextUID', type: 'Binary' },
38
+ 0x1e83bb: { name: 'NextFilename', type: 'String' },
39
+ 0x444: { name: 'SegmentFamily', type: 'Binary' },
40
+ 0x2924: { name: 'ChapterTranslate', type: 'Container' },
41
+ 0x29fc: { name: 'ChapterTranslateEditionUID', type: 'Uint' },
42
+ 0x29bf: { name: 'ChapterTranslateCodec', type: 'Uint' },
43
+ 0x29a5: { name: 'ChapterTranslateID', type: 'Binary' },
44
+ 0xad7b1: { name: 'TimecodeScale', type: 'Uint' },
45
+ 0x489: { name: 'Duration', type: 'Float' },
46
+ 0x461: { name: 'DateUTC', type: 'Date' },
47
+ 0x3ba9: { name: 'Title', type: 'String' },
48
+ 0xd80: { name: 'MuxingApp', type: 'String' },
49
+ 0x1741: { name: 'WritingApp', type: 'String' },
50
+ // 0xf43b675: { name: 'Cluster', type: 'Container' },
51
+ 0x67: { name: 'Timecode', type: 'Uint' },
52
+ 0x1854: { name: 'SilentTracks', type: 'Container' },
53
+ 0x18d7: { name: 'SilentTrackNumber', type: 'Uint' },
54
+ 0x27: { name: 'Position', type: 'Uint' },
55
+ 0x2b: { name: 'PrevSize', type: 'Uint' },
56
+ 0x23: { name: 'SimpleBlock', type: 'Binary' },
57
+ 0x20: { name: 'BlockGroup', type: 'Container' },
58
+ 0x21: { name: 'Block', type: 'Binary' },
59
+ 0x22: { name: 'BlockVirtual', type: 'Binary' },
60
+ 0x35a1: { name: 'BlockAdditions', type: 'Container' },
61
+ 0x26: { name: 'BlockMore', type: 'Container' },
62
+ 0x6e: { name: 'BlockAddID', type: 'Uint' },
63
+ 0x25: { name: 'BlockAdditional', type: 'Binary' },
64
+ 0x1b: { name: 'BlockDuration', type: 'Uint' },
65
+ 0x7a: { name: 'ReferencePriority', type: 'Uint' },
66
+ 0x7b: { name: 'ReferenceBlock', type: 'Int' },
67
+ 0x7d: { name: 'ReferenceVirtual', type: 'Int' },
68
+ 0x24: { name: 'CodecState', type: 'Binary' },
69
+ 0x35a2: { name: 'DiscardPadding', type: 'Int' },
70
+ 0xe: { name: 'Slices', type: 'Container' },
71
+ 0x68: { name: 'TimeSlice', type: 'Container' },
72
+ 0x4c: { name: 'LaceNumber', type: 'Uint' },
73
+ 0x4d: { name: 'FrameNumber', type: 'Uint' },
74
+ 0x4b: { name: 'BlockAdditionID', type: 'Uint' },
75
+ 0x4e: { name: 'Delay', type: 'Uint' },
76
+ 0x4f: { name: 'SliceDuration', type: 'Uint' },
77
+ 0x48: { name: 'ReferenceFrame', type: 'Container' },
78
+ 0x49: { name: 'ReferenceOffset', type: 'Uint' },
79
+ 0x4a: { name: 'ReferenceTimeCode', type: 'Uint' },
80
+ 0x2f: { name: 'EncryptedBlock', type: 'Binary' },
81
+ 0x654ae6b: { name: 'Tracks', type: 'Container' },
82
+ 0x2e: { name: 'TrackEntry', type: 'Container' },
83
+ 0x57: { name: 'TrackNumber', type: 'Uint' },
84
+ 0x33c5: { name: 'TrackUID', type: 'Uint' },
85
+ 0x3: { name: 'TrackType', type: 'Uint' },
86
+ 0x39: { name: 'FlagEnabled', type: 'Uint' },
87
+ 0x8: { name: 'FlagDefault', type: 'Uint' },
88
+ 0x15aa: { name: 'FlagForced', type: 'Uint' },
89
+ 0x1c: { name: 'FlagLacing', type: 'Uint' },
90
+ 0x2de7: { name: 'MinCache', type: 'Uint' },
91
+ 0x2df8: { name: 'MaxCache', type: 'Uint' },
92
+ 0x3e383: { name: 'DefaultDuration', type: 'Uint' },
93
+ 0x34e7a: { name: 'DefaultDecodedFieldDuration', type: 'Uint' },
94
+ 0x3314f: { name: 'TrackTimecodeScale', type: 'Float' },
95
+ 0x137f: { name: 'TrackOffset', type: 'Int' },
96
+ 0x15ee: { name: 'MaxBlockAdditionID', type: 'Uint' },
97
+ 0x136e: { name: 'Name', type: 'String' },
98
+ 0x2b59c: { name: 'Language', type: 'String' },
99
+ 0x6: { name: 'CodecID', type: 'String' },
100
+ 0x23a2: { name: 'CodecPrivate', type: 'Binary' },
101
+ 0x58688: { name: 'CodecName', type: 'String' },
102
+ 0x3446: { name: 'AttachmentLink', type: 'Uint' },
103
+ 0x1a9697: { name: 'CodecSettings', type: 'String' },
104
+ 0x1b4040: { name: 'CodecInfoURL', type: 'String' },
105
+ 0x6b240: { name: 'CodecDownloadURL', type: 'String' },
106
+ 0x2a: { name: 'CodecDecodeAll', type: 'Uint' },
107
+ 0x2fab: { name: 'TrackOverlay', type: 'Uint' },
108
+ 0x16aa: { name: 'CodecDelay', type: 'Uint' },
109
+ 0x16bb: { name: 'SeekPreRoll', type: 'Uint' },
110
+ 0x2624: { name: 'TrackTranslate', type: 'Container' },
111
+ 0x26fc: { name: 'TrackTranslateEditionUID', type: 'Uint' },
112
+ 0x26bf: { name: 'TrackTranslateCodec', type: 'Uint' },
113
+ 0x26a5: { name: 'TrackTranslateTrackID', type: 'Binary' },
114
+ 0x60: { name: 'Video', type: 'Container' },
115
+ 0x1a: { name: 'FlagInterlaced', type: 'Uint' },
116
+ 0x13b8: { name: 'StereoMode', type: 'Uint' },
117
+ 0x13c0: { name: 'AlphaMode', type: 'Uint' },
118
+ 0x13b9: { name: 'OldStereoMode', type: 'Uint' },
119
+ 0x30: { name: 'PixelWidth', type: 'Uint' },
120
+ 0x3a: { name: 'PixelHeight', type: 'Uint' },
121
+ 0x14aa: { name: 'PixelCropBottom', type: 'Uint' },
122
+ 0x14bb: { name: 'PixelCropTop', type: 'Uint' },
123
+ 0x14cc: { name: 'PixelCropLeft', type: 'Uint' },
124
+ 0x14dd: { name: 'PixelCropRight', type: 'Uint' },
125
+ 0x14b0: { name: 'DisplayWidth', type: 'Uint' },
126
+ 0x14ba: { name: 'DisplayHeight', type: 'Uint' },
127
+ 0x14b2: { name: 'DisplayUnit', type: 'Uint' },
128
+ 0x14b3: { name: 'AspectRatioType', type: 'Uint' },
129
+ 0xeb524: { name: 'ColourSpace', type: 'Binary' },
130
+ 0xfb523: { name: 'GammaValue', type: 'Float' },
131
+ 0x383e3: { name: 'FrameRate', type: 'Float' },
132
+ 0x61: { name: 'Audio', type: 'Container' },
133
+ 0x35: { name: 'SamplingFrequency', type: 'Float' },
134
+ 0x38b5: { name: 'OutputSamplingFrequency', type: 'Float' },
135
+ 0x1f: { name: 'Channels', type: 'Uint' },
136
+ 0x3d7b: { name: 'ChannelPositions', type: 'Binary' },
137
+ 0x2264: { name: 'BitDepth', type: 'Uint' },
138
+ 0x62: { name: 'TrackOperation', type: 'Container' },
139
+ 0x63: { name: 'TrackCombinePlanes', type: 'Container' },
140
+ 0x64: { name: 'TrackPlane', type: 'Container' },
141
+ 0x65: { name: 'TrackPlaneUID', type: 'Uint' },
142
+ 0x66: { name: 'TrackPlaneType', type: 'Uint' },
143
+ 0x69: { name: 'TrackJoinBlocks', type: 'Container' },
144
+ 0x6d: { name: 'TrackJoinUID', type: 'Uint' },
145
+ 0x40: { name: 'TrickTrackUID', type: 'Uint' },
146
+ 0x41: { name: 'TrickTrackSegmentUID', type: 'Binary' },
147
+ 0x46: { name: 'TrickTrackFlag', type: 'Uint' },
148
+ 0x47: { name: 'TrickMasterTrackUID', type: 'Uint' },
149
+ 0x44: { name: 'TrickMasterTrackSegmentUID', type: 'Binary' },
150
+ 0x2d80: { name: 'ContentEncodings', type: 'Container' },
151
+ 0x2240: { name: 'ContentEncoding', type: 'Container' },
152
+ 0x1031: { name: 'ContentEncodingOrder', type: 'Uint' },
153
+ 0x1032: { name: 'ContentEncodingScope', type: 'Uint' },
154
+ 0x1033: { name: 'ContentEncodingType', type: 'Uint' },
155
+ 0x1034: { name: 'ContentCompression', type: 'Container' },
156
+ 0x254: { name: 'ContentCompAlgo', type: 'Uint' },
157
+ 0x255: { name: 'ContentCompSettings', type: 'Binary' },
158
+ 0x1035: { name: 'ContentEncryption', type: 'Container' },
159
+ 0x7e1: { name: 'ContentEncAlgo', type: 'Uint' },
160
+ 0x7e2: { name: 'ContentEncKeyID', type: 'Binary' },
161
+ 0x7e3: { name: 'ContentSignature', type: 'Binary' },
162
+ 0x7e4: { name: 'ContentSigKeyID', type: 'Binary' },
163
+ 0x7e5: { name: 'ContentSigAlgo', type: 'Uint' },
164
+ 0x7e6: { name: 'ContentSigHashAlgo', type: 'Uint' },
165
+ 0xc53bb6b: { name: 'Cues', type: 'Container' },
166
+ 0x3b: { name: 'CuePoint', type: 'Container' },
167
+ 0x33: { name: 'CueTime', type: 'Uint' },
168
+ 0x37: { name: 'CueTrackPositions', type: 'Container' },
169
+ 0x77: { name: 'CueTrack', type: 'Uint' },
170
+ 0x71: { name: 'CueClusterPosition', type: 'Uint' },
171
+ 0x70: { name: 'CueRelativePosition', type: 'Uint' },
172
+ 0x32: { name: 'CueDuration', type: 'Uint' },
173
+ 0x1378: { name: 'CueBlockNumber', type: 'Uint' },
174
+ 0x6a: { name: 'CueCodecState', type: 'Uint' },
175
+ 0x5b: { name: 'CueReference', type: 'Container' },
176
+ 0x16: { name: 'CueRefTime', type: 'Uint' },
177
+ 0x17: { name: 'CueRefCluster', type: 'Uint' },
178
+ 0x135f: { name: 'CueRefNumber', type: 'Uint' },
179
+ 0x6b: { name: 'CueRefCodecState', type: 'Uint' },
180
+ 0x941a469: { name: 'Attachments', type: 'Container' },
181
+ 0x21a7: { name: 'AttachedFile', type: 'Container' },
182
+ 0x67e: { name: 'FileDescription', type: 'String' },
183
+ 0x66e: { name: 'FileName', type: 'String' },
184
+ 0x660: { name: 'FileMimeType', type: 'String' },
185
+ 0x65c: { name: 'FileData', type: 'Binary' },
186
+ 0x6ae: { name: 'FileUID', type: 'Uint' },
187
+ 0x675: { name: 'FileReferral', type: 'Binary' },
188
+ 0x661: { name: 'FileUsedStartTime', type: 'Uint' },
189
+ 0x662: { name: 'FileUsedEndTime', type: 'Uint' },
190
+ 0x43a770: { name: 'Chapters', type: 'Container' },
191
+ 0x5b9: { name: 'EditionEntry', type: 'Container' },
192
+ 0x5bc: { name: 'EditionUID', type: 'Uint' },
193
+ 0x5bd: { name: 'EditionFlagHidden', type: 'Uint' },
194
+ 0x5db: { name: 'EditionFlagDefault', type: 'Uint' },
195
+ 0x5dd: { name: 'EditionFlagOrdered', type: 'Uint' },
196
+ 0x36: { name: 'ChapterAtom', type: 'Container' },
197
+ 0x33c4: { name: 'ChapterUID', type: 'Uint' },
198
+ 0x1654: { name: 'ChapterStringUID', type: 'String' },
199
+ 0x11: { name: 'ChapterTimeStart', type: 'Uint' },
200
+ 0x12: { name: 'ChapterTimeEnd', type: 'Uint' },
201
+ 0x18: { name: 'ChapterFlagHidden', type: 'Uint' },
202
+ 0x598: { name: 'ChapterFlagEnabled', type: 'Uint' },
203
+ 0x2e67: { name: 'ChapterSegmentUID', type: 'Binary' },
204
+ 0x2ebc: { name: 'ChapterSegmentEditionUID', type: 'Uint' },
205
+ 0x23c3: { name: 'ChapterPhysicalEquiv', type: 'Uint' },
206
+ 0xf: { name: 'ChapterTrack', type: 'Container' },
207
+ 0x9: { name: 'ChapterTrackNumber', type: 'Uint' },
208
+ 0x0: { name: 'ChapterDisplay', type: 'Container' },
209
+ 0x5: { name: 'ChapString', type: 'String' },
210
+ 0x37c: { name: 'ChapLanguage', type: 'String' },
211
+ 0x37e: { name: 'ChapCountry', type: 'String' },
212
+ 0x2944: { name: 'ChapProcess', type: 'Container' },
213
+ 0x2955: { name: 'ChapProcessCodecID', type: 'Uint' },
214
+ 0x50d: { name: 'ChapProcessPrivate', type: 'Binary' },
215
+ 0x2911: { name: 'ChapProcessCommand', type: 'Container' },
216
+ 0x2922: { name: 'ChapProcessTime', type: 'Uint' },
217
+ 0x2933: { name: 'ChapProcessData', type: 'Binary' },
218
+ 0x254c367: { name: 'Tags', type: 'Container' },
219
+ 0x3373: { name: 'Tag', type: 'Container' },
220
+ 0x23c0: { name: 'Targets', type: 'Container' },
221
+ 0x28ca: { name: 'TargetTypeValue', type: 'Uint' },
222
+ 0x23ca: { name: 'TargetType', type: 'String' },
223
+ 0x23c5: { name: 'TagTrackUID', type: 'Uint' },
224
+ 0x23c9: { name: 'TagEditionUID', type: 'Uint' },
225
+ 0x23c4: { name: 'TagChapterUID', type: 'Uint' },
226
+ 0x23c6: { name: 'TagAttachmentUID', type: 'Uint' },
227
+ 0x27c8: { name: 'SimpleTag', type: 'Container' },
228
+ 0x5a3: { name: 'TagName', type: 'String' },
229
+ 0x47a: { name: 'TagLanguage', type: 'String' },
230
+ 0x484: { name: 'TagDefault', type: 'Uint' },
231
+ 0x487: { name: 'TagString', type: 'String' },
232
+ 0x485: { name: 'TagBinary', type: 'Binary' }
233
+ };
234
+
235
+ function doInherit(newClass, baseClass) {
236
+ newClass.prototype = Object.create(baseClass.prototype);
237
+ newClass.prototype.constructor = newClass;
238
+ }
239
+
240
+ function WebmBase(name, type) {
241
+ this.name = name || 'Unknown';
242
+ this.type = type || 'Unknown';
243
+ }
244
+ WebmBase.prototype.updateBySource = function () { };
245
+ WebmBase.prototype.setSource = function (source) {
246
+ this.source = source;
247
+ this.updateBySource();
248
+ };
249
+ WebmBase.prototype.updateByData = function () { };
250
+ WebmBase.prototype.setData = function (data) {
251
+ this.data = data;
252
+ this.updateByData();
253
+ };
254
+
255
+ function WebmUint(name, type) {
256
+ WebmBase.call(this, name, type || 'Uint');
257
+ }
258
+ doInherit(WebmUint, WebmBase);
259
+ function padHex(hex) {
260
+ return hex.length % 2 === 1 ? '0' + hex : hex;
261
+ }
262
+ WebmUint.prototype.updateBySource = function () {
263
+ // use hex representation of a number instead of number value
264
+ this.data = '';
265
+ for (var i = 0; i < this.source.length; i++) {
266
+ var hex = this.source[i].toString(16);
267
+ this.data += padHex(hex);
268
+ }
269
+ };
270
+ WebmUint.prototype.updateByData = function () {
271
+ var length = this.data.length / 2;
272
+ this.source = new Uint8Array(length);
273
+ for (var i = 0; i < length; i++) {
274
+ var hex = this.data.substr(i * 2, 2);
275
+ this.source[i] = parseInt(hex, 16);
276
+ }
277
+ };
278
+ WebmUint.prototype.getValue = function () {
279
+ return parseInt(this.data, 16);
280
+ };
281
+ WebmUint.prototype.setValue = function (value) {
282
+ this.setData(padHex(value.toString(16)));
283
+ };
284
+
285
+ function WebmFloat(name, type) {
286
+ WebmBase.call(this, name, type || 'Float');
287
+ }
288
+ doInherit(WebmFloat, WebmBase);
289
+ WebmFloat.prototype.getFloatArrayType = function () {
290
+ return this.source && this.source.length === 4 ? Float32Array : Float64Array;
291
+ };
292
+ WebmFloat.prototype.updateBySource = function () {
293
+ var byteArray = this.source.reverse();
294
+ var floatArrayType = this.getFloatArrayType();
295
+ var floatArray = new floatArrayType(byteArray.buffer);
296
+ this.data = floatArray[0];
297
+ };
298
+ WebmFloat.prototype.updateByData = function () {
299
+ var floatArrayType = this.getFloatArrayType();
300
+ var floatArray = new floatArrayType([this.data]);
301
+ var byteArray = new Uint8Array(floatArray.buffer);
302
+ this.source = byteArray.reverse();
303
+ };
304
+ WebmFloat.prototype.getValue = function () {
305
+ return this.data;
306
+ };
307
+ WebmFloat.prototype.setValue = function (value) {
308
+ this.setData(value);
309
+ };
310
+
311
+ function WebmContainer(name, type) {
312
+ WebmBase.call(this, name, type || 'Container');
313
+ }
314
+ doInherit(WebmContainer, WebmBase);
315
+ WebmContainer.prototype.readByte = function () {
316
+ return this.source[this.offset++];
317
+ };
318
+ WebmContainer.prototype.readUint = function () {
319
+ var firstByte = this.readByte();
320
+ var bytes = 8 - firstByte.toString(2).length;
321
+ var value = firstByte - (1 << (7 - bytes));
322
+ for (var i = 0; i < bytes; i++) {
323
+ // don't use bit operators to support x86
324
+ value *= 256;
325
+ value += this.readByte();
326
+ }
327
+ return value;
328
+ };
329
+ WebmContainer.prototype.updateBySource = function () {
330
+ this.data = [];
331
+ for (this.offset = 0; this.offset < this.source.length; this.offset = end) {
332
+ var id = this.readUint();
333
+ var len = this.readUint();
334
+ var end = Math.min(this.offset + len, this.source.length);
335
+ var data = this.source.slice(this.offset, end);
336
+
337
+ var info = sections[id] || { name: 'Unknown', type: 'Unknown' };
338
+ var ctr = WebmBase;
339
+ switch (info.type) {
340
+ case 'Container':
341
+ ctr = WebmContainer;
342
+ break;
343
+ case 'Uint':
344
+ ctr = WebmUint;
345
+ break;
346
+ case 'Float':
347
+ ctr = WebmFloat;
348
+ break;
349
+ }
350
+ var section = new ctr(info.name, info.type);
351
+ section.setSource(data);
352
+ this.data.push({
353
+ id: id,
354
+ idHex: id.toString(16),
355
+ data: section
356
+ });
357
+ }
358
+ };
359
+ WebmContainer.prototype.writeUint = function (x, draft) {
360
+ for (var bytes = 1, flag = 0x80; x >= flag && bytes < 8; bytes++, flag *= 0x80) { }
361
+
362
+ if (!draft) {
363
+ var value = flag + x;
364
+ for (var i = bytes - 1; i >= 0; i--) {
365
+ // don't use bit operators to support x86
366
+ var c = value % 256;
367
+ this.source[this.offset + i] = c;
368
+ value = (value - c) / 256;
369
+ }
370
+ }
371
+
372
+ this.offset += bytes;
373
+ };
374
+ WebmContainer.prototype.writeSections = function (draft) {
375
+ this.offset = 0;
376
+ for (var i = 0; i < this.data.length; i++) {
377
+ var section = this.data[i],
378
+ content = section.data.source,
379
+ contentLength = content.length;
380
+ this.writeUint(section.id, draft);
381
+ this.writeUint(contentLength, draft);
382
+ if (!draft) {
383
+ this.source.set(content, this.offset);
384
+ }
385
+ this.offset += contentLength;
386
+ }
387
+ return this.offset;
388
+ };
389
+ WebmContainer.prototype.updateByData = function () {
390
+ // run without accessing this.source to determine total length - need to know it to create Uint8Array
391
+ var length = this.writeSections('draft');
392
+ this.source = new Uint8Array(length);
393
+ // now really write data
394
+ this.writeSections();
395
+ };
396
+ WebmContainer.prototype.getSectionById = function (id) {
397
+ for (var i = 0; i < this.data.length; i++) {
398
+ var section = this.data[i];
399
+ if (section.id === id) {
400
+ return section.data;
401
+ }
402
+ }
403
+ return null;
404
+ };
405
+
406
+ function WebmFile(source) {
407
+ WebmContainer.call(this, 'File', 'File');
408
+ this.setSource(source);
409
+ }
410
+ doInherit(WebmFile, WebmContainer);
411
+ WebmFile.prototype.fixDuration = function (duration, options) {
412
+ var logger = options && options.logger;
413
+ if (logger === undefined) {
414
+ logger = function (message) {
415
+ console.log(message);
416
+ };
417
+ } else if (!logger) {
418
+ logger = function () { };
419
+ }
420
+
421
+ var segmentSection = this.getSectionById(0x8538067);
422
+ if (!segmentSection) {
423
+ logger('[fix-webm-duration] Segment section is missing');
424
+ return false;
425
+ }
426
+
427
+ var infoSection = segmentSection.getSectionById(0x549a966);
428
+ if (!infoSection) {
429
+ logger('[fix-webm-duration] Info section is missing');
430
+ return false;
431
+ }
432
+
433
+ var timeScaleSection = infoSection.getSectionById(0xad7b1);
434
+ if (!timeScaleSection) {
435
+ logger('[fix-webm-duration] TimecodeScale section is missing');
436
+ return false;
437
+ }
438
+
439
+ var durationSection = infoSection.getSectionById(0x489);
440
+ if (durationSection) {
441
+ if (durationSection.getValue() <= 0) {
442
+ logger('[fix-webm-duration] Duration section is present, but the value is empty. Applying ' + duration.toLocaleString() + ' ms.');
443
+ durationSection.setValue(duration);
444
+ } else {
445
+ logger('[fix-webm-duration] Duration section is present');
446
+ return false;
447
+ }
448
+ } else {
449
+ logger('[fix-webm-duration] Duration section is missing. Applying ' + duration.toLocaleString() + ' ms.');
450
+ // append Duration section
451
+ durationSection = new WebmFloat('Duration', 'Float');
452
+ durationSection.setValue(duration);
453
+ infoSection.data.push({
454
+ id: 0x489,
455
+ data: durationSection
456
+ });
457
+ }
458
+
459
+ // set default time scale to 1 millisecond (1000000 nanoseconds)
460
+ timeScaleSection.setValue(1000000);
461
+ infoSection.updateByData();
462
+ segmentSection.updateByData();
463
+ this.updateByData();
464
+
465
+ return true;
466
+ };
467
+ WebmFile.prototype.toBlob = function (mimeType) {
468
+ return new Blob([this.source.buffer], { type: mimeType || 'audio/webm' });
469
+ };
470
+
471
+ function fixWebmDuration(blob, duration, callback, options) {
472
+ // The callback may be omitted - then the third argument is options
473
+ if (typeof callback === "object") {
474
+ options = callback;
475
+ callback = undefined;
476
+ }
477
+
478
+ if (!callback) {
479
+ return new Promise(function (resolve) {
480
+ fixWebmDuration(blob, duration, resolve, options);
481
+ });
482
+ }
483
+
484
+ try {
485
+ var reader = new FileReader();
486
+ reader.onloadend = function () {
487
+ try {
488
+ var file = new WebmFile(new Uint8Array(reader.result));
489
+ if (file.fixDuration(duration, options)) {
490
+ blob = file.toBlob(blob.type);
491
+ }
492
+ } catch (ex) {
493
+ // ignore
494
+ }
495
+ callback(blob);
496
+ };
497
+ reader.readAsArrayBuffer(blob);
498
+ } catch (ex) {
499
+ callback(blob);
500
+ }
501
+ }
502
+
503
+ // Support AMD import default
504
+ fixWebmDuration.default = fixWebmDuration;
505
+
506
+ return fixWebmDuration;
507
+ });