Struct msf_rtp::utils::ReorderingBuffer
source · [−]pub struct ReorderingBuffer { /* private fields */ }
Expand description
Reordering buffer for RTP packets.
The reordering buffer internally uses u64
packet indices. These indices
are estimated from packet sequence numbers according to the algorithm
presented in RFC 3711, section 3.3.1.
This simplifies the original algorithm presented in RFC 3550.
Note: RFC 3711 uses 32-bit ROC. This implementation uses 64-bit indices, so
the actual bit width of the ROC is 48 bits here (48-bit ROC + 16-bit
sequence number gives 64-bit packet index). The 32-bit ROC value can be
extracted from packet indices simply by cutting off the upper 16 bits, e.g.
(index >> 16) as u32
.
Implementations
sourceimpl ReorderingBuffer
impl ReorderingBuffer
sourcepub fn estimate_index(&self, sequence_nr: u16) -> u64
pub fn estimate_index(&self, sequence_nr: u16) -> u64
Estimate packet index from a given sequence number.
sourcepub fn is_duplicate(&self, index: u64) -> bool
pub fn is_duplicate(&self, index: u64) -> bool
Check if a packet with a given index would be a duplicate.
sourcepub fn push(&mut self, packet: RtpPacket) -> Result<u64, ReorderingError>
pub fn push(&mut self, packet: RtpPacket) -> Result<u64, ReorderingError>
Push a given packet into the buffer and return index of the inserted packet.
The method returns an error if the packet cannot be inserted into the buffer because it is either a duplicate or the buffer would exceed its capacity.
sourcepub fn next(&mut self) -> Option<RtpPacket>
pub fn next(&mut self) -> Option<RtpPacket>
Take the next packet from the buffer.
This method will return a packet only if there is a packet in the front slot of the buffer. In other words, the index of the returned packet will always be equal to the start index.
Auto Trait Implementations
impl RefUnwindSafe for ReorderingBuffer
impl Send for ReorderingBuffer
impl Sync for ReorderingBuffer
impl Unpin for ReorderingBuffer
impl UnwindSafe for ReorderingBuffer
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more