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
- 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.
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.