pub trait Packetizer {
    type Frame;
    type Error;

    fn push(&mut self, frame: Self::Frame) -> Result<(), Self::Error>;
    fn flush(&mut self) -> Result<(), Self::Error>;
    fn take(&mut self) -> Result<Option<RtpPacket>, Self::Error>;

    fn with_frame<F, T>(self, f: F) -> WithFrame<Self, F, T>
    where
        F: FnMut(T) -> Self::Frame,
        Self: Sized
, { ... } fn map_err<F, E>(self, f: F) -> MapErr<Self, F>
    where
        F: FnMut(Self::Error) -> E,
        Self: Sized
, { ... } }
Expand description

Common trait for packetizers.

Packetizers are responsible for converting media frames into RTP packets.

Usage

  1. Push a media frame into the packetizer.
  2. Take all RTP packets from the packetizer.
  3. Repeat from (1) if needed.
  4. Flush the packetizer.
  5. Take all RTP packets from the packetizer.

Required Associated Types

Required Methods

Process a given media frame.

Panics

The method may panic if calling the take method would not return None.

Flush the packetizer.

Panics

The method may panic if calling the take method would not return None.

Take the next available RTP packet.

Note that only after this method returns None, it is allowed to call the push method or the flush method again.

Provided Methods

Convert this packetizer into a new one accepting media frames of a given type.

Map the packetizer error into a different one.

Implementations on Foreign Types

Implementors