Browse Source

please pass

pull/101/head
Dan 7 years ago
parent
commit
da8c721f1c
  1. 10
      disco/voice/client.py
  2. 2
      disco/voice/packets.py
  3. 63
      disco/voice/udp.py

10
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)

2
disco/voice/packets.py

@ -14,4 +14,4 @@ VoiceOPCode = Enum(
CLIENT_CONNECT=12,
CLIENT_DISCONNECT=13,
CODECS=14,
)
)

63
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)

Loading…
Cancel
Save