aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Repinski <[email protected]>2017-01-02 15:32:42 -0600
committerRapptz <[email protected]>2017-01-03 09:51:14 -0500
commit643950abf844c2caac74642fdab45e8704bee915 (patch)
treebbf5b13117bc6eeaab62f18b38f38c0845d44b43
parent[commands] Bugfix on the teardown function call. (diff)
downloaddiscord.py-643950abf844c2caac74642fdab45e8704bee915.tar.xz
discord.py-643950abf844c2caac74642fdab45e8704bee915.zip
Add ability to set opus encoder input signal type.
-rw-r--r--discord/opus.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/discord/opus.py b/discord/opus.py
index a5f81486..5869599f 100644
--- a/discord/opus.py
+++ b/discord/opus.py
@@ -166,6 +166,7 @@ CTL_SET_BITRATE = 4002
CTL_SET_BANDWIDTH = 4008
CTL_SET_FEC = 4012
CTL_SET_PLP = 4014
+CTL_SET_SIGNAL = 4024
band_ctl = {
'narrow': 1101,
@@ -175,6 +176,12 @@ band_ctl = {
'full': 1105,
}
+signal_ctl = {
+ 'auto': -1000,
+ 'voice': 3001,
+ 'music': 3002,
+}
+
class Encoder:
def __init__(self, sampling, channels, application=APPLICATION_AUDIO):
self.sampling_rate = sampling
@@ -194,6 +201,7 @@ class Encoder:
self.set_fec(True)
self.set_expected_packet_loss_percent(0.15)
self.set_bandwidth('full')
+ self.set_signal_type('auto')
def __del__(self):
if hasattr(self, '_state'):
@@ -231,6 +239,17 @@ class Encoder:
log.info('error has happened in set_bandwidth')
raise OpusError(ret)
+ def set_signal_type(self, req):
+ if req not in signal_ctl:
+ raise KeyError('%r is not a valid signal setting. Try one of: %s' % (req, ','.join(signal_ctl)))
+
+ k = signal_ctl[req]
+ ret = _lib.opus_encoder_ctl(self._state, CTL_SET_SIGNAL, k)
+
+ if ret < 0:
+ log.info('error has happened in set_signal_type')
+ raise OpusError(ret)
+
def set_fec(self, enabled=True):
ret = _lib.opus_encoder_ctl(self._state, CTL_SET_FEC, 1 if enabled else 0)