Skip to main content

Video

Struct Video 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional 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

Source

pub fn insert(&mut self, name: &str, config: VideoConfig) -> Result<()>

Insert a track config, returning an error if the name already exists.

Source

pub fn remove(&mut self, name: &str) -> Option<VideoConfig>

Remove the track from the catalog and return the configuration if found.

Source

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.

Source

pub fn enabled(&self) -> impl Iterator<Item = (&String, &VideoConfig)>

Iterate enabled renditions in quality order.

Source

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.

Source

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.

Source

pub fn set_properties(&mut self, properties: VideoProperties) -> Result<()>

Normalize and replace the properties shared by every video rendition.

Trait Implementations§

Source§

impl Clone for Video

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 Video

Source§

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

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

impl Default for Video

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for Video

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Video

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Video

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Video

Auto Trait Implementations§

§

impl Freeze for Video

§

impl RefUnwindSafe for Video

§

impl Send for Video

§

impl Sync for Video

§

impl Unpin for Video

§

impl UnsafeUnpin for Video

§

impl UnwindSafe for Video

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
§

impl<T> CatalogExt for T
where T: Serialize + DeserializeOwned + Default + Clone + Send + Unpin + 'static,

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more