Skip to main content

TextConfig

Struct TextConfig 

Source
#[non_exhaustive]
pub struct TextConfig { pub broadcast: Option<Relative>, pub track: Option<String>, pub format: TextFormat, pub role: TextRole, pub lang: Option<String>, pub label: Option<String>, pub container: Container, pub jitter: Option<Duration>, pub delay: Option<Duration>, }
Expand description

Timed-text (caption/subtitle) track configuration.

Unlike audio and video there is no WebCodecs decoder for text: a consumer parses the cue payload directly (see TextFormat) and renders it as an overlay. Each frame is one cue (or a self-contained segment of cues), and the frame timestamp is the cue’s start time on the shared media clock.

Marked #[non_exhaustive] so additional optional fields can be added without bumping the major version. External callers build a config with TextConfig::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
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.
§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.

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

§format: TextFormat

The serialization format of each cue payload.

§role: TextRole

The accessibility role of the track. Defaults to TextRole::Subtitle.

§lang: Option<String>

The BCP-47 language tag of the track (e.g. en, es-419), if known.

§label: Option<String>

A human-readable label for a track picker, when lang alone is ambiguous (e.g. distinguishing “English” from “English (SDH)”).

§container: Container

Container format for frame encoding. Defaults to “legacy” (a microsecond timestamp prefix followed by the cue payload).

§jitter: Option<Duration>

The largest media span the publisher hands to the transport behind a cue’s timestamp, with the same meaning and whole-millisecond encoding as VideoConfig::jitter. A cue written in timestamp order adds nothing.

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

Source

pub fn new(format: TextFormat) -> Self

Construct a config with the required format set and every optional field cleared. role defaults to TextRole::Subtitle and container 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 TextConfig since the type is #[non_exhaustive].

Trait Implementations§

Source§

impl Clone for TextConfig

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 TextConfig

Source§

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

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

impl<'de> Deserialize<'de> for TextConfig

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 TextConfig

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 Reference for TextConfig

Source§

fn broadcast(&self) -> Option<&Relative>

The broadcast publishing the track, relative to the catalog’s; None is the catalog’s own.
Source§

fn track<'a>(&'a self, id: &'a str) -> &'a str

The track’s name in its broadcast, given this entry’s ID.
Source§

impl Serialize for TextConfig

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 TextConfig

Auto Trait Implementations§

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