Commit Graph

75 Commits

Author SHA1 Message Date
Kyle Simpson
f72175b799 Deps: Update dev-dependencies 2023-11-20 00:02:55 +00:00
Kyle Simpson
6a38fc82f4 Deps: Update Ringbuf, Serde-Aux, Simd-Json, Typemap 2023-11-20 00:02:55 +00:00
Kyle Simpson
646190eaf8 Deps: Update Twilight -> v0.14 2023-11-20 00:02:55 +00:00
Kyle Simpson
03b0803a1d Input: Fix audio stream selection for video files. (#150)
`youtube-dl` has a tendency to return mp4 files containing video and audio data vs `yt-dlp`. Naturally, the default stream in such cases will be the video data, so we fail to create a decoder.

This PR changes `LiveInput::promote` to first attempt to instantiate a decoder for the default track. If this fails to do so, then we reattempt this for all available tracks until one can be found. Previously, this method chose the default (or first available) track ID, and then failed if *that* track could not be decoded even if a compatible stream existed.

This was tested using `cargo make ready`, as well as manually verifying and adding a test case with a simple mp4 file.
2023-11-20 00:02:54 +00:00
Erk
372156e638 Deps: Update twilight to 0.13 (#147)
* update twilight to 0.13

* Update src/manager.rs

Co-authored-by: Kyle Simpson <kyleandrew.simpson@gmail.com>

Co-authored-by: Kyle Simpson <kyleandrew.simpson@gmail.com>
2023-11-20 00:02:54 +00:00
Kyle Simpson
48db45ffd8 Chore: Update xsalsa20poly1305 -> 0.9
A few extra error types needed adding and handling due to the new `KeyInit::new_from_slice` returning a non-exported error.
2023-11-20 00:02:54 +00:00
Kyle Simpson
2277595be4 Driver: Split receive into its own feature (#141)
Adds the "receive" feature, which is disabled by default. When this is disabled, the UDP receive task is not compiled and not run, and as an optimisation the UDP receive buffer size is set to 0. All related events are also removed.

This also removes the UDP Tx task, and moves packet and keepalive sends back into the mixer thread. This allows us to entirely remove channels and various allocations between the mixer and an async task created only for sending data (i.e., fewer memcopies).

If "receive" is enabled, UDP sends are now non-blocking due to technical constraints -- failure to send is non-fatal, but *will* drop affected packets. Given that blocking on a UDP send indicates that the OS cannot clear send buffers fast enough, this should alleviate OS load.

Closes #131.
2023-11-20 00:02:54 +00:00
Kyle Simpson
d8061d5029 Chore: Rework crate features (#139)
All dependencies have been moved to the new "dep:x" and "x?/feature" syntax to remove the bloat from the docs.rs/crates.io/lib.rs feature panes.

Accordingly, this lets us break "rustls" and "native" out from annoying hybrids like "serenity-rustls" or "twilight-native" -- specify your library and your backend, and it should just work.

The complete list of features is now: driver, gateway, serenity, twilight, rustls, native, builtin-queue, simd-json, internals (plus "default" and "full-doc").
2023-11-20 00:02:54 +00:00
Kyle Simpson
76c9851034 Driver: Migrate to tokio_tungstenite (#138)
This places songbird, serenity, and twilight onto the same WS library, hopefully reducing the compile overhead for everyone.

Tested using `cargo make ready` and by running `examples/voice`.

Closes #129.
2023-11-19 23:58:34 +00:00
Gnome!
0beb0f0d76 Input: lazy_static -> once_cell::sync::Lazy (#136) 2023-11-19 23:58:34 +00:00
Victoria Casasampere Fernandez
cb0a74f511 Support simd_json (#105)
This PR adds support for the simd-json library whenever decoding or encoding JSON responses. This may be enabled independently of serenity and twilight support for SIMD acceleration.

Co-authored-by: Kyle Simpson <kyleandrew.simpson@gmail.com>
2023-11-19 23:58:34 +00:00
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
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
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
tkt
67ad7c9e49 Deps: Bump streamcatcher version -> 1.0 (#93) 2022-07-22 15:41:18 +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
16acfd4ee1 Chore: Release v0.2.2 2022-02-13 19:25:52 +00:00
Kyle Simpson
00295bd3be Chore: Release v0.2.1 2022-01-05 10:40:10 +00: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
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
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
8381f8c461 Chore: Release v0.2.0-beta.3 2021-07-01 11:34:53 +01:00
Vilgot Fredenberg
d6d6acabe1 Deps: Bump twilight versions -> 0.5 (#79) 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
cdebf79f07 Deps: Bump DiscoRTP version -> 0.4
Simple enough, tested using `cargo make ready`.
2021-07-01 11:33:51 +01:00
Kyle Simpson
6a441ba2f9 Chore: Release v0.2.0-beta1 2021-07-01 11:33:51 +01:00
Kyle Simpson
6d66b499e5 Deps: Bump twilight versions -> 0.4 2021-07-01 11:33:12 +01:00
Kyle Simpson
94c57f4ab5 Deps: Bump xsalsa20poly1305 version -> 0.7
This dependency upgrade (at last) resolves the duplicated rand_core versions present in builds. This was tested using `cargo make ready`.
2021-07-01 11:30:02 +01:00
James Liu
bc9a78e050 Use symphonia::io::MediaSource for Reader extensions (#61)
This PR does the following:

 * Changes both `Reader::Extension` and `Reader::ExtensionSeek`  to use `symphonia::io::MediaSource`.
 * Removes the `File` and `Vec` variants of readers, instead opting to provide a `from_file` and `from_memory` associated function to create readers from the `File` and `Cursor<Vec<u8>>` implementations of `MediaSource`. 
 * Removes the ReadSeek trait.
 * Added a dependency on `symphonia_core`. This crate has no additional dependencies.
2021-07-01 11:30:02 +01:00
Kyle Simpson
0bb2572deb Chore: Adapt #60, #64 in line with other breaking changes.
This commit undoes #64 (and bumps the library MSRV accordingly), and modifies #60 to match the new `Call` connection handling.

This was tested using `cargo make ready`, and rustc v1.49.0 on `examples/serenity/voice`.
2021-07-01 11:30:01 +01:00
Kyle Simpson
1fc3dc2259 Gateway: Add connection timeout, add Config to gateway. (#51)
This change fixes tasks hanging due to rare cases of messages being lost between full Discord reconnections by placing a configurable timeout on the `ConnectionInfo` responses. This is a companion fix to [serenity#1255](https://github.com/serenity-rs/serenity/pull/1255). To make this doable, `Config`s are now used by all versions of `Songbird`/`Call`, and relevant functions are  added to simplify setup with configuration. These are now non-exhaustive, correcting an earlier oversight. For future extensibility, this PR moves the return type of `join`/`join_gateway` into a custom future (no longer leaking flume's `RecvFut` type).

Additionally, this fixes the Makefile's feature sets for driver/gateway-only compilation.

This is a breaking change in:
* the return types of `join`/`join_gateway`
* moving `crate::driver::Config` -> `crate::Config`,
* `Config` and `JoinError` becoming `#[non_breaking]`.

This was tested via `cargo make ready`, and by testing `examples/serenity/voice_receive` with various timeout settings.
2021-07-01 11:30:01 +01:00
Kyle Simpson
f449d4f679 Deps: Bump DiscoRTP version -> 0.3 (#52)
This change increases the version of DiscoRTP, which fixes upstream issues in libpnet and allows additional RTCP types to be added over time without breaking semver. This is a breaking change for users explicitly matching on RTCP packet types, as DiscoRTP is exposed here.

This has been tested using `cargo make ready`.
2021-07-01 11:30:01 +01:00
Kyle Simpson
ebff98e873 Release v0.1.8 2021-07-01 10:27:03 +01:00
Kyle Simpson
d01bef729d Release v0.1.7 2021-06-14 23:07:10 +01:00
Kyle Simpson
9e202f602d Release v0.1.6 2021-04-11 13:33:19 +01:00
Kyle Simpson
a88b185676 Deps: Prevent MSRV breakage via spinning_top (#64)
The upstream crate `spinning_top` used newer elements of rustc's std in a patch release, unknowingly bumping its MSRV to 1.49.0. This patch reverts to the older, compatible, version.

This has been tested by manually building `examples/serenity/voice` using rustc v1.48.0.

Closes #62.
2021-04-10 22:56:30 +01:00
Kyle Simpson
df64ad92e5 Release v0.1.5 2021-03-23 09:09:09 +00:00
Kyle Simpson
f230b41110 Deps: Update async-tungstenite -> 0.13 (#50)
Updates to the latest async-tungstenite version. This was tested by `cargo make ready` and by testing driver/gateway function via `examples/serenity/voice_storage`.
2021-03-23 08:22:38 +00:00