Skip to content

Commit e5739a2

Browse files
authored
fix: Remove Extra Bytes Added By Discord Before OPUS Decoding (#2925)
* fix: Remove Extra Bytes Added By Discord Before OPUS Decoding * chore: Changelog
1 parent 02865fb commit e5739a2

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ These changes are available on the `master` branch, but have not yet been releas
4343
([#2916](https://github.com/Pycord-Development/pycord/pull/2916))
4444
- Fixed a crash when processing message edit events while message cache was disabled.
4545
([#2924](https://github.com/Pycord-Development/pycord/pull/2924))
46+
- Fixed OPUS Decode Error when recording audio.
47+
([#2925](https://github.com/Pycord-Development/pycord/pull/2925))
4648

4749
### Removed
4850

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)