Skip to content

Commit b581e79

Browse files
committed
fix: Remove Extra Bytes Added By Discord Before OPUS Decoding
1 parent 3b8b79f commit b581e79

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

discord/voice_client.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -652,9 +652,10 @@ def _decrypt_aead_xchacha20_poly1305_rtpsize(self, header, data):
652652
nonce[:4] = data[-4:]
653653
data = data[:-4]
654654

655-
return self.strip_header_ext(
656-
box.decrypt(bytes(data), bytes(header), bytes(nonce))
657-
)
655+
r = box.decrypt(bytes(data), bytes(header), bytes(nonce))
656+
# Discord adds 8 bytes of data before the opus data.
657+
# This can be removed, and at this time, discarded as it is unclear what they are for.
658+
return r[8:]
658659

659660
@staticmethod
660661
def strip_header_ext(data):
@@ -774,7 +775,7 @@ def unpack_audio(self, data):
774775
data: :class:`bytes`
775776
Bytes received by Discord via the UDP connection used for sending and receiving voice data.
776777
"""
777-
if data[1] != 0x78:
778+
if data[1] & 0x78 != 0x78:
778779
# We Should Ignore Any Payload Types We Do Not Understand
779780
# Ref RFC 3550 5.1 payload type
780781
# At Some Point We Noted That We Should Ignore Only Types 200 - 204 inclusive.

0 commit comments

Comments
 (0)