mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
backporting the fix for RTP header extensions (#2185)
This commit is contained in:
@@ -161,6 +161,25 @@ class VoiceReceiver extends EventEmitter {
|
||||
return;
|
||||
}
|
||||
data = Buffer.from(data);
|
||||
|
||||
// Strip RTP Header Extensions (one-byte only)
|
||||
if (data[0] === 0xBE && data[1] === 0xDE && data.length > 4) {
|
||||
const headerExtensionLength = data.readUInt16BE(2);
|
||||
let offset = 4;
|
||||
for (let i = 0; i < headerExtensionLength; i++) {
|
||||
const byte = data[offset];
|
||||
offset++;
|
||||
if (byte === 0) {
|
||||
continue;
|
||||
}
|
||||
offset += 1 + (0b1111 & (byte >> 4));
|
||||
}
|
||||
while (data[offset] === 0) {
|
||||
offset++;
|
||||
}
|
||||
data = data.slice(offset);
|
||||
}
|
||||
|
||||
if (this.opusStreams.get(user.id)) this.opusStreams.get(user.id)._push(data);
|
||||
/**
|
||||
* Emitted whenever voice data is received from the voice connection. This is _always_ emitted (unlike PCM).
|
||||
|
||||
Reference in New Issue
Block a user