Packetizer

Trait Packetizer 

Source
pub trait Packetizer {
    type Frame;
    type Error;

    // Required methods
    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>;

    // Provided methods
    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§

Source

fn push(&mut self, frame: Self::Frame) -> Result<(), Self::Error>

Process a given media frame.

§Panics

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

Source

fn flush(&mut self) -> Result<(), Self::Error>

Flush the packetizer.

§Panics

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

Source

fn take(&mut self) -> Result<Option<RtpPacket>, Self::Error>

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§

Source

fn with_frame<F, T>(self, f: F) -> WithFrame<Self, F, T>
where F: FnMut(T) -> Self::Frame, Self: Sized,

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

Source

fn map_err<F, E>(self, f: F) -> MapErr<Self, F>
where F: FnMut(Self::Error) -> E, Self: Sized,

Map the packetizer error into a different one.

Implementations on Foreign Types§

Source§

impl<T> Packetizer for Box<T>
where T: Packetizer + ?Sized,

Source§

type Frame = <T as Packetizer>::Frame

Source§

type Error = <T as Packetizer>::Error

Source§

fn push(&mut self, frame: Self::Frame) -> Result<(), Self::Error>

Source§

fn flush(&mut self) -> Result<(), Self::Error>

Source§

fn take(&mut self) -> Result<Option<RtpPacket>, Self::Error>

Implementors§

Source§

impl<P, F, E> Packetizer for MapErr<P, F>
where P: Packetizer, F: FnMut(P::Error) -> E,

Source§

impl<P, F, T> Packetizer for WithFrame<P, F, T>
where P: Packetizer, F: FnMut(T) -> P::Frame,