mirror of
https://github.com/azlux/pymumble
synced 2024-11-23 22:06:10 +00:00
Compare commits
2 Commits
ac3b6dee0c
...
d37c4c721c
Author | SHA1 | Date | |
---|---|---|---|
d37c4c721c | |||
|
ae905fbac4 |
@ -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**. 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
|
### With pip
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@ 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
|
||||||
|
|
||||||
@ -108,7 +107,11 @@ 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
|
||||||
@ -211,6 +214,7 @@ 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
|
||||||
@ -296,6 +300,7 @@ 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:
|
||||||
@ -431,7 +436,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:
|
||||||
@ -466,6 +471,7 @@ 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):
|
||||||
@ -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)
|
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:
|
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,
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
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
|
||||||
|
|
||||||
@ -64,7 +63,11 @@ 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"""
|
||||||
|
Loading…
Reference in New Issue
Block a user