From da8c721f1c4b32ba5744df563d2b401a5a1a607b Mon Sep 17 00:00:00 2001 From: Dan <31395415+cakedan@users.noreply.github.com> Date: Thu, 14 Jun 2018 23:54:03 -0400 Subject: [PATCH] please pass --- disco/voice/client.py | 10 +++---- disco/voice/packets.py | 2 +- disco/voice/udp.py | 63 ++++++++++++++---------------------------- 3 files changed, 27 insertions(+), 48 deletions(-) diff --git a/disco/voice/client.py b/disco/voice/client.py index e7b0f64..1bf5aa0 100644 --- a/disco/voice/client.py +++ b/disco/voice/client.py @@ -18,7 +18,7 @@ from disco.voice.udp import AudioCodecs, PayloadTypes, UDPVoiceClient SpeakingCodes = Enum( NONE=0, VOICE=1 << 0, - SOUNDSHARE=1 << 1 + SOUNDSHARE=1 << 1, ) VoiceState = Enum( @@ -139,7 +139,7 @@ class VoiceClient(LoggingClass): self.send(VoiceOPCode.SPEAKING, { 'speaking': int(value), 'delay': delay, - 'ssrc': self.ssrc + 'ssrc': self.ssrc, }) def send(self, op, data): @@ -214,12 +214,12 @@ class VoiceClient(LoggingClass): 'address': ip, 'mode': self.mode, }, - 'codecs': codecs + 'codecs': codecs, }) self.send(VoiceOPCode.CLIENT_CONNECT, { 'audio_ssrc': self.ssrc, 'video_ssrc': 0, - 'rtx_ssrc': 0 + 'rtx_ssrc': 0, }) def on_voice_resumed(self, data): @@ -261,7 +261,7 @@ class VoiceClient(LoggingClass): payload = VoiceSpeaking( user_id=data['user_id'], speaking=(data['speaking'] & SpeakingCodes.VOICE.value), - soundshare=(data['speaking'] & SpeakingCodes.SOUNDSHARE.value) + soundshare=(data['speaking'] & SpeakingCodes.SOUNDSHARE.value), ) self.client.gw.events.emit('VoiceSpeaking', payload) diff --git a/disco/voice/packets.py b/disco/voice/packets.py index 567317d..fec6391 100644 --- a/disco/voice/packets.py +++ b/disco/voice/packets.py @@ -14,4 +14,4 @@ VoiceOPCode = Enum( CLIENT_CONNECT=12, CLIENT_DISCONNECT=13, CODECS=14, -) \ No newline at end of file +) diff --git a/disco/voice/udp.py b/disco/voice/udp.py index 0481081..6b7015e 100644 --- a/disco/voice/udp.py +++ b/disco/voice/udp.py @@ -23,46 +23,25 @@ MAX_SEQUENCE = 65535 RTP_HEADER_ONE_BYTE = (0xBE, 0xDE) -class RTPHeader(namedtuple('RTPHeader', ['version', 'padding', 'extension', 'csrc_count', 'marker', 'payload_type', 'sequence', 'timestamp', 'ssrc'])): - """ - RTP Packet's Header information - Attributes - --------- - version : integer - the RTP version the packet's using - padding : integer - is this RTP packet using padding - extension : integer - is this RTP packet using extension - csrc_count : integer - marker : integer - is this RTP packet having a marker - payload_type : integer - RTP packet's payload type, currently should only be OPUS data - sequence : integer - RTP packet's sequence - timestamp : integer - RTP packet's timestamp - ssrc : integer - RTP packet's SSRC, the person talking - """ - - -class VoiceData(namedtuple('VoiceData', ['data', 'user_id', 'payload_type', 'channel', 'rtp'])): - """ - Voice Data received from the UDP socket - Attributes - --------- - data : bytes - the decrypted data - user_id: snowflake - the id of the user who sent this data - payload_type : string - the payload's type, currently only 'opus' supported - channel : object?? - rtp : RTPHeader - the rtp packet's header data - """ +RTPHeader = namedtuple('RTPHeader', [ + 'version', + 'padding', + 'extension', + 'csrc_count', + 'marker', + 'payload_type', + 'sequence', + 'timestamp', + 'ssrc', +]) + +VoiceData = namedtuple('VoiceData', [ + 'data', + 'user_id', + 'payload_type', + 'channel', + 'rtp', +]) class UDPVoiceClient(LoggingClass): @@ -154,7 +133,7 @@ class UDPVoiceClient(LoggingClass): payload_type=second & 0x7F, sequence=sequence, timestamp=timestamp, - ssrc=ssrc + ssrc=ssrc, ) # Check if rtp version is 2 @@ -231,7 +210,7 @@ class UDPVoiceClient(LoggingClass): payload_type=payload_type.name, user_id=user_id, channel=self.vc.channel, - rtp=rtp + rtp=rtp, ) self.vc.client.gw.events.emit('VoiceData', payload)