diff options
| author | Maiddog <[email protected]> | 2017-08-26 17:55:43 -0500 |
|---|---|---|
| committer | alex <[email protected]> | 2017-08-27 00:55:43 +0200 |
| commit | 3e0b1032d80a1847558a752e8316d97f9ae58f04 (patch) | |
| tree | ca65390091cb3c0ab98b6497a1447ba69df3d20d /src/voice/audio.rs | |
| parent | Use `$crate` for `Args` (diff) | |
| download | serenity-3e0b1032d80a1847558a752e8316d97f9ae58f04.tar.xz serenity-3e0b1032d80a1847558a752e8316d97f9ae58f04.zip | |
Add ability to play DCA and Opus files. (#148)
Diffstat (limited to 'src/voice/audio.rs')
| -rw-r--r-- | src/voice/audio.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/voice/audio.rs b/src/voice/audio.rs index 14b9ccd..be3ae60 100644 --- a/src/voice/audio.rs +++ b/src/voice/audio.rs @@ -5,7 +5,11 @@ pub const SAMPLE_RATE: u32 = 48000; pub trait AudioSource: Send { fn is_stereo(&mut self) -> bool; - fn read_frame(&mut self, buffer: &mut [i16]) -> Option<usize>; + fn get_type(&self) -> AudioType; + + fn read_pcm_frame(&mut self, buffer: &mut [i16]) -> Option<usize>; + + fn read_opus_frame(&mut self) -> Option<Vec<u8>>; } /// A receiver for incoming audio. @@ -19,3 +23,9 @@ pub trait AudioReceiver: Send { stereo: bool, data: &[i16]); } + +#[derive(Clone)] +pub enum AudioType { + Opus, + Pcm, +} |