Driver/receive: Implement audio reorder/jitter buffer (#156)
This PR Introduces a new `VoiceTick` event which collects and reorders all RTP packets to smooth over network instability, as well as to synchronise user audio streams. Raw packet events have been moved to `RtpPacket`, while `SpeakingUpdate`s have been removed as they can be easily computed using the `silent`/`speaking` audio maps included in each event. Closes #146.
This commit is contained in:
@@ -657,6 +657,8 @@ impl Mixer {
|
||||
None => {},
|
||||
}
|
||||
|
||||
self.advance_rtp_timestamp();
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
} else {
|
||||
@@ -809,6 +811,18 @@ impl Mixer {
|
||||
rtp.set_timestamp(rtp.get_timestamp() + MONO_FRAME_SIZE as u32);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
// Even if we don't send a packet, we *do* need to keep advancing the timestamp
|
||||
// to make it easier for a receiver to reorder packets and compute jitter measures
|
||||
// wrt. our clock difference vs. theirs.
|
||||
fn advance_rtp_timestamp(&mut self) {
|
||||
let mut rtp = MutableRtpPacket::new(&mut self.packet[..]).expect(
|
||||
"FATAL: Too few bytes in self.packet for RTP header.\
|
||||
(Blame: VOICE_PACKET_MAX?)",
|
||||
);
|
||||
rtp.set_timestamp(rtp.get_timestamp() + MONO_FRAME_SIZE as u32);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn check_and_send_keepalive(&mut self) -> Result<()> {
|
||||
if let Some(conn) = self.conn_active.as_mut() {
|
||||
|
||||
Reference in New Issue
Block a user