mirror of
https://github.com/danbulant/discord.js
synced 2026-06-08 01:01:30 +00:00
backporting the fix for RTP header extensions (#2185)
This commit is contained in:
parent
6683c40a6f
commit
fc5d4438f8
1 changed files with 19 additions and 0 deletions
|
|
@ -161,6 +161,25 @@ class VoiceReceiver extends EventEmitter {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
data = Buffer.from(data);
|
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);
|
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).
|
* Emitted whenever voice data is received from the voice connection. This is _always_ emitted (unlike PCM).
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue