@zygout/eris 0.19.0 → 0.19.2
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.
- package/LICENSE +20 -20
- package/README.md +71 -80
- package/esm.mjs +72 -72
- package/index.d.ts +4407 -4397
- package/index.js +75 -75
- package/lib/Client.js +4708 -4683
- package/lib/Constants.d.ts +990 -988
- package/lib/Constants.js +1163 -1161
- package/lib/command/Command.js +552 -552
- package/lib/command/CommandClient.js +460 -460
- package/lib/errors/DiscordHTTPError.js +63 -63
- package/lib/errors/DiscordRESTError.js +77 -77
- package/lib/gateway/Shard.js +3029 -3029
- package/lib/gateway/ShardManager.js +164 -164
- package/lib/rest/Endpoints.js +172 -172
- package/lib/rest/RequestHandler.js +459 -459
- package/lib/structures/ApplicationCommand.js +125 -125
- package/lib/structures/AutoModerationRule.js +143 -143
- package/lib/structures/AutocompleteInteraction.js +80 -80
- package/lib/structures/Base.js +81 -81
- package/lib/structures/CategoryChannel.js +77 -77
- package/lib/structures/Channel.js +98 -98
- package/lib/structures/CommandInteraction.js +473 -473
- package/lib/structures/ComponentInteraction.js +538 -538
- package/lib/structures/DMChannel.js +278 -278
- package/lib/structures/Entitlement.js +77 -77
- package/lib/structures/ExtendedUser.js +46 -46
- package/lib/structures/ForumChannel.js +24 -24
- package/lib/structures/GroupChannel.js +106 -106
- package/lib/structures/Guild.js +1677 -1677
- package/lib/structures/GuildAuditLogEntry.js +190 -190
- package/lib/structures/GuildChannel.js +128 -128
- package/lib/structures/GuildIntegration.js +99 -99
- package/lib/structures/GuildPreview.js +97 -97
- package/lib/structures/GuildScheduledEvent.js +176 -176
- package/lib/structures/GuildTemplate.js +76 -76
- package/lib/structures/GuildTextableChannel.js +260 -260
- package/lib/structures/Interaction.js +133 -133
- package/lib/structures/Invite.js +143 -143
- package/lib/structures/Lobby.js +108 -108
- package/lib/structures/LobbyMember.js +59 -59
- package/lib/structures/MediaChannel.js +216 -216
- package/lib/structures/Member.js +371 -371
- package/lib/structures/Message.js +708 -708
- package/lib/structures/ModalSubmitInteraction.js +478 -478
- package/lib/structures/NewsChannel.js +34 -34
- package/lib/structures/NewsThreadChannel.js +12 -12
- package/lib/structures/Permission.js +80 -80
- package/lib/structures/PermissionOverwrite.js +32 -32
- package/lib/structures/PingInteraction.js +39 -39
- package/lib/structures/PrivateThreadChannel.js +25 -25
- package/lib/structures/PublicThreadChannel.js +26 -26
- package/lib/structures/Role.js +163 -163
- package/lib/structures/SKU.js +80 -80
- package/lib/structures/SoundboardSound.js +79 -79
- package/lib/structures/StageChannel.js +59 -59
- package/lib/structures/StageInstance.js +55 -55
- package/lib/structures/Subscription.js +69 -69
- package/lib/structures/TextChannel.js +202 -202
- package/lib/structures/ThreadChannel.js +143 -143
- package/lib/structures/ThreadMember.js +59 -59
- package/lib/structures/UnavailableGuild.js +26 -26
- package/lib/structures/UnknownInteraction.js +502 -502
- package/lib/structures/User.js +296 -296
- package/lib/structures/VoiceChannel.js +166 -166
- package/lib/structures/VoiceState.js +84 -84
- package/lib/util/BrowserWebSocket.js +76 -76
- package/lib/util/Bucket.js +89 -89
- package/lib/util/Collection.js +202 -202
- package/lib/util/MultipartData.js +70 -70
- package/lib/util/Opus.js +33 -33
- package/lib/util/SequentialBucket.js +83 -83
- package/lib/util/emitDeprecation.js +26 -26
- package/lib/voice/Piper.js +300 -300
- package/lib/voice/SharedStream.js +238 -238
- package/lib/voice/VoiceConnection.js +1440 -1440
- package/lib/voice/VoiceConnectionManager.js +151 -151
- package/lib/voice/VoiceDataStream.js +22 -22
- package/lib/voice/streams/BaseTransformer.js +40 -40
- package/lib/voice/streams/DCAOpusTransformer.js +78 -78
- package/lib/voice/streams/FFmpegDuplex.js +192 -192
- package/lib/voice/streams/FFmpegOggTransformer.js +35 -35
- package/lib/voice/streams/FFmpegPCMTransformer.js +26 -26
- package/lib/voice/streams/OggOpusTransformer.js +108 -108
- package/lib/voice/streams/PCMOpusTransformer.js +61 -61
- package/lib/voice/streams/VolumeTransformer.js +50 -50
- package/lib/voice/streams/WebmOpusTransformer.js +258 -258
- package/package.json +83 -82
|
@@ -1,258 +1,258 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const BaseTransformer = require("./BaseTransformer");
|
|
4
|
-
|
|
5
|
-
// EBML VInt max value is (2 ^ 56 - 2), but JS only supports 2^53
|
|
6
|
-
// 45 = 53 - 8 - check before last 8 bytes
|
|
7
|
-
const MAX_SHIFTED_VINT = Math.pow(2, 45);
|
|
8
|
-
|
|
9
|
-
const STATE_CONTENT = 0;
|
|
10
|
-
const STATE_TAG = 1;
|
|
11
|
-
|
|
12
|
-
const TAG_TYPE_END = 0;
|
|
13
|
-
const TAG_TYPE_START = 1;
|
|
14
|
-
const TAG_TYPE_TAG = 2;
|
|
15
|
-
|
|
16
|
-
const TRACKTYPE_AUDIO = 2; // EBML spec: https://www.matroska.org/technical/specs/index.html#TrackType
|
|
17
|
-
|
|
18
|
-
class WebmOpusTransformer extends BaseTransformer {
|
|
19
|
-
constructor(options = {}) {
|
|
20
|
-
super(options);
|
|
21
|
-
|
|
22
|
-
this._tag_stack = [];
|
|
23
|
-
this._state = STATE_TAG;
|
|
24
|
-
this._total = 0;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
getVIntLength(buffer, index) {
|
|
28
|
-
let length = 1;
|
|
29
|
-
for (; length <= 8; ++length) {
|
|
30
|
-
if (buffer[index] & (1 << (8 - length))) {
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
if (length > 8) {
|
|
35
|
-
this.emit("debug", new Error(`VInt length ${length} | ${buffer.toString("hex", index, index + length)}`));
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
if (index + length > buffer.length) {
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
return length;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
process(type, info) {
|
|
45
|
-
if (type === TAG_TYPE_TAG) {
|
|
46
|
-
if (info.name === "SimpleBlock" && (info.data.readUInt8(0) & 0xF) === this.firstAudioTrack.TrackNumber) {
|
|
47
|
-
this.push(info.data.subarray(4));
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
if (info.name === "CodecPrivate") {
|
|
51
|
-
const head = info.data.toString("utf8", 0, 8);
|
|
52
|
-
if (head !== "OpusHead") {
|
|
53
|
-
this.emit("error", new Error("Invalid codec: " + head));
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
this.codecData = {
|
|
58
|
-
version: info.data.readUInt8(8),
|
|
59
|
-
channelCount: info.data.readUInt8(9),
|
|
60
|
-
preSkip: info.data.readUInt16LE(10),
|
|
61
|
-
inputSampleRate: info.data.readUInt32LE(12),
|
|
62
|
-
outputGain: info.data.readUInt16LE(16),
|
|
63
|
-
mappingFamily: info.data.readUInt8(18),
|
|
64
|
-
};
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (!this.firstAudioTrack) {
|
|
70
|
-
if (info.name === "TrackEntry") {
|
|
71
|
-
if (type === TAG_TYPE_START) {
|
|
72
|
-
this.parsingTrack = {};
|
|
73
|
-
} else if (type === TAG_TYPE_END) {
|
|
74
|
-
if (this.parsingTrack.TrackNumber && this.parsingTrack.TrackType === TRACKTYPE_AUDIO) {
|
|
75
|
-
this.firstAudioTrack = this.parsingTrack;
|
|
76
|
-
}
|
|
77
|
-
delete this.parsingTrack;
|
|
78
|
-
}
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
if (this.parsingTrack) {
|
|
82
|
-
if (info.name === "TrackNumber") {
|
|
83
|
-
this.parsingTrack.TrackNumber = info.data[0];
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
if (info.name === "TrackType") {
|
|
87
|
-
this.parsingTrack.TrackType = info.data[0];
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
if (type === TAG_TYPE_END && info.name === "Tracks") {
|
|
92
|
-
this.emit("error", new Error("No audio track"));
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
readContent(buffer) {
|
|
100
|
-
const tagObj = this._tag_stack[this._tag_stack.length - 1];
|
|
101
|
-
|
|
102
|
-
if (tagObj.type === "m") {
|
|
103
|
-
this.process(TAG_TYPE_START, tagObj);
|
|
104
|
-
this._state = STATE_TAG;
|
|
105
|
-
return true;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (buffer.length < buffer._index + tagObj.size) {
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
tagObj.data = buffer.subarray(buffer._index, buffer._index + tagObj.size);
|
|
113
|
-
buffer._index += tagObj.size;
|
|
114
|
-
this._total += tagObj.size;
|
|
115
|
-
this._state = STATE_TAG;
|
|
116
|
-
|
|
117
|
-
this._tag_stack.pop();
|
|
118
|
-
|
|
119
|
-
this.process(TAG_TYPE_TAG, tagObj);
|
|
120
|
-
|
|
121
|
-
while (this._tag_stack.length > 0) {
|
|
122
|
-
if (this._total < this._tag_stack[this._tag_stack.length - 1].end) {
|
|
123
|
-
break;
|
|
124
|
-
}
|
|
125
|
-
this.process(TAG_TYPE_END, this._tag_stack.pop());
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
return true;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
readTag(buffer) {
|
|
132
|
-
const tagSize = this.getVIntLength(buffer, buffer._index);
|
|
133
|
-
if (tagSize === null) {
|
|
134
|
-
return false;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const size = this.getVIntLength(buffer, buffer._index + tagSize);
|
|
138
|
-
if (size === null) {
|
|
139
|
-
return false;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const tagStr = buffer.toString("hex", buffer._index, buffer._index + tagSize);
|
|
143
|
-
|
|
144
|
-
const tagObj = {
|
|
145
|
-
type: "unknown",
|
|
146
|
-
name: "unknown",
|
|
147
|
-
end: this._total + tagSize,
|
|
148
|
-
};
|
|
149
|
-
if (schema[tagStr]) {
|
|
150
|
-
tagObj.type = schema[tagStr].type;
|
|
151
|
-
tagObj.name = schema[tagStr].name;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
buffer._index += tagSize;
|
|
155
|
-
|
|
156
|
-
let value = buffer[buffer._index] & (1 << (8 - size)) - 1;
|
|
157
|
-
for (let i = 1; i < size; ++i) {
|
|
158
|
-
if (i === 7 && value >= MAX_SHIFTED_VINT && buffer[buffer._index + 7] > 0) {
|
|
159
|
-
tagObj.end = -1; // Special livestreaming int 0x1FFFFFFFFFFFFFF
|
|
160
|
-
break;
|
|
161
|
-
}
|
|
162
|
-
value = (value << 8) + buffer[buffer._index + i];
|
|
163
|
-
}
|
|
164
|
-
if (tagObj.end !== -1) {
|
|
165
|
-
tagObj.end += value + size;
|
|
166
|
-
}
|
|
167
|
-
tagObj.size = value;
|
|
168
|
-
|
|
169
|
-
buffer._index += size;
|
|
170
|
-
this._total += tagSize + size;
|
|
171
|
-
this._state = STATE_CONTENT;
|
|
172
|
-
|
|
173
|
-
this._tag_stack.push(tagObj);
|
|
174
|
-
|
|
175
|
-
return true;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
_transform(chunk, enc, cb) {
|
|
179
|
-
if (this._remainder) {
|
|
180
|
-
chunk = Buffer.concat([this._remainder, chunk]);
|
|
181
|
-
this._remainder = null;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
chunk._index = 0;
|
|
185
|
-
|
|
186
|
-
while (chunk._index < chunk.length) {
|
|
187
|
-
if (this._state === STATE_TAG && !this.readTag(chunk)) {
|
|
188
|
-
break;
|
|
189
|
-
}
|
|
190
|
-
if (this._state === STATE_CONTENT && !this.readContent(chunk)) {
|
|
191
|
-
break;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
if (chunk._index < chunk.length) {
|
|
196
|
-
this._remainder = chunk.subarray(chunk._index);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
this.setTransformCB(cb);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
module.exports = WebmOpusTransformer;
|
|
204
|
-
|
|
205
|
-
const schema = {
|
|
206
|
-
"ae": {
|
|
207
|
-
name: "TrackEntry",
|
|
208
|
-
type: "m",
|
|
209
|
-
},
|
|
210
|
-
"d7": {
|
|
211
|
-
name: "TrackNumber",
|
|
212
|
-
type: "u",
|
|
213
|
-
},
|
|
214
|
-
"86": {
|
|
215
|
-
name: "CodecID",
|
|
216
|
-
type: "s",
|
|
217
|
-
},
|
|
218
|
-
"83": {
|
|
219
|
-
name: "TrackType",
|
|
220
|
-
type: "u",
|
|
221
|
-
},
|
|
222
|
-
"1654ae6b": {
|
|
223
|
-
name: "Tracks",
|
|
224
|
-
type: "m",
|
|
225
|
-
},
|
|
226
|
-
"63a2": {
|
|
227
|
-
name: "CodecPrivate",
|
|
228
|
-
type: "b",
|
|
229
|
-
},
|
|
230
|
-
"a3": {
|
|
231
|
-
name: "SimpleBlock",
|
|
232
|
-
type: "b",
|
|
233
|
-
},
|
|
234
|
-
"1a45dfa3": {
|
|
235
|
-
name: "EBML",
|
|
236
|
-
type: "m",
|
|
237
|
-
},
|
|
238
|
-
"18538067": {
|
|
239
|
-
name: "Segment",
|
|
240
|
-
type: "m",
|
|
241
|
-
},
|
|
242
|
-
"114d9b74": {
|
|
243
|
-
name: "SeekHead",
|
|
244
|
-
type: "m",
|
|
245
|
-
},
|
|
246
|
-
"1549a966": {
|
|
247
|
-
name: "Info",
|
|
248
|
-
type: "m",
|
|
249
|
-
},
|
|
250
|
-
"e1": {
|
|
251
|
-
name: "Audio",
|
|
252
|
-
type: "m",
|
|
253
|
-
},
|
|
254
|
-
"1f43b675": {
|
|
255
|
-
name: "Cluster",
|
|
256
|
-
type: "m",
|
|
257
|
-
},
|
|
258
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const BaseTransformer = require("./BaseTransformer");
|
|
4
|
+
|
|
5
|
+
// EBML VInt max value is (2 ^ 56 - 2), but JS only supports 2^53
|
|
6
|
+
// 45 = 53 - 8 - check before last 8 bytes
|
|
7
|
+
const MAX_SHIFTED_VINT = Math.pow(2, 45);
|
|
8
|
+
|
|
9
|
+
const STATE_CONTENT = 0;
|
|
10
|
+
const STATE_TAG = 1;
|
|
11
|
+
|
|
12
|
+
const TAG_TYPE_END = 0;
|
|
13
|
+
const TAG_TYPE_START = 1;
|
|
14
|
+
const TAG_TYPE_TAG = 2;
|
|
15
|
+
|
|
16
|
+
const TRACKTYPE_AUDIO = 2; // EBML spec: https://www.matroska.org/technical/specs/index.html#TrackType
|
|
17
|
+
|
|
18
|
+
class WebmOpusTransformer extends BaseTransformer {
|
|
19
|
+
constructor(options = {}) {
|
|
20
|
+
super(options);
|
|
21
|
+
|
|
22
|
+
this._tag_stack = [];
|
|
23
|
+
this._state = STATE_TAG;
|
|
24
|
+
this._total = 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
getVIntLength(buffer, index) {
|
|
28
|
+
let length = 1;
|
|
29
|
+
for (; length <= 8; ++length) {
|
|
30
|
+
if (buffer[index] & (1 << (8 - length))) {
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (length > 8) {
|
|
35
|
+
this.emit("debug", new Error(`VInt length ${length} | ${buffer.toString("hex", index, index + length)}`));
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
if (index + length > buffer.length) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
return length;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
process(type, info) {
|
|
45
|
+
if (type === TAG_TYPE_TAG) {
|
|
46
|
+
if (info.name === "SimpleBlock" && (info.data.readUInt8(0) & 0xF) === this.firstAudioTrack.TrackNumber) {
|
|
47
|
+
this.push(info.data.subarray(4));
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (info.name === "CodecPrivate") {
|
|
51
|
+
const head = info.data.toString("utf8", 0, 8);
|
|
52
|
+
if (head !== "OpusHead") {
|
|
53
|
+
this.emit("error", new Error("Invalid codec: " + head));
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
this.codecData = {
|
|
58
|
+
version: info.data.readUInt8(8),
|
|
59
|
+
channelCount: info.data.readUInt8(9),
|
|
60
|
+
preSkip: info.data.readUInt16LE(10),
|
|
61
|
+
inputSampleRate: info.data.readUInt32LE(12),
|
|
62
|
+
outputGain: info.data.readUInt16LE(16),
|
|
63
|
+
mappingFamily: info.data.readUInt8(18),
|
|
64
|
+
};
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (!this.firstAudioTrack) {
|
|
70
|
+
if (info.name === "TrackEntry") {
|
|
71
|
+
if (type === TAG_TYPE_START) {
|
|
72
|
+
this.parsingTrack = {};
|
|
73
|
+
} else if (type === TAG_TYPE_END) {
|
|
74
|
+
if (this.parsingTrack.TrackNumber && this.parsingTrack.TrackType === TRACKTYPE_AUDIO) {
|
|
75
|
+
this.firstAudioTrack = this.parsingTrack;
|
|
76
|
+
}
|
|
77
|
+
delete this.parsingTrack;
|
|
78
|
+
}
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (this.parsingTrack) {
|
|
82
|
+
if (info.name === "TrackNumber") {
|
|
83
|
+
this.parsingTrack.TrackNumber = info.data[0];
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (info.name === "TrackType") {
|
|
87
|
+
this.parsingTrack.TrackType = info.data[0];
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (type === TAG_TYPE_END && info.name === "Tracks") {
|
|
92
|
+
this.emit("error", new Error("No audio track"));
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
readContent(buffer) {
|
|
100
|
+
const tagObj = this._tag_stack[this._tag_stack.length - 1];
|
|
101
|
+
|
|
102
|
+
if (tagObj.type === "m") {
|
|
103
|
+
this.process(TAG_TYPE_START, tagObj);
|
|
104
|
+
this._state = STATE_TAG;
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (buffer.length < buffer._index + tagObj.size) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
tagObj.data = buffer.subarray(buffer._index, buffer._index + tagObj.size);
|
|
113
|
+
buffer._index += tagObj.size;
|
|
114
|
+
this._total += tagObj.size;
|
|
115
|
+
this._state = STATE_TAG;
|
|
116
|
+
|
|
117
|
+
this._tag_stack.pop();
|
|
118
|
+
|
|
119
|
+
this.process(TAG_TYPE_TAG, tagObj);
|
|
120
|
+
|
|
121
|
+
while (this._tag_stack.length > 0) {
|
|
122
|
+
if (this._total < this._tag_stack[this._tag_stack.length - 1].end) {
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
this.process(TAG_TYPE_END, this._tag_stack.pop());
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
readTag(buffer) {
|
|
132
|
+
const tagSize = this.getVIntLength(buffer, buffer._index);
|
|
133
|
+
if (tagSize === null) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const size = this.getVIntLength(buffer, buffer._index + tagSize);
|
|
138
|
+
if (size === null) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const tagStr = buffer.toString("hex", buffer._index, buffer._index + tagSize);
|
|
143
|
+
|
|
144
|
+
const tagObj = {
|
|
145
|
+
type: "unknown",
|
|
146
|
+
name: "unknown",
|
|
147
|
+
end: this._total + tagSize,
|
|
148
|
+
};
|
|
149
|
+
if (schema[tagStr]) {
|
|
150
|
+
tagObj.type = schema[tagStr].type;
|
|
151
|
+
tagObj.name = schema[tagStr].name;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
buffer._index += tagSize;
|
|
155
|
+
|
|
156
|
+
let value = buffer[buffer._index] & (1 << (8 - size)) - 1;
|
|
157
|
+
for (let i = 1; i < size; ++i) {
|
|
158
|
+
if (i === 7 && value >= MAX_SHIFTED_VINT && buffer[buffer._index + 7] > 0) {
|
|
159
|
+
tagObj.end = -1; // Special livestreaming int 0x1FFFFFFFFFFFFFF
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
value = (value << 8) + buffer[buffer._index + i];
|
|
163
|
+
}
|
|
164
|
+
if (tagObj.end !== -1) {
|
|
165
|
+
tagObj.end += value + size;
|
|
166
|
+
}
|
|
167
|
+
tagObj.size = value;
|
|
168
|
+
|
|
169
|
+
buffer._index += size;
|
|
170
|
+
this._total += tagSize + size;
|
|
171
|
+
this._state = STATE_CONTENT;
|
|
172
|
+
|
|
173
|
+
this._tag_stack.push(tagObj);
|
|
174
|
+
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
_transform(chunk, enc, cb) {
|
|
179
|
+
if (this._remainder) {
|
|
180
|
+
chunk = Buffer.concat([this._remainder, chunk]);
|
|
181
|
+
this._remainder = null;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
chunk._index = 0;
|
|
185
|
+
|
|
186
|
+
while (chunk._index < chunk.length) {
|
|
187
|
+
if (this._state === STATE_TAG && !this.readTag(chunk)) {
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
if (this._state === STATE_CONTENT && !this.readContent(chunk)) {
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (chunk._index < chunk.length) {
|
|
196
|
+
this._remainder = chunk.subarray(chunk._index);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
this.setTransformCB(cb);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
module.exports = WebmOpusTransformer;
|
|
204
|
+
|
|
205
|
+
const schema = {
|
|
206
|
+
"ae": {
|
|
207
|
+
name: "TrackEntry",
|
|
208
|
+
type: "m",
|
|
209
|
+
},
|
|
210
|
+
"d7": {
|
|
211
|
+
name: "TrackNumber",
|
|
212
|
+
type: "u",
|
|
213
|
+
},
|
|
214
|
+
"86": {
|
|
215
|
+
name: "CodecID",
|
|
216
|
+
type: "s",
|
|
217
|
+
},
|
|
218
|
+
"83": {
|
|
219
|
+
name: "TrackType",
|
|
220
|
+
type: "u",
|
|
221
|
+
},
|
|
222
|
+
"1654ae6b": {
|
|
223
|
+
name: "Tracks",
|
|
224
|
+
type: "m",
|
|
225
|
+
},
|
|
226
|
+
"63a2": {
|
|
227
|
+
name: "CodecPrivate",
|
|
228
|
+
type: "b",
|
|
229
|
+
},
|
|
230
|
+
"a3": {
|
|
231
|
+
name: "SimpleBlock",
|
|
232
|
+
type: "b",
|
|
233
|
+
},
|
|
234
|
+
"1a45dfa3": {
|
|
235
|
+
name: "EBML",
|
|
236
|
+
type: "m",
|
|
237
|
+
},
|
|
238
|
+
"18538067": {
|
|
239
|
+
name: "Segment",
|
|
240
|
+
type: "m",
|
|
241
|
+
},
|
|
242
|
+
"114d9b74": {
|
|
243
|
+
name: "SeekHead",
|
|
244
|
+
type: "m",
|
|
245
|
+
},
|
|
246
|
+
"1549a966": {
|
|
247
|
+
name: "Info",
|
|
248
|
+
type: "m",
|
|
249
|
+
},
|
|
250
|
+
"e1": {
|
|
251
|
+
name: "Audio",
|
|
252
|
+
type: "m",
|
|
253
|
+
},
|
|
254
|
+
"1f43b675": {
|
|
255
|
+
name: "Cluster",
|
|
256
|
+
type: "m",
|
|
257
|
+
},
|
|
258
|
+
};
|