skua_voice/
lib.rs

1#![doc(
2    html_logo_url = "https://raw.githubusercontent.com/skuasongbird/current/songbird.png",
3    html_favicon_url = "https://raw.githubusercontent.com/skua-rs/songbird/current/songbird-ico.png"
4)]
5#![cfg_attr(docsrs, feature(doc_auto_cfg))]
6#![deny(missing_docs)]
7#![deny(rustdoc::broken_intra_doc_links)]
8//! ![project logo][logo]
9//!
10//! Songbird is an async, cross-library compatible voice system for Discord, written in Rust.
11//! The library offers:
12//!  * A standalone gateway frontend compatible with [skua] and [twilight] using the
13//!  `"gateway"` and `"[skua/twilight]"` plus `"[rustls/native]"` features. You can even run
14//!  driverless, to help manage your [lavalink] sessions.
15//!  * A standalone driver for voice calls, via the `"driver"` feature. If you can create
16//!  a `ConnectionInfo` using any other gateway, or language for your bot, then you
17//!  can run the songbird voice driver.
18//!  * Voice receive and RT(C)P packet handling via the `"receive"` feature.
19//!  * SIMD-accelerated JSON decoding via the `"simd-json"` feature.
20//!  * And, by default, a fully featured voice system featuring events, queues,
21//!  seeking on compatible streams, shared multithreaded audio stream caches,
22//!  and direct Opus data passthrough from DCA files.
23//!
24//! ## Intents
25//! Songbird's gateway functionality requires you to specify the `GUILD_VOICE_STATES` intent.
26//!
27//! ## Examples
28//! Full examples showing various types of functionality and integrations can be found
29//! in [this crate's examples directory].
30//!
31//! ## Codec support
32//! Songbird supports all [codecs and formats provided by Symphonia] (pure-Rust), with Opus support
33//! provided by [audiopus] (an FFI wrapper for libopus).
34//!
35//! **By default, *Songbird will not request any codecs from Symphonia*.** To change this, in your own
36//! project you will need to depend on Symphonia as well.
37//!
38//! ```toml
39//! # Including songbird alone gives you support for Opus via the DCA file format.
40//! [dependencies.songbird]
41//! version = "0.4"
42//! features = ["builtin-queue"]
43//!
44//! # To get additional codecs, you *must* add Symphonia yourself.
45//! # This includes the default formats (MKV/WebM, Ogg, Wave) and codecs (FLAC, PCM, Vorbis)...
46//! [dependencies.symphonia]
47//! version = "0.5"
48//! features = ["aac", "mp3", "isomp4", "alac"] # ...as well as any extras you need!
49//! ```
50//!
51//! ## Attribution
52//!
53//! Songbird's logo is based upon the copyright-free image ["Black-Capped Chickadee"] by George Gorgas White.
54//!
55//! [logo]: https://raw.githubusercontent.com/skua-rs/songbird/current/songbird.png
56//! [skua]: https://github.com/skua-rs/skua
57//! [twilight]: https://github.com/twilight-rs/twilight
58//! [this crate's examples directory]: https://github.com/skua-rs/songbird/tree/current/examples
59//! ["Black-Capped Chickadee"]: https://www.oldbookillustrations.com/illustrations/black-capped-chickadee/
60//! [`ConnectionInfo`]: struct@ConnectionInfo
61//! [lavalink]: https://github.com/freyacodes/Lavalink
62//! [codecs and formats provided by Symphonia]: https://github.com/pdeljanov/Symphonia#formats-demuxers
63//! [audiopus]: https://github.com/lakelezz/audiopus
64
65#![warn(clippy::pedantic, rust_2018_idioms)]
66#![allow(
67    // Allowed as they are too pedantic
68    clippy::module_name_repetitions,
69    clippy::wildcard_imports,
70    clippy::too_many_lines,
71    clippy::cast_lossless,
72    clippy::cast_sign_loss,
73    clippy::cast_possible_wrap,
74    clippy::cast_precision_loss,
75    clippy::cast_possible_truncation,
76    // TODO: would require significant rewriting of all existing docs
77    clippy::missing_errors_doc,
78    clippy::missing_panics_doc,
79    clippy::doc_link_with_quotes,
80)]
81
82mod config;
83pub mod constants;
84#[cfg(feature = "driver")]
85pub mod driver;
86pub mod error;
87#[cfg(feature = "driver")]
88pub mod events;
89#[cfg(feature = "gateway")]
90mod handler;
91pub mod id;
92pub(crate) mod info;
93#[cfg(feature = "driver")]
94pub mod input;
95#[cfg(feature = "gateway")]
96pub mod join;
97#[cfg(feature = "gateway")]
98mod manager;
99#[cfg(feature = "gateway")]
100pub mod shards;
101#[cfg(feature = "skua")]
102pub mod skua;
103#[cfg(any(test, feature = "internals"))]
104pub mod test_utils;
105#[cfg(feature = "driver")]
106pub mod tracks;
107#[cfg(feature = "driver")]
108mod ws;
109
110#[cfg(all(feature = "driver", feature = "receive"))]
111pub use discortp as packet;
112#[cfg(feature = "driver")]
113pub use skua_voice_model as model;
114#[cfg(feature = "driver")]
115pub use typemap_rev as typemap;
116
117// Re-export serde-json APIs locally to minimise conditional config elsewhere.
118#[cfg(not(feature = "simd-json"))]
119pub(crate) use serde_json as json;
120#[cfg(feature = "simd-json")]
121pub(crate) use simd_json::serde as json;
122
123#[cfg(feature = "driver")]
124pub use crate::{
125    driver::Driver,
126    events::{CoreEvent, Event, EventContext, EventHandler, TrackEvent},
127};
128
129#[cfg(feature = "gateway")]
130pub use crate::{handler::*, manager::*};
131
132#[cfg(feature = "skua")]
133pub use crate::skua::*;
134
135pub use config::Config;
136pub use info::ConnectionInfo;