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: boolSends 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
impl Vp9Payloader
Sourcepub fn set_scalability_structure(
&mut self,
structure: Option<Vp9ScalabilityStructure>,
) -> Result<()>
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.
Sourcepub fn picture_id(&self) -> u16
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).
Sourcepub fn payload_layer_frame(
&mut self,
mtu: usize,
frame: &Bytes,
info: &Vp9FrameInfo,
) -> Result<Vec<Bytes>>
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
impl Clone for Vp9Payloader
Source§impl Debug for Vp9Payloader
impl Debug for Vp9Payloader
Source§impl Default for Vp9Payloader
impl Default for Vp9Payloader
Source§impl Payloader for Vp9Payloader
impl Payloader for Vp9Payloader
Source§fn payload(&mut self, mtu: usize, payload: &Bytes) -> Result<Vec<Bytes>>
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
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)
fn set_next_frame_info(&mut self, info: &dyn Any)
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 payload_duration(&self, _payload: &Bytes) -> Option<u32>
fn payload_duration(&self, _payload: &Bytes) -> Option<u32>
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.