pub struct TrackInfo<E: DemuxAdapter> { /* private fields */ }Expand description
One row of the track table Demuxer::tracks returns.
Carries what a consumer needs to decide whether it wants the track and how to open a decoder for it: the kind, the timebase every timestamp on that track is expressed in, the duration when the container knows it, the per-kind codec parameters, the language the container declares for the track, and — for attachments — the identity the file was attached under.
Everything a particular backend knows and this row has no seat for
rides DemuxAdapter::TrackExtra.
No Clone, on this type or on TrackParams. The
message-carrier law: messages may be Clone, but Clone is
always a refcount bump, never a deep copy — and a track row,
backend metadata down to codec parameters, is not cheap to
duplicate. A consumer that needs to share a row shares a handle
on it instead: Demuxer::tracks hands out
Demuxer::TrackHandles over rows the session keeps for its
whole life, so a row is built once and every consumer after that
shares it by refcount.
The absence is load-bearing, not incidental. It is what leaves
TrackHandle’s Clone bound with no cheap deep-copying carrier
to admit: there is no #[derive(Clone)] road over a row that has
none, and Box<TrackInfo<_>> is not Clone either. A shared
handle or a borrow is what an implementor reaches for; a deep copy
would have to be hand-written, field by field, against the law
this paragraph states.
Implementations§
Source§impl<E: DemuxAdapter> TrackInfo<E>
impl<E: DemuxAdapter> TrackInfo<E>
Sourcepub const fn new(
timebase: Timebase,
params: TrackParams<E>,
extra: E::TrackExtra,
) -> Self
pub const fn new( timebase: Timebase, params: TrackParams<E>, extra: E::TrackExtra, ) -> Self
Constructs a TrackInfo. Identity metadata defaults to None.
Sourcepub const fn kind(&self) -> TrackKind
pub const fn kind(&self) -> TrackKind
Returns the track’s kind, read off Self::params.
Sourcepub const fn timebase(&self) -> Timebase
pub const fn timebase(&self) -> Timebase
Returns the timebase every timestamp on this track is expressed in.
Sourcepub const fn duration(&self) -> Option<Timestamp>
pub const fn duration(&self) -> Option<Timestamp>
Returns the track duration, or None when the container does not
carry one.
Sourcepub const fn params(&self) -> &TrackParams<E>
pub const fn params(&self) -> &TrackParams<E>
Returns the per-kind codec parameters.
Sourcepub const fn filename(&self) -> Option<&E::Text>
pub const fn filename(&self) -> Option<&E::Text>
Returns the filename an attachment was attached under, when the
container carries one. None for every other kind.
Sourcepub const fn mime_type(&self) -> Option<&E::Text>
pub const fn mime_type(&self) -> Option<&E::Text>
Returns an attachment’s declared MIME type, when the container
carries one. None for every other kind.
Sourcepub const fn language(&self) -> Option<&E::Text>
pub const fn language(&self) -> Option<&E::Text>
Returns the language the container declares for this track,
exactly as it is written there — None where the file declares
none.
§The file’s word, unfolded
This is a reading, never a reckoning. None means the container
said nothing, and a Some is the tag as written: an MKV’s ISO
639-2/B ger, an MP4’s 639-2/T deu, a decades-old muxer’s iw,
a BCP 47 zh-Hans, or und where a file declares its language
unknown. Each of those is a different string for something a
vocabulary may well call one language, and none of them is
normalised here.
Deliberately, and the alternative was measured. Folding those
spellings together takes registry tables — the IANA subtag
registry for BCP 47 and ISO 639-2’s own for the alpha-3 space BCP
47 does not register — and a crate that owns one is where that
fold belongs. A demux tier that folded early would be a second
authority on the same question, disagreeing with the first in
exactly the cases the registries exist for; and a narrower seat —
a three-letter code, say — would have had nowhere to put
zh-Hans, which is a tag Matroska really writes. So the seat
carries the declaration whole and leaves the fold downstream,
where one door can apply it once.
§Every kind, not only subtitles
Containers tag audio tracks as readily as subtitle ones — a dub
and its captions are the same question asked twice — so the seat
is on the row rather than on one arm of
TrackParams.
Sourcepub const fn extra(&self) -> &E::TrackExtra
pub const fn extra(&self) -> &E::TrackExtra
Returns the backend-specific extras.
Sourcepub fn extra_mut(&mut self) -> &mut E::TrackExtra
pub fn extra_mut(&mut self) -> &mut E::TrackExtra
Returns a mutable reference to the backend-specific extras.
Sourcepub const fn with_duration(self, v: Option<Timestamp>) -> Self
pub const fn with_duration(self, v: Option<Timestamp>) -> Self
Sets the duration (consuming builder).
Sourcepub fn with_filename(self, v: Option<E::Text>) -> Self
pub fn with_filename(self, v: Option<E::Text>) -> Self
Sets the attachment filename (consuming builder).
Sourcepub fn with_mime_type(self, v: Option<E::Text>) -> Self
pub fn with_mime_type(self, v: Option<E::Text>) -> Self
Sets the attachment MIME type (consuming builder).
Sourcepub fn with_language(self, v: Option<E::Text>) -> Self
pub fn with_language(self, v: Option<E::Text>) -> Self
Sets the container’s declared language (consuming builder).
Pass the tag as the container writes it — see
language for why nothing normalises it.
Sourcepub const fn set_duration(&mut self, v: Option<Timestamp>) -> &mut Self
pub const fn set_duration(&mut self, v: Option<Timestamp>) -> &mut Self
Sets the duration in place.
Sourcepub fn set_filename(&mut self, v: Option<E::Text>) -> &mut Self
pub fn set_filename(&mut self, v: Option<E::Text>) -> &mut Self
Sets the attachment filename in place.
Sourcepub fn set_mime_type(&mut self, v: Option<E::Text>) -> &mut Self
pub fn set_mime_type(&mut self, v: Option<E::Text>) -> &mut Self
Sets the attachment MIME type in place.
Sourcepub fn set_language(&mut self, v: Option<E::Text>) -> &mut Self
pub fn set_language(&mut self, v: Option<E::Text>) -> &mut Self
Sets the container’s declared language in place.