#[non_exhaustive]pub struct Video {
pub renditions: BTreeMap<String, VideoConfig>,
pub display: Option<Display>,
pub rotation: Option<f64>,
pub flip: Option<bool>,
}Expand description
Information about a video track in the catalog.
This struct contains a map of renditions (different quality/codec options) and optional metadata like detection, display settings, rotation, and flip.
Marked #[non_exhaustive] so additional optional fields can be added without
bumping the major version. External callers start from Video::default and
fill in what they need (insert for renditions); 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.renditions: BTreeMap<String, VideoConfig>A map of track name to rendition configuration. This is not an array in order for it to work with JSON Merge Patch. We use a BTreeMap so keys are sorted alphabetically for some deterministic behavior.
A malformed rendition refuses the whole catalog when decoding.
display: Option<Display>Render the video at this size in pixels. This is separate from the display aspect ratio because it does not require reinitialization.
rotation: Option<f64>The clockwise rotation of the video in degrees. Default: 0
flip: Option<bool>If true, the decoder will flip the video horizontally Default: false
Implementations§
Source§impl Video
impl Video
Sourcepub fn insert(&mut self, name: &str, config: VideoConfig) -> Result<()>
pub fn insert(&mut self, name: &str, config: VideoConfig) -> Result<()>
Insert a track config, returning an error if the name already exists.
Sourcepub fn remove(&mut self, name: &str) -> Option<VideoConfig>
pub fn remove(&mut self, name: &str) -> Option<VideoConfig>
Remove the track from the catalog and return the configuration if found.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
True when there are no renditions, so the section can be omitted from the catalog.
Display, rotation, and flip ride this section, so they are omitted too when nothing is published.
Sourcepub fn enabled(&self) -> impl Iterator<Item = (&String, &VideoConfig)>
pub fn enabled(&self) -> impl Iterator<Item = (&String, &VideoConfig)>
Iterate enabled renditions in quality order.
Sourcepub fn ranked(&self) -> impl Iterator<Item = (&String, &VideoConfig)>
pub fn ranked(&self) -> impl Iterator<Item = (&String, &VideoConfig)>
Iterate the renditions best first: enabled, then highest preference, then largest picture, then highest bitrate.
A consumer that carries one rendition takes the first it supports, so the picture doesn’t depend on how the tracks are named, and a lower preference is taken only when nothing preferred is supported. Unknown dimensions or bitrate rank below known ones, and exact ties keep name order.
Sourcepub fn orientation(&self, config: &VideoConfig) -> Option<Orientation>
pub fn orientation(&self, config: &VideoConfig) -> Option<Orientation>
Which way config is shown once rotated, or None when square or of unknown size.
The section’s display size decides it when set, else the rendition’s display aspect ratio or coded size, turned by the section’s rotation. A player with a viewport keeps the renditions shaped like it, so preference ranks within an orientation.
Sourcepub fn set_properties(&mut self, properties: VideoProperties) -> Result<()>
pub fn set_properties(&mut self, properties: VideoProperties) -> Result<()>
Normalize and replace the properties shared by every video rendition.