Skip to main content

TrackInfo

Struct TrackInfo 

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

Source

pub const fn new( timebase: Timebase, params: TrackParams<E>, extra: E::TrackExtra, ) -> Self

Constructs a TrackInfo. Identity metadata defaults to None.

Source

pub const fn kind(&self) -> TrackKind

Returns the track’s kind, read off Self::params.

Source

pub const fn timebase(&self) -> Timebase

Returns the timebase every timestamp on this track is expressed in.

Source

pub const fn duration(&self) -> Option<Timestamp>

Returns the track duration, or None when the container does not carry one.

Source

pub const fn params(&self) -> &TrackParams<E>

Returns the per-kind codec parameters.

Source

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.

Source

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.

Source

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.

Source

pub const fn extra(&self) -> &E::TrackExtra

Returns the backend-specific extras.

Source

pub fn extra_mut(&mut self) -> &mut E::TrackExtra

Returns a mutable reference to the backend-specific extras.

Source

pub const fn with_duration(self, v: Option<Timestamp>) -> Self

Sets the duration (consuming builder).

Source

pub fn with_filename(self, v: Option<E::Text>) -> Self

Sets the attachment filename (consuming builder).

Source

pub fn with_mime_type(self, v: Option<E::Text>) -> Self

Sets the attachment MIME type (consuming builder).

Source

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.

Source

pub const fn set_duration(&mut self, v: Option<Timestamp>) -> &mut Self

Sets the duration in place.

Source

pub fn set_filename(&mut self, v: Option<E::Text>) -> &mut Self

Sets the attachment filename in place.

Source

pub fn set_mime_type(&mut self, v: Option<E::Text>) -> &mut Self

Sets the attachment MIME type in place.

Source

pub fn set_language(&mut self, v: Option<E::Text>) -> &mut Self

Sets the container’s declared language in place.

Trait Implementations§

Source§

impl<E: DemuxAdapter> Debug for TrackInfo<E>
where E::TrackExtra: Debug,

Source§

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

Formats the value using the given formatter. Read more

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.