#[non_exhaustive]pub struct VideoConfig {Show 22 fields
pub broadcast: Option<Relative>,
pub track: Option<String>,
pub label: Option<String>,
pub codec: VideoCodec,
pub description: Option<Bytes>,
pub coded_width: Option<u32>,
pub coded_height: Option<u32>,
pub display_aspect_width: Option<u32>,
pub display_aspect_height: Option<u32>,
pub color: Option<Color>,
pub projection: Option<Projection>,
pub stereo: Option<Stereo>,
pub interlaced: bool,
pub bitrate: Option<u64>,
pub enabled: bool,
pub preference: i32,
pub framerate: Option<f64>,
pub reorder: Option<u8>,
pub optimize_for_latency: Option<bool>,
pub container: Container,
pub jitter: Option<Duration>,
pub delay: Option<Duration>,
}Expand description
Video decoder configuration based on WebCodecs VideoDecoderConfig.
This struct contains all the information needed to initialize a video decoder, including codec-specific parameters, resolution, and optional metadata.
Reference: https://www.w3.org/TR/webcodecs/#video-decoder-config
Marked #[non_exhaustive] so additional optional fields can be added
without bumping the major version. External callers build a config with
VideoConfig::new and then assign whichever optional fields they need;
struct-literal construction (with or without ..base) is not available
outside this crate.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.broadcast: Option<Relative>Optional reference to another broadcast that publishes this track, expressed
relative to the broadcast that served this catalog (e.g. ./source). If unset,
the track lives in the same broadcast as the catalog.
This allows a transcoder to author a downstream catalog that points unchanged renditions at the source broadcast without re-publishing the bytes.
Resolve it with Path::resolve: a reference that walks
above the root names no broadcast, so the catalog is rejected.
track: Option<String>The track’s name in its broadcast, when it differs from this entry’s ID: its key in the catalog. Absent means the ID is the track name, as in every catalog before this field.
Set it only when the ID can’t be the name, such as two renditions of same-named tracks
from different broadcasts. Readers resolve the name with
Reference::track; one that predates the
field subscribes to the ID instead.
label: Option<String>Human-readable rendition name for track pickers.
codec: VideoCodecThe codec, see the registry for details: https://w3c.github.io/webcodecs/codec_registry.html
description: Option<Bytes>Information used to initialize the decoder on a per-codec basis.
One of the best examples is H264, which needs the sps/pps to function. If not provided, this information is (automatically) inserted before each key-frame (marginally higher overhead).
coded_width: Option<u32>The largest encoded width/height the track carries, fixed for its name, never zero.
The picture resizes in band at a keyframe below these ceilings, unless the
description pins it. Absent means unknown; a publisher may fill it once.
coded_height: Option<u32>The height counterpart of coded_width.
display_aspect_width: Option<u32>The aspect ratio the whole picture is displayed at, as WebCodecs’
VideoDecoderConfig.displayAspectWidth / displayAspectHeight, never zero.
Absent means the decoded picture’s own shape. A publisher with non-square samples sets the picture’s aspect here, never the sample aspect.
display_aspect_height: Option<u32>The height counterpart of display_aspect_width.
color: Option<Color>The colour the decoded pixels carry, so a renderer need not guess or reparse the bitstream.
Live state, not identity: a publisher may fill it in once the bitstream reveals it.
projection: Option<Projection>How the picture maps onto the viewer’s field of view. Absent means rectilinear.
Live state, like color.
stereo: Option<Stereo>How each eye’s view is packed into the frame. Absent means mono.
Live state, like color.
interlaced: boolEach picture weaves two fields, so a renderer deinterlaces it. Only written when true.
Decides decoder configuration, since some hardware decoders refuse interlaced streams.
bitrate: Option<u64>The maximum bitrate of the video track, if known, at most 2^53 - 1.
enabled: boolWhether this rendition may be selected. When false, no frames are coming and a consumer must not select it. Only written when false.
preference: i32Higher is preferred: a consumer selects among the highest preference it can decode,
then by picture and bitrate within it. A compatibility transcode is -1 so only a
consumer that can’t decode the source pulls it. A player with a viewport first keeps
the renditions of its orientation, so preference ranks within
one: a publisher ranks its secondary orientation lower, and a consumer without a
viewport takes the main one. Only written when nonzero.
framerate: Option<f64>The maximum frame rate of the video track, if known.
reorder: Option<u8>The most frames that can precede a frame in decode order and follow it in presentation
order, as H.264 max_num_reorder_frames and HEVC sps_max_num_reorder_pics count them.
0 declares that presentation order is decode order. Absent declares nothing: a consumer
that authors decode times infers them from the timestamps instead. A publisher that
declares it keeps it for the track’s life, and never reorders deeper.
optimize_for_latency: Option<bool>If true, the decoder will optimize for latency.
Default: true
container: ContainerContainer format for frame encoding. Defaults to “legacy” for backward compatibility.
jitter: Option<Duration>The largest media span the publisher hands to the transport behind a frame’s presentation timestamp: the reorder delay of a frame presented after frames decoded behind it, or the span of a batch written together, such as an fMP4 fragment. A consumer’s jitter buffer should be at least this large. Absent when the publisher measured none.
Measured from media timestamps alone, so a frame written in presentation order adds nothing, whatever the frame rate; encoder latency and the network don’t count. It only ever grows over the life of a stream.
Serialized as a whole number of milliseconds, rounded up, so an upper bound never rounds down into a promise the publisher can’t keep.
delay: Option<Duration>How far this rendition’s frames reach the transport behind the broadcast’s other renditions: a constant offset, either supplied by the publisher or measured as the least its frames trailed the others’ over a window of a second of media, keeping the largest window. Lateness only some frames have, such as B-frame reorder, is left out, since a consumer measures it. Absent on a rendition that trails nothing, and on any rendition the publisher neither supplied nor measured.
A consumer adds a frame duration on top, so a publisher that knows its frames trail by no
more than their own duration, such as an encoder configured not to reorder or queue, states
Some(Duration::ZERO). It is never measured, and is omitted on the
wire like an absent value, which means the same to a consumer. None leaves it to
measurement.
A consumer holds delay + jitter for this rendition and MUST NOT subtract one rendition’s
delay from another’s: each is taken against whichever rendition was ahead, so two need not
share an origin. It only ever grows over the life of a stream, and is serialized like
jitter.
Implementations§
Source§impl VideoConfig
impl VideoConfig
Sourcepub fn new(codec: impl Into<VideoCodec>) -> Self
pub fn new(codec: impl Into<VideoCodec>) -> Self
Construct a config with the required codec set and every optional
field cleared. container defaults to Container::default. Fields
are pub, so callers set whatever they need by assignment afterwards.
This is the only path external crates have to build a VideoConfig
since the type is #[non_exhaustive].
Sourcepub fn same_identity(&self, other: &Self) -> bool
pub fn same_identity(&self, other: &Self) -> bool
Whether other keeps this config’s track identity: the fields a consumer cannot change
without reinitializing its decoder or demuxer (codec, description, container,
display_aspect_width, display_aspect_height, and interlaced).
A track name always means the same content, so a publisher that changes any of them publishes under a new name; every other field may update in place. See the draft’s Track Identity.