Skip to main content

Packetizer

Trait Packetizer 

Source
pub trait Packetizer:
    Send
    + Sync
    + Debug {
    // Required methods
    fn enable_abs_send_time(&mut self, value: u8);
    fn packetize(
        &mut self,
        now: Instant,
        payload: &Bytes,
        samples: u32,
    ) -> Result<Vec<Packet>>;
    fn skip_samples(&mut self, skipped_samples: u32);
    fn clone_to(&self) -> Box<dyn Packetizer>;

    // Provided method
    fn set_next_frame_info(&mut self, _info: &dyn Any) { ... }
}
Expand description

Packetizer packetizes a payload

Required Methods§

Source

fn enable_abs_send_time(&mut self, value: u8)

Attaches the absolute-send-time header extension under id value.

Source

fn packetize( &mut self, now: Instant, payload: &Bytes, samples: u32, ) -> Result<Vec<Packet>>

Packetizes one frame, advancing the timestamp by samples.

Assigns sequence numbers, sets the marker bit as the payload format has it (see MarkerRule: the final packet of a video frame, the first packet of an audio talkspurt) and applies any enabled header extensions. now is the instant the frame is being sent at; it is what the absolute-send-time extension is derived from, so the caller supplies it rather than the packetizer sampling a clock of its own.

§Errors

Propagates payloader failures, and fails when the MTU leaves no room for a payload after the 12-byte RTP header.

Source

fn skip_samples(&mut self, skipped_samples: u32)

Advances the timestamp without sending anything, for dropped or silent frames. For an audio format this is a silence period: the next packet starts a talkspurt and carries the marker bit (RFC 3551 section 4.1; Opus DTX, RFC 7587 section 3.1.3).

Source

fn clone_to(&self) -> Box<dyn Packetizer>

Clones this packetizer behind a trait object.

Provided Methods§

Source

fn set_next_frame_info(&mut self, _info: &dyn Any)

Describes the next frame packetize is given to the payloader (Payloader::set_next_frame_info): for VP9 a Vp9FrameInfo, so that the frames of a picture with spatial layers carry their layer indices and only the picture’s last packet the marker (RFC 9628 section 4.1). The default ignores it.

Trait Implementations§

Source§

impl Clone for Box<dyn Packetizer>

Source§

fn clone(&self) -> Box<dyn Packetizer>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§