Skip to content

Commit

Permalink
fix(VoiceReceiver): parsePacket correctly (#8277)
Browse files Browse the repository at this point in the history
  • Loading branch information
cm-ayf committed Jul 17, 2022
1 parent 32f9056 commit 1a6ddbb
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions packages/voice/src/receive/VoiceReceiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,20 +130,9 @@ export class VoiceReceiver {
if (!packet) return;

// Strip RTP Header Extensions (one-byte only)
if (packet[0] === 0xbe && packet[1] === 0xde && packet.length > 4) {
if (packet[0] === 0xbe && packet[1] === 0xde) {
const headerExtensionLength = packet.readUInt16BE(2);
let offset = 4;
for (let i = 0; i < headerExtensionLength; i++) {
const byte = packet[offset]!;
offset++;
if (byte === 0) continue;
offset += 1 + (byte >> 4);
}
// Skip over undocumented Discord byte (if present)
const byte = packet.readUInt8(offset);
if (byte === 0x00 || byte === 0x02) offset++;

packet = packet.slice(offset);
packet = packet.subarray(4 + 4 * headerExtensionLength);
}

return packet;
Expand Down

0 comments on commit 1a6ddbb

Please sign in to comment.