1
0
mirror of https://github.com/azlux/pymumble synced 2024-11-23 22:06:10 +00:00

Compare commits

..

No commits in common. "d37c4c721ce1ee0252e6126cd93c179c5684eadf" and "ac3b6dee0c35841b6513bce740c2fe47d70673c4" have entirely different histories.

3 changed files with 11 additions and 20 deletions

View File

@ -11,7 +11,7 @@ The wiki/API explanation is [HERE](https://github.com/azlux/pymumble/blob/pymumb
### Requirements ### Requirements
**`libopus` is a mandatory OS library when sending and receiving audio**. Please refer to your package manager to install it. **`libopus` is a mandatory OS library**. Please refer to your package manager to install it.
### With pip ### With pip

View File

@ -15,6 +15,7 @@ from . import blobs
from . import commands from . import commands
from . import callbacks from . import callbacks
from . import tools from . import tools
from . import soundoutput
from . import mumble_pb2 from . import mumble_pb2
@ -107,11 +108,7 @@ class Mumble(threading.Thread):
self.users = users.Users(self, self.callbacks) # contains the server's connected users information self.users = users.Users(self, self.callbacks) # contains the server's connected users information
self.channels = channels.Channels(self, self.callbacks) # contains the server's channels information self.channels = channels.Channels(self, self.callbacks) # contains the server's channels information
self.blobs = blobs.Blobs(self) # manage the blob objects self.blobs = blobs.Blobs(self) # manage the blob objects
if self.receive_sound:
from . import soundoutput
self.sound_output = soundoutput.SoundOutput(self, PYMUMBLE_AUDIO_PER_PACKET, self.bandwidth, stereo=self.stereo, opus_profile=self.__opus_profile) # manage the outgoing sounds self.sound_output = soundoutput.SoundOutput(self, PYMUMBLE_AUDIO_PER_PACKET, self.bandwidth, stereo=self.stereo, opus_profile=self.__opus_profile) # manage the outgoing sounds
else:
self.sound_output = None
self.commands = commands.Commands() # manage commands sent between the main and the mumble threads self.commands = commands.Commands() # manage commands sent between the main and the mumble threads
self.receive_buffer = bytes() # initialize the control connection input buffer self.receive_buffer = bytes() # initialize the control connection input buffer
@ -214,7 +211,6 @@ class Mumble(threading.Thread):
while self.commands.is_cmd(): while self.commands.is_cmd():
self.treat_command(self.commands.pop_cmd()) # send the commands coming from the application to the server self.treat_command(self.commands.pop_cmd()) # send the commands coming from the application to the server
if self.sound_output:
self.sound_output.send_audio() # send outgoing audio if available self.sound_output.send_audio() # send outgoing audio if available
(rlist, wlist, xlist) = select.select([self.control_socket], [], [self.control_socket], self.loop_rate) # wait for a socket activity (rlist, wlist, xlist) = select.select([self.control_socket], [], [self.control_socket], self.loop_rate) # wait for a socket activity
@ -300,7 +296,6 @@ class Mumble(threading.Thread):
"""Dispatch control messages based on their type""" """Dispatch control messages based on their type"""
self.Log.debug("dispatch control message") self.Log.debug("dispatch control message")
if type == PYMUMBLE_MSG_TYPES_UDPTUNNEL: # audio encapsulated in control message if type == PYMUMBLE_MSG_TYPES_UDPTUNNEL: # audio encapsulated in control message
if self.sound_output:
self.sound_received(message) self.sound_received(message)
elif type == PYMUMBLE_MSG_TYPES_VERSION: elif type == PYMUMBLE_MSG_TYPES_VERSION:
@ -436,7 +431,7 @@ class Mumble(threading.Thread):
mess = mumble_pb2.CodecVersion() mess = mumble_pb2.CodecVersion()
mess.ParseFromString(message) mess.ParseFromString(message)
self.Log.debug("message: CodecVersion : %s", mess) self.Log.debug("message: CodecVersion : %s", mess)
if self.sound_output:
self.sound_output.set_default_codec(mess) self.sound_output.set_default_codec(mess)
elif type == PYMUMBLE_MSG_TYPES_USERSTATS: elif type == PYMUMBLE_MSG_TYPES_USERSTATS:
@ -471,7 +466,6 @@ class Mumble(threading.Thread):
else: else:
self.bandwidth = bandwidth self.bandwidth = bandwidth
if self.sound_output:
self.sound_output.set_bandwidth(self.bandwidth) # communicate the update to the outgoing audio manager self.sound_output.set_bandwidth(self.bandwidth) # communicate the update to the outgoing audio manager
def sound_received(self, message): def sound_received(self, message):
@ -518,7 +512,7 @@ class Mumble(threading.Thread):
self.Log.debug("Audio frame : time:%f, last:%s, size:%i, type:%i, target:%i, pos:%i", time.time(), str(terminator), size, type, target, pos - 1) self.Log.debug("Audio frame : time:%f, last:%s, size:%i, type:%i, target:%i, pos:%i", time.time(), str(terminator), size, type, target, pos - 1)
if size > 0: if size > 0 and self.receive_sound: # if audio must be treated
try: try:
newsound = self.users[session.value].sound.add(message[pos:pos + size], newsound = self.users[session.value].sound.add(message[pos:pos + size],
sequence.value, sequence.value,

View File

@ -2,6 +2,7 @@
from .constants import * from .constants import *
from .errors import TextTooLongError, ImageTooBigError from .errors import TextTooLongError, ImageTooBigError
from threading import Lock from threading import Lock
from . import soundqueue
from . import messages from . import messages
from . import mumble_pb2 from . import mumble_pb2
@ -63,11 +64,7 @@ class User(dict):
self["channel_id"] = 0 self["channel_id"] = 0
self.update(message) self.update(message)
if mumble_object.receive_sound:
from . import soundqueue
self.sound = soundqueue.SoundQueue(self.mumble_object) # will hold this user incoming audio self.sound = soundqueue.SoundQueue(self.mumble_object) # will hold this user incoming audio
else:
self.sound = None
def update(self, message): def update(self, message):
"""Update user state, based on an incoming message""" """Update user state, based on an incoming message"""