Trait discord::voice::AudioReceiver
[−]
[src]
pub trait AudioReceiver: Send { fn speaking_update(&mut self, ssrc: u32, user_id: UserId, speaking: bool); fn voice_packet(
&mut self,
ssrc: u32,
sequence: u16,
timestamp: u32,
stereo: bool,
data: &[i16]
); }
A receiver for incoming audio.
Required Methods
fn speaking_update(&mut self, ssrc: u32, user_id: UserId, speaking: bool)
Called when a user's currently-speaking state has updated.
This method is the only way to know the ssrc
to user_id
mapping, but is unreliable and
only a hint for when users are actually speaking, due both to latency differences and that
it is possible for a user to leave speaking
true even when they are not sending audio.
fn voice_packet(
&mut self,
ssrc: u32,
sequence: u16,
timestamp: u32,
stereo: bool,
data: &[i16]
)
&mut self,
ssrc: u32,
sequence: u16,
timestamp: u32,
stereo: bool,
data: &[i16]
)
Called when a voice packet is received.
The sequence number increases by one per packet sent, and can be used to reorder packets
if they have been received out of order. The timestamp increases at 48000Hz (typically by
960 per 20ms frame). If stereo
is true, the length of the data
slice is doubled and
samples have been interleaved. The typical length of data
is 960 or 1920 for a 20ms frame,
but may be larger or smaller in some situations.