1
0
mirror of https://github.com/azlux/pymumble synced 2024-11-23 13:56:26 +00:00

Compare commits

..

2 Commits

Author SHA1 Message Date
d37c4c721c
Allow usage of pymumble without libopus when receive_sound is off
Merge pull request #118 from raek/pymumble_py3
2021-11-01 23:28:51 +01:00
Rasmus Bondesson
ae905fbac4 Allow usage of pymumble without libopus when receive_sound is off 2021-10-24 20:36:02 +02:00
3 changed files with 20 additions and 11 deletions

View File

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

View File

@ -15,7 +15,6 @@ from . import blobs
from . import commands
from . import callbacks
from . import tools
from . import soundoutput
from . import mumble_pb2
@ -108,7 +107,11 @@ class Mumble(threading.Thread):
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.blobs = blobs.Blobs(self) # manage the blob objects
self.sound_output = soundoutput.SoundOutput(self, PYMUMBLE_AUDIO_PER_PACKET, self.bandwidth, stereo=self.stereo, opus_profile=self.__opus_profile) # manage the outgoing sounds
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
else:
self.sound_output = None
self.commands = commands.Commands() # manage commands sent between the main and the mumble threads
self.receive_buffer = bytes() # initialize the control connection input buffer
@ -211,7 +214,8 @@ class Mumble(threading.Thread):
while self.commands.is_cmd():
self.treat_command(self.commands.pop_cmd()) # send the commands coming from the application to the server
self.sound_output.send_audio() # send outgoing audio if available
if self.sound_output:
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
@ -296,7 +300,8 @@ class Mumble(threading.Thread):
"""Dispatch control messages based on their type"""
self.Log.debug("dispatch control message")
if type == PYMUMBLE_MSG_TYPES_UDPTUNNEL: # audio encapsulated in control message
self.sound_received(message)
if self.sound_output:
self.sound_received(message)
elif type == PYMUMBLE_MSG_TYPES_VERSION:
mess = mumble_pb2.Version()
@ -431,8 +436,8 @@ class Mumble(threading.Thread):
mess = mumble_pb2.CodecVersion()
mess.ParseFromString(message)
self.Log.debug("message: CodecVersion : %s", mess)
self.sound_output.set_default_codec(mess)
if self.sound_output:
self.sound_output.set_default_codec(mess)
elif type == PYMUMBLE_MSG_TYPES_USERSTATS:
mess = mumble_pb2.UserStats()
@ -466,7 +471,8 @@ class Mumble(threading.Thread):
else:
self.bandwidth = bandwidth
self.sound_output.set_bandwidth(self.bandwidth) # communicate the update to the outgoing audio manager
if self.sound_output:
self.sound_output.set_bandwidth(self.bandwidth) # communicate the update to the outgoing audio manager
def sound_received(self, message):
"""Manage a received sound message"""
@ -512,7 +518,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)
if size > 0 and self.receive_sound: # if audio must be treated
if size > 0:
try:
newsound = self.users[session.value].sound.add(message[pos:pos + size],
sequence.value,

View File

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