Voice Rework -- Events, Track Queues (#806)
This implements a proof-of-concept for an improved audio frontend. The largest change is the introduction of events and event handling: both by time elapsed and by track events, such as ending or looping. Following on from this, the library now includes a basic, event-driven track queue system (which people seem to ask for unusually often). A new sample, `examples/13_voice_events`, demonstrates both the `TrackQueue` system and some basic events via the `~queue` and `~play_fade` commands. Locks are removed from around the control of `Audio` objects, which should allow the backend to be moved to a more granular futures-based backend solution in a cleaner way.
This commit is contained in:
38
src/driver/crypto.rs
Normal file
38
src/driver/crypto.rs
Normal file
@@ -0,0 +1,38 @@
|
||||
//! Encryption schemes supported by Discord's secure RTP negotiation.
|
||||
|
||||
/// Variants of the XSalsa20Poly1305 encryption scheme.
|
||||
///
|
||||
/// At present, only `Normal` is supported or selectable.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
#[non_exhaustive]
|
||||
pub enum Mode {
|
||||
/// The RTP header is used as the source of nonce bytes for the packet.
|
||||
///
|
||||
/// Equivalent to a nonce of at most 48b (6B) at no extra packet overhead:
|
||||
/// the RTP sequence number and timestamp are the varying quantities.
|
||||
Normal,
|
||||
/// An additional random 24B suffix is used as the source of nonce bytes for the packet.
|
||||
///
|
||||
/// Full nonce width of 24B (192b), at an extra 24B per packet (~1.2 kB/s).
|
||||
Suffix,
|
||||
/// An additional random 24B suffix is used as the source of nonce bytes for the packet.
|
||||
///
|
||||
/// Nonce width of 4B (32b), at an extra 4B per packet (~0.2 kB/s).
|
||||
Lite,
|
||||
}
|
||||
|
||||
impl Mode {
|
||||
/// Returns the name of a mode as it will appear during negotiation.
|
||||
pub fn to_request_str(self) -> &'static str {
|
||||
use Mode::*;
|
||||
match self {
|
||||
Normal => "xsalsa20_poly1305",
|
||||
Suffix => "xsalsa20_poly1305_suffix",
|
||||
Lite => "xsalsa20_poly1305_lite",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: implement encrypt + decrypt + nonce selection for each.
|
||||
// This will probably need some research into correct handling of
|
||||
// padding, reported length, SRTP profiles, and so on.
|
||||
Reference in New Issue
Block a user