Commit Graph

143 Commits

Author SHA1 Message Date
Kyle Simpson
8cc7a22b0b Driver/Input: Migrate audio backend to Symphonia (#89)
This extensive PR rewrites the internal mixing logic of the driver to use symphonia for parsing and decoding audio data, and rubato to resample audio. Existing logic to decode DCA and Opus formats/data have been reworked as plugins for symphonia. The main benefit is that we no longer need to keep yt-dlp and ffmpeg processes alive, saving a lot of memory and CPU: all decoding can be done in Rust! In exchange, we now need to do a lot of the HTTP handling and resumption ourselves, but this is still a huge net positive.

`Input`s have been completely reworked such that all default (non-cached) sources are lazy by default, and are no longer covered by a special-case `Restartable`. These now span a gamut from a `Compose` (lazy), to a live source, to a fully `Parsed` source. As mixing is still sync, this includes adapters for `AsyncRead`/`AsyncSeek`, and HTTP streams.

`Track`s have been reworked so that they only contain initialisation state for each track. `TrackHandles` are only created once a `Track`/`Input` has been handed over to the driver, replacing `create_player` and related functions. `TrackHandle::action` now acts on a `View` of (im)mutable state, and can request seeks/readying via `Action`.

Per-track event handling has also been improved -- we can now determine and propagate the reason behind individual track errors due to the new backend. Some `TrackHandle` commands (seek etc.) benefit from this, and now use internal callbacks to signal completion.

Due to associated PRs on felixmcfelix/songbird from avid testers, this includes general clippy tweaks, API additions, and other repo-wide cleanup. Thanks go out to the below co-authors.

Co-authored-by: Gnome! <45660393+GnomedDev@users.noreply.github.com>
Co-authored-by: Alakh <36898190+alakhpc@users.noreply.github.com>
2023-11-19 23:58:34 +00:00
Kyle Simpson
6c6ffa7ca8 Chore: Release v0.3 2022-07-22 16:11:12 +01:00
Kyle Simpson
865c75f3c3 Chore: Update to twilight 0.12 2022-07-22 15:41:18 +01:00
Kyle Simpson
a85a1f08e1 Chore: Update to serenity 0.11 2022-07-22 15:41:18 +01:00
Erk
69339e8d45 Update twilight support to twilight 0.11 (#132)
* update twilight support to twilight 0.11

* rustfmt
2022-07-22 15:41:18 +01:00
Kyle Simpson
4eb95d4b59 Deps: Update to Audiopus v0.3.0-rc.0 (#125)
Tested using `cargo make ready`.

Co-authored-by: André Vennberg <andre.vennberg@gmail.com>
2022-07-22 15:41:18 +01:00
Kyle Simpson
d3a40fe691 Examples: support new Serenity Intents init
Fixes up the serenity examples to account for a bunch of API changes on `next`/v0.11.

Tested using `cargo make ready`.
2022-07-22 15:41:18 +01:00
Gnome!
e3476e7965 Driver: Remove spin_sleep in Mixer::march_deadline (#124)
* Remove spin_sleep

* Remove comment
2022-07-22 15:41:18 +01:00
Gnome!
98f0d025c0 Deps: Bump dependencies and document bumped MSRV (#119)
* Bump dependencies

* Document bumped MSRV
2022-07-22 15:41:18 +01:00
Gnome!
f2cd8a0b6a Driver, Gateway: Remove tokio 0.2 support (#118)
* Remove tokio 0.2 compat
* Remove tokio 0.2 test
* Remove tokio 0.2 CI
2022-07-22 15:41:18 +01:00
Kyle Simpson
fac6664072 Gateway: Twilight v0.10 support (#117) 2022-07-22 15:41:18 +01:00
Jan
bacf681465 driver, queue: return track handle when adding an Input to the queue (#116) 2022-07-22 15:41:18 +01:00
Kyle Simpson
ac20764157 Events: Remove deprecated events. (#115)
This removes the `ClientConnect`, `DriverConnectFailed`, `DriverReconnectFailed` and `SsrcKnown` events.

Tested using `cargo make ready`.
2022-07-22 15:41:18 +01:00
Kyle Simpson
0730a00dc7 Gateway: Twilight v0.9 support (#110)
This handles twilight's migration to a unified `Id` type, which is the only design change needing any handling on our part. All our `From`/`Into`s are covered now, and deprecated type aliases are no longer used.

This was tested using `cargo make ready` and by manually running "examples/twilight".
2022-07-22 15:41:18 +01:00
Kyle Simpson
b4ce84546b Gateway: Generic Shard and Twilight v0.8 Support (#109)
This PR adds support for twilight v0.8, mainly adapting to significant API changes introduced by v0.7. As a result of these, twilight no longer accepts arbitrary JSON input, so it seemed sensible to adapt our `Shard` design to no longer require the same.

Adding to this, I've added in a trait to allow an arbitrary `Shard` to be installed, given only an implementation of a method to send a `VoiceStateUpdate`. Together, `Sharder::Generic` (songbird::shards::VoiceUpdate) and `Shard::Generic` (songbird::shards::GenericSharder) should allow any library to be hooked in to Songbird.

This PR was tested using `cargo make ready` and by manually testing `examples/twilight`.
2022-07-22 15:41:18 +01:00
Kyle Simpson
12c76a9046 Gateway: Remove lifetime from Serenity setup trait (#103)
This matches a recent serenity change where `ClientBuilder` no longer has an explicit lifetime parameter.

This was tested using `cargo make ready`.
2022-07-22 15:41:18 +01:00
Kyle Simpson
8dedf3bf01 Gateway: Add generics to Call methods. (#102)
Adds generics to any `Id` types on `Call`. Also includes the overlooked `Songbird::get_or_insert`.

Closes #94. Tested using `cargo make ready`.
2022-07-22 15:41:18 +01:00
Kyle Simpson
f1ed41ea28 Examples: Fix serenity-next cache accesses (#99)
Serenity's cache design has changed, this (finally) prevents the examples from failing to compile on CI.
2022-07-22 15:41:18 +01:00
tkt
67ad7c9e49 Deps: Bump streamcatcher version -> 1.0 (#93) 2022-07-22 15:41:18 +01:00
Sam W
f9b7e76bb1 Chore: Update link to lavalink-basic-bot.rs (#135)
Update the link to lavalink-basic-bot.rs in the twilight example.
2022-07-17 22:31:44 +01:00
Kyle Simpson
8791805804 Driver: Prevent panic when decrypting undersized RTP packets (#122)
Decrypt logic had two locations where the nonce would be separated from the payload without verifying the buffer size first, causing a panic for small packets.

Nonce and header removal now return an error if there are insufficient bytes.

Tested using `cargo make ready`, with some new tests to check that small packets simply return an `Err(...)`, and that encryption/decryption still function.
2022-04-19 11:16:47 +01:00
Kyle Simpson
312457eb74 Chore: Pin flume version to prevent MSRV breakage.
Flume's latest patch version requires toe new Rust 2021 edition, which is at odds with the current MSRV. This was tested using `cargo msrv` on the default feature set.
2022-04-02 17:31:35 +01:00
Kyle Simpson
05c6762228 Chore: Bump MSRV to 1.51.0
This bump must occur due to a patch update for Rustls which has (unfortunately) broken MSRV.
2022-03-21 13:39:47 +00:00
Kyle Simpson
806a422a2e Events: Document format of VoiceData. (#114)
Closes #100.
2022-02-14 15:00:57 +00:00
Kyle Simpson
16acfd4ee1 Chore: Release v0.2.2 2022-02-13 19:25:52 +00:00
Kyle Simpson
652ec1f293 Docs: fix ClientConnect to recommend SpeakingStateUpdate 2022-02-13 18:53:33 +00:00
Kyle Simpson
c464fcc38d Events: Deprecate ClientConnect (#112)
Discord no longer send these websocket payloads, users should instead rely on the main part of their bot for determining actual connection events, or `SpeakingUpdate`s for SSRC mapping.

Closes #104.
2022-02-13 12:06:50 +00:00
Ryo Takahashi
2feadc761e Chore: Fix typo in CHANGELOG.md (#111) 2022-01-26 21:48:07 +00:00
Miles Frankel
ecc47d588a Input: add ChildContainer::new (#108) 2022-01-12 10:58:59 +00:00
Kyle Simpson
00295bd3be Chore: Release v0.2.1 2022-01-05 10:40:10 +00:00
Lunarmagpie
73323e58dd Docs: added documentation for yt-dlp feature (#106)
* Docs: added documentation for yt-dlp feature
* Docs: remove trailing whitespace
2022-01-04 13:45:39 +00:00
Luukas Pörtfors
62ecfe68d6 Examples: Fix unmatched quotation mark in comment. (#101) 2021-10-18 10:59:57 +01:00
Miezhiko
6fcb196e34 Input: Allows yt-dlp usage as another youtube-dl fork (#90)
Signed-off-by: Miezhiko <Miezhiko@gmail.com>
2021-10-10 20:56:32 +01:00
Kyle Simpson
e25cc140b8 Events: fix handling of multiple timed events on a single track (#96)
Fixes an issue where the `EventData` were not stored in reverse order, meaning that only the last added TimedEvent would be serviced.

This reverses the `Ord` for `EventData`, which should only be internally compared, allowing all timed events to be processed correctly in order.

Fixes #95.
2021-09-29 09:51:39 +01:00
Kyle Simpson
562723f4b1 Chore: Release v0.2.0 2021-08-17 14:09:13 +01:00
Kyle Simpson
47e20d6177 Deps: Bump async-tungstenite version -> 0.14 2021-08-17 14:01:32 +01:00
Kyle Simpson
dad48ca835 Driver: Fix incorrect leave behaviour in Drop handler
Sending poison messages should suffice to kill the voice session: attempting to `.leave()`. Fixes #88.

This was tested using `cargo make ready` and the modified `serenity/voice/` example.
2021-08-17 12:14:50 +01:00
Kyle Simpson
3efe756ca5 Chore: Update Lavalink URLs
Author's GitHub page had changed. Closes #86.
2021-08-17 11:41:52 +01:00
Vilgot Fredenberg
1b0bcbb5f6 Deps: Bump twilight versions -> [0.5, 0.7) (#87)
Includes two more small changes too small to warrant PRs.
1. Removes the `shard_count` parameter from `Songbird::twilight` & `Songbird::twilight_from_config` since the cluster contains it.
2. Drops the `Arc` wrapper around `Songbird` to match against an upcoming twilight 0.7 change
2021-08-16 20:31:27 +01:00
Kyle Simpson
54e75bdc28 Release v0.2.0-beta.4 2021-07-01 12:17:22 +01:00
Kyle Simpson
338a042343 Fix: Update Benchmark Imports 2021-07-01 11:55:40 +01:00
Vilgot Fredenberg
91d7542593 Tracks: Remove box around TrackState (#84)
Boxing is unnecessary since `TrackState` implements copy.

Tested using `cargo make ready`.
2021-07-01 11:55:35 +01:00
Kyle Simpson
210e3ae584 Driver: Automate (re)connection logic (#81)
This PR adds several enhancements to Driver connection logic:
* Driver (re)connection attempts now have a default timeout of around 10s.
* The driver will now attempt to retry full connection attempts using a user-provided strategy: currently, this defaults to 5 attempts under an exponential backoff strategy.
* The driver will now fire `DriverDisconnect` events at the end of any session -- this unifies (re)connection failure events with session expiry as seen in #76, which should provide users with enough detail to know *which* voice channel to reconnect to. Users still need to be careful to read the session/channel IDs to ensure that they aren't overwriting another join.

This has been tested using `cargo make ready`, and by setting low timeouts to force failures in the voice receive example (with some additional error handlers).

Closes #68.
2021-07-01 11:55:31 +01:00
Kyle Simpson
8381f8c461 Chore: Release v0.2.0-beta.3 2021-07-01 11:34:53 +01:00
Kyle Simpson
be3030932e Chore: Clippy fixes for new lints 2021-07-01 11:34:30 +01:00
Vilgot Fredenberg
d6d6acabe1 Deps: Bump twilight versions -> 0.5 (#79) 2021-07-01 11:34:30 +01:00
Vilgot Fredenberg
00c8bc915a Input: Add separate YouTube title and channel to Metadata (#75) 2021-07-01 11:34:30 +01:00
Kyle Simpson
e47861c009 Chore: Release v0.2.0-beta.2 2021-07-01 11:34:30 +01:00
Vilgot Fredenberg
55e1567b90 Input, Driver: Make error messages more idiomatic (#74) 2021-07-01 11:33:51 +01:00
Kyle Simpson
3e0793644f Chore: Rewrite update pathway.
I had written this out before, but evidently it was lost somehow. This should fill in most of what was lost.
2021-07-01 11:33:51 +01:00