pub struct PacketReorderer { /* private fields */ }Expand description
Reorders DTS-ordered packets (as produced by encoders with B-frames) into PTS order (required by muxers and decoders operating on display order).
Internally uses a min-heap keyed on PTS. A packet is considered ready
once the heap has accumulated at least max_buffer entries, which bounds
the maximum PTS reordering delay.
§Flushing
Call drain at end-of-stream to retrieve all remaining packets in PTS
order.
Implementations§
Source§impl PacketReorderer
impl PacketReorderer
Sourcepub fn new(max_buffer: usize) -> Self
pub fn new(max_buffer: usize) -> Self
Create a new reorderer.
max_buffer controls the maximum reorder window. A value of 4–8 is
appropriate for streams with up to 3 consecutive B-frames.
Sourcepub fn push(&mut self, pkt: CodecPacket)
pub fn push(&mut self, pkt: CodecPacket)
Push a packet into the reorder buffer.
Sourcepub fn pop_ready(&mut self) -> Option<CodecPacket>
pub fn pop_ready(&mut self) -> Option<CodecPacket>
Pop the packet with the lowest PTS if the buffer is full enough to guarantee it is the next in display order.
Returns None if the buffer is smaller than max_buffer.
Sourcepub fn drain(&mut self) -> Vec<CodecPacket>
pub fn drain(&mut self) -> Vec<CodecPacket>
Drain all remaining packets from the buffer, ordered by PTS ascending.
The buffer is empty after this call.
Auto Trait Implementations§
impl Freeze for PacketReorderer
impl RefUnwindSafe for PacketReorderer
impl Send for PacketReorderer
impl Sync for PacketReorderer
impl Unpin for PacketReorderer
impl UnsafeUnpin for PacketReorderer
impl UnwindSafe for PacketReorderer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more