Skip to main content

ReorderingBuffer

Struct 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§

Source§

impl ReorderingBuffer

Source

pub fn new(depth: usize) -> Self

Create a new reordering buffer with a given depth.

Source

pub fn estimate_index(&self, sequence_nr: u16) -> u64

Estimate packet index from a given sequence number.

Source

pub fn is_duplicate(&self, index: u64) -> bool

Check if a packet with a given index would be a duplicate.

Source

pub fn push( &mut self, packet: IncomingRtpPacket, ) -> 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.

Source

pub fn next(&mut self) -> Option<OrderedRtpPacket>

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, a packet will be returned only if it is an in-order packet and returning it would not skip any packets.

Source

pub fn take(&mut self) -> Option<OrderedRtpPacket>

Remove the front slot from the buffer and return the contained packet (if any).

The method will always advance start position of the reordering window by one even if the front slot is empty or if the underlying buffer itself is empty.

Source

pub fn is_empty(&self) -> bool

Check if the buffer is empty.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.