99 Commits

Author SHA1 Message Date
Cryptex
06184dc25f Update lavalink's repo url 2021-05-01 10:28:28 -04:00
Nihaal Sangha
69bdc3a184
Change copyright year to present 2021-01-15 05:28:11 -05:00
Rapptz
52865dfa99 Clear the connected flag when potentially reconnecting the player
Fix #5953
2020-11-21 22:53:04 -05:00
Rapptz
b76b5b42c0 Fix attribute error during rapid disconnects in VoiceClient.
Fix #6039
2020-11-21 22:47:04 -05:00
Rapptz
21ed9f61d2 Fix disconnect when trying to move to another voice channel.
Not overly proud of this implementation but this allows the library
to differentiate between a 4014 that means "move to another channel" or
"move nowhere". Sometimes the VOICE_STATE_UPDATE comes before the
actual websocket disconnect so special care had to be taken in that
case.

Fix #5904
2020-10-17 22:01:57 -04:00
Rapptz
9036b9651b Properly handle disconnects in voice when force disconnected 2020-09-23 03:20:35 -04:00
Josh
9830e0ed8a Fix issues with VoiceProtocol docstrsings. 2020-09-23 03:20:35 -04:00
Rapptz
e3922e24d9 Correct some protocol errors in v4 of voice gateway 2020-09-23 03:20:35 -04:00
Rapptz
0b93fa3a82 Implement VoiceProtocol lower level hooks.
This allows changing the connect flow and taking control of it without
relying on internal events or tricks.
2020-09-23 03:20:35 -04:00
Rapptz
250f29989b Be defensive in case Discord breaks something with WS URLs again 2020-08-05 08:35:43 -04:00
Rapptz
a9824ffabf Fix endpoint strings with :443 instead of :80
Fix #5191
Close #5188
2020-08-05 04:21:27 -04:00
Tsumiki
5cbbbca193
Add versionadded to VoiceClient latency and average_latency 2020-06-26 22:57:32 -04:00
Jeffrey
4078d64520 Fix reconnecting loop due to failed handshake on region change 2020-06-22 04:00:40 -04:00
매리
ddfed5a610 Change _handshaking variable when handshake terminate 2020-05-23 21:56:40 -04:00
Fwf
fa34d357a1 Added VoiceClient.latency and VoiceClient.average_latency
This also implements the heartbeating a bit more consistent to the
official Discord client.
2020-04-04 03:00:27 -04:00
Rapptz
6071607176 Bump copyright year to 2020
Closes #2510
2020-01-19 20:03:00 -05:00
Matt Carey
bcbfc354cf Add support for xsalsa20_poly1305_lite 2019-12-17 00:11:40 -05:00
Imayhaveborkedit
839afce178 Print exception tracebacks in voice threads
Errors occurring within `AudioSource.read()` and `after()` functions will now display their tracebacks as if they were unhandled exceptions.
2019-11-26 05:16:53 -05:00
Rapptz
a6f61dcbde Fix all deprecation warnings for 3.8 2019-11-20 02:30:19 -05:00
Imayhaveborkedit
fedf26bf3e Add FFmpegOpusAudio and other voice improvements
Rework FFmpeg player and add FFmpegOpusAudio

I have extracted some of the base FFmpeg source code into its own
base class and reimplemented the PCM and the new Opus variants.

Support avconv probing

Also fix a few things

Update `__all__`

Fix the bugs

Rework probe functions and add factory function

Probing involves subprocess so it has been reworked into an async
factory function.

Add docs + a few tweaks

* Removed unnecessary read() and is_opus() functions from FFmpegAudio
* Clear self._stdout in cleanup()
* Add 20 second process communication timeout to probe functions
* Capped probe function bitrate values at 512

Change AudioPlayer to use more accurate, monotonic time.perf_counter()

Add lazy opus loading

The library now no longer loads libopus on import, only on
opus.Encoder creation or manually.

Fix review nits
2019-07-22 20:46:40 -04:00
NCPlayz
3c9bcc2851 Improve documentation 2019-06-07 19:27:46 -04:00
Rapptz
abb9c067cc Add log line to show if we disconnected normally. 2019-05-01 02:49:52 -04:00
Imayhaveborkedit
7eb8417883 Fix voice handshake race condition
In the event that two voice_server_updates are received in a short time frame, the second one is now ignored.
2019-04-10 00:55:52 -04:00
Daniel
3a36f78e08 Use is_connected() instead of _connected in checks
Was doing a falsy check on an Event object instead of using the (unused) is_connected() function.
2019-04-09 00:14:41 -04:00
Rapptz
78459f3ed0 Don't reconnect during 4014/4015 in voice websocket. 2019-03-05 19:45:13 -05:00
Imayhaveborkedit
9c5259afd7 Update voice code to vws V4
- Update internals to be compatible with v4
- Adds multiple encryption mode support.  Previously only `xsalsa20_poly1305` was supported.  Now `xsalsa20_poly1305_suffix` is also supported.
  Note: There is no (nice) way to manually select a mode.  The user needn't worry about this however.
- Fixed speaking state bug.  When you disconnected from a voice channel while a bot was playing, upon reconnect you would be unable to hear the bot.  This was caused by bots not sending their speaking state while transmitting.  Bots will now set their speaking state properly when transmitting.  
  Note: This does not account for sending actual silence, the speaking indicator will still be active.
2019-01-28 22:22:52 -05:00
Dante Dam
9656a21ebe Bumped copyright years to 2019. 2019-01-28 22:22:50 -05:00
Hornwitser
efb4ff850e [lint] Fix import order
Reorder imports to be consistenly grouped by standard library, third
party library, and local modules in that order thoughout the library.
2018-11-24 22:17:58 -05:00
Hornwitser
fa46b07db1 [lint] Rename exception variables to exc
Use the more explicit (and common) exc instead of e as the variable
holding the exception in except handlers.
2018-11-24 22:17:57 -05:00
Hornwitser
4ae8e81660 [lint] Remove redundant exception variables
Use bare raise statement when reraising the exception that occured, and
remove unused exception variables.  Also remove a pointless exception
handler in discord.opus.
2018-11-24 22:17:57 -05:00
Hornwitser
a71b3b5fa0 [lint] Limit unneccessarily broad except clauses
Add exception qualifier(s) to bare except clauses swallowing exceptions.
2018-11-24 22:17:57 -05:00
Rapptz
5c24e69cf2 Fix up the Sphinx strings causing warnings. 2018-09-15 09:54:00 -04:00
Hornwitser
119c5a0618 [lint] Remove unused variables
Left over from various refactoring and rewrites.
2018-08-22 21:43:51 -04:00
Rapptz
f25091efe1 Drop support for Python 3.4 and make minimum version 3.5.2. 2018-06-10 18:10:00 -04:00
Rapptz
a425bd91be Fix invalid close errors on websockets 4.x
Fixes #1110
2018-03-06 00:15:36 -05:00
Tobotimus
3112e1c17e Add intersphinx 2018-01-06 17:23:59 -05:00
Rapptz
305cc3acfa Clarify VoiceClient.disconnect docs a little more. 2017-09-16 13:29:36 -04:00
Rapptz
fe3b917564 Continue connection loop with back-off if connecting fails >5 times. 2017-07-25 20:00:00 -04:00
Rapptz
b06899e7d4 Defer logging formatting until the logger is actually called.
This would cause unnecessary format calls even if you didn't have
logging enabled.
2017-06-09 18:53:24 -04:00
Rapptz
64d09f3720 Force disconnect in abc.Connectable.connect.
Some cases of is_connected is not set so we need to force it to clear
it anyway.
2017-05-13 16:01:32 -04:00
Rapptz
b44bba6ee6 First pass at documentation reform. 2017-05-12 20:14:34 -04:00
Rapptz
663315f7ac Explicitly close UDP sockets when re-creating them.
This does not actually make a big difference since the GC should
technically close them when needed but might as well be more explicit.
2017-05-02 20:25:54 -04:00
Rapptz
f5cfc96aaf Add PCMVolumeTransformer to augment volume of a PCM stream.
This also introduces the idea of replacing the VoiceClient.source on
the fly. Note that this internally pauses and resumes the audio
stream.
2017-04-19 17:23:39 -04:00
Rapptz
07d5328873 Add VoiceClient.is_paused to query pause state. 2017-04-19 16:06:45 -04:00
Rapptz
55e63ed87f Add VoiceClient.source to get the AudioSource being played. 2017-04-19 01:19:39 -04:00
Rapptz
aa32c384ea Clean cache when TimeoutError occurs. 2017-04-18 20:13:34 -04:00
Rapptz
f9c2ac9d25 Better handling of VOICE_SERVER_UPDATE.
This now sort of respects "Awaiting Endpoint..." waiting. I haven't
actually tested out this case since it's hard to get it. However this
new code does work with the regular connection flow.
2017-04-18 19:05:34 -04:00
Rapptz
3b1b26ffb1 Re-implement voice sending.
This is a complete redesign of the old voice code.

A list of major changes is as follows:

* The voice websocket will now automatically reconnect with
  exponential back-off just like the regular Client does.
* Removal of the stream player concept.
* Audio now gracefully pauses and resumes when a disconnect is found.
* Introduce a discord.AudioSource concept to abstract streams
* Flatten previous stream player functionality with the
  VoiceClient, e.g. player.stop() is now voice_client.stop()
* With the above re-coupling this means you no longer have to
  store players anywhere.
* The after function now requires a single parameter, the error,
  if any existed. This will typically be None.

A lot of this design is experimental.
2017-04-18 03:49:48 -04:00
Rapptz
132ac45010 Ensure after is called inside the daemon thread for players. 2017-02-14 02:10:07 -05:00
Rapptz
ff9f5749e1 Update copyright year to 2017. 2017-01-20 23:19:19 -05:00