Skip to main content

MultiTrackSeeker

Struct MultiTrackSeeker 

Source
pub struct MultiTrackSeeker { /* private fields */ }
Expand description

Multi-track sample-accurate seeker with a per-track PTS→byte-offset index.

Unlike SampleAccurateSeeker (which wraps a single TrackIndex), MultiTrackSeeker manages a separate sorted index for each track and exposes an O(log n) seek_to_pts lookup.

§Example

use oximedia_container::seek::{MultiTrackSeeker, SampleIndexEntry};

let mut seeker = MultiTrackSeeker::new();

let samples = vec![
    SampleIndexEntry::keyframe(0,     1000),
    SampleIndexEntry::delta(3000,  1200),
    SampleIndexEntry::keyframe(6000,  1500),
];
seeker.build_index(1, &samples).expect("index built");

let result = seeker.seek_to_pts(1, 4500).expect("seek ok");
println!("found_pts={} offset={} idx={}", result.found_pts, result.byte_offset, result.sample_idx);

Implementations§

Source§

impl MultiTrackSeeker

Source

pub fn new() -> Self

Creates an empty MultiTrackSeeker.

Source

pub fn build_index( &mut self, track_id: u32, samples: &[SampleIndexEntry], ) -> Result<(), MultiTrackSeekerError>

Builds (or replaces) the index for track_id from the provided sample list.

The entries are sorted by PTS so that seek_to_pts can use binary search.

§Errors

This method currently always succeeds. It is defined with Result for forward compatibility (e.g. if validation logic is added later).

Source

pub fn seek_to_pts( &self, track_id: u32, target_pts: i64, ) -> Result<PtsSeekResult, MultiTrackSeekerError>

Seeks to the sample-accurate position for target_pts within track_id.

Uses binary search (O(log n)) to locate the last sample whose PTS is ≤ target_pts. If the target_pts is exactly a sample boundary the result is exact; otherwise the sample immediately preceding the target is returned (the decoder must decode from that point).

§Errors
Source

pub fn indexed_track_count(&self) -> usize

Returns the number of tracks that have been indexed.

Source

pub fn sample_count(&self, track_id: u32) -> Option<usize>

Returns the number of indexed samples for track_id, or None.

Source

pub fn clear_index(&mut self, track_id: u32)

Clears the index for track_id.

Source

pub fn entries(&self, track_id: u32) -> Option<&[SampleIndexEntry]>

Returns a sorted slice of index entries for track_id, or None.

Trait Implementations§

Source§

impl Default for MultiTrackSeeker

Source§

fn default() -> Self

Returns the “default value” for a type. 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> 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, 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.