Commit Graph

258 Commits

Author SHA1 Message Date
Gnome!
9a244ba4c2 Update to DashMap 6 (#253) 2025-02-21 12:41:44 +00:00
Gnome!
e9b2243b83 Bump dependencies (#237) 2025-02-21 12:41:44 +00:00
Carson M
3bc132faaf Chore: Update tokio-websockets to v0.7 (#229) 2025-02-21 12:41:44 +00:00
Erk
c81f2a9578 Remove Simd-json (#228)
This mirrors the serenity pr https://github.com/serenity-rs/serenity/pull/2735.
2025-02-21 12:40:49 +00:00
Carson M
c4331c451f Driver: Support tokio-websockets (#226)
* Driver: Support `tokio-websockets`

* Fix bad feature flag

* Fix CI & examples features

* Use tungstenite in twilight example

* Error if none or both ws features are enabled

* Match `twilight-gateway` features
2025-02-21 12:40:49 +00:00
Gnome!
0d6a226910 Tracks: Replace RwLock<TypeMap> data store with Arc<dyn Any> (#219) 2025-02-21 12:40:49 +00:00
Gnome!
2bcc5223fe Allow borrowed strings for YoutubeDl (#215) 2025-02-21 12:40:49 +00:00
Gnome!
743a1d262e Deps: Replace OnceCell with std::sync::OnceLock (#207) 2025-02-21 12:40:49 +00:00
Kyle Simpson
2146846df4 Chore: Release v0.4.6 2024-12-04 09:54:53 +00:00
Jude Southworth
651d037a54 Fix: Clear track_handles when SetTrack heard (#270)
Clear `track_handles` when `SetTrack` heard, to prevent an issue where
indices of `tracks` become desynced with those of `track_handles`.

Closes #232.
2024-12-04 09:32:25 +00:00
Kyle Simpson
17993bc0d0 Fix: pass mid-connection WS events to task (#269)
Discord will send `GatewayEvent::Speaking` (opcode 5) messages
after the Hello+Ready exchange, but will happily interleave
them with crypto mode negotiation. We were previously not expecting
such messages and dropping them -- this hurts receive-based bots'
ability to map SSRCs to UserIds when joining a call with existing
users.

This PR feeds all unexpected messages into the WS task directly,
which will handle them once all tasks are fully started.
2024-11-26 00:51:52 +00:00
Gilles Henaux
71535c5e87 Input: accept additional user arguments for yt-dlp (#268)
This PR makes it possible to give additional user-specified arguments to spawned yt-dlp processes.
2024-11-24 22:43:27 +00:00
Kyle Simpson
fe46da6b0d Chore: Release v0.4.5 2024-11-22 13:28:24 +00:00
Kyle Simpson
af95296ee1 Receive: Fix handling for large timestamp/sequence jumps (#266)
This PR addresses some issues which have cropped up on voice receive at scale:

* In unknown circumstances, we can be left with adjacent packets queued which have very different timestamps. The playout buffer would withhold its held packets, leading to the loss of many subsequent packets if the timestamp jump is larger than 64 frames. This seems to occur for some specific clients which join before a bot, suggesting the DAVE -> legacy switchover is involved.
* Some loss patterns can leave us unable to correctly track the next expected sequence number (i.e., large loss runs), leaving the playout buffer unable to accept any packets if the packet sequence differed by over 64 entries.

The fixes are fallbacks which treat sufficiently large desynchronisation, and allow the playout to get back into a consistent state in both cases. Large timestamp jumps on adjacent packets now update the next expected TS (noting that we only want to withhold a few playout delays at most ). Failure to insert 0.25s of packets (or attempting to add a new sequence number into an empty buffer) can now take precedence.

Closes #261.
2024-11-22 12:52:11 +00:00
Kyle Simpson
91bf1538fc Receive: Config of decode sample rate/channels (#265)
* Receive: Config of decode sample rate/channels

This PR allows for dynamic configuration of the output sample rate and
channel count of received Opus audio. Users who rely on supported
formats should no longer need to manually resample & downmix audio
decoded from SSRCs in a call.

Opus exposes tuples of (Mono, Stereo) x (8, 12, 16, 24, 48)kHz.
Changing this at runtime (mid-call) may cause some audio glitches, as
decoder state must be reconstructed from scratch for all affected SSRCs.

* Fix doc typo, consistent naming with MixMode.
2024-11-16 11:57:52 +00:00
Erk
312799d231 fix(source): HLS would not work if used directly. (#262)
This changes HlsRequest to return true in
Compose::should_create_async.

This would otherwise cause it to be spawned on a thread without a
executor causing it to panic.

This would only cause issues if used directly since we otherwise use
Compose::create in a context where we have access to the executor.
2024-11-15 05:47:06 +01:00
Kyle Simpson
8eace22e25 Chore: Release v0.4.4 2024-11-11 12:41:02 +00:00
tig
10ce458456 feat: v8 encryption modes (#264)
This PR adds support for the new AEAD cryptosystems advertised by Discord, AES256-GCM and XChaCha20Poly1305. These schemes will shortly become mandatory, and provider stronger integrity/authentication guarantees over the cleartext portions of any voice packet by correctly specifying additional authenticated data.

To provide smooth switchover, we've added basic negotiation over the `CryptoMode`. This ensures that any clients who are manually specifying one of the legacy modes will automatically migrate to `Aes256Gcm` when Discord cease to advertise their original preference.

Closes #246.

---------

Co-authored-by: Kyle Simpson <kyleandrew.simpson@gmail.com>
2024-11-11 12:30:15 +00:00
rhgndf
fe9b156906 Change HlsStream to a more generic AsyncReadOnlySource (#256) 2024-09-28 17:50:40 +01:00
Gnome!
095feb1065 Fix clippy warnings (#251) 2024-09-09 09:54:17 +00:00
Kyle Simpson
0844537024 Fix(ci): Move problem tests purely to cargo make test (#250)
A few tests are routinely failing on CI because they explicitly
hit YouTube URLs, even if the content in question is CC-licensed.
This PR simply adds the `#[ignore]` attribute, and adds the
`--include-ignored` flag to `cargo make test` so that correct WebM
parsing behaviour can be locally verified.

We could go a bit further and conditionally ignore the tests based
on CI-specific ENV vars, but that's probably overkill given the
scope of the issue.
2024-08-24 23:11:37 +01:00
Kyle Simpson
530286c6a6 Fix(receive): Handle sleds of identical RTP timestamps (#249)
Bots joining calls with users seem to provoke large runs of packets
with identical timestamps -- the existing logic was intended to handle this catchup case in addition to the normal (+=960) at all
times.

However, we were checking that a packet was modulo greater-than
the next ts, rather than modulo less-than. Simple enough to fix.
2024-08-24 22:38:09 +01:00
Kyle Simpson
ec665a8f87 Fix: Ringbuf patch release requires explicit type param
Ringbuf 0.4.2 onwards adds in a new storage type for `SharedRb`.
Unfortunately, this is handled in such a way that we fail to
compile because an explicit type parameter is required to
disambiguate the method in question.
2024-08-17 23:01:51 +01:00
Kyle Simpson
2d7dc29fd6 Fix: Generate heartbeat nonces under JS max-int size 2024-08-05 12:04:47 +01:00
Kyle Simpson
2b76eb9923 Chore: Release v0.4.3 2024-07-17 11:35:19 +01:00
Kyle Simpson
6a9335628c Revert bbc9e03, update tracing-subscriber in examples
Tokio-tungstenite have made some runtime-breaking changes to how
crypto setup is init'd -- i.e., users must do it themselves.
Reverting due to the huge (breaking) inconvenience this poses.
2024-07-17 11:31:12 +01:00
Erk
2dc812bd6a fix(dependecies): don't use default features for stream_lib (#244)
stream_lib would always pull in native-tls, this was changed in 0.4.2
which contains a backport of https://github.com/Erk-/rsget/pull/45.
2024-07-09 17:33:48 +01:00
Kyle Simpson
25d59a6956 chore: Release v0.4.2 2024-07-08 12:03:02 +01:00
Kyle Simpson
bbc9e03e47 chore(deps): Update tokio-tungstenite -> 0.23 2024-07-08 11:58:23 +01:00
Kyle Simpson
169d527e54 chore(deps): Update rubato -> 0.15 2024-07-08 11:49:46 +01:00
Kyle Simpson
93f2e0b636 chore(deps): Update ringbuf -> 0.4 2024-07-08 11:46:08 +01:00
Erk
8e92c49b2b feat(input): Support HLS streams (#242)
This patch adds support for yt-dl streams with the protocol m3u8_native which includes sites like Soundcloud.

Closes: #241
2024-07-07 19:37:25 +02:00
Erk
2e683380fa fix(conn): Some operating systems does not allow 0 recv buffer (#243)
This will cause FreeBSD to fail setting up the socket. It may also be true of some other operating systems, but these are the ones I have been able to test.

It works on Windows and Linux.
2024-07-07 16:29:26 +01:00
Gnome!
5bbe80f20c Fix clippy warnings (#236) 2024-04-02 08:57:47 +01:00
Alvaro
1d5b25965b Make DisposalThread reachable (#235)
The `Config` object provided to `Call`s and `Driver`s allows setting a `DisposalThread`, but since it is unreachable from outside the crate, the only way to properly set it is using a `Songbird` instance, which may not be adequate for all use cases. This PR just makes `DisposalThread` reachable from the outside.
2024-03-30 12:14:24 +00:00
Kyle Simpson
a5d9b58e94 Driver: Fix multiple disconnect events on leave (#233)
Fixes behaviour where a Driver which was asked to leave an active call would receive the disconnect event several times: once when we started the disconnect, and once again when Discord killed the WS client.
2024-03-19 08:28:56 +00:00
Kyle Simpson
58f5c89f92 Driver: Fix slot length check on packet passthrough (#231)
Corrects a buffer length check identified in #230 which was reversed,
such that overly large Opus packets would panic on a subsequent
`write_all`.
2024-03-04 08:59:25 +00:00
Kyle Simpson
8f60cf573e Chore: Fix timestamp in \git cliff -u\ 2024-02-29 23:11:39 +00:00
Kyle Simpson
b07e9b4178 Chore: Release v0.4.1 2024-02-29 23:07:04 +00:00
Kyle Simpson
cdb2df69c7 Chore: Initial git-cliff config
A little hacked together, but it is close enough to our primary format.
Will still require manual sorting of commits by function since we're not
doing conventional commits, but its lower friction for filling out
github usernames etc.
2024-02-29 22:39:22 +00:00
Kyle Simpson
4d67a73851 Chore: update tokio-tungstenite 2024-02-24 20:58:27 +00:00
Kyle Simpson
873fb68726 Move empty packet check to also cover 48kHz audio (#225)
Previously, we were only skipping zero-packet frames when we needed to
resample because the source sampling rate was not set to 48kHz. This
check should have also been applied in the case that a packet did not
need a resampler to be built.

Fixes #224.
2024-02-24 19:46:15 +00:00
Kyle Simpson
087e5f2292 Driver: Fix transition to Live on connect (#222)
This PR fixes a case where a call which changes channel or gracefully
reconnects would have been stuck in the Idle state. SetConn events will
now allow a transition straight back to Live if any tracks are found
attached to a mixer.
2024-01-24 09:30:50 +00:00
Gnome!
1b98c30746 Fix clippy warnings (#214)
* Fix clippy warnings

* Fix implicitly elided lifetimes
2024-01-03 16:45:23 +00:00
Cycle Five
d681b71b1f Input: Add ytdl search (#210)
* Add ytdl search

* fix fmt

* Remove compose, add tests, return AuxMetadata

* fix parsing of AuxMetadata and better test

* Fix playability of `YoutubeDl::new_search`

Refactors such that parsing of (ND)JSON is handled in only one location
now, which allows us to greatly simplify the actual `search` method. The
main change is that any `new_search` is now instantly playable.

---------

Co-authored-by: Kyle Simpson <kyleandrew.simpson@gmail.com>
2023-12-12 08:28:13 +00:00
Kyle Simpson
873aeae16a Chore: Release v0.4.0 2023-11-27 22:22:19 +00:00
Kyle Simpson
22ceb175b6 Chore: Fixup examples, bump version pre-push
Takes the chance to bring shared deps into the example workspace while we're here. Release notes, tags etc will follow in time.
2023-11-27 21:16:53 +00:00
Kane Wang
1ec569baf2 Driver: Remove RwLock from ThreadPool (#206) 2023-11-27 20:03:57 +00:00
Kyle Simpson
1f616daee6 Chore: Release v0.4.0-rc-2 2023-11-23 12:21:33 +00:00
Kyle Simpson
cc53312569 Deps: Re-disable default Serenity features 2023-11-23 12:01:24 +00:00