#[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
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: TextFormatThe serialization format of each cue payload.
role: TextRoleThe 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: ContainerContainer 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
impl TextConfig
Sourcepub fn new(format: TextFormat) -> Self
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].