Skip to main content

Vp9Payloader

Struct Vp9Payloader 

Source
pub struct Vp9Payloader {
    pub initial_picture_id_fn: Option<InitialPictureIDFn>,
    pub flexible_mode: bool,
    pub initial_tl0_pic_idx: Option<u8>,
    /* private fields */
}
Expand description

Vp9Payloader payloads VP9 packets.

By default it uses the non-flexible mode, as browsers expect from a sender without SVC (RFC 9628 section 4.2): it reads each frame’s uncompressed header, marks a frame that predicts from another picture with P=1 (a key or intra-only frame with P=0), and puts a scalability structure with the frame size on a key frame’s first packet. flexible_mode selects the flexible mode instead: no scalability structure unless one is set, and the reference indices (P_DIFF) of every predicted frame, read from the header’s reference slots.

The mode only changes at a key picture, as the RFC requires. A stream whose first frame is not VP9 at all starts in flexible mode, as before, and stays there until a key frame parses; such a frame is sent with P=1 (unknown, so not offered as a switch point) unless it is the stream’s first.

Payloader::payload sends a picture of one frame without layer indices. Vp9Payloader::payload_layer_frame takes the frame’s layer information from the encoder and writes the layer indices (TID, U, SID, D, TL0PICIDX), Z, and one picture ID for all the frames of a picture.

Fields§

§initial_picture_id_fn: Option<InitialPictureIDFn>

Supplies the starting picture id; randomized when absent.

§flexible_mode: bool

Sends in flexible mode (F=1) instead of non-flexible mode.

§initial_tl0_pic_idx: Option<u8>

The TL0PICIDX of the first picture of temporal layer 0; random when absent (RFC 9628 section 4.2: “SHOULD start on a random number”).

Implementations§

Source§

impl Vp9Payloader

Source

pub fn set_scalability_structure( &mut self, structure: Option<Vp9ScalabilityStructure>, ) -> Result<()>

Sets the scalability structure sent on the first packet of every key picture (RFC 9628 section 4.2.1), or with None goes back to the default: in non-flexible mode one spatial layer of the key frame’s size and a picture group of one picture, in flexible mode no SS.

In non-flexible mode the picture group is what tells a receiver the temporal structure, and payload_layer_frame refuses a frame whose TID is not the one its picture maps to. It takes effect at the next key picture, the only place an SS may change.

§Errors

A structure Vp9ScalabilityStructure::validate refuses.

Source

pub fn picture_id(&self) -> u16

The picture ID the next picture is sent with (meaningful once a frame has been sent, or with initial_picture_id_fn set).

Source

pub fn payload_layer_frame( &mut self, mtu: usize, frame: &Bytes, info: &Vp9FrameInfo, ) -> Result<Vec<Bytes>>

Fragments one VP9 frame of a layered stream, describing it with info.

Every packet carries the layer indices (L=1). The frames of a picture are passed in increasing spatial_id order, the last with end_of_picture; they share one picture ID, and in non-flexible mode one TL0PICIDX, incremented for a picture of temporal layer 0. The caller sets the RTP marker on the last packet of the frame with end_of_picture and on no other (RFC 9628 section 4.1).

§Errors

Layer information the descriptor cannot carry or the RFC forbids: TID or SID above 7; D on spatial layer 0; a frame that is not inter-picture predicted outside temporal layer 0; spatial layers out of order within a picture; more than three reference indices, or one outside 1 to 127; in non-flexible mode a TID that is not the one the picture group gives the picture; an MTU with no room for the descriptor (and, on a key picture’s first packet, the scalability structure).

Trait Implementations§

Source§

impl Clone for Vp9Payloader

Source§

fn clone(&self) -> Self

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

impl Debug for Vp9Payloader

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Vp9Payloader

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Payloader for Vp9Payloader

Source§

fn payload(&mut self, mtu: usize, payload: &Bytes) -> Result<Vec<Bytes>>

Payload fragments an Vp9Payloader packet across one or more byte arrays

Source§

fn marker_rule(&self) -> MarkerRule

RFC 9628 section 4.1: the marker is set on “the final packet of the highest spatial layer frame”, the picture’s last. After a frame that leaves its picture open (end_of_picture unset) no packet of that frame carries it.

Source§

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

What the encoder says about the next frame payload is given, for a format whose payload describes more than the frame’s bytes (VP9’s layer indices, Vp9FrameInfo); a type the payloader does not use is ignored, as is the call by a payloader that uses none (the default).
Source§

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

Clones this payloader behind a trait object.
Source§

fn payload_duration(&self, _payload: &Bytes) -> Option<u32>

For a sample-based format, the RTP timestamp units one payload of payload covers, so that a frame split over several packets gets a timestamp per packet (RFC 3551 section 4.3: the timestamp is the sampling instant of the packet’s first sample). None, the default, is a frame-based format: every packet of the frame carries the frame’s timestamp.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Vp9Payloader

§

impl !UnwindSafe for Vp9Payloader

§

impl Forget for Vp9Payloader

§

impl Freeze for Vp9Payloader
where *const ArcInner<dyn Fn() -> u16 + Sync + Send> is !null: Freeze, PhantomData<ArcInner<dyn Fn() -> u16 + Sync + Send>>: Freeze, *const u8 is !null: Freeze, PhantomData<(u16, u16)>: Freeze, PhantomData<Vp9PictureGroupEntry>: Freeze, PhantomData<u8>: Freeze,

§

impl Move for Vp9Payloader

§

impl Send for Vp9Payloader
where Arc<dyn Fn() -> u16 + Sync + Send>: Send, RawVecInner: Send,

§

impl Sync for Vp9Payloader
where Arc<dyn Fn() -> u16 + Sync + Send>: Sync, RawVecInner: Sync,

§

impl Unpin for Vp9Payloader
where Arc<dyn Fn() -> u16 + Sync + Send>: Unpin, *const u8 is !null: Unpin,

§

impl UnsafeUnpin for Vp9Payloader

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.