Skip to main content

SampleTable

Struct SampleTable 

Source
pub struct SampleTable {
    pub time_to_sample: Vec<TimeToSampleEntry>,
    pub sample_to_chunk: Vec<SampleToChunkEntry>,
    pub sample_sizes: SampleSizeMode,
    pub chunk_offsets: Vec<u64>,
    pub sync_samples: Option<BTreeSet<u32>>,
    pub timescale: u32,
}
Expand description

Complete sample table for one track.

Fields§

§time_to_sample: Vec<TimeToSampleEntry>

Time-to-sample entries from stts.

§sample_to_chunk: Vec<SampleToChunkEntry>

Sample-to-chunk entries from stsc.

§sample_sizes: SampleSizeMode

Per-sample sizes from stsz.

§chunk_offsets: Vec<u64>

Chunk offsets from stco / co64.

§sync_samples: Option<BTreeSet<u32>>

Set of sync (key-frame) sample numbers (1-based) from stss. If None, every sample is a sync sample.

§timescale: u32

Track timescale (ticks per second).

Implementations§

Source§

impl SampleTable

Source

pub fn new(timescale: u32) -> Self

Creates an empty sample table with the given timescale.

Source

pub fn sample_count_from_stts(&self) -> u64

Returns the total number of samples described by the stts entries.

Source

pub fn sample_count(&self) -> u64

Returns the total number of samples from the size table.

Source

pub fn total_duration_ticks(&self) -> u64

Returns the total media duration in timescale units.

Source

pub fn duration_seconds(&self) -> f64

Returns the total media duration in seconds.

Source

pub fn sample_size(&self, sample_number: u32) -> Option<u32>

Returns the size of the given sample (1-based index).

Source

pub fn is_sync_sample(&self, sample_number: u32) -> bool

Returns true if the given sample (1-based) is a sync sample.

Source

pub fn nearest_sync_before(&self, sample_number: u32) -> Option<u32>

Finds the nearest sync sample at or before sample_number (1-based).

Source

pub fn nearest_sync_after(&self, sample_number: u32) -> Option<u32>

Finds the nearest sync sample at or after sample_number (1-based).

Source

pub fn sample_at_time(&self, ticks: u64) -> Option<u32>

Converts a decode timestamp (in timescale ticks) to a sample number (1-based). Returns None if the timestamp exceeds the track duration.

Source

pub fn sample_time(&self, sample_number: u32) -> Option<u64>

Returns the decode timestamp (in ticks) of a given sample (1-based).

Source

pub fn total_data_size(&self) -> u64

Total data size of all samples.

Source

pub fn average_sample_size(&self) -> f64

Returns the average sample size in bytes.

Source

pub fn chunk_count(&self) -> usize

Number of chunk offsets.

Trait Implementations§

Source§

impl Clone for SampleTable

Source§

fn clone(&self) -> SampleTable

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SampleTable

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<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> 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> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.