pub trait SampleIndex {
// Required methods
fn sample_count(&self, stream: usize) -> u64;
fn sample_info(&self, stream: usize, index: u64) -> Option<SampleInfo>;
fn read_sample(&mut self, stream: usize, index: u64) -> Result<Packet>;
fn sync_at_or_before(&self, stream: usize, pts: i64) -> Option<u64>;
// Provided methods
fn edit_list(&self, _stream: usize) -> &[EditEntry] { ... }
fn movie_timescale(&self) -> Option<u32> { ... }
fn raw_sample_count(&self, stream: usize) -> u64 { ... }
fn raw_sample_info(&self, stream: usize, index: u64) -> Option<SampleInfo> { ... }
fn read_raw_sample(&mut self, stream: usize, index: u64) -> Result<Packet> { ... }
fn sample_groups(&self, _stream: usize) -> &[SampleGrouping] { ... }
fn sample_source(&mut self) -> Option<Arc<dyn SampleSource>> { ... }
}Expand description
Random access over a demuxer’s index; see Demuxer::sample_index.
Required Methods§
Sourcefn sample_count(&self, stream: usize) -> u64
fn sample_count(&self, stream: usize) -> u64
Samples in stream stream (0 for an unknown stream).
Sourcefn sample_info(&self, stream: usize, index: u64) -> Option<SampleInfo>
fn sample_info(&self, stream: usize, index: u64) -> Option<SampleInfo>
The index entry of sample index of stream, in decode order.
Sourcefn read_sample(&mut self, stream: usize, index: u64) -> Result<Packet>
fn read_sample(&mut self, stream: usize, index: u64) -> Result<Packet>
Read sample index of stream as a packet, in the same form as
Demuxer::read_packet would give it (see
Demuxer::set_raw_samples).
Provided Methods§
Sourcefn edit_list(&self, _stream: usize) -> &[EditEntry]
fn edit_list(&self, _stream: usize) -> &[EditEntry]
The stream’s edit list (empty when it has none, or the container has no such thing).
Sourcefn movie_timescale(&self) -> Option<u32>
fn movie_timescale(&self) -> Option<u32>
The movie time scale EditEntry::segment_duration counts in (MP4
mvhd), when the container has one.
Sourcefn raw_sample_count(&self, stream: usize) -> u64
fn raw_sample_count(&self, stream: usize) -> u64
Samples in the stream’s stored sample table: what
raw_sample_info numbers. Without an
edit list this is sample_count; an MP4
edit list can replay samples or leave some out of the edited index.
Sourcefn raw_sample_info(&self, stream: usize, index: u64) -> Option<SampleInfo>
fn raw_sample_info(&self, stream: usize, index: u64) -> Option<SampleInfo>
Sample index of the stored sample table, in decode order, with the
edit list not applied: for MP4 the stbl row verbatim, dts the
sum of the stts deltas before it (0 for the first sample), pts =
dts + its ctts offset, duration its stts delta, all in the
media time scale (the stream’s time base). An editor applies
edit_list itself on this — for example
AAC encoder priming (the first edit’s media_time) and padding (where
its segment_duration ends) — and a muxer given these samples and the
same edit list (Muxer::set_edit_list) writes the same table back.
Defaults to sample_info for containers
without edit lists.
Sourcefn read_raw_sample(&mut self, stream: usize, index: u64) -> Result<Packet>
fn read_raw_sample(&mut self, stream: usize, index: u64) -> Result<Packet>
Read stored sample index (numbered as
raw_sample_info numbers them) as a
packet timed by that entry, shaped as
read_sample shapes it.
Sourcefn sample_groups(&self, _stream: usize) -> &[SampleGrouping]
fn sample_groups(&self, _stream: usize) -> &[SampleGrouping]
The stream’s sample groups (MP4 sbgp/sgpd, in the movie and in
fragments), numbered as
raw_sample_info numbers samples.
Empty when it has none, or the container has no such thing.
Sourcefn sample_source(&mut self) -> Option<Arc<dyn SampleSource>>
fn sample_source(&mut self) -> Option<Arc<dyn SampleSource>>
A shareable, &self view of this index for reading samples from
several places at once (an editor’s media pool): cheap to clone (an
Arc), Send + Sync, and independent of this demuxer’s
read_packet position and of every other
source. Each call gives a source with its own read position; they
share the index tables and the input (reads take turns on it). Packets
are shaped as read_sample shapes them
at the time of the call (see Demuxer::set_raw_samples). None
from demuxers that cannot share their input (the default).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".