Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Driver/Input: Migrate audio backend to Symphonia #89

Merged
merged 215 commits into from
Jul 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
215 commits
Select commit Hold shift + click to select a range
95b36f1
Initial Symphonia libopus wrapper
FelixMcFelix Aug 20, 2021
7e8c81e
Messy DCA(1) framing for Symphonia, DCA export on `Compressed`
FelixMcFelix Aug 23, 2021
9556871
Primitive mixer code.
FelixMcFelix Sep 3, 2021
454637f
Early measurements, thinking about right granularity for resampling w…
FelixMcFelix Sep 15, 2021
0c9689a
Some structuring, committing for now.
FelixMcFelix Sep 28, 2021
10bca95
Prelim integration of mix code (not input readying yet...)
FelixMcFelix Oct 4, 2021
4663884
Minor progress on dropping in new inputs...
FelixMcFelix Oct 10, 2021
ae69e5e
Deps: Depend on Serenity's `next` branch on Songbird's `next` branch …
arqunis Nov 15, 2020
3784490
Deps: Bump streamcatcher version -> 1.0 (#93)
tktcorporation Sep 22, 2021
94bd290
Examples: Fix serenity-next cache accesses (#99)
FelixMcFelix Oct 10, 2021
2129422
Gateway: Add generics to `Call` methods. (#102)
FelixMcFelix Oct 19, 2021
6a63e78
Merge branch 'next' into symphonia
FelixMcFelix Oct 27, 2021
7956792
Gateway: Remove lifetime from Serenity setup trait (#103)
FelixMcFelix Nov 5, 2021
b8cf942
Merge branch 'next' into symphonia
FelixMcFelix Nov 5, 2021
213535b
Working MP3 playback.
FelixMcFelix Nov 7, 2021
069cbd9
Dumb hack for Ogg playback.
FelixMcFelix Nov 7, 2021
0d10631
Lazy input creation pipeline.
FelixMcFelix Nov 13, 2021
07e278e
Use new `last_decoded` Decoder semantics.
FelixMcFelix Nov 15, 2021
af88b64
Lazy inputs work as expected -- for Files at least.
FelixMcFelix Nov 15, 2021
45bd5d5
Http lazy inputs!
FelixMcFelix Nov 25, 2021
64cdb6c
Seek support.
FelixMcFelix Dec 13, 2021
140db80
Basic youtube-dl input, remove old tokio support.
FelixMcFelix Dec 19, 2021
04abb1f
Update to 2021 edition
FelixMcFelix Dec 20, 2021
f6e9253
Re-enable SetTrack
FelixMcFelix Dec 20, 2021
e666131
Redesign cached::Memory, port cached::Compressed
FelixMcFelix Dec 27, 2021
c3c67ee
Opus frame passthrough support restored
FelixMcFelix Dec 29, 2021
170fff0
Stereo/mono mix target support.
FelixMcFelix Dec 29, 2021
ecc9cf1
DCA seek support, metadata fixes.
FelixMcFelix Dec 30, 2021
ca3fa1f
WIP reorganisation, dead code removal.
FelixMcFelix Dec 31, 2021
43d8d3c
Deps: Depend on Serenity's `next` branch on Songbird's `next` branch …
arqunis Nov 15, 2020
a1c87e3
Deps: Bump streamcatcher version -> 1.0 (#93)
tktcorporation Sep 22, 2021
3207c02
Examples: Fix serenity-next cache accesses (#99)
FelixMcFelix Oct 10, 2021
d63e1d8
Gateway: Add generics to `Call` methods. (#102)
FelixMcFelix Oct 19, 2021
28e370a
Gateway: Remove lifetime from Serenity setup trait (#103)
FelixMcFelix Nov 5, 2021
6fd69ff
Merge branch 'next' into symphonia
FelixMcFelix Jan 5, 2022
24f5bf7
The great clippification.
FelixMcFelix Jan 5, 2022
a18bb0c
Gateway: Generic Shard and Twilight v0.8 Support (#109)
FelixMcFelix Jan 13, 2022
42663db
Merge branch 'next' into symphonia
FelixMcFelix Jan 14, 2022
d3f0974
Gateway: Twilight v0.9 support (#110)
FelixMcFelix Jan 24, 2022
fc454d6
Update Audiopus -> 0.3.0-rc.0.
FelixMcFelix Jan 28, 2022
cbead05
Merge branch 'next' into symphonia
FelixMcFelix Jan 31, 2022
c0faad5
Merge remote-tracking branch 'origin/symphonia' into symphonia
FelixMcFelix Jan 31, 2022
b2d635c
WebM support merged upstream! Allow WebM from youtube-dl.
FelixMcFelix Jan 31, 2022
9cd05f8
Fix Symphonia to v0.5
FelixMcFelix Jan 31, 2022
20e6a86
Catching up on documentation.
FelixMcFelix Feb 5, 2022
897945f
Update ARCHITECTURE.md
FelixMcFelix Feb 5, 2022
ccf3e35
Add (untested) wrapper for raw PCM data.
FelixMcFelix Feb 5, 2022
b74cff2
Add cached::decompressed, fix interleaved PCM adapter, nice docs for …
FelixMcFelix Feb 6, 2022
40bd634
Fix non-Send future in TrackQueue::add_raw
FelixMcFelix Feb 6, 2022
d71ab72
Resume HTTP sessions on failure.
FelixMcFelix Feb 11, 2022
b214a47
Clean up imports in the HTTP/async adapter.
FelixMcFelix Feb 12, 2022
8e736ed
Deps: Depend on Serenity's `next` branch on Songbird's `next` branch …
arqunis Nov 15, 2020
3150551
Deps: Bump streamcatcher version -> 1.0 (#93)
tktcorporation Sep 22, 2021
2fa79e6
Examples: Fix serenity-next cache accesses (#99)
FelixMcFelix Oct 10, 2021
0218c33
Gateway: Add generics to `Call` methods. (#102)
FelixMcFelix Oct 19, 2021
4c98789
Gateway: Remove lifetime from Serenity setup trait (#103)
FelixMcFelix Nov 5, 2021
50cc5bb
Gateway: Generic Shard and Twilight v0.8 Support (#109)
FelixMcFelix Jan 13, 2022
8b9f2b8
Gateway: Twilight v0.9 support (#110)
FelixMcFelix Jan 24, 2022
b680b84
Merge branch 'next' into symphonia
FelixMcFelix Feb 14, 2022
a36b589
Deps: Depend on Serenity's `next` branch on Songbird's `next` branch …
arqunis Nov 15, 2020
6039aa0
Deps: Bump streamcatcher version -> 1.0 (#93)
tktcorporation Sep 22, 2021
a439bf5
Examples: Fix serenity-next cache accesses (#99)
FelixMcFelix Oct 10, 2021
823b421
Gateway: Add generics to `Call` methods. (#102)
FelixMcFelix Oct 19, 2021
dcb33eb
Gateway: Remove lifetime from Serenity setup trait (#103)
FelixMcFelix Nov 5, 2021
1136b8f
Gateway: Generic Shard and Twilight v0.8 Support (#109)
FelixMcFelix Jan 13, 2022
1e39658
Gateway: Twilight v0.9 support (#110)
FelixMcFelix Jan 24, 2022
e0ab49c
Events: Remove deprecated events. (#115)
FelixMcFelix Feb 14, 2022
49caa22
Merge branch 'next' into symphonia
FelixMcFelix Feb 14, 2022
ab2e251
Example cleanup.
FelixMcFelix Feb 15, 2022
1b92770
Update benchmarks to use symphonia, fix Compressed with 48kHz input
FelixMcFelix Feb 20, 2022
c5706f3
Some restructuring work on Tracks
FelixMcFelix Feb 20, 2022
c8b3b0e
driver, queue: return track handle when adding an `Input` to the queu…
vaporoxx Mar 7, 2022
fc6b358
Gateway: Twilight v0.10 support (#117)
FelixMcFelix Mar 14, 2022
aacb618
Merge branch 'next' into symphonia
FelixMcFelix Mar 14, 2022
923af13
Update to rubato v0.11.
FelixMcFelix Mar 14, 2022
ad8377c
Driver, Gateway: Remove tokio 0.2 support (#118)
GnomedDev Mar 31, 2022
507b46a
Deps: Bump dependencies and document bumped MSRV (#119)
GnomedDev Apr 2, 2022
99818e9
Driver: Prevent panic when decrypting undersized RTP packets (#122)
FelixMcFelix Apr 19, 2022
9840de3
Merge 'next'.
FelixMcFelix Apr 19, 2022
d23f7f1
Accidentally an await.
FelixMcFelix Apr 19, 2022
ff7561a
Driver: Remove spin_sleep in `Mixer::march_deadline` (#124)
GnomedDev Apr 22, 2022
28cf252
Examples: support new Serenity Intents init
FelixMcFelix Apr 24, 2022
dabf73b
Deps: Update to Audiopus v0.3.0-rc.0 (#125)
FelixMcFelix Apr 24, 2022
b6d3601
Merge branch 'next' into symphonia
GnomedDev May 21, 2022
119d178
Update deps
GnomedDev May 21, 2022
430d83a
Fix otherwise broken state-change commands.
FelixMcFelix May 21, 2022
7fa84e3
Merge remote-tracking branch 'author/symphonia' into symphonia
GnomedDev May 21, 2022
9bb42d2
Try fix clippy warnings
GnomedDev May 23, 2022
c5c11e4
fmt
GnomedDev May 23, 2022
c4a33f1
Merge pull request #1 from GnomedDev/symphonia-next
FelixMcFelix May 23, 2022
2346585
Bump MSRV to 1.61.0.
FelixMcFelix May 23, 2022
bfbccb9
Into<Input> for static/owned bytes
FelixMcFelix May 23, 2022
49c3346
Update twilight support to twilight 0.11 (#132)
Erk- May 25, 2022
175262b
Fix broken 22.05kHz->48kHz resample
FelixMcFelix May 30, 2022
23905d1
Tracks + TrackHandles rework.
FelixMcFelix May 31, 2022
4fa8491
Merge branch 'next' into symphonia
FelixMcFelix May 31, 2022
067643b
Add `aux_metadata()` to `Input`.
FelixMcFelix Jun 1, 2022
6e6ef6a
Expose probe and format metadata via `action`.
FelixMcFelix Jun 1, 2022
24a7795
Add + Expose ReadyState via View.
FelixMcFelix Jun 1, 2022
712e378
Helper methods for input upgrading/creation/created access.
FelixMcFelix Jun 2, 2022
7250c6d
Temporarily pin serenity version.
FelixMcFelix Jun 2, 2022
988a191
Create + Parse error signalling, listeners for TrackErrors
FelixMcFelix Jun 2, 2022
c7c7f51
Decode error handling + events.
FelixMcFelix Jun 3, 2022
2132812
Some cleanup in the mixer logic.
FelixMcFelix Jun 3, 2022
a975dd2
Refactor and reorganise mixing internals.
FelixMcFelix Jun 3, 2022
18506b8
Code restructure for `crate::input`.
FelixMcFelix Jun 4, 2022
c67c4bf
Document `Symphonia` requirement in README and docs root
FelixMcFelix Jun 4, 2022
3a6a3ce
Accidentally a space
FelixMcFelix Jun 4, 2022
629d5cf
Update mixing benchmarks wrt. restructured code
FelixMcFelix Jun 6, 2022
fc7b8f5
Document some errors, explain how to get (Aux)Metadata.
FelixMcFelix Jun 6, 2022
28f09a9
Clarify failure reasons for Input::aux_metadata
FelixMcFelix Jun 6, 2022
22874f1
Document remaining types.
FelixMcFelix Jun 6, 2022
4b5bf12
A slightly exhausting example on the wonders of `Input`
FelixMcFelix Jun 6, 2022
c281b9b
Removing some old error variants.
FelixMcFelix Jun 6, 2022
ec681e0
Make Metadata link to action clearer.
FelixMcFelix Jun 6, 2022
163ce11
Make Passthrough a bit more lenient
FelixMcFelix Jun 6, 2022
c2c40e4
Appease Clippy
FelixMcFelix Jun 6, 2022
7ae3ea3
Attempt to add yt-dlp to CI, make it the preferred fork in README.
FelixMcFelix Jun 6, 2022
bbd84c7
Clarify audiopus v0.3.0 build details.
FelixMcFelix Jun 6, 2022
d32ef43
Make Driver.add_raw a public function
alakhpc Jun 9, 2022
f1289b9
Fix clippy::must_use_candidate
GnomedDev Jun 9, 2022
5018d2b
Fix clippy::default_trait_access
GnomedDev Jun 9, 2022
f1b8345
Fix clippy::match_same_arms
GnomedDev Jun 9, 2022
b38a58b
Fix clippy::semicolon_if_nothing_returned
GnomedDev Jun 9, 2022
7b31847
Fix clippy::enum_glob_use
GnomedDev Jun 9, 2022
b849d90
Fix clippy::return_self_not_must_use
GnomedDev Jun 9, 2022
abcc681
Fix clippy::unused_self
GnomedDev Jun 9, 2022
3a8fcb6
Fix clippy::trivially_copy_pass_by_ref
GnomedDev Jun 9, 2022
2a0ed58
Fix clippy::let_underscore_drop
GnomedDev Jun 9, 2022
9af87a4
Fix clippy::map_unwrap_or
GnomedDev Jun 9, 2022
6dcfe36
Fix clippy::if_not_else
GnomedDev Jun 9, 2022
c5e3593
Fix clippy::unnested_or_patterns
GnomedDev Jun 9, 2022
9ae1d8d
Fix clippy::single_match_else
GnomedDev Jun 9, 2022
eb61f32
Fmt and fix clippy::mut_mut
GnomedDev Jun 9, 2022
27b269a
Fix clippy::similar_names
GnomedDev Jun 9, 2022
9c0b93a
Fix clippy::needless_pass_by_value
GnomedDev Jun 9, 2022
5c4d039
Fix clippy::match_wildcard_for_single_variants
GnomedDev Jun 9, 2022
a984678
Fix clippy::redundant_closure_for_method_calls
GnomedDev Jun 9, 2022
b50338e
Fix clippy::doc_markdown
GnomedDev Jun 9, 2022
7eb9c91
Fix clippy::explicit_iter_loop
GnomedDev Jun 9, 2022
f251e6f
Swap warn specific to warn all and allow, fix last couple warns
GnomedDev Jun 9, 2022
cab6b96
Fix comment in lib.rs
GnomedDev Jun 10, 2022
633ac83
Merge pull request #3 from GnomedDev/symphonia-clippy
FelixMcFelix Jun 10, 2022
b3263a9
Merge branch 'FelixMcFelix:symphonia' into symphonia
alakhpc Jun 10, 2022
79c2c32
Update DiscoRTP
FelixMcFelix Jun 10, 2022
e13cafd
Initial work on headless test config for driver
FelixMcFelix Jun 10, 2022
8d08e65
Merge branch 'FelixMcFelix:symphonia' into symphonia
alakhpc Jun 11, 2022
9ce9bb3
An actual driver test for the queue.
FelixMcFelix Jun 11, 2022
6eab117
Pin to another 0.11-ish version of next
FelixMcFelix Jun 12, 2022
7cdf073
From<ChildContainer> for Input
FelixMcFelix Jun 12, 2022
5aba830
Recursive From/Into for all Input sources -> Track
FelixMcFelix Jun 12, 2022
53c8a8f
De-pub TrackHandle::new
FelixMcFelix Jun 12, 2022
eb8b189
Typos in README/lib-docs
FelixMcFelix Jun 12, 2022
7ea8922
Remove reused code from `Decompressed`'s byte transform
FelixMcFelix Jun 12, 2022
9225ff6
Revisit LiveInput::promote
FelixMcFelix Jun 12, 2022
8ef1463
Placeholder YTDL test, convenience methods for output checking
FelixMcFelix Jun 12, 2022
9aa10ae
Add missing `Config` fields.
FelixMcFelix Jun 12, 2022
7074521
Add Preparing and Playable events, expose ReadyState on TrackState.
FelixMcFelix Jun 13, 2022
5ba7b71
YoutubeDl seek tests.
FelixMcFelix Jun 13, 2022
deda98e
Fix: `Err(_)` events now also fire `End`
FelixMcFelix Jun 14, 2022
935a79c
Move test/example resources to unified location.
FelixMcFelix Jun 14, 2022
1b150e2
Hopefully fix windows CI. Unsure what's up with Http/Opus seeking.
FelixMcFelix Jun 14, 2022
c791b05
Add timeouts to all tests, unify code paths for format checking.
FelixMcFelix Jun 14, 2022
851761e
Document/explain safety of OpusDecoder.
FelixMcFelix Jun 14, 2022
dfff113
Manually check for backseeking with one-way Inputs
FelixMcFelix Jun 15, 2022
fed104c
Remove one incidental panic.
FelixMcFelix Jun 15, 2022
28586b4
Update tests to remove reliance on racy behaviour, record thoughts on…
FelixMcFelix Jun 15, 2022
835325c
Temporary pin to symphonia PR to keep the CI ticking.
FelixMcFelix Jun 15, 2022
a60afb0
A nightly clippy nit.
FelixMcFelix Jun 15, 2022
1c02610
Temp Symphonia branch for my pile of fixes.
FelixMcFelix Jun 15, 2022
bfb9512
Merge branch 'FelixMcFelix:symphonia' into symphonia
alakhpc Jun 16, 2022
00f832e
Rework `add_raw` into `add_`/`enqueue_with_preload`.
FelixMcFelix Jun 17, 2022
849100d
Next got forced, again.
FelixMcFelix Jun 17, 2022
ae2dd0c
Rework ClientData to wrap in Option instead of initialised bool (#2)
GnomedDev Jun 21, 2022
1ed51ab
Repair some broken doc-links.
FelixMcFelix Jun 21, 2022
522188c
Add cfg(test) around all testing paths (#5)
GnomedDev Jun 21, 2022
4c0e93f
Reduce default thread pool allocation.
FelixMcFelix Jun 21, 2022
e39d325
Fix packet sending outside of cfg(test)
FelixMcFelix Jun 21, 2022
4f0be83
Use YoutubeDl-suggested header values in HttpRequest
FelixMcFelix Jun 22, 2022
049ee6b
Support serenity@next instead of pinning version (#7)
GnomedDev Jun 23, 2022
a33a334
Update examples to work with serenity@next.
FelixMcFelix Jun 24, 2022
eef3593
Bypass Youtube ratelimiting
FelixMcFelix Jun 24, 2022
b5e13fa
Seek/MakePlayable callbacks on TrackHandle.
FelixMcFelix Jun 24, 2022
7a42abf
Unbreak tests.
FelixMcFelix Jun 24, 2022
4f333a8
Callback tests, fix input ready notification on paused tracks.
FelixMcFelix Jun 25, 2022
11b2127
Document TrackCallback
FelixMcFelix Jun 25, 2022
303c1c4
TrackHandle::seek_time -> seek
FelixMcFelix Jun 25, 2022
3b03275
Prevent track times from ticking while preparing.
FelixMcFelix Jun 25, 2022
8e71be5
Accidental commit of some seek testing in example.
FelixMcFelix Jun 25, 2022
9572344
Tests ensuring Loops work in perpetuity.
FelixMcFelix Jun 25, 2022
98dd16f
Fix looping on streamed MKVs
FelixMcFelix Jun 27, 2022
ee520d2
Fix HTTP Range resume
FelixMcFelix Jun 27, 2022
90f813a
Some leniency on tougher tests.
FelixMcFelix Jun 27, 2022
c069ac4
Remove unnecessary poison messages (#6)
GnomedDev Jun 27, 2022
8b23dcd
Use OnceCell and DashMap (#8)
GnomedDev Jun 27, 2022
fa9352b
Format, alphabetise feature deps.
FelixMcFelix Jun 27, 2022
185038f
Fix ShardMessage for serenity::next
FelixMcFelix Jun 28, 2022
965ba4a
Structify YoutubeDL Json reading
FelixMcFelix Jun 28, 2022
b4bd427
Make `url` field mandatory in YtDL Output.
FelixMcFelix Jun 28, 2022
82b29ea
FFprobe output as File::aux_metadata
FelixMcFelix Jun 30, 2022
29d8d55
Quick once-over of the serenity examples.
FelixMcFelix Jul 4, 2022
bcb23d2
Review Pt. 1: Doc mix logic, extend passthrough to one *live* track
FelixMcFelix Jul 11, 2022
d29dec1
Some unneeded refs caught by clippy
FelixMcFelix Jul 11, 2022
5557e6c
Minor cleanup: not a fan of From<&Type> vs. dedicated method.
FelixMcFelix Jul 12, 2022
d9f0ef7
Track removals from event context, sans `Vec`
FelixMcFelix Jul 12, 2022
cf256ad
Review Pt 2: Mixer task.
FelixMcFelix Jul 14, 2022
c69d11f
Act on queued seeks given mid-track--prepare.
FelixMcFelix Jul 16, 2022
afb5cb5
Review pt 3: Starting on inputs
FelixMcFelix Jul 16, 2022
71f1e46
Remove unnecessary chrono dep (#9)
GnomedDev Jul 17, 2022
5f87e23
Merge branch 'next' into symphonia
FelixMcFelix Jul 23, 2022
20cd609
Adapt examples to new serenity framework.
FelixMcFelix Jul 23, 2022
bfcc932
impl Error for Cached adapters
FelixMcFelix Jul 23, 2022
01e1030
Review pt 4: adapters.
FelixMcFelix Jul 23, 2022
fae374a
Review pt 5: Inputs
FelixMcFelix Jul 23, 2022
e7a233c
Finis
FelixMcFelix Jul 23, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ jobs:
- Windows
- driver only
- gateway only
- legacy tokio

include:
- name: beta
Expand Down Expand Up @@ -75,6 +74,16 @@ jobs:
sudo apt-get update
sudo apt-get install -y libopus-dev

- name: Install yt-dlp (Unix)
if: runner.os != 'Windows'
run: |
sudo wget https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -O /usr/local/bin/yt-dlp
sudo chmod a+rx /usr/local/bin/yt-dlp

- name: Install yt-dlp (Windows)
if: runner.os == 'Windows'
run: choco install yt-dlp

- name: Setup cache
if: runner.os != 'macOS'
uses: actions/cache@v2
Expand Down Expand Up @@ -175,9 +184,9 @@ jobs:
- name: 'Build serenity/voice_receive'
working-directory: examples
run: cargo build -p voice_receive
- name: 'Build serenity/voice_storage'
- name: 'Build serenity/voice_cached_audio'
working-directory: examples
run: cargo build -p voice_storage
run: cargo build -p voice_cached_audio
- name: 'Build twilight'
working-directory: examples
run: cargo build -p twilight
17 changes: 9 additions & 8 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ Songbird's **driver** is a mixed sync/async system for running voice connections
Audio processing remains synchronous for the following reasons:
* Encryption, encoding, and mixing are compute bound tasks which cannot be subdivided cleanly by the Tokio executor. Having these block the scheduler's finite thread count has a significant impact on servicing other tasks.
* `Read` and `Seek` are considerably more user-friendly to use, implement, and integrate than `AsyncRead`, `AsyncBufRead`, and `AsyncSeek`.
* Symphonia implements all of its functionality based on synchronous I/O.

## Tasks
Songbird subdivides voice connection handling into several long- and short-lived tasks.

* **Core**: Handles and directs commands received from the driver. Responsible for connection/reconnection, and creates network tasks.
* **Mixer**: Combines audio sources together, Opus encodes the result, and encrypts the built packets every 20ms. Responsible for handling track commands/state. ***Synchronous***.
* **Thread Pool**: A dynamically sized thread-pool for I/O tasks. Creates lazy tracks using `Compose` if sync creation is needed, otherwise spawns a tokio task. Seek operations always go to the thread pool. ***Synchronous***.
* **Disposer**: Used by mixer thread to dispose of data with potentially long/blocking `Drop` implementations (i.e., audio sources). ***Synchronous***.
* **Events**: Stores and runs event handlers, tracks event timing, and handles
* **Websocket**: *Network task.* Sends speaking status updates and keepalives to Discord, and receives client (dis)connect events.
Expand All @@ -52,23 +54,22 @@ src/driver/*
## Audio handling

### Input
Inputs are raw audio sources: composed of a `Reader` (which can be `Read`-only or `Read + Seek`), a framing mechanism, and a codec.
Several wrappers exist to add `Seek` capabilities to one-way streams via storage or explicitly recreating the struct.
Inputs are audio sources supporting lazy initialisation, being either:
* **lazy inputs**—a trait object which allows an instructions to create an audio source to be cheaply stored. This will be initialised when needed either synchronously or asynchronously based on what which methods the trait object supports.
* **live inputs**—a usable audio object implementing `MediaSource: Read + Seek`. `Seek` support may be dummied in, as seek use and support is gated by `MediaSource`. These can be passed in at various stages of processing by symphonia.

Framing is not always needed (`Raw`), but makes it possible to consume the correct number of bytes needed to decode one audio packet (and/or simplify skipping through the stream).
Currently, Opus and raw (`i16`/`f32`) audio sources are supported, though only the DCA framing for Opus is implemented.
At present, the use of the FFmpeg executable allows us to receive raw input, but at heavy memory cost.
Further implementations are possible in the present framework (e.g., WebM/MKV and Ogg containers, MP3 and linked FFI FFmpeg as codecs).
Several wrappers exist to add `Seek` capabilities to one-way streams via storage or explicitly recreating the struct, `AsyncRead` adapters, and raw audio input adapters.

Internally, the mixer uses floating-point audio to prevent clipping and allow more granular volume control.
If a source is known to use the Opus codec (and is the only source), then it can bypass mixing altogether.
Symphonia is used to demux and decode input files in a variety of formats into this floating-point buffer: songbird supports all codecs and containers which are part of the symphonia project, while adding support for Opus decoding and DCA1 container files.
If a source uses the Opus codec (and is the only source), then it can bypass mixing and re-encoding altogether, saving CPU cycles per server.

```
src/input/*
```

### Tracks
Tracks hold additional state which is expected to change over the lifetime of a track: position, play state, and modifiers like volume.
Tracks hold additional state which is expected to change over the lifetime of a track: position, play state, and modifiers like volume.
Tracks (and their handles) also allow per-source events to be inserted.

Tracks are defined in user code, where they are fully modifiable, before being passed into the driver.
Expand Down
112 changes: 81 additions & 31 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,28 @@
authors = ["Kyle Simpson <kyleandrew.simpson@gmail.com>"]
description = "An async Rust library for the Discord voice API."
documentation = "https://docs.rs/songbird"
edition = "2018"
edition = "2021"
homepage = "https://github.com/serenity-rs/songbird"
include = ["src/**/*.rs", "Cargo.toml", "build.rs"]
keywords = ["discord", "api", "rtp", "audio"]
license = "ISC"
name = "songbird"
readme = "README.md"
repository = "https://github.com/serenity-rs/songbird.git"
version = "0.3.0"
version = "0.2.2"
rust-version = "1.61"

[dependencies]
derivative = "2"
pin-project = "1"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
tracing = { version = "0.1", features = ["log"] }
tracing-futures = "0.2"
symphonia-core = "0.5"

[dependencies.once_cell]
version = "1"
optional = true

[dependencies.async-trait]
optional = true
Expand All @@ -45,28 +50,50 @@ version = "5"
[dependencies.discortp]
features = ["discord-full"]
optional = true
version = "0.4"
version = "0.5"

# Temporary hack to pin MSRV.
[dependencies.flume]
optional = true
version = "0.10"

[dependencies.futures]
version = "0.3"

[dependencies.parking_lot]
[dependencies.lazy_static]
optional = true
version = "0.12"
version = "1"

[dependencies.pin-project]
[dependencies.parking_lot]
optional = true
version = "1"
version = "0.12"

[dependencies.rand]
optional = true
version = "0.8"

[dependencies.reqwest]
optional = true
default-features = false
features = ["stream"]
version = "0.11"

[dependencies.ringbuf]
optional = true
version = "0.2"

[dependencies.rubato]
optional = true
version = "0.12"

[dependencies.rusty_pool]
optional = true
version = "0.7"

[dependencies.serde-aux]
default-features = false
optional = true
version = "3"

[dependencies.serenity]
optional = true
default-features = false
Expand All @@ -83,11 +110,29 @@ branch = "next"
optional = true
version = "1"

[dependencies.symphonia]
optional = true
default-features = false
version = "0.5"
git = "https://github.com/FelixMcFelix/Symphonia"
branch = "songbird-fixes"

[dependencies.symphonia-core]
optional = true
version = "0.5"
git = "https://github.com/FelixMcFelix/Symphonia"
branch = "songbird-fixes"

[dependencies.tokio]
optional = true
version = "1.0"
default-features = false

[dependencies.tokio-util]
optional = true
version = "0.7"
features = ["io"]

[dependencies.twilight-gateway]
optional = true
version = "0.12.0"
Expand All @@ -108,7 +153,7 @@ version = "2"

[dependencies.uuid]
optional = true
version = "0.8"
version = "1"
features = ["v4"]

[dependencies.xsalsa20poly1305]
Expand All @@ -118,7 +163,10 @@ features = ["std"]

[dev-dependencies]
criterion = "0.3"
ntest = "0.8"
symphonia = { version = "0.5", features = ["mp3"], git = "https://github.com/FelixMcFelix/Symphonia", branch = "songbird-fixes" }
utils = { path = "utils" }
tokio = { version = "1", features = ["rt", "rt-multi-thread"] }

[features]
# Core features
Expand All @@ -128,45 +176,48 @@ default = [
"gateway",
]
gateway = [
"gateway-core",
"tokio/sync",
"tokio/time",
]
gateway-core = [
"dashmap",
"flume",
"once_cell",
"parking_lot",
"pin-project",
]
driver = [
"async-tungstenite",
"driver-core",
"tokio/fs",
"tokio/io-util",
"tokio/macros",
"tokio/net",
"tokio/process",
"tokio/rt",
"tokio/sync",
"tokio/time",
]
driver-core = [
driver = [
"async-trait",
"async-tungstenite",
"audiopus",
"byteorder",
"discortp",
"reqwest",
"flume",
"lazy_static",
"parking_lot",
"rand",
"ringbuf",
"rubato",
"serde-aux",
"serenity-voice-model",
"streamcatcher",
"symphonia",
"symphonia-core",
"rusty_pool",
"tokio-util",
"tokio/fs",
"tokio/io-util",
"tokio/macros",
"tokio/net",
"tokio/process",
"tokio/rt",
"tokio/sync",
"tokio/time",
"typemap_rev",
"url",
"uuid",
"xsalsa20poly1305",
]
rustls = ["async-tungstenite/tokio-rustls-webpki-roots", "rustls-marker"]
native = ["async-tungstenite/tokio-native-tls", "native-marker"]
rustls = ["async-tungstenite/tokio-rustls-webpki-roots", "reqwest/rustls-tls", "rustls-marker"]
native = ["async-tungstenite/tokio-native-tls", "native-marker", "reqwest/native-tls"]
serenity-rustls = ["serenity/rustls_backend", "rustls", "gateway", "serenity-deps"]
serenity-native = ["serenity/native_tls_backend", "native", "gateway", "serenity-deps"]
twilight-rustls = ["twilight", "twilight-gateway/rustls-native-roots", "rustls", "gateway"]
Expand All @@ -180,8 +231,6 @@ rustls-marker = []
native-marker = []

# Behaviour altering features.
youtube-dlc = []
yt-dlp = []
builtin-queue = []

# Used for docgen/testing/benchmarking.
Expand All @@ -191,6 +240,7 @@ internals = []
[[bench]]
name = "base-mixing"
path = "benches/base-mixing.rs"
required-features = ["internals"]
harness = false

[[bench]]
Expand Down
4 changes: 4 additions & 0 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ dependencies = ["format"]
[tasks.build-variants]
dependencies = ["build", "build-gateway", "build-driver"]

[tasks.check]
args = ["check", "--features", "full-doc"]
dependencies = ["format"]

[tasks.clippy]
args = ["clippy", "--features", "full-doc", "--", "-D", "warnings"]
dependencies = ["format"]
Expand Down
Loading